mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-26 18:11:52 +01:00
Added enderman pickup to sign protection
This commit is contained in:
parent
ad3bc2ad98
commit
d60dd01f0f
@ -182,6 +182,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
final SignEntityListener signEntityListener = new SignEntityListener(this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.ENDERMAN_PICKUP, signEntityListener, Priority.Low, this);
|
||||
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
|
||||
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
|
||||
|
@ -177,6 +177,11 @@ public class EssentialsSign
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onBlockBreak(final Block block, final IEssentials ess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onBlockExplode(final Block block, final IEssentials ess)
|
||||
{
|
||||
|
@ -3,6 +3,8 @@ package com.earth2me.essentials.signs;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.entity.EndermanPickupEvent;
|
||||
import org.bukkit.event.entity.EndermanPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
@ -40,4 +42,33 @@ public class SignEntityListener extends EntityListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndermanPickup(EndermanPickupEvent event)
|
||||
{
|
||||
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Block block = event.getBlock();
|
||||
if (((block.getType() == Material.WALL_SIGN
|
||||
|| block.getType() == Material.SIGN_POST)
|
||||
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Signs signs : Signs.values())
|
||||
{
|
||||
final EssentialsSign sign = signs.getSign();
|
||||
if (sign.getBlocks().contains(block.getType())
|
||||
&& !sign.onBlockBreak(block, ess))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -300,6 +300,14 @@ public class SignProtection extends EssentialsSign
|
||||
player.sendMessage(Util.format("noDestroyPermission", block.getType().toString().toLowerCase()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockBreak(final Block block, final IEssentials ess)
|
||||
{
|
||||
final SignProtectionState state = isBlockProtected(block, null, null, false);
|
||||
|
||||
return state == SignProtectionState.NOSIGN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockExplode(final Block block, final IEssentials ess)
|
||||
|
Loading…
Reference in New Issue
Block a user