From 399ab5c36367ac321e650ada7311baf35e223edf Mon Sep 17 00:00:00 2001 From: xXVevzZXx Date: Fri, 17 Jun 2016 20:25:57 +0200 Subject: [PATCH] fix supply chest protection, absorbtion effect, tnt and level bugs --- .../src/nautilus/game/arcade/GameType.java | 23 ++++--- .../src/nautilus/game/arcade/game/Game.java | 2 +- .../game/arcade/game/games/AbsorptionFix.java | 2 +- .../games/bridge/modes/OverpoweredBridge.java | 61 ++++++++++++++----- .../game/arcade/kit/ProgressingKit.java | 4 +- .../arcade/managers/GameLobbyManager.java | 2 +- 6 files changed, 68 insertions(+), 26 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index ec3f1e5bb..0e44d3a63 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -218,7 +218,7 @@ public enum GameType Pair[] _resourcePacks; Class _gameClass; - GameMode[] _gameModes; + private GameMode[] _gameModes; private boolean _gameMaps; private int _gameId; // Unique identifying id for this gamemode (used for statistics) @@ -322,16 +322,15 @@ public enum GameType return _display.getGameCategory(); } - public String GetKitGameName() + public String GetKitGameName(Game game) { + if (hasGamemodes()) + { + return getModeGameType(game.getClass())._display.getKitGameName(); + } return _display.getKitGameName(); } - public boolean isUsingGameModes() - { - return _gameMaps; - } - public GameType getModeGameType(Class game) { for (GameMode mode : getGameModes()) @@ -343,4 +342,14 @@ public enum GameType } return null; } + + public boolean isUsingGameModesMaps() + { + return _gameMaps; + } + + public boolean hasGamemodes() + { + return _gameModes.length != 0; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index aa6fe3de0..e75edf107 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -462,7 +462,7 @@ public abstract class Game implements Listener } } - if (GetType().isUsingGameModes()) + if (GetType().isUsingGameModesMaps()) { GameType mode = GetType().getModeGameType(getClass()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/AbsorptionFix.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/AbsorptionFix.java index c4b3dde6c..12e76f397 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/AbsorptionFix.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/AbsorptionFix.java @@ -48,7 +48,7 @@ public class AbsorptionFix implements Listener { player.removePotionEffect(PotionEffectType.ABSORPTION); player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles())); - player.setHealth(player.getMaxHealth()); + player.setHealth(player.getHealth() + 4); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java index a81bdfde5..54c93ec8b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -21,6 +22,7 @@ import org.bukkit.potion.Potion; import org.bukkit.potion.PotionType; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.ArcadeManager; @@ -49,6 +51,8 @@ public class OverpoweredBridge extends Bridge WorldBoundaryKill = true; + Manager.GetDamage().SetEnabled(false); + new AbsorptionFix(this); } @@ -128,6 +132,10 @@ public class OverpoweredBridge extends Bridge public void supplyChest(PlayerPrepareTeleportEvent event) { Location chestLoc = event.GetPlayer().getLocation().clone().add(0, 0, 1); + + while (chestLoc.getBlock().getType() == Material.CHEST) + chestLoc.add(2, 0, 0); + _starterChests.put(event.GetPlayer(), chestLoc); Block block = chestLoc.getBlock(); @@ -136,8 +144,9 @@ public class OverpoweredBridge extends Bridge Chest chest = (Chest) block.getState(); - event.GetPlayer().getLocation().getBlock().setType(Material.WALL_SIGN); - Sign sign = (Sign) event.GetPlayer().getLocation().getBlock().getState(); + Block signBlock = chestLoc.clone().add(0, 0, -1).getBlock(); + signBlock.setType(Material.WALL_SIGN); + Sign sign = (Sign) signBlock.getState(); sign.setLine(0, "§b============="); sign.setLine(1, "§4§l" + event.GetPlayer().getName() + ChatColor.RESET + "§4's"); sign.setLine(2, "§4Supply Chest"); @@ -182,20 +191,18 @@ public class OverpoweredBridge extends Bridge if (event.getClickedBlock().getType() != Material.CHEST) return; - for (Player player : _starterChests.keySet()) - { - if (player == event.getPlayer()) - continue; - - if (_starterChests.get(player).getBlock().getLocation() - .equals(event.getClickedBlock().getLocation())) - { - event.setCancelled(true); - break; - } - } + event.setCancelled(disallow(event.getPlayer(), event.getClickedBlock())); } } + + @EventHandler + public void placeChest(BlockPlaceEvent event) + { + if (event.getBlockPlaced().getType() != Material.CHEST) + return; + + event.setCancelled(disallow(event.getPlayer(), event.getBlock())); + } @EventHandler public void CheatChestBreak(BlockBreakEvent event) @@ -219,6 +226,32 @@ public class OverpoweredBridge extends Bridge } } } + + private boolean disallow(Player clicker, Block block) + { + for (Player player : _starterChests.keySet()) + { + System.out.println("test4"); + if (player == clicker) + continue; + + System.out.println("test2"); + Location chest = _starterChests.get(player); + + if (chest.getBlock().getLocation().equals(block.getLocation())) + { + System.out.println("test1"); + return true; + } + + for (Block surround : UtilBlock.getSurrounding(block, false)) + { + if(chest.getBlock().getLocation().equals(surround.getLocation())) + return true; + } + } + return false; + } @Override public void ParseOre(ArrayList teamOre) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index 609d3ba39..4985238d4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -292,7 +292,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit if (this.GetAvailability() == KitAvailability.Free || Manager.hasKitsUnlocked(player) || (this.GetAvailability() == KitAvailability.Achievement && Manager.GetAchievement().hasCategory(player, this.getAchievementRequirement())) || - donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + this.GetName()) || + donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()) + " " + this.GetName()) || Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || Manager.GetServerConfig().Tournament) { @@ -306,7 +306,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { Manager.GetGame().SetKit(player, this, true); } - }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(), this), CurrencyType.GEM, player)); + }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(Manager.GetGame()), this), CurrencyType.GEM, player)); } else if (this.GetAvailability() == KitAvailability.Achievement) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 3f57172cf..4c5e08125 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -1177,7 +1177,7 @@ public class GameLobbyManager implements Listener Manager.hasKitsUnlocked(player) || //YouTube (ent.GetKit().GetAvailability() == KitAvailability.Achievement && Manager.GetAchievement().hasCategory(player, ent.GetKit().getAchievementRequirement())) || //Achievement - donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + ent.GetKit().GetName()) || //Green + donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName(game) + " " + ent.GetKit().GetName()) || //Green Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) Manager.GetServerConfig().Tournament) //Tournament