From ff37cc7935ffbde64a904a30207d2b8d2b85980a Mon Sep 17 00:00:00 2001 From: wizjany Date: Wed, 6 Mar 2019 19:05:36 -0500 Subject: [PATCH] Add item-frame-rotation flag. When set to allow, allows players to rotate item in item frames even if they wouldn't normally have permissions to modify the item frame. Fixes WORLDGUARD-3588. --- .../java/com/sk89q/worldguard/protection/flags/Flags.java | 1 + .../bukkit/listener/RegionProtectionListener.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java b/worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java index f4ee3789..d1a2ec35 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java @@ -59,6 +59,7 @@ public final class Flags { public static final StateFlag LIGHTER = register(new StateFlag("lighter", false)); public static final StateFlag RIDE = register(new StateFlag("ride", false)); public static final StateFlag POTION_SPLASH = register(new StateFlag("potion-splash", false)); + public static final StateFlag ITEM_FRAME_ROTATE = register(new StateFlag("item-frame-rotation", false)); // These flags are similar to the ones above (used in tandem with BUILD), // but their defaults are set to TRUE because it is more user friendly. diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java index 220074d6..07e2eb5b 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java @@ -424,7 +424,12 @@ public void onUseEntity(UseEntityEvent event) { /* Paintings, item frames, etc. */ } else if (Entities.isConsideredBuildingIfUsed(event.getEntity())) { - canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event)); + if (event.getEntity().getType() == EntityType.ITEM_FRAME && event.getCause().getFirstPlayer() != null + && ((org.bukkit.entity.ItemFrame) event.getEntity()).getItem() != null) { + canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.ITEM_FRAME_ROTATE)); + } else { + canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event)); + } what = "change that"; /* Ridden on use */