From 6670a3263f6cb5a5ef2a7d0b4a88bdc4c0f42be5 Mon Sep 17 00:00:00 2001 From: Aria Sangarin Date: Thu, 4 Jun 2020 16:32:24 +0200 Subject: [PATCH] [DEBUG] WorldGuard Flag info This build just prints info about worldguard flags to console. Nothing else has changed from last (working) dev. The debug messages may be spammy, so I recommend not updating quite yet. --- pom.xml | 2 +- .../mmocore/comp/flags/WorldGuardFlags.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8dce9cea..3ab287fc 100644 --- a/pom.xml +++ b/pom.xml @@ -136,7 +136,7 @@ com.sk89q.worldguard worldguard-bukkit - 7.0.1-SNAPSHOT + 7.0.2-SNAPSHOT provided diff --git a/src/main/java/net/Indyuce/mmocore/comp/flags/WorldGuardFlags.java b/src/main/java/net/Indyuce/mmocore/comp/flags/WorldGuardFlags.java index ba0c8740..0d11f334 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/flags/WorldGuardFlags.java +++ b/src/main/java/net/Indyuce/mmocore/comp/flags/WorldGuardFlags.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.comp.flags; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -14,6 +15,8 @@ import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; +import net.Indyuce.mmocore.MMOCore; + public class WorldGuardFlags implements FlagPlugin { private final WorldGuard worldguard; private final WorldGuardPlugin worldguardPlugin; @@ -30,7 +33,11 @@ public class WorldGuardFlags implements FlagPlugin { try { registry.register(flag); flags.put(customFlag.getPath(), flag); + MMOCore.log(Level.INFO, "[FLAGDEBUG] Registered WG Flag\n" + + " - Info{name=" + flag.getName() + ",path=" + customFlag.getPath() + "}"); } catch (Exception exception) { + MMOCore.log(Level.SEVERE, "[FLAGDEBUG] FAILED to register WG Flag\n" + + " - Info{name=" + flag.getName() + ",path=" + customFlag.getPath() + "}"); exception.printStackTrace(); } } @@ -48,8 +55,14 @@ public class WorldGuardFlags implements FlagPlugin { @Override public boolean isFlagAllowed(Player player, CustomFlag customFlag) { + StateFlag flag = flags.get(customFlag.getPath()); + if(flag == null) MMOCore.log(Level.SEVERE, "[FLAGDEBUG] Found Null value WG Flag\n" + + " - Info{path=" + customFlag.getPath() + "}"); + else MMOCore.log(Level.INFO, "[FLAGDEBUG] Checking WG Flag\n" + + " - Info{name=" + flag.getName() + ",path=" + customFlag.getPath() + "}"); + return getApplicableRegion(player.getLocation()).queryValue(worldguardPlugin.wrapPlayer(player), - flags.get(customFlag.getPath())) != StateFlag.State.DENY; + flag) != StateFlag.State.DENY; } private ApplicableRegionSet getApplicableRegion(Location loc) {