Allow Villagers to be named public to bypass claim checks

This commit is contained in:
destro174 2022-02-14 09:46:51 +01:00
parent 244e582e97
commit 01d303d484

View File

@ -52,6 +52,7 @@ import org.bukkit.entity.Mule;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.Villager;
import org.bukkit.entity.minecart.PoweredMinecart;
import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.event.EventHandler;
@ -860,6 +861,17 @@ class PlayerEventHandler implements Listener
//if the entity is an animal, apply container rules
if ((instance.config_claims_preventTheft && (entity instanceof Animals || entity instanceof Fish)) || (entity.getType() == EntityType.VILLAGER && instance.config_claims_villagerTradingRequiresTrust))
{
if (entity.getType() == EntityType.VILLAGER) {
// early check for custom name to not waste time on getting the claim if not needed?
Villager villager = (Villager) entity;
if (villager.getCustomName() != null)
{
if (ChatColor.stripColor(villager.getCustomName()).equalsIgnoreCase("public"))
{
return;
}
}
}
//if the entity is in a claim
Claim claim = this.dataStore.getClaimAt(entity.getLocation(), false, null);
if (claim != null)