mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-12-22 17:11:46 +00:00
Update WorldGuardWrapper depdendency
This commit is contained in:
parent
8581622a57
commit
c3227e9a42
2
pom.xml
2
pom.xml
@ -116,7 +116,7 @@
|
||||
<dependency>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper</artifactId>
|
||||
<version>1.0.3-SNAPSHOT</version>
|
||||
<version>1.1.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.palmergames</groupId>
|
||||
|
@ -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<IWrappedFlag<WrappedState>> createFlag = wrapper.registerFlag("create-shop",
|
||||
WrappedState.class, Config.wgAllowCreateShopDefault ? WrappedState.ALLOW : WrappedState.DENY);
|
||||
|
||||
Optional<IWrappedFlag<WrappedState>> useFlag = wrapper.registerFlag("use-shop",
|
||||
WrappedState.class, Config.wgAllowUseShopDefault ? WrappedState.ALLOW : WrappedState.DENY);
|
||||
|
||||
Optional<IWrappedFlag<WrappedState>> 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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<IWrappedFlag<WrappedState>> 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) {
|
||||
|
@ -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<IWrappedFlag<WrappedState>> 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<IWrappedFlag<WrappedState>> 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<IWrappedFlag<WrappedState>> 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();
|
||||
|
@ -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<IWrappedFlag<WrappedState>> 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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user