diff --git a/pom.xml b/pom.xml
index f0ee1db6..877aeee6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
io.github.rypofalem.armorstandeditor
armorstandeditor
jar
- 1.xx.x-37
+ 1.19.2-37
armorstandeditor
http://maven.apache.org
@@ -117,7 +117,7 @@
com.palmergames.bukkit.towny
towny
- 0.98.3.4
+ 0.98.3.8
provided
@@ -141,6 +141,13 @@
2.1.0-SNAPSHOT
provided
+
+
+ com.github.angeschossen
+ LandsAPI
+ 6.12.1
+ provided
+
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java
index ebacce2d..b3d6954f 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java
@@ -19,6 +19,7 @@
package io.github.rypofalem.armorstandeditor;
+import com.google.common.collect.ImmutableList;
import io.github.rypofalem.armorstandeditor.menu.ASEHolder;
import io.github.rypofalem.armorstandeditor.protections.*;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
@@ -56,12 +57,10 @@ public class PlayerEditorManager implements Listener {
private TickCounter counter;
private ArrayList as = null;
private ArrayList itemF = null;
- private TownyProtection townyProtection;
- private PlotSquaredProtection plotSquaredProtection;
- private WorldGuardProtection worldGuardProtection;
- private GriefPreventionProtection griefPreventionProtection;
- private SkyblockProtection skyblockProtection;
- private GriefDefenderProtection griefDefenderProtection;
+ // Instantiate protections used to determine whether a player may edit an armor stand or item frame
+ private final List protections = ImmutableList.of(
+ new GriefDefenderProtection(), new GriefPreventionProtection(), new LandsProtection(),
+ new PlotSquaredProtection(), new SkyblockProtection(), new TownyProtection(), new WorldGuardProtection());
PlayerEditorManager( ArmorStandEditorPlugin plugin) {
this.plugin = plugin;
@@ -72,14 +71,6 @@ public class PlayerEditorManager implements Listener {
fineMov = .03125; // 1/32
counter = new TickCounter();
Bukkit.getServer().getScheduler().runTaskTimer(plugin, counter, 0, 1);
-
- //Implementation of Protection Support - PlotSquared, WorldGuard, Towny, GriefPrevention etc.
- townyProtection = new TownyProtection();
- plotSquaredProtection = new PlotSquaredProtection();
- worldGuardProtection = new WorldGuardProtection();
- griefPreventionProtection = new GriefPreventionProtection();
- skyblockProtection = new SkyblockProtection();
- griefDefenderProtection = new GriefDefenderProtection();
}
@EventHandler(priority = EventPriority.LOWEST)
@@ -290,37 +281,11 @@ private ArrayList getFrameTargets(Player player) {
}
- boolean canEdit( Player player, ArmorStand as) {
-
+ boolean canEdit( Player player, Entity entity) {
//Get the Entity being checked for editing
- Block block = as.getLocation().getBlock();
-
- //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);
- boolean protectSkyActive = skyblockProtection.checkPermission(player);
- boolean protectGDActive = griefDefenderProtection.checkPermission(block, player);
-
- return protectTActive && protectPSActive && protectWGActive && protectGPActive && protectSkyActive && protectGDActive;
-
- }
-
- boolean canEdit( Player player, ItemFrame itemf) {
-
- //Get the Entity being checked for editing
- Block block = itemf.getLocation().getBlock();
-
- //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);
- boolean protectSkyActive = skyblockProtection.checkPermission(player);
- boolean protectGDActive = griefDefenderProtection.checkPermission(block, player);
-
- return protectTActive && protectPSActive && protectWGActive && protectGPActive && protectSkyActive && protectGDActive;
+ Block block = entity.getLocation().getBlock();
+ // Check if all protections allow this edit, if one fails, don't allow edit
+ return protections.stream().allMatch(protection -> protection.checkPermission(block, player));
}
void applyLeftTool( Player player, ArmorStand as) {
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java
index bee0fb38..18221a7c 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java
@@ -12,7 +12,7 @@
import static com.griefdefender.api.claim.TrustTypes.BUILDER;
-public class GriefDefenderProtection {
+public class GriefDefenderProtection implements Protection {
private final boolean gdEnabled;
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefPreventionProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefPreventionProtection.java
index dc852f65..7e92e0e7 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefPreventionProtection.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefPreventionProtection.java
@@ -10,7 +10,7 @@
import org.bukkit.entity.Player;
-public class GriefPreventionProtection {
+public class GriefPreventionProtection implements Protection {
private boolean gpEnabled;
private GriefPrevention griefPrevention = null;
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/LandsProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/LandsProtection.java
new file mode 100644
index 00000000..aac12c11
--- /dev/null
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/LandsProtection.java
@@ -0,0 +1,33 @@
+package io.github.rypofalem.armorstandeditor.protections;
+
+import io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin;
+import me.angeschossen.lands.api.integration.LandsIntegration;
+import me.angeschossen.lands.api.land.Area;
+import me.angeschossen.lands.api.land.Land;
+import me.angeschossen.lands.api.player.LandPlayer;
+import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+
+public class LandsProtection implements Protection {
+ private final boolean landsEnabled;
+ private LandsIntegration lands;
+
+ public LandsProtection() {
+ landsEnabled = Bukkit.getPluginManager().isPluginEnabled("Lands");
+
+ if (landsEnabled)
+ lands = new LandsIntegration(ArmorStandEditorPlugin.instance());
+ }
+
+ @Override
+ public boolean checkPermission(Block block, Player player) {
+ if (!landsEnabled || player.hasPermission("asedit.ignoreProtection.lands")) return true;
+
+ // Check if the player is trusted in the area or land, in case they're not in an area, they're in.
+ Land land = lands.getLand(block.getLocation());
+ Area area = land == null ? null : land.getArea(block.getLocation());
+ LandPlayer lPlayer = lands.getLandPlayer(player.getUniqueId());
+ return area == null ? land == null || land.isTrusted(lPlayer) : area.isTrusted(player.getUniqueId());
+ }
+}
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/PlotSquaredProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/PlotSquaredProtection.java
index 175081fd..850faa42 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/PlotSquaredProtection.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/PlotSquaredProtection.java
@@ -9,7 +9,7 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
-public class PlotSquaredProtection {
+public class PlotSquaredProtection implements Protection {
private final boolean psEnabled;
private BukkitPlatform psPlatform = null;
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/Protection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/Protection.java
new file mode 100644
index 00000000..971c1126
--- /dev/null
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/Protection.java
@@ -0,0 +1,8 @@
+package io.github.rypofalem.armorstandeditor.protections;
+
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+
+public interface Protection {
+ boolean checkPermission(Block block, Player player);
+}
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/SkyblockProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/SkyblockProtection.java
index 2b30e655..7dd5a0f0 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/SkyblockProtection.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/SkyblockProtection.java
@@ -4,9 +4,10 @@
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
import org.bukkit.entity.Player;
-public class SkyblockProtection {
+public class SkyblockProtection implements Protection {
private final boolean skyblockEnabled;
public SkyblockProtection(){
@@ -16,7 +17,7 @@ public SkyblockProtection(){
skyblockEnabled = Bukkit.getPluginManager().isPluginEnabled("SuperiorSkyblock2");
}
- public boolean checkPermission(Player player) {
+ public boolean checkPermission(Block block, Player player) {
if (!skyblockEnabled) return true;
if (player.isOp()) return true;
if (player.hasPermission("asedit.ignoreProtection.skyblock")) return true; //Add Additional Permission
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/TownyProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/TownyProtection.java
index f9b52413..04f1c511 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/TownyProtection.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/TownyProtection.java
@@ -10,7 +10,7 @@
import org.bukkit.entity.Player;
//FIX for https://github.com/Wolfieheart/ArmorStandEditor-Issues/issues/15
-public class TownyProtection {
+public class TownyProtection implements Protection {
private final boolean tEnabled;
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java
index 0cda9b42..25cc4941 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java
@@ -32,7 +32,7 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
-public class WorldGuardProtection {
+public class WorldGuardProtection implements Protection {
private final boolean wgEnabled;
private RegionQuery regionQry;
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 413e8a85..2f89b56c 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,12 +1,12 @@
name: ArmorStandEditor
main: io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin
-version: 1.xx.x-37
+version: 1.19.2-37
api-version: "1.13"
website: https://www.spigotmc.org/resources/94503/
author: Wolfstorm
-authors: [Wolfstorm, Marfjeh, miknes123, rypofalem, sekwah41, Sikatsu1997, Cool_boy, sumdream, Amaury Carrade, nicuch, kotarobo, prettydude, Jumpy91, Niasio, Patbox, Puremin0rez, Prof-Bloodstone]
+authors: [Wolfstorm, Marfjeh, miknes123, rypofalem, sekwah41, Sikatsu1997, Cool_boy, sumdream, Amaury Carrade, nicuch, kotarobo, prettydude, Jumpy91, Niasio, Patbox, Puremin0rez, Prof-Bloodstone, PlanetTeamSpeak]
description: Allows players to edit data of armorstands without any commands.
-softdepend: [Towny, WorldGuard, GriefPrevention, PlotSquared]
+softdepend: [Towny, WorldGuard, GriefPrevention, PlotSquared, Lands]
commands:
ase:
@@ -74,6 +74,9 @@ permissions:
asedit.ignoreProtection.griefDefender:
description: Allows user to ignore GriefDefender's Protection Limitations.
default: false
+ asedit.ignoreProtection.lands:
+ description: Allows user to ignore Lands' Protection Limitations.
+ default: false
asedit.ignoreProtection.*:
@@ -86,6 +89,7 @@ permissions:
asedit.ignoreProtection.worldGuard: true
asedit.ignoreProtection.skyblock: true
asedit.ignoreProtection.griefDefender: true
+ asedit.ignoreProtection.lands: true
asedit.permpack.dontIgnoreProtections:
default: true
@@ -96,6 +100,7 @@ permissions:
asedit.ignoreProtection.worldGuard: false
asedit.ignoreProtection.skyblock: false
asedit.ignoreProtection.griefDefender: false
+ asedit.ignoreProtection.lands: false
asedit.permpack.basic:
default: true
@@ -121,4 +126,4 @@ permissions:
asedit.disableSlots: true
asedit.rename: true
asedit.update: true
- asedit.ignorePermissions.*: true
\ No newline at end of file
+ asedit.ignorePermissions.*: true