diff --git a/pom.xml b/pom.xml
index 0c8ad71..c14ecad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,7 +116,7 @@
org.codemc.worldguardwrapper
worldguardwrapper
- 1.0.3-SNAPSHOT
+ 1.1.5-SNAPSHOT
com.palmergames
diff --git a/src/main/java/de/epiceric/shopchest/external/WorldGuardShopFlag.java b/src/main/java/de/epiceric/shopchest/external/WorldGuardShopFlag.java
index bbb3c59..266d819 100644
--- a/src/main/java/de/epiceric/shopchest/external/WorldGuardShopFlag.java
+++ b/src/main/java/de/epiceric/shopchest/external/WorldGuardShopFlag.java
@@ -1,6 +1,10 @@
package de.epiceric.shopchest.external;
+import java.util.Optional;
+
import org.codemc.worldguardwrapper.WorldGuardWrapper;
+import org.codemc.worldguardwrapper.flag.IWrappedFlag;
+import org.codemc.worldguardwrapper.flag.WrappedState;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
@@ -10,9 +14,18 @@ public class WorldGuardShopFlag {
public static void register(final ShopChest plugin) {
WorldGuardWrapper wrapper = WorldGuardWrapper.getInstance();
- plugin.debug("Flag create-shop: " + wrapper.registerStateFlag("create-shop", Config.wgAllowCreateShopDefault));
- plugin.debug("Flag use-shop: " + wrapper.registerStateFlag("use-shop", Config.wgAllowUseShopDefault));
- plugin.debug("Flag use-admin-shop: " + wrapper.registerStateFlag("use-admin-shop", Config.wgAllowUseAdminShopDefault));
+ Optional> createFlag = wrapper.registerFlag("create-shop",
+ WrappedState.class, Config.wgAllowCreateShopDefault ? WrappedState.ALLOW : WrappedState.DENY);
+
+ Optional> useFlag = wrapper.registerFlag("use-shop",
+ WrappedState.class, Config.wgAllowUseShopDefault ? WrappedState.ALLOW : WrappedState.DENY);
+
+ Optional> useAdminFlag = wrapper.registerFlag("use-admin-shop",
+ WrappedState.class, Config.wgAllowUseAdminShopDefault ? WrappedState.ALLOW : WrappedState.DENY);
+
+ plugin.debug("Flag create-shop: " + String.valueOf(createFlag.isPresent()));
+ plugin.debug("Flag use-shop: " + String.valueOf(useFlag.isPresent()));
+ plugin.debug("Flag use-admin-shop: " + String.valueOf(useAdminFlag.isPresent()));
}
}
diff --git a/src/main/java/de/epiceric/shopchest/listeners/AreaShopListener.java b/src/main/java/de/epiceric/shopchest/listeners/AreaShopListener.java
index e50c9cb..8012223 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/AreaShopListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/AreaShopListener.java
@@ -11,7 +11,7 @@ import me.wiefferink.areashop.regions.GeneralRegion;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.codemc.worldguardwrapper.WorldGuardWrapper;
-import org.codemc.worldguardwrapper.region.WrappedRegion;
+import org.codemc.worldguardwrapper.region.IWrappedRegion;
public class AreaShopListener implements Listener {
@@ -55,7 +55,7 @@ public class AreaShopListener implements Listener {
for (Shop shop : plugin.getShopUtils().getShops()) {
if (!shop.getLocation().getWorld().getName().equals(generalRegion.getWorldName())) continue;
- for (WrappedRegion r : WorldGuardWrapper.getInstance().getRegions(shop.getLocation())) {
+ for (IWrappedRegion r : WorldGuardWrapper.getInstance().getRegions(shop.getLocation())) {
if (generalRegion.getLowerCaseName().equals(r.getId())) {
plugin.getShopUtils().removeShop(shop, true);
break;
diff --git a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java
index 817ce02..efd8fe8 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java
@@ -43,11 +43,14 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryHolder;
import org.codemc.worldguardwrapper.WorldGuardWrapper;
+import org.codemc.worldguardwrapper.flag.IWrappedFlag;
+import org.codemc.worldguardwrapper.flag.WrappedState;
import pl.islandworld.api.IslandWorldApi;
import us.talabrek.ultimateskyblock.api.IslandInfo;
import java.util.ArrayList;
+import java.util.Optional;
public class ChestProtectListener implements Listener {
@@ -201,7 +204,11 @@ public class ChestProtectListener implements Listener {
boolean externalPluginsAllowed = true;
if (plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
- externalPluginsAllowed = WorldGuardWrapper.getInstance().queryStateFlag(p, b.getLocation(), "create-shop").orElse(false);
+ WorldGuardWrapper wgWrapper = WorldGuardWrapper.getInstance();
+ Optional> flag = wgWrapper.getFlag("create-shop", WrappedState.class);
+ if (!flag.isPresent()) plugin.debug("WorldGuard flag 'create-shop' is not present!");
+ WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
+ externalPluginsAllowed = state == WrappedState.ALLOW;
}
if (externalPluginsAllowed && plugin.hasTowny() && Config.enableTownyIntegration) {
diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
index 9b08f30..2beafb8 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
@@ -63,6 +63,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.codemc.worldguardwrapper.WorldGuardWrapper;
+import org.codemc.worldguardwrapper.flag.IWrappedFlag;
+import org.codemc.worldguardwrapper.flag.WrappedState;
import pl.islandworld.api.IslandWorldApi;
import us.talabrek.ultimateskyblock.api.IslandInfo;
@@ -70,6 +72,7 @@ import us.talabrek.ultimateskyblock.api.IslandInfo;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
@@ -84,12 +87,14 @@ public class ShopInteractListener implements Listener {
private Economy econ;
private Database database;
private ShopUtils shopUtils;
+ private WorldGuardWrapper wgWrapper;
public ShopInteractListener(ShopChest plugin) {
this.plugin = plugin;
this.econ = plugin.getEconomy();
this.database = plugin.getShopDatabase();
this.shopUtils = plugin.getShopUtils();
+ this.wgWrapper = WorldGuardWrapper.getInstance();
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@@ -162,7 +167,10 @@ public class ShopInteractListener implements Listener {
for (Location loc : chestLocations) {
if (loc != null) {
- externalPluginsAllowed &= WorldGuardWrapper.getInstance().queryStateFlag(p, loc, "create-shop").orElse(false);
+ Optional> flag = wgWrapper.getFlag("create-shop", WrappedState.class);
+ if (!flag.isPresent()) plugin.debug("WorldGuard flag 'create-shop' is not present!");
+ WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, loc, f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
+ externalPluginsAllowed = state == WrappedState.ALLOW;
}
}
@@ -458,7 +466,10 @@ public class ShopInteractListener implements Listener {
if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
- externalPluginsAllowed = WorldGuardWrapper.getInstance().queryStateFlag(p, b.getLocation(), flagName).orElse(false);
+ Optional> flag = wgWrapper.getFlag(flagName, WrappedState.class);
+ if (!flag.isPresent()) plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
+ WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
+ externalPluginsAllowed = state == WrappedState.ALLOW;
}
if (shop.getShopType() == ShopType.ADMIN) {
@@ -568,7 +579,10 @@ public class ShopInteractListener implements Listener {
if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
- externalPluginsAllowed = WorldGuardWrapper.getInstance().queryStateFlag(p, b.getLocation(), flagName).orElse(false);
+ Optional> flag = wgWrapper.getFlag(flagName, WrappedState.class);
+ if (!flag.isPresent()) plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
+ WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
+ externalPluginsAllowed = state == WrappedState.ALLOW;
}
ItemStack itemStack = shop.getProduct().getItemStack();
diff --git a/src/main/java/de/epiceric/shopchest/listeners/WorldGuardListener.java b/src/main/java/de/epiceric/shopchest/listeners/WorldGuardListener.java
index 803a980..07e746e 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/WorldGuardListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/WorldGuardListener.java
@@ -25,9 +25,13 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.codemc.worldguardwrapper.WorldGuardWrapper;
import org.codemc.worldguardwrapper.event.AbstractWrappedEvent;
-import org.codemc.worldguardwrapper.event.DamageEntityEvent;
-import org.codemc.worldguardwrapper.event.UseBlockEvent;
-import org.codemc.worldguardwrapper.event.UseEntityEvent;
+import org.codemc.worldguardwrapper.event.WrappedDamageEntityEvent;
+import org.codemc.worldguardwrapper.event.WrappedUseBlockEvent;
+import org.codemc.worldguardwrapper.event.WrappedUseEntityEvent;
+import org.codemc.worldguardwrapper.flag.IWrappedFlag;
+import org.codemc.worldguardwrapper.flag.WrappedState;
+
+import java.util.Optional;
public class WorldGuardListener implements Listener {
@@ -46,7 +50,11 @@ public class WorldGuardListener implements Listener {
// access to the chest, show the 'permission denied' message
// (if not previously set to allowed by another plugin).
// If the player can open the chest, that message should be hidden.
- return WorldGuardWrapper.getInstance().queryStateFlag(player, location, "chest-access").orElse(false);
+ WorldGuardWrapper wgWrapper = WorldGuardWrapper.getInstance();
+ Optional> flag = wgWrapper.getFlag("chest-access", WrappedState.class);
+ if (!flag.isPresent()) plugin.debug("WorldGuard flag 'chest-access' is not present!");
+ WrappedState state = flag.map(f -> wgWrapper.queryFlag(player, location, f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
+ return state == WrappedState.ALLOW;
}
Shop shop = plugin.getShopUtils().getShop(location);
@@ -78,7 +86,7 @@ public class WorldGuardListener implements Listener {
}
@EventHandler(priority = EventPriority.LOW)
- public void onUseEntity(UseEntityEvent event) {
+ public void onUseEntity(WrappedUseEntityEvent event) {
if (Config.enableWorldGuardIntegration) {
Player player = event.getPlayer();
@@ -89,7 +97,7 @@ public class WorldGuardListener implements Listener {
}
@EventHandler(priority = EventPriority.LOW)
- public void onDamageEntity(DamageEntityEvent event) {
+ public void onDamageEntity(WrappedDamageEntityEvent event) {
if (Config.enableWorldGuardIntegration) {
Player player = event.getPlayer();
@@ -100,7 +108,7 @@ public class WorldGuardListener implements Listener {
}
@EventHandler(priority = EventPriority.LOW)
- public void onUseBlock(UseBlockEvent event) {
+ public void onUseBlock(WrappedUseBlockEvent event) {
if (Config.enableWorldGuardIntegration) {
Player player = event.getPlayer();