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