Fixes a problem in the spawn egg check

This commit is contained in:
Kristian Knarvik 2024-01-12 21:29:43 +01:00
parent 69a667dd95
commit 71a2ae03f3

View File

@ -113,7 +113,7 @@ public class PlayerListener extends WorldGuardListener {
private boolean updateClearRegions(@NotNull Player player, @NotNull Location from, @NotNull Location to) { private boolean updateClearRegions(@NotNull Player player, @NotNull Location from, @NotNull Location to) {
Set<ProtectedRegion> regionsEntered = getRegionsEntered(from, to); Set<ProtectedRegion> regionsEntered = getRegionsEntered(from, to);
if (!regionsEntered.isEmpty()) { if (!regionsEntered.isEmpty()) {
if (!player.getInventory().isEmpty()) { if (!player.getInventory().isEmpty() || player.isInsideVehicle() || !player.getPassengers().isEmpty()) {
return true; return true;
} }
Bukkit.getPluginManager().callEvent(new EnterClearRegionEvent(player, regionsEntered)); Bukkit.getPluginManager().callEvent(new EnterClearRegionEvent(player, regionsEntered));
@ -172,8 +172,8 @@ public class PlayerListener extends WorldGuardListener {
// Block usage of spawn eggs // Block usage of spawn eggs
ItemStack item = event.getItem(); ItemStack item = event.getItem();
if (item != null && isInClearRegion(player) && item.hasItemMeta()) { if (item != null && PlayerRegionTracker.isInClearRegion(player)) {
ItemMeta meta = event.getItem().getItemMeta(); ItemMeta meta = item.getItemMeta();
if (meta instanceof SpawnEggMeta && !player.hasPermission(Permission.BYPASS_MOB_SPAWNING.toString())) { if (meta instanceof SpawnEggMeta && !player.hasPermission(Permission.BYPASS_MOB_SPAWNING.toString())) {
ClearOnWorldGuard.logDebugMessage("Prevented player " + player + " from using the spawn egg " + item); ClearOnWorldGuard.logDebugMessage("Prevented player " + player + " from using the spawn egg " + item);
event.setCancelled(true); event.setCancelled(true);