Skip to content

Commit

Permalink
Support for new trial spawners protection
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jul 9, 2024
1 parent 2733e31 commit 2d9bbb9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
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;

Expand Down Expand Up @@ -101,6 +103,10 @@ public void onPlayerInteract(final PlayerInteractEvent e)
{
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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"))
Expand Down

0 comments on commit 2d9bbb9

Please sign in to comment.