From 05f47be8644305baede8a819170df8c3ab73282f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 19 Sep 2015 16:38:07 -0400 Subject: [PATCH] - Some fixes --- .../game/games/common/CaptureTheFlag.java | 22 ++++++++++++--- .../game/games/common/ctf_data/Flag.java | 28 +++++++++++++++---- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java index 043dd9448..821e9d68c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java @@ -45,6 +45,7 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_7_R4.PacketPlayOutSetSlot; import net.minecraft.server.v1_7_R4.PacketPlayOutWindowItems; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Location; @@ -268,6 +269,7 @@ public class CaptureTheFlag extends TeamGame /*ItemDropAllow.add(Material.REDSTONE_BLOCK.getId()); ItemDropAllow.add(Material.LAPIS_BLOCK.getId());*/ + CreatureAllowOverride = true; for (GameTeam team : GetTeamList()) { @@ -281,8 +283,6 @@ public class CaptureTheFlag extends TeamGame if (this instanceof ChampionsCTF) { - CreatureAllowOverride = true; - for (int i = 0; i < GetKits().length && i < WorldData.GetDataLocs("LIGHT_BLUE").size() && i < WorldData.GetDataLocs("PINK").size(); i++) { Entity ent = GetKits()[i].SpawnEntity(WorldData.GetDataLocs("PINK").get(i)); @@ -291,9 +291,14 @@ public class CaptureTheFlag extends TeamGame ent = GetKits()[i].SpawnEntity(WorldData.GetDataLocs("LIGHT_BLUE").get(i)); Manager.GetLobby().AddKitLocation(ent, GetKits()[i], WorldData.GetDataLocs("LIGHT_BLUE").get(i)); } - - CreatureAllowOverride = false; } + + Bukkit.getScheduler().runTaskLater(getArcadeManager().getPlugin(), new Runnable(){ + @Override + public void run() + { + CreatureAllowOverride = false; + }}, 20 * 5); //End kit spawning } @@ -784,4 +789,13 @@ public class CaptureTheFlag extends TeamGame } } } + + @EventHandler + public void flagDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity() != null) + for (Flag f : _flags) + if (f.isFlagEntity(event.GetDamageeEntity())) + event.SetCancelled("Flag Entity"); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/ctf_data/Flag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/ctf_data/Flag.java index 06a192011..5d08e999e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/ctf_data/Flag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/ctf_data/Flag.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseArmorStand; +import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.hologram.Hologram; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.GameTeam; @@ -19,6 +20,7 @@ import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -48,6 +50,7 @@ public class Flag private String _displayName; private LivingEntity _flagEntity; + private DisguiseBase _disguise; public Flag (CaptureTheFlag host, Location spawn, GameTeam team) { @@ -71,7 +74,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, team.GetColor() == ChatColor.RED, true); } public GameTeam getTeam() @@ -105,6 +108,12 @@ public class Flag return _displayName; } + public boolean isFlagEntity(Entity e) + { + if (_flagEntity == null) return false; + return _flagEntity.getEntityId() == e.getEntityId(); + } + private void AnnounceSteal(Player cap, boolean steal) { if (steal) @@ -130,6 +139,9 @@ public class Flag public void Update() { + if (_holding == null && _disguise != null) + Host.getArcadeManager().GetDisguise().updateDisguise(_disguise); + if (_moved) { if (_dropped) @@ -148,7 +160,7 @@ public class Flag _moved = false; _dropped = false; - SpawnFlag(_spawn, _team.GetColor() == ChatColor.RED); + SpawnFlag(_spawn, _team.GetColor() == ChatColor.RED, false); AnnounceReturn(); @@ -192,15 +204,18 @@ public class Flag return ChatColor.RED; } - public void SpawnFlag(Location loc, boolean red) + public void SpawnFlag(Location loc, boolean red, boolean initial) { + if (!initial) Host.CreatureAllowOverride = true; _current = loc; _flagEntity = (LivingEntity) Host.getArcadeManager().GetCreature().SpawnEntity(loc, EntityType.CHICKEN); UtilEnt.Vegetate(_flagEntity); DisguiseArmorStand disguise = new DisguiseArmorStand(_flagEntity); disguise.setInvisible(true); - disguise.setHelmet(_representation); + disguise.setBoots(_representation); Host.getArcadeManager().GetDisguise().disguise(disguise, UtilServer.getPlayers()); + _disguise = disguise; + if (!initial) Host.CreatureAllowOverride = false; if (!_moved) { @@ -222,6 +237,7 @@ public class Flag private void DeleteFlag() { Host.getArcadeManager().GetDisguise().undisguise(_flagEntity); + _disguise = null; _flagEntity.remove(); _current = null; _flagEntity = null; @@ -292,7 +308,7 @@ public class Flag { Recharge.Instance.recharge(player, "Flag Pickup"); Recharge.Instance.use(player, "Flag Pickup", 3000, false, false); - SpawnFlag(player.getLocation(), _team.GetColor() == ChatColor.RED); + SpawnFlag(player.getLocation(), _team.GetColor() == ChatColor.RED, false); AnnounceDrop(player); _holding = null; _dropped = true; @@ -333,7 +349,7 @@ public class Flag _dropped = false; _dropTime = 0; _holding = null; - SpawnFlag(_spawn, _team.GetColor() == ChatColor.RED); + SpawnFlag(_spawn, _team.GetColor() == ChatColor.RED, false); } } }