Added system to mount flags on carrier's head for easier identification and disabling of abilities as per Chiss' request
This commit is contained in:
parent
e93db405d0
commit
bff9c99e2c
@ -66,6 +66,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
//protected String[] _blockedItems = new String[] {"SWORD", "AXE", "BOW"};
|
||||
|
||||
private ConcurrentHashMap<Player, List<ItemStack>> _hotbars = new ConcurrentHashMap<Player, List<ItemStack>>();
|
||||
private ConcurrentHashMap<Player, ItemStack> _helmets = new ConcurrentHashMap<Player, ItemStack>();
|
||||
|
||||
public CaptureTheFlag(ArcadeManager manager, GameType type, Kit[] kits)
|
||||
{
|
||||
@ -174,6 +175,9 @@ public class CaptureTheFlag extends TeamGame
|
||||
for (Player player : _hotbars.keySet())
|
||||
if (!player.isOnline() || UtilPlayer.isSpectator(player) || !IsAlive(player))
|
||||
_hotbars.remove(player);
|
||||
for (Player player : _helmets.keySet())
|
||||
if (!player.isOnline() || UtilPlayer.isSpectator(player) || !IsAlive(player))
|
||||
_helmets.remove(player);
|
||||
}
|
||||
else if (event.getType() == UpdateType.TICK)
|
||||
for (Flag flag : _flags)
|
||||
@ -216,7 +220,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
EndCheckScore();
|
||||
}
|
||||
|
||||
public void SaveHotbar(Player player)
|
||||
public void SaveInventory(Player player)
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
for (int i = 0; i < 9; i++)
|
||||
@ -227,9 +231,11 @@ public class CaptureTheFlag extends TeamGame
|
||||
items.add(i, new ItemStack(Material.AIR));
|
||||
}
|
||||
_hotbars.put(player, items);
|
||||
|
||||
_helmets.put(player, player.getInventory().getHelmet());
|
||||
}
|
||||
|
||||
public void ResetItems(Player player)
|
||||
public void ResetInventory(Player player)
|
||||
{
|
||||
if (_hotbars.containsKey(player))
|
||||
{
|
||||
@ -241,8 +247,10 @@ public class CaptureTheFlag extends TeamGame
|
||||
else
|
||||
player.getInventory().setItem(i, new ItemStack(Material.AIR));
|
||||
}
|
||||
player.getInventory().setHelmet(_helmets.get(player));
|
||||
player.updateInventory();
|
||||
_hotbars.remove(player);
|
||||
_helmets.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,7 +539,7 @@ public class CaptureTheFlag extends TeamGame
|
||||
event.setCancelled(false);
|
||||
event.getItemDrop().remove();
|
||||
flag.Drop(event.getPlayer());
|
||||
ResetItems(event.getPlayer());
|
||||
ResetInventory(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,13 +271,18 @@ public class Flag
|
||||
_name.stop();
|
||||
_time.stop();
|
||||
|
||||
Host.SaveHotbar(player);
|
||||
Host.SaveInventory(player);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
player.getInventory().setItem(i, _representation);
|
||||
}
|
||||
player.getInventory().setItem(4, new ItemStack(Material.COMPASS));
|
||||
ItemStack compass = new ItemStack(Material.COMPASS);
|
||||
ItemMeta im = compass.getItemMeta();
|
||||
im.setDisplayName(C.cDAqua + "Your Base");
|
||||
compass.setItemMeta(im);
|
||||
player.getInventory().setItem(4, compass);
|
||||
player.getInventory().setHelmet(_representation);
|
||||
player.updateInventory();
|
||||
|
||||
AnnounceCapture(player);
|
||||
@ -343,7 +348,7 @@ public class Flag
|
||||
return;
|
||||
}
|
||||
|
||||
Host.ResetItems(player);
|
||||
Host.ResetInventory(player);
|
||||
UtilTextMiddle.display("", player.getName() + " has captured " + _team.GetName() + "'s flag!".replace("s's", "s'"));
|
||||
for (Player p : UtilServer.getPlayers())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user