Fix duplication glitch using fissure

This commit is contained in:
samczsun 2016-05-25 19:35:20 -04:00 committed by cnr
parent ef0dcdb0df
commit daf1d1a9ba
3 changed files with 64 additions and 0 deletions

View File

@ -81,6 +81,7 @@ import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; 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.Skill.SkillFactory;
import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.item.ItemFactory;
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
@ -99,6 +100,7 @@ import org.bukkit.entity.Horse;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
@ -310,6 +312,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
ClanTerritory territory = _clanUtility.getClaim(location); ClanTerritory territory = _clanUtility.getClaim(location);
return territory == null || !territory.Safe; 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); _worldEvent.setFactory(skillManager);
_classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress); _classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress);

View File

@ -8,6 +8,8 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; 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.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -122,6 +124,11 @@ public class FissureData
{ {
return false; return false;
} }
FissureModifyBlockEvent event = UtilServer.CallEvent(new FissureModifyBlockEvent(block));
if (event.isCancelled())
{
return false;
}
if (block.getType().toString().contains("BANNER")) if (block.getType().toString().contains("BANNER"))
return false; return false;
if (block.getRelative(BlockFace.UP).getType().toString().contains("BANNER")) if (block.getRelative(BlockFace.UP).getType().toString().contains("BANNER"))

View File

@ -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;
}
}