mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
Fix error when WorldGuard not installed
This commit is contained in:
parent
71f6ee5d6f
commit
f09d57b2a2
@ -88,14 +88,12 @@ public class ShopInteractListener implements Listener {
|
|||||||
private Economy econ;
|
private Economy econ;
|
||||||
private Database database;
|
private Database database;
|
||||||
private ShopUtils shopUtils;
|
private ShopUtils shopUtils;
|
||||||
private WorldGuardWrapper wgWrapper;
|
|
||||||
|
|
||||||
public ShopInteractListener(ShopChest plugin) {
|
public ShopInteractListener(ShopChest plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.econ = plugin.getEconomy();
|
this.econ = plugin.getEconomy();
|
||||||
this.database = plugin.getShopDatabase();
|
this.database = plugin.getShopDatabase();
|
||||||
this.shopUtils = plugin.getShopUtils();
|
this.shopUtils = plugin.getShopUtils();
|
||||||
this.wgWrapper = WorldGuardWrapper.getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@ -165,14 +163,17 @@ public class ShopInteractListener implements Listener {
|
|||||||
|
|
||||||
if (plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
if (plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
||||||
plugin.debug("Checking if WorldGuard allows shop creation...");
|
plugin.debug("Checking if WorldGuard allows shop creation...");
|
||||||
|
WorldGuardWrapper wgWrapper = WorldGuardWrapper.getInstance();
|
||||||
for (Location loc : chestLocations) {
|
Optional<IWrappedFlag<WrappedState>> flag = wgWrapper.getFlag("create-shop", WrappedState.class);
|
||||||
if (loc != null) {
|
if (flag.isPresent()) {
|
||||||
Optional<IWrappedFlag<WrappedState>> flag = wgWrapper.getFlag("create-shop", WrappedState.class);
|
for (Location loc : chestLocations) {
|
||||||
if (!flag.isPresent()) plugin.debug("WorldGuard flag 'create-shop' is not present!");
|
if (loc != null) {
|
||||||
WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, loc, f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
|
WrappedState state = wgWrapper.queryFlag(p, loc, flag.get()).orElse(WrappedState.DENY);
|
||||||
externalPluginsAllowed = state == WrappedState.ALLOW;
|
externalPluginsAllowed = state == WrappedState.ALLOW;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
plugin.debug("WorldGuard flag 'create-shop' is not present!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!externalPluginsAllowed) denyReason = "WorldGuard";
|
if (!externalPluginsAllowed) denyReason = "WorldGuard";
|
||||||
@ -467,6 +468,7 @@ public class ShopInteractListener implements Listener {
|
|||||||
|
|
||||||
if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
||||||
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
|
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
|
||||||
|
WorldGuardWrapper wgWrapper = WorldGuardWrapper.getInstance();
|
||||||
Optional<IWrappedFlag<WrappedState>> flag = wgWrapper.getFlag(flagName, WrappedState.class);
|
Optional<IWrappedFlag<WrappedState>> flag = wgWrapper.getFlag(flagName, WrappedState.class);
|
||||||
if (!flag.isPresent()) plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
|
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);
|
WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
|
||||||
@ -580,6 +582,7 @@ public class ShopInteractListener implements Listener {
|
|||||||
|
|
||||||
if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
||||||
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
|
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
|
||||||
|
WorldGuardWrapper wgWrapper = WorldGuardWrapper.getInstance();
|
||||||
Optional<IWrappedFlag<WrappedState>> flag = wgWrapper.getFlag(flagName, WrappedState.class);
|
Optional<IWrappedFlag<WrappedState>> flag = wgWrapper.getFlag(flagName, WrappedState.class);
|
||||||
if (!flag.isPresent()) plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
|
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);
|
WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
|
||||||
|
Loading…
Reference in New Issue
Block a user