Added container trust for rotating item frames

This commit is contained in:
Teriuihi 2023-05-01 02:33:15 +02:00
parent f5a99cefd3
commit 4776000c30

View File

@ -48,6 +48,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Item;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Mule;
import org.bukkit.entity.Player;
@ -623,7 +624,7 @@ class PlayerEventHandler implements Listener
}
//don't allow interaction with item frames or armor stands in claimed areas without build permission
if (entity.getType() == EntityType.ARMOR_STAND || entity instanceof Hanging)
if (entity.getType() == EntityType.ARMOR_STAND || entity instanceof Hanging && !(entity instanceof ItemFrame))
{
String noBuildReason = instance.allowBuild(player, entity.getLocation(), Material.ITEM_FRAME);
if (noBuildReason != null)
@ -634,6 +635,17 @@ class PlayerEventHandler implements Listener
}
}
//don't allow interaction with item frames in claimed areas without container permission
if (entity instanceof ItemFrame) {
Claim claim = this.dataStore.getClaimAt(entity.getLocation(), false, playerData.lastClaim);
Supplier<String> stringSupplier = claim.checkPermission(player, ClaimPermission.Access, event);
if (stringSupplier != null) {
instance.sendMessage(player, TextMode.Err, stringSupplier.get());
event.setCancelled(true);
return;
}
}
//always allow interactions when player is in ignore claims mode
if (playerData.ignoreClaims) return;