From fed894a9b030c97165b6ad069a7453177a45f0c5 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 24 Jul 2019 14:45:45 +0200 Subject: [PATCH] Handle custom WorldGuard flags not existing Don't query and try to use flags if they haven't been registered --- .../shopchest/external/listeners/WorldGuardListener.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/external/listeners/WorldGuardListener.java b/src/main/java/de/epiceric/shopchest/external/listeners/WorldGuardListener.java index 763f5d4..fe7b440 100644 --- a/src/main/java/de/epiceric/shopchest/external/listeners/WorldGuardListener.java +++ b/src/main/java/de/epiceric/shopchest/external/listeners/WorldGuardListener.java @@ -70,6 +70,11 @@ public class WorldGuardListener implements Listener { // } private boolean handleForLocation(Player player, Location loc, Cancellable e, IWrappedFlag flag) { + if (flag == null) { + // Flag may have not been registered successfully, so ignore them. + return false; + } + WrappedState state = wgWrapper.queryFlag(player, loc, flag).orElse(WrappedState.DENY); if (state == WrappedState.DENY) { e.setCancelled(true); @@ -82,8 +87,8 @@ public class WorldGuardListener implements Listener { private IWrappedFlag getStateFlag(String flagName) { Optional> flagOptional = wgWrapper.getFlag(flagName, WrappedState.class); if (!flagOptional.isPresent()) { - plugin.getLogger().severe("Failed to get WorldGuard flag '" + flagName + "'."); - plugin.debug("WorldGuard flag '" + flagName + "' is not present!"); + plugin.getLogger().severe("Failed to get WorldGuard state flag '" + flagName + "'."); + plugin.debug("WorldGuard state flag '" + flagName + "' is not present!"); return null; } return flagOptional.get();