From ef4a575d28ac036d7448f7f5ee7e09db29720079 Mon Sep 17 00:00:00 2001 From: Cheese Date: Thu, 16 Jul 2015 12:47:39 +1000 Subject: [PATCH] fixed blocktoss exploits --- .../classcombat/Skill/Brute/BlockToss.java | 52 ++++++------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index 204129272..4813d73f5 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -26,6 +26,7 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilServer; @@ -43,7 +44,14 @@ public class BlockToss extends SkillCharge implements IThrown { private HashMap _holding = new HashMap(); private HashMap _falling = new HashMap(); - + + private Material[] _blacklist = new Material[] + { + Material.TNT, + Material.IRON_DOOR, + Material.IRON_DOOR_BLOCK, + }; + public BlockToss(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { super(skills, name, classType, skillType, cost, levels, @@ -101,32 +109,16 @@ public class BlockToss extends SkillCharge implements IThrown //Recharge if (!Recharge.Instance.use(player, GetName(), 1000, false, false)) - return; + return; - //Door - if (grab.getRelative(BlockFace.UP).getTypeId() == 64 || grab.getRelative(BlockFace.UP).getTypeId() == 71) - { - UtilPlayer.message(player, F.main(GetName(), "You cannot grab this block.")); + //Blacklist + for (Material mat : _blacklist) + if (mat == grab.getType()) + return; + + //Usable + if (UtilBlock.usable(grab)) return; - } - - //TrapDoor or ladder - for (int x = -1; x <= 1; x++) - { - for (int z = -1; z <= 1; z++) - { - if (x != z && (z == 0 || x == 0)) - { - Block block = grab.getRelative(x, 0, z); - - if (block.getType() == Material.TRAP_DOOR || block.getType() == Material.LADDER) - { - UtilPlayer.message(player, F.main(GetName(), "You cannot grab this block.")); - return; - } - } - } - } //Block to Item FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), event.getClickedBlock().getType(), (byte)0); @@ -295,16 +287,6 @@ public class BlockToss extends SkillCharge implements IThrown { int id = event.getEntity().getItemStack().getTypeId(); - if ( - id != 1 && - id != 2 && - id != 3 && - id != 4 && - id != 12 && - id != 13 && - id != 80) - return; - for (FallingBlock block : _falling.keySet()) if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1) event.setCancelled(true);