Skip to content

Commit

Permalink
[CORE] Reimplement Protection Fix and Split ItemFrame and ArmorStand …
Browse files Browse the repository at this point in the history
…CanEdit. Potential Fix for: Wolfieheart/ArmorStandEditor-Issues#28

Signed-off-by: Wolfieheart <xMakeItRain94@gmail.com>
Signed-off-by: Github <xMakeItRain94@gmail.com>
  • Loading branch information
Wolfieheart committed May 17, 2022
1 parent ec0ea02 commit cdbab61
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private ArrayList<ArmorStand> 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;
}
Expand Down Expand Up @@ -262,7 +262,7 @@ private ArrayList<ItemFrame> 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;
}
Expand All @@ -277,10 +277,30 @@ private ArrayList<ItemFrame> 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();
Expand Down

0 comments on commit cdbab61

Please sign in to comment.