Make outposts utilize the Clan Banner of their owner

This commit is contained in:
AlexTheCoder 2017-03-10 14:59:54 -05:00
parent 2e04490001
commit cc1bb3cfe9
2 changed files with 20 additions and 10 deletions

View File

@ -149,7 +149,7 @@ public class Outpost implements Listener
_preHologram2.start(); _preHologram2.start();
} }
_blocks = _type.createBuildQueue(_origin, _ownerClan.Clans); _blocks = _type.createBuildQueue(_origin, _ownerClan.Clans, _ownerClan);
_state = token.OutpostState; _state = token.OutpostState;
@ -498,7 +498,7 @@ public class Outpost implements Listener
_lifetimeLeft.start(); _lifetimeLeft.start();
_state = OutpostState.CONSTRUCTING; _state = OutpostState.CONSTRUCTING;
_blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_origin, _ownerClan.Clans)); _blocks = new LinkedHashMap<>(_buildQueue = _type.createBuildQueue(_origin, _ownerClan.Clans, _ownerClan));
_ownerClan.inform("Siege", "Your Outpost is now being constructed.", null); _ownerClan.inform("Siege", "Your Outpost is now being constructed.", null);

View File

@ -1,27 +1,29 @@
package mineplex.game.clans.clans.siege.outpost; package mineplex.game.clans.clans.siege.outpost;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.banner.Pattern;
import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.banners.BannerManager;
import mineplex.game.clans.clans.banners.BannerPattern;
import mineplex.game.clans.clans.banners.ClanBanner;
import mineplex.game.clans.clans.siege.outpost.build.OutpostBlock; import mineplex.game.clans.clans.siege.outpost.build.OutpostBlock;
import mineplex.game.clans.clans.siege.outpost.build.OutpostBlockBanner; import mineplex.game.clans.clans.siege.outpost.build.OutpostBlockBanner;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
public enum OutpostType public enum OutpostType
{ {
MK_I(1, 3, 6) { MK_I(1, 3, 6) {
public LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans) public LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans, ClanInfo owner)
{ {
LinkedHashMap<String, OutpostBlock> build = new LinkedHashMap<>(); LinkedHashMap<String, OutpostBlock> build = new LinkedHashMap<>();
@ -232,7 +234,7 @@ public enum OutpostType
} }
}, },
MK_II(2, 5, 25) { MK_II(2, 5, 25) {
public LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans) public LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans, ClanInfo owner)
{ {
try try
{ {
@ -292,7 +294,7 @@ public enum OutpostType
} }
}, },
MK_III(3, 5, 25) { MK_III(3, 5, 25) {
public LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans) public LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans, ClanInfo owner)
{ {
try try
{ {
@ -300,6 +302,8 @@ public enum OutpostType
File file = new File("schematic" + File.separator + "outpost_mk_III.schematic"); File file = new File("schematic" + File.separator + "outpost_mk_III.schematic");
Schematic schematic = UtilSchematic.loadSchematic(file); Schematic schematic = UtilSchematic.loadSchematic(file);
BannerManager bm = clans.getBannerManager();
ClanBanner cb = bm.LoadedBanners.get(owner.getName());
for (int y = 0; y < schematic.getHeight(); y++) for (int y = 0; y < schematic.getHeight(); y++)
{ {
@ -319,10 +323,16 @@ public enum OutpostType
if (Material.getMaterial(schematic.getBlock(x, y, z)).name().contains("BANNER")) if (Material.getMaterial(schematic.getBlock(x, y, z)).name().contains("BANNER"))
{ {
build.put(UtilWorld.locToStr(loc), new OutpostBlockBanner(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z), DyeColor.RED)); if (cb == null)
{
continue;
}
build.put(UtilWorld.locToStr(loc), new OutpostBlockBanner(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z), cb.getBaseColor(), (Pattern[]) cb.getPatterns().stream().map(BannerPattern::getBukkitPattern).toArray()));
} }
else else
{
build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z))); build.put(UtilWorld.locToStr(loc), new OutpostBlock(build, loc, schematic.getBlock(x, y, z), schematic.getData(x, y, z)));
}
} }
} }
} }
@ -374,7 +384,7 @@ public enum OutpostType
return _id; return _id;
} }
public abstract LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans); public abstract LinkedHashMap<String, OutpostBlock> createBuildQueue(Location location, ClansManager clans, ClanInfo owner);
public abstract Location getCoreLocation(Location location); public abstract Location getCoreLocation(Location location);