From daf1d1a9ba372170255fbfaaf1c3f2441931d60e Mon Sep 17 00:00:00 2001 From: samczsun Date: Wed, 25 May 2016 19:35:20 -0400 Subject: [PATCH] Fix duplication glitch using fissure --- .../game/clans/clans/ClansManager.java | 11 +++++ .../classcombat/Skill/Mage/FissureData.java | 7 +++ .../Mage/events/FissureModifyBlockEvent.java | 46 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/events/FissureModifyBlockEvent.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 69af91170..dca0a3881 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -81,6 +81,7 @@ import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; +import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; @@ -99,6 +100,7 @@ import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.SignChangeEvent; @@ -310,6 +312,15 @@ public class ClansManager extends MiniClientPluginimplements IRelati ClanTerritory territory = _clanUtility.getClaim(location); return territory == null || !territory.Safe; }); + registerEvents(new Listener() + { + @EventHandler + public void on(FissureModifyBlockEvent event) + { + Material targetType = event.getTargetBlock().getType(); + event.setCancelled(targetType == Material.POTATO || targetType == Material.CARROT); + } + }); _worldEvent.setFactory(skillManager); _classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java index 45833b8d1..8fd59a6d1 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java @@ -8,6 +8,8 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.block.Block; @@ -122,6 +124,11 @@ public class FissureData { return false; } + FissureModifyBlockEvent event = UtilServer.CallEvent(new FissureModifyBlockEvent(block)); + if (event.isCancelled()) + { + return false; + } if (block.getType().toString().contains("BANNER")) return false; if (block.getRelative(BlockFace.UP).getType().toString().contains("BANNER")) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/events/FissureModifyBlockEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/events/FissureModifyBlockEvent.java new file mode 100644 index 000000000..fe34bd51e --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/events/FissureModifyBlockEvent.java @@ -0,0 +1,46 @@ +package mineplex.minecraft.game.classcombat.Skill.Mage.events; + +import org.bukkit.block.Block; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class FissureModifyBlockEvent extends Event implements Cancellable +{ + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Block _targetBlock; + + private boolean _cancelled; + + public FissureModifyBlockEvent(Block targetBlock) + { + this._targetBlock = targetBlock; + } + + public boolean isCancelled() + { + return this._cancelled; + } + + public void setCancelled(boolean cancelled) + { + this._cancelled = cancelled; + } + + public Block getTargetBlock() + { + return this._targetBlock; + } + + @Override + public HandlerList getHandlers() + { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() + { + return HANDLER_LIST; + } +}