mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 15:08:18 +01:00
[Protect] Prevent creepers from breaking paintings if their explosions are disabled.
Backport from 3.0
This commit is contained in:
parent
964bdc6d30
commit
d5f702f2cb
@ -13,6 +13,8 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsProtectEntityListener implements Listener
|
public class EssentialsProtectEntityListener implements Listener
|
||||||
@ -176,7 +178,7 @@ public class EssentialsProtectEntityListener implements Listener
|
|||||||
private boolean shouldBeDamaged(final User user, final String type)
|
private boolean shouldBeDamaged(final User user, final String type)
|
||||||
{
|
{
|
||||||
return (user.isAuthorized("essentials.protect.damage.".concat(type))
|
return (user.isAuthorized("essentials.protect.damage.".concat(type))
|
||||||
&& !user.isAuthorized("essentials.protect.damage.disable"));
|
&& !user.isAuthorized("essentials.protect.damage.disable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -232,7 +234,7 @@ public class EssentialsProtectEntityListener implements Listener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This code will prevent explosions near protected rails, signs or protected chests
|
// This code will prevent explosions near protected rails, signs or protected chests
|
||||||
// TODO: Use protect db instead of this code
|
// TODO: Use protect db instead of this code
|
||||||
|
|
||||||
@ -332,4 +334,15 @@ public class EssentialsProtectEntityListener implements Listener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onPaintingBreak(HangingBreakByEntityEvent event)
|
||||||
|
{
|
||||||
|
if (event.getCause() == HangingBreakEvent.RemoveCause.ENTITY
|
||||||
|
&& event.getRemover() instanceof Creeper
|
||||||
|
&& prot.getSettingBool(ProtectConfig.prevent_creeper_explosion))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user