Allow inventoryholders to be named public to bypass claims

This commit is contained in:
destro174 2022-02-14 09:45:55 +01:00
parent 1a22d4acc0
commit 244e582e97

View File

@ -27,6 +27,7 @@ import org.bukkit.Chunk;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Nameable;
import org.bukkit.OfflinePlayer;
import org.bukkit.Tag;
import org.bukkit.World;
@ -1326,6 +1327,21 @@ class PlayerEventHandler implements Listener
return;
}
// there's no need to check for claims as this is a claiming bypass?
Block block = event.getClickedBlock();
// TODO : doesn't cover cartography tables add these...
/* This should cover all chests, enderchests, barrels, furnacetypes, lectern, ....*/
if(block.getState() instanceof InventoryHolder) {
if (block.getState() instanceof Nameable) {
Nameable nameable = (Nameable) block.getState();
if (nameable.getCustomName() != null) {
if (ChatColor.stripColor(nameable.getCustomName()).equalsIgnoreCase("public")) {
return;
}
}
}
}
//otherwise check permissions for the claim the player is in
Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, playerData.lastClaim);
if (claim != null)