Support for new trial spawners protection

This commit is contained in:
tastybento 2024-07-09 07:31:25 -07:00
parent 2733e31535
commit 2d9bbb9cc1
2 changed files with 8 additions and 3 deletions

View File

@ -21,6 +21,8 @@ import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import com.google.common.base.Enums;
import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.lists.Flags;
@ -101,6 +103,10 @@ public class BreakBlocksListener extends FlagListener {
{
return;
}
if (Enums.getIfPresent(Material.class, "TRIAL_SPAWNER").isPresent() && m.equals(Material.TRIAL_SPAWNER)) {
this.checkIsland(e, p, l, Flags.BREAK_SPAWNERS);
return;
}
switch (m)
{
case CAKE -> this.checkIsland(e, p, l, Flags.BREAK_BLOCKS);

View File

@ -1,6 +1,5 @@
package world.bentobox.bentobox.listeners.flags.worldsettings;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
@ -21,8 +20,8 @@ public class SpawnerSpawnEggsListener extends FlagListener {
public void onSpawnerChange(final PlayerInteractEvent e) {
User user = User.getInstance(e.getPlayer());
// Checking if the clicked block is a spawner and the item in hand is a mob egg
if (e.getClickedBlock() != null && e.getClickedBlock().getType().equals(Material.SPAWNER)
&& e.getItem() != null && e.getItem().getType().toString().endsWith("_SPAWN_EGG")
if (e.getClickedBlock() != null && e.getClickedBlock().getType().name().endsWith("_SPAWNER")
&& e.getItem() != null && e.getItem().getType().name().endsWith("_SPAWN_EGG")
&& getIWM().inWorld(e.getClickedBlock().getWorld())
&& !(user.hasPermission(getIWM().getPermissionPrefix(e.getClickedBlock().getWorld()) + "mod.bypass." + Flags.SPAWNER_SPAWN_EGGS.getID() + ".everywhere")
|| user.hasPermission(getIWM().getPermissionPrefix(e.getClickedBlock().getWorld()) + "mod.bypassprotect"))