- Fixed banners, begun work on patterns

This commit is contained in:
AlexTheCoder 2015-11-08 02:42:31 -05:00
parent dfbf19c66a
commit 211298327f
2 changed files with 48 additions and 54 deletions

View File

@ -49,7 +49,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -769,12 +768,4 @@ public class CaptureTheFlag extends TeamGame
} }
} }
} }
@EventHandler
public void debug(BlockPlaceEvent event)
{
Bukkit.broadcastMessage(event.getBlock().toString());
Bukkit.broadcastMessage("SPLIT");
Bukkit.broadcastMessage(event.getBlockReplacedState().getRawData() + "");
}
} }

View File

@ -1,5 +1,7 @@
package nautilus.game.arcade.game.games.common.ctf_data; package nautilus.game.arcade.game.games.common.ctf_data;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -27,7 +29,8 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Banner; import org.bukkit.block.Banner;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.block.CraftBanner; import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BannerMeta;
@ -41,16 +44,17 @@ public class Flag
private Location _spawn; private Location _spawn;
private Block[] _flagBlocks; private Block _flagBlock;
private Material[] _priorBlocks; private Material _priorBlock;
private Byte[] _priorData; private Byte _priorData;
private GameTeam _team; private GameTeam _team;
private ChatColor _enemy; private ChatColor _enemy;
private ItemStack _representation; private ItemStack _representation;
private DyeColor _dyeData; private DyeColor _dyeData;
private List<Pattern> _patterns;
private Player _holding = null; private Player _holding = null;
@ -70,19 +74,35 @@ public class Flag
_spawn = spawn; _spawn = spawn;
_team = team; _team = team;
_displayName = team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'"); _displayName = team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'");
_patterns = new ArrayList<Pattern>();
ItemStack i; ItemStack i;
if (team.GetColor() == ChatColor.RED) if (team.GetColor() == ChatColor.RED)
{ {
i = new ItemStack(Material.BANNER); i = new ItemStack(Material.BANNER);
_dyeData = DyeColor.RED; _dyeData = DyeColor.BLACK;
_enemy = ChatColor.BLUE; _enemy = ChatColor.BLUE;
_patterns.add(new Pattern(DyeColor.RED, PatternType.STRIPE_SMALL));
_patterns.add(new Pattern(DyeColor.RED, PatternType.FLOWER));
_patterns.add(new Pattern(DyeColor.BLACK, PatternType.BORDER));
_patterns.add(new Pattern(DyeColor.BLACK, PatternType.TRIANGLE_TOP));
} }
else else
{ {
i = new ItemStack(Material.BANNER); i = new ItemStack(Material.BANNER);
_dyeData = DyeColor.BLUE; _dyeData = DyeColor.GRAY;
_enemy = ChatColor.RED; _enemy = ChatColor.RED;
_patterns.add(new Pattern(DyeColor.BLACK, PatternType.GRADIENT));
_patterns.add(new Pattern(DyeColor.BLACK, PatternType.GRADIENT_UP));
_patterns.add(new Pattern(DyeColor.CYAN, PatternType.TRIANGLE_BOTTOM));
_patterns.add(new Pattern(DyeColor.CYAN, PatternType.TRIANGLE_TOP));
_patterns.add(new Pattern(DyeColor.BLACK, PatternType.RHOMBUS_MIDDLE));
_patterns.add(new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_TOP));
_patterns.add(new Pattern(DyeColor.BLACK, PatternType.TRIANGLES_BOTTOM));
_patterns.add(new Pattern(DyeColor.BLUE, PatternType.DIAGONAL_LEFT));
_patterns.add(new Pattern(DyeColor.BLUE, PatternType.DIAGONAL_RIGHT));
_patterns.add(new Pattern(DyeColor.BLACK, PatternType.CROSS));
_patterns.add(new Pattern(DyeColor.BLUE, PatternType.FLOWER));
} }
BannerMeta im = (BannerMeta) i.getItemMeta(); BannerMeta im = (BannerMeta) i.getItemMeta();
@ -95,7 +115,7 @@ public class Flag
_name = new Hologram(_host.getArcadeManager().getHologramManager(), spawn, team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'")); _name = new Hologram(_host.getArcadeManager().getHologramManager(), spawn, team.GetColor() + team.GetName() + "'s Flag".replace("s's", "s'"));
_time = new Hologram(_host.getArcadeManager().getHologramManager(), spawn, ""); _time = new Hologram(_host.getArcadeManager().getHologramManager(), spawn, "");
spawnFlag(spawn, team.GetColor() == ChatColor.RED); spawnFlag(spawn);
} }
public GameTeam getTeam() public GameTeam getTeam()
@ -115,7 +135,7 @@ public class Flag
public Location getPlacedLocation() public Location getPlacedLocation()
{ {
return _flagBlocks[0].getLocation(); return _flagBlock.getLocation();
} }
@ -155,8 +175,12 @@ public class Flag
public void update() public void update()
{ {
if (!_moved || _dropped) if (!_moved || _dropped)
for (Block block : _flagBlocks) {
block.setType(_representation.getType()); _flagBlock.setType(Material.STANDING_BANNER);
Banner banner = (Banner) _flagBlock.getState();
banner.setBaseColor(_dyeData);
banner.update();
}
if (_moved) if (_moved)
{ {
@ -183,7 +207,7 @@ public class Flag
_moved = false; _moved = false;
_dropped = false; _dropped = false;
spawnFlag(_spawn, _team.GetColor() == ChatColor.RED); spawnFlag(_spawn);
announceReturn(); announceReturn();
@ -230,36 +254,19 @@ public class Flag
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void spawnFlag(Location loc, boolean red) public void spawnFlag(Location loc)
{ {
_flagBlocks = new Block[] _flagBlock = loc.getBlock();
{ _host.getArcadeManager().getClassManager().GetSkillFactory().BlockRestore().Restore(_flagBlock);
loc.getBlock()
};
for (Block block : _flagBlocks) _priorBlock = loc.getBlock().getType();
{
_host.getArcadeManager().getClassManager().GetSkillFactory().BlockRestore().Restore(block);
}
_priorBlocks = new Material[] _priorData = loc.getBlock().getData();
{
loc.getBlock().getType()
};
_priorData = new Byte[] _flagBlock.setType(Material.STANDING_BANNER);
{ Banner banner = (Banner) _flagBlock.getState();
loc.getBlock().getData() banner.setBaseColor(_dyeData);
}; banner.update();
for (Block block : _flagBlocks)
{
block.setType(Material.STANDING_BANNER);
block.setData((byte) 0);
//Banner banner = (Banner) block.getState();
//banner.setBaseColor(_dyeData);
//banner.update();
}
if (!_moved) if (!_moved)
{ {
@ -281,12 +288,8 @@ public class Flag
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void deleteFlag() private void deleteFlag()
{ {
for (int i = 0; i < _flagBlocks.length; i++) _flagBlock.setType(_priorBlock);
{ _flagBlock.setData(_priorData);
Block flagBlock = _flagBlocks[i];
flagBlock.setType(_priorBlocks[i]);
flagBlock.setData(_priorData[i]);
}
_name.stop(); _name.stop();
_time.stop(); _time.stop();
@ -372,7 +375,7 @@ public class Flag
{ {
Recharge.Instance.recharge(player, "Flag Pickup"); Recharge.Instance.recharge(player, "Flag Pickup");
Recharge.Instance.use(player, "Flag Pickup", 5000, false, false); Recharge.Instance.use(player, "Flag Pickup", 5000, false, false);
spawnFlag(player.getLocation(), _team.GetColor() == ChatColor.RED); spawnFlag(player.getLocation());
announceDrop(player); announceDrop(player);
_holding = null; _holding = null;
_dropped = true; _dropped = true;
@ -415,7 +418,7 @@ public class Flag
_dropped = false; _dropped = false;
_dropTime = 0; _dropTime = 0;
_holding = null; _holding = null;
spawnFlag(_spawn, _team.GetColor() == ChatColor.RED); spawnFlag(_spawn);
} }
} }
} }