From 0ab3213b7b50f37ec6d8b720cdcf5849b7ed882a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 27 Oct 2015 01:38:41 -0400 Subject: [PATCH] - Fixed permanent dwarf toss bug - Fixed skills being active while player is editing class --- .../game/arcade/addons/TeamArmorAddon.java | 6 +- .../arcade/events/PlayerKitApplyEvent.java | 6 +- .../arcade/events/PlayerKitGiveEvent.java | 6 +- .../game/games/champions/ChampionsCTF.java | 15 ++-- .../games/champions/ChampionsDominate.java | 5 +- .../game/games/champions/ChampionsTDM.java | 17 ++-- .../game/games/champions/kits/SkillFixer.java | 84 +++++++++++++++++++ .../game/games/common/CaptureTheFlag.java | 2 +- .../game/games/common/ctf_data/Flag.java | 3 +- .../game/games/dragonescape/DragonEscape.java | 2 +- .../game/games/minestrike/MineStrike.java | 24 +++--- 11 files changed, 131 insertions(+), 39 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/kits/SkillFixer.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/TeamArmorAddon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/TeamArmorAddon.java index d0820dadf..5e723449f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/TeamArmorAddon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/TeamArmorAddon.java @@ -28,9 +28,9 @@ public class TeamArmorAddon extends MiniPlugin @EventHandler public void GiveArmor(PlayerKitGiveEvent event) { - Player player = event.GetPlayer(); + Player player = event.getPlayer(); - if (event.GetGame().TeamArmor) + if (event.getGame().TeamArmor) { ItemStack helm = new ItemStack(Material.LEATHER_HELMET); LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); @@ -57,7 +57,7 @@ public class TeamArmorAddon extends MiniPlugin player.getInventory().setBoots(boots); } - if (event.GetGame().TeamArmorHotbar && event.GetGame().InProgress()) + if (event.getGame().TeamArmorHotbar && event.getGame().InProgress()) { ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitApplyEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitApplyEvent.java index 7ec303648..3b0025105 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitApplyEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitApplyEvent.java @@ -34,17 +34,17 @@ public class PlayerKitApplyEvent extends Event implements Cancellable return handlers; } - public Game GetGame() + public Game getGame() { return _game; } - public Kit GetKit() + public Kit getKit() { return _kit; } - public Player GetPlayer() + public Player getPlayer() { return _player; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitGiveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitGiveEvent.java index dc17e9a25..939ea2ef7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitGiveEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitGiveEvent.java @@ -32,17 +32,17 @@ public class PlayerKitGiveEvent extends Event return handlers; } - public Game GetGame() + public Game getGame() { return _game; } - public Kit GetKit() + public Kit getKit() { return _kit; } - public Player GetPlayer() + public Player getPlayer() { return _player; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java index 2d84dfe02..c06264277 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsCTF.java @@ -1,11 +1,5 @@ package nautilus.game.arcade.game.games.champions; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.inventory.InventoryType; - import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; @@ -15,6 +9,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.champions.kits.SkillFixer; import nautilus.game.arcade.game.games.champions.kits.KitAssassin; import nautilus.game.arcade.game.games.champions.kits.KitBrute; import nautilus.game.arcade.game.games.champions.kits.KitKnight; @@ -29,6 +24,12 @@ import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.SeismicSlamStatTracker; import nautilus.game.arcade.stats.TheLongestShotStatTracker; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.inventory.InventoryType; + public class ChampionsCTF extends CaptureTheFlag { public ChampionsCTF(ArcadeManager manager) @@ -78,6 +79,8 @@ public class ChampionsCTF extends CaptureTheFlag new CapturesStatTracker(this, "Captures"), new ClutchStatTracker(this, "Clutch") ); + + new SkillFixer(this); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java index f7eb0d360..67f587ad1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsDominate.java @@ -9,6 +9,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.champions.kits.SkillFixer; import nautilus.game.arcade.game.games.champions.kits.KitAssassin; import nautilus.game.arcade.game.games.champions.kits.KitBrute; import nautilus.game.arcade.game.games.champions.kits.KitKnight; @@ -16,8 +17,8 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.Domination; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.ElectrocutionStatTracker; +import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.SeismicSlamStatTracker; import nautilus.game.arcade.stats.TheLongestShotStatTracker; @@ -76,6 +77,8 @@ public class ChampionsDominate extends Domination new TheLongestShotStatTracker(this), new SeismicSlamStatTracker(this) ); + + new SkillFixer(this); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java index cc414be9b..68da35d26 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/ChampionsTDM.java @@ -1,11 +1,5 @@ package nautilus.game.arcade.game.games.champions; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.inventory.InventoryType; - import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; @@ -15,6 +9,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.champions.kits.SkillFixer; import nautilus.game.arcade.game.games.champions.kits.KitAssassin; import nautilus.game.arcade.game.games.champions.kits.KitBrute; import nautilus.game.arcade.game.games.champions.kits.KitKnight; @@ -22,13 +17,19 @@ import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.common.TeamDeathmatch; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.ElectrocutionStatTracker; import nautilus.game.arcade.stats.KillAllOpposingStatTracker; +import nautilus.game.arcade.stats.KillReasonStatTracker; import nautilus.game.arcade.stats.SeismicSlamStatTracker; import nautilus.game.arcade.stats.TheLongestShotStatTracker; import nautilus.game.arcade.stats.WinWithoutLosingTeammateStatTracker; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.inventory.InventoryType; + public class ChampionsTDM extends TeamDeathmatch { public ChampionsTDM(ArcadeManager manager) @@ -76,6 +77,8 @@ public class ChampionsTDM extends TeamDeathmatch new TheLongestShotStatTracker(this), new SeismicSlamStatTracker(this) ); + + new SkillFixer(this); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/kits/SkillFixer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/kits/SkillFixer.java new file mode 100644 index 000000000..361c82fe6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/champions/kits/SkillFixer.java @@ -0,0 +1,84 @@ +package nautilus.game.arcade.game.games.champions.kits; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.classcombat.Skill.Skill; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerKitApplyEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryType; + +public class SkillFixer implements Listener +{ + private Game _host; + + public SkillFixer(Game game) + { + _host = game; + Bukkit.getPluginManager().registerEvents(this, _host.getArcadeManager().getPlugin()); + } + + @EventHandler + public void disable(GameStateChangeEvent event) + { + if (event.GetGame() != _host) + return; + + if (event.GetState() == GameState.End) + HandlerList.unregisterAll(this); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void fixDwarf(PlayerKitApplyEvent event) + { + if (!_host.IsLive()) + return; + + if (event.isCancelled()) + return; + + if (event.getPlayer().getPassenger() == null) + return; + + event.setCancelled(true); + event.setCancelMessage("You cannot change kits while holding someone in Dwarf Toss!"); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void fixBlizzard(PlayerKitApplyEvent event) + { + if (!_host.IsLive()) + return; + + if (event.isCancelled()) + return; + + _host.getArcadeManager().getClassManager().GetSkillFactory().GetSkill("Blizzard").Reset(event.getPlayer()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!_host.IsLive()) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (player.getOpenInventory() == null || player.getOpenInventory().getTopInventory() == null) + continue; + + if (player.getOpenInventory().getTopInventory().getType() == InventoryType.CHEST) + for (Skill skill : _host.getArcadeManager().getClassManager().GetSkillFactory().GetAllSkills()) + skill.Reset(player); + } + } + +} 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 f28fe44c6..cd14c1a97 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 @@ -587,7 +587,7 @@ public class CaptureTheFlag extends TeamGame for (Flag flag : _flags) if (!flag.isAtHome()) if (flag.getCarrier() != null) - if (flag.getCarrier().getName().equals(event.GetPlayer().getName())) + if (flag.getCarrier().getName().equals(event.getPlayer().getName())) { event.setCancelled(true); event.setCancelMessage("You cannot change kits while holding a flag!"); 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 603041ee6..e25eff6f8 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 @@ -4,10 +4,10 @@ import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextBottom; @@ -21,7 +21,6 @@ import nautilus.game.arcade.game.games.common.CaptureTheFlag; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.FireworkEffect; -import org.bukkit.Sound; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 05be6dd43..11253f420 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -200,7 +200,7 @@ public class DragonEscape extends SoloGame @EventHandler public void Invisibility(PlayerKitGiveEvent event) { - Manager.GetCondition().Factory().Invisible(GetName(), event.GetPlayer(), event.GetPlayer(), 40, 0, false, false, false); + Manager.GetCondition().Factory().Invisible(GetName(), event.getPlayer(), event.getPlayer(), 40, 0, false, false, false); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index a49a647fd..51deb7fae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -341,45 +341,45 @@ public class MineStrike extends TeamGame @EventHandler public void giveStartEquipment(PlayerKitGiveEvent event) { - GameTeam team = GetTeam(event.GetPlayer()); + GameTeam team = GetTeam(event.getPlayer()); if (team == null) return; if (team.GetColor() == ChatColor.RED) { - if (IsAlive(event.GetPlayer())) + if (IsAlive(event.getPlayer())) { //Pistol Gun gun = new Gun(GunStats.GLOCK_18); - registerGun(gun, event.GetPlayer()); - gun.giveToPlayer(event.GetPlayer(), true); + registerGun(gun, event.getPlayer()); + gun.giveToPlayer(event.getPlayer(), true); //Knife - event.GetPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, "Knife")); + event.getPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, "Knife")); //Armor - giveTeamArmor(event.GetPlayer(), Color.fromRGB(255, 0, 0)); + giveTeamArmor(event.getPlayer(), Color.fromRGB(255, 0, 0)); } } else if (team.GetColor() == ChatColor.AQUA) { - if (IsAlive(event.GetPlayer())) + if (IsAlive(event.getPlayer())) { //Pistol Gun gun = new Gun(GunStats.P2000); - registerGun(gun, event.GetPlayer()); - gun.giveToPlayer(event.GetPlayer(), true); + registerGun(gun, event.getPlayer()); + gun.giveToPlayer(event.getPlayer(), true); //Knife - event.GetPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Knife")); + event.getPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Knife")); //Armor - giveTeamArmor(event.GetPlayer(), Color.fromRGB(0, 0, 255)); + giveTeamArmor(event.getPlayer(), Color.fromRGB(0, 0, 255)); } } //Enter Shop - _shopManager.enterShop(event.GetPlayer()); + _shopManager.enterShop(event.getPlayer()); } @EventHandler(priority = EventPriority.MONITOR)