|
@@ -1,9 +1,6 @@
|
|
|
package com.gmail.nossr50.worldguard;
|
|
|
|
|
|
-import com.gmail.nossr50.mcMMO;
|
|
|
-import com.sk89q.worldguard.WorldGuard;
|
|
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
|
-import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -15,10 +12,9 @@ public class WorldGuardUtils {
|
|
|
private boolean isLoaded = false;
|
|
|
private boolean detectedIncompatibleWG = false;
|
|
|
private static final ArrayList<String> WGClassList;
|
|
|
- private final mcMMO pluginRef;
|
|
|
+ private WorldGuardManager worldGuardManager;
|
|
|
|
|
|
- public WorldGuardUtils(mcMMO pluginRef) {
|
|
|
- this.pluginRef = pluginRef;
|
|
|
+ public WorldGuardUtils() {
|
|
|
}
|
|
|
|
|
|
static {
|
|
@@ -72,7 +68,7 @@ public class WorldGuardUtils {
|
|
|
if(plugin == null) {
|
|
|
//WG is not present
|
|
|
detectedIncompatibleWG = true;
|
|
|
- pluginRef.getLogger().info("WorldGuard was not detected.");
|
|
|
+ System.out.println("[mcMMO WorldGuardUtils Debug] WorldGuard was not detected.");
|
|
|
} else {
|
|
|
//Check that its actually of class WorldGuardPlugin
|
|
|
if(plugin instanceof WorldGuardPlugin)
|
|
@@ -81,6 +77,9 @@ public class WorldGuardUtils {
|
|
|
{
|
|
|
worldGuardPluginRef = (WorldGuardPlugin) plugin;
|
|
|
isLoaded = true;
|
|
|
+
|
|
|
+ //Init WG Manager
|
|
|
+ worldGuardManager = new WorldGuardManager();
|
|
|
}
|
|
|
} else {
|
|
|
//Plugin is not of the expected type
|
|
@@ -88,7 +87,6 @@ public class WorldGuardUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return worldGuardPluginRef;
|
|
|
}
|
|
|
|
|
@@ -100,7 +98,7 @@ public class WorldGuardUtils {
|
|
|
*/
|
|
|
private boolean isCompatibleVersion(Plugin plugin) {
|
|
|
//Check that the version of WG is at least version 7.xx
|
|
|
- boolean allClassesFound = true;
|
|
|
+// boolean allClassesFound = true;
|
|
|
|
|
|
if (!plugin.getDescription().getVersion().startsWith("7")) {
|
|
|
markWGIncompatible();
|
|
@@ -111,8 +109,8 @@ public class WorldGuardUtils {
|
|
|
Class<?> checkForClass = Class.forName(classString);
|
|
|
detectedIncompatibleWG = false; //In case this was set to true previously
|
|
|
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
|
|
- allClassesFound = false;
|
|
|
- pluginRef.getLogger().severe("Missing WorldGuard class - "+classString);
|
|
|
+// allClassesFound = false;
|
|
|
+ System.out.println("[mcMMO WorldGuardUtils Debug] Missing WorldGuard class - "+classString);
|
|
|
markWGIncompatible();
|
|
|
}
|
|
|
}
|
|
@@ -120,17 +118,17 @@ public class WorldGuardUtils {
|
|
|
/*
|
|
|
* If WG appears to have all of its classes we can then check to see if its been initialized properly
|
|
|
*/
|
|
|
- try {
|
|
|
- if(allClassesFound) {
|
|
|
- if(!((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).isInitialized()) {
|
|
|
- markWGIncompatible();
|
|
|
- pluginRef.getLogger().severe("WG did not initialize properly, this can cause errors with mcMMO so mcMMO is disabling certain features.");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- markWGIncompatible();
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+// try {
|
|
|
+// if(allClassesFound) {
|
|
|
+// if(!((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).isInitialized()) {
|
|
|
+// markWGIncompatible();
|
|
|
+// System.out.println("[mcMMO WorldGuardUtils Debug] WG did not initialize properly, this can cause errors with mcMMO so mcMMO is disabling certain features.");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// markWGIncompatible();
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
return !detectedIncompatibleWG;
|
|
@@ -140,10 +138,14 @@ public class WorldGuardUtils {
|
|
|
* Mark WG as being incompatible to avoid unnecessary operations
|
|
|
*/
|
|
|
private void markWGIncompatible() {
|
|
|
- pluginRef.getLogger().severe("You are using a version of WG that is not compatible with mcMMO, " +
|
|
|
+ System.out.println("[mcMMO WorldGuardUtils Debug] You are using a version of WG that is not compatible with mcMMO, " +
|
|
|
"WG features for mcMMO will be disabled. mcMMO requires you to be using a new version of WG7 " +
|
|
|
"in order for it to use WG features. Not all versions of WG7 are compatible.");
|
|
|
- pluginRef.getLogger().severe("mcMMO will continue to function normally, but if you wish to use WG support you must use a compatible version.");
|
|
|
+ System.out.println("[mcMMO WorldGuardUtils Debug] mcMMO will continue to function normally, but if you wish to use WG support you must use a compatible version.");
|
|
|
detectedIncompatibleWG = true;
|
|
|
}
|
|
|
+
|
|
|
+ public WorldGuardManager getWorldGuardManager() {
|
|
|
+ return worldGuardManager;
|
|
|
+ }
|
|
|
}
|