From cdbab61382c43ad6653f14bd22c4979e388872cc Mon Sep 17 00:00:00 2001 From: Github Date: Mon, 21 Mar 2022 10:06:40 +0100 Subject: [PATCH] [CORE] Reimplement Protection Fix and Split ItemFrame and ArmorStand CanEdit. Potential Fix for: Wolfieheart/ArmorStandEditor-Issues#28 Signed-off-by: Wolfieheart Signed-off-by: Github --- .../armorstandeditor/PlayerEditorManager.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java index c1d295d6..3b5f452e 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java @@ -231,7 +231,7 @@ private ArrayList getTargets(Player player) { if (!nearby.isEmpty()) { boolean endLaser = false; for ( Entity e : nearby) { - if (e instanceof ArmorStand && canEdit(player, e)) { + if (e instanceof ArmorStand) { armorStands.add((ArmorStand) e); endLaser = true; } @@ -262,7 +262,7 @@ private ArrayList getFrameTargets(Player player) { if (!nearby.isEmpty()) { boolean endLaser = false; for ( Entity e : nearby) { - if (e instanceof ItemFrame && canEdit(player, e)) { + if (e instanceof ItemFrame) { itemFrames.add((ItemFrame) e); endLaser = true; } @@ -277,10 +277,30 @@ private ArrayList getFrameTargets(Player player) { return itemFrames; } - boolean canEdit( Player player, Entity entity) { + boolean canEdit( Player player, ArmorStand as) { //Get the Entity being checked for editing - Block block = entity.getLocation().getBlock(); + Block block = as.getLocation().getBlock(); + + //Implementation of Protection Support - PlotSquared, WorldGuard, Towny, GriefPrevention etc. + TownyProtection townyProtection = new TownyProtection(); + PlotSquaredProtection plotSquaredProtection = new PlotSquaredProtection(); + WorldGuardProtection worldGuardProtection = new WorldGuardProtection(); + GriefPreventionProtection griefPreventionProtection = new GriefPreventionProtection(); + + //Permission checks for Protection + boolean protectTActive = townyProtection.checkPermission(block, player); + boolean protectPSActive = plotSquaredProtection.checkPermission(block, player); + boolean protectWGActive = worldGuardProtection.checkPermission(block, player); + boolean protectGPActive = griefPreventionProtection.checkPermission(block, player); + + return protectTActive && protectPSActive && protectWGActive && protectGPActive; + } + + boolean canEdit( Player player, ItemFrame itemF) { + + //Get the Entity being checked for editing + Block block = itemF.getLocation().getBlock(); //Implementation of Protection Support - PlotSquared, WorldGuard, Towny, GriefPrevention etc. TownyProtection townyProtection = new TownyProtection();