From c24f79950353094e04ace0f817a55e1ded9c9605 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 21 Jun 2018 18:19:38 +0100 Subject: [PATCH] Make some adjustments from comparing branches --- .../game/arcade/game/games/AbsorptionFix.java | 67 ------------------- .../games/bridge/modes/InsaneBridges.java | 5 +- .../game/games/bridge/modes/LuckyBridges.java | 5 +- .../games/bridge/modes/OverpoweredBridge.java | 5 +- .../game/games/bridge/modes/UHCBridges.java | 5 +- .../arcade/game/games/cakewars/CakeWars.java | 5 +- .../cakewars/general/CakePlayerModule.java | 18 ++--- .../games/cakewars/item/items/CakeSheep.java | 5 +- .../games/cakewars/shop/CakeTeamItem.java | 6 +- .../sheep/modes/OverpoweredSheepQuest.java | 5 +- .../skywars/modes/OverpoweredSkywars.java | 5 +- .../game/games/skywars/modes/UHCSkywars.java | 5 +- .../game/arcade/game/games/uhc/UHC.java | 5 +- .../arcade/game/modules/AbsorptionFix.java | 36 ++++++++++ 14 files changed, 75 insertions(+), 102 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/AbsorptionFix.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AbsorptionFix.java 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 deleted file mode 100644 index 75bb001fb..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/AbsorptionFix.java +++ /dev/null @@ -1,67 +0,0 @@ -package nautilus.game.arcade.game.games; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; - -/** - * AbsorptionFix takes care of Absorption being ignored - * use this if you want to give out Golden apples - * it will convert Absorbtion into Health boost - * - * @author xXVevzZXx - */ -public class AbsorptionFix implements Listener -{ - private final Game _host; - - public AbsorptionFix(Game game) - { - _host = game; - - game.Manager.registerEvents(this); - } - - @EventHandler - public void convertAbsorption(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - for (Player player : _host.GetPlayers(true)) - { - if (player.hasPotionEffect(PotionEffectType.ABSORPTION)) - { - for (PotionEffect effect : player.getActivePotionEffects()) - { - if (effect.getType().toString().equalsIgnoreCase(PotionEffectType.ABSORPTION.toString())) - { - player.removePotionEffect(PotionEffectType.ABSORPTION); - player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles())); - player.setHealth(player.getHealth() + 4); - } - } - } - } - } - - @EventHandler - public void disable(GameStateChangeEvent event) - { - if (event.GetState() == GameState.End || event.GetState() == GameState.Dead) - { - HandlerList.unregisterAll(this); - } - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/InsaneBridges.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/InsaneBridges.java index b3c655d27..30632e560 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/InsaneBridges.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/InsaneBridges.java @@ -17,7 +17,7 @@ import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.bridge.Bridge; /** @@ -33,7 +33,8 @@ public class InsaneBridges extends Bridge { super(manager, GameType.Brawl); - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); Manager.GetDamage().SetEnabled(false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/LuckyBridges.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/LuckyBridges.java index fcf06d09e..c9050aaa1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/LuckyBridges.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/LuckyBridges.java @@ -3,7 +3,7 @@ package nautilus.game.arcade.game.games.bridge.modes; import mineplex.core.common.util.UtilMath; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.bridge.Bridge; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -45,7 +45,8 @@ public class LuckyBridges extends Bridge Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS, Material.GOLD_PICKAXE, Material.GOLD_AXE, Material.GOLD_SWORD, Material.GOLDEN_APPLE)); - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); } @EventHandler 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 5935aaee0..35a3654af 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 @@ -28,7 +28,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.bridge.Bridge; import net.md_5.bungee.api.ChatColor; @@ -51,7 +51,8 @@ public class OverpoweredBridge extends Bridge Manager.GetDamage().SetEnabled(false); - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); _starterItems = new HashMap<>(); _starterItems.put(Material.WOOD, 64); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/UHCBridges.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/UHCBridges.java index 076133a39..56dd41e3d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/UHCBridges.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/UHCBridges.java @@ -24,7 +24,7 @@ import mineplex.core.common.util.UtilServer; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.bridge.Bridge; /** @@ -41,7 +41,8 @@ public class UHCBridges extends Bridge SoupEnabled = false; - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); ShapedRecipe headApple = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1)); headApple.shape("GGG", "GHG", "GGG"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java index 2cf6b50de..212f73f94 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java @@ -44,7 +44,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.cakewars.capturepoint.CakePointModule; import nautilus.game.arcade.game.games.cakewars.general.CakeBatModule; import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule; @@ -192,7 +192,8 @@ public class CakeWars extends TeamGame manager.GetDamage().setConstantKnockback(GAME_KNOCKBACK); manager.GetCreature().SetDisableCustomDrops(true); - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); new CompassModule() .register(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/general/CakePlayerModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/general/CakePlayerModule.java index 779e6e681..e4d5852e6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/general/CakePlayerModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/general/CakePlayerModule.java @@ -13,7 +13,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.InventoryOpenEvent; @@ -31,7 +30,6 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -294,6 +292,11 @@ public class CakePlayerModule extends CakeModule @EventHandler public void spawnProtection(CustomDamageEvent event) { + if (event.IsCancelled()) + { + return; + } + Player damager = event.GetDamagerPlayer(true); Player damagee = event.GetDamageePlayer(); @@ -302,16 +305,9 @@ public class CakePlayerModule extends CakeModule damager.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); } - if (damagee != null) + if (damagee != null && damagee.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) { - if (event.GetCause() == DamageCause.SUFFOCATION && !Recharge.Instance.use(damagee, "Suffocation", 1100, false, false)) - { - event.SetCancelled("Suffocation Rate"); - } - else if (damagee.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) - { - event.SetCancelled("Damage Resistance"); - } + event.SetCancelled("Damage Resistance"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/item/items/CakeSheep.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/item/items/CakeSheep.java index f180baf4f..a33dbf3f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/item/items/CakeSheep.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/item/items/CakeSheep.java @@ -47,7 +47,7 @@ public class CakeSheep extends CakeSpecialItem implements Listener "", "Spawns Polly The Sheep...", "After " + C.cRed + "5 seconds" + C.cGray + " she explodes destroying", - "all player placed blocks around her.", + "nearby player placed blocks.", "If she is killed she does not explode.", "Warning! Polly has a", C.cRed + "20 second" + C.cGray + " cooldown between uses." ) @@ -138,8 +138,7 @@ public class CakeSheep extends CakeSpecialItem implements Listener // I originally was going to use the NMS way to get the "hardness" of a block // but I decided against it as the values were way too varied for this game. - // The value for chance should be taken from if the blocks was within half of - // the explosion radius, after that it decreases. + // The value for chance should be taken from if the block was right next to the sheep. switch (block.getType()) { case WOOL: diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeTeamItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeTeamItem.java index d9851fd9f..4051e9a61 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeTeamItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/shop/CakeTeamItem.java @@ -96,7 +96,7 @@ public enum CakeTeamItem implements CakeItem RESOURCE( "Resource Generator", new ItemStack(Material.NETHER_STAR), - "When an item generates in your generator it also generate %s extra.", + "When an item generates in your generator it will also generate %s extra.", Pair.create("1", 10), Pair.create("2", 20) ), @@ -104,8 +104,8 @@ public enum CakeTeamItem implements CakeItem "Healing Station", new ItemStack(Material.GOLDEN_APPLE), "Receive %s when within %s of your cake.", - Pair.create("Regeneration I;5 blocks", 8), - Pair.create("Regeneration I;8 blocks", 12) + Pair.create("Regeneration I;" + CakeShopModule.getHealingStationRadius(1) + " blocks", 8), + Pair.create("Regeneration I;" + CakeShopModule.getHealingStationRadius(2) + " blocks", 12) ) { @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/OverpoweredSheepQuest.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/OverpoweredSheepQuest.java index 64a4c46ae..a613bbf26 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/OverpoweredSheepQuest.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/OverpoweredSheepQuest.java @@ -2,7 +2,7 @@ package nautilus.game.arcade.game.games.sheep.modes; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.sheep.SheepGame; import nautilus.game.arcade.game.games.sheep.modes.kits.KitShepherd; import nautilus.game.arcade.game.modules.TeamArmorModule; @@ -26,7 +26,8 @@ public class OverpoweredSheepQuest extends SheepGame getModule(TeamArmorModule.class) .dontGiveTeamArmor(); - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/OverpoweredSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/OverpoweredSkywars.java index 7b015cda5..9ed8d421e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/OverpoweredSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/OverpoweredSkywars.java @@ -2,7 +2,7 @@ package nautilus.game.arcade.game.games.skywars.modes; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.skywars.TeamSkywars; /** @@ -17,7 +17,8 @@ public class OverpoweredSkywars extends TeamSkywars { super(manager, GameType.Brawl); - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java index 1cbc14f81..43dfe52b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/modes/UHCSkywars.java @@ -13,7 +13,7 @@ import org.bukkit.scoreboard.Objective; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.skywars.SoloSkywars; /** @@ -30,7 +30,8 @@ public class UHCSkywars extends SoloSkywars SoupEnabled = false; - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index 14487f056..252c29c2b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -105,7 +105,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.AbsorptionFix; +import nautilus.game.arcade.game.modules.AbsorptionFix; import nautilus.game.arcade.game.games.uhc.components.UHCBorder; import nautilus.game.arcade.game.games.uhc.components.UHCFreezer; import nautilus.game.arcade.game.games.uhc.components.UHCSpeedMode; @@ -307,7 +307,8 @@ public abstract class UHC extends Game .register(this); new OreVeinEditorModule().removeNonAirVeins().register(this); new RejoinModule().register(this); - new AbsorptionFix(this); + new AbsorptionFix() + .register(this); registerStatTrackers(new CollectFoodStat(this), new HoeCraftingStat(this), new LuckyMinerStat(this), new HalfHeartHealStat(this)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AbsorptionFix.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AbsorptionFix.java new file mode 100644 index 000000000..d8970a30f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/AbsorptionFix.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.modules; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class AbsorptionFix extends Module +{ + + @EventHandler + public void convertAbsorption(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (Player player : getGame().GetPlayers(true)) + { + for (PotionEffect effect : player.getActivePotionEffects()) + { + if (effect.getType().toString().equalsIgnoreCase(PotionEffectType.ABSORPTION.toString())) + { + player.removePotionEffect(PotionEffectType.ABSORPTION); + player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles())); + UtilPlayer.health(player, 4); + } + } + } + } +} \ No newline at end of file