mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
Handle custom WorldGuard flags not existing
Don't query and try to use flags if they haven't been registered
This commit is contained in:
parent
e82c28e5e8
commit
fed894a9b0
@ -70,6 +70,11 @@ public class WorldGuardListener implements Listener {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
private boolean handleForLocation(Player player, Location loc, Cancellable e, IWrappedFlag<WrappedState> flag) {
|
private boolean handleForLocation(Player player, Location loc, Cancellable e, IWrappedFlag<WrappedState> 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);
|
WrappedState state = wgWrapper.queryFlag(player, loc, flag).orElse(WrappedState.DENY);
|
||||||
if (state == WrappedState.DENY) {
|
if (state == WrappedState.DENY) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -82,8 +87,8 @@ public class WorldGuardListener implements Listener {
|
|||||||
private IWrappedFlag<WrappedState> getStateFlag(String flagName) {
|
private IWrappedFlag<WrappedState> getStateFlag(String flagName) {
|
||||||
Optional<IWrappedFlag<WrappedState>> flagOptional = wgWrapper.getFlag(flagName, WrappedState.class);
|
Optional<IWrappedFlag<WrappedState>> flagOptional = wgWrapper.getFlag(flagName, WrappedState.class);
|
||||||
if (!flagOptional.isPresent()) {
|
if (!flagOptional.isPresent()) {
|
||||||
plugin.getLogger().severe("Failed to get WorldGuard flag '" + flagName + "'.");
|
plugin.getLogger().severe("Failed to get WorldGuard state flag '" + flagName + "'.");
|
||||||
plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
|
plugin.debug("WorldGuard state flag '" + flagName + "' is not present!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return flagOptional.get();
|
return flagOptional.get();
|
||||||
|
Loading…
Reference in New Issue
Block a user