Browse Source

Grab the version of WG in a better way

nossr50 6 năm trước cách đây
mục cha
commit
577e3339f1

+ 3 - 0
Changelog.txt

@@ -6,6 +6,9 @@ Key:
   = Fix
   ! Change
   - Removal
+Version 2.2.0
+    Fixed a bug where grabbing the version of WG would throw classnotdefined errors
+
 Version 2.1.8
     mcMMO now checks for WG 7 before attempting to use the WG API
     Made some optimizations for our WG integration

+ 13 - 15
src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java

@@ -21,18 +21,6 @@ public class WorldGuardUtils {
             if (plugin == null) {
                 return false; // Maybe you want throw an exception instead
             }
-
-            if(!WorldGuard.getVersion().startsWith("7"))
-            {
-                if(!hasWarned)
-                {
-                    mcMMO.p.getLogger().severe("mcMMO only supports WorldGuard version 7! Make sure you have WG 7! This warning will not appear again.");
-                    hasWarned = true;
-                }
-
-                return false; // WG 7 is required
-            }
-
         } catch (Exception e) {
             e.printStackTrace();
             //Silently Fail
@@ -53,10 +41,20 @@ public class WorldGuardUtils {
 
         if(plugin instanceof WorldGuardPlugin)
         {
-            worldGuardPluginRef = (WorldGuardPlugin) plugin;
+            if(plugin.getDescription().getVersion().startsWith("7"))
+            {
+                worldGuardPluginRef = (WorldGuardPlugin) plugin;
+
+                if(worldGuardPluginRef != null)
+                    isLoaded = true;
 
-            if(worldGuardPluginRef != null)
-                isLoaded = true;
+            } else {
+                if(!hasWarned)
+                {
+                    mcMMO.p.getLogger().severe("mcMMO only supports WorldGuard version 7! Make sure you have WG 7! This warning will not appear again.");
+                    hasWarned = true;
+                }
+            }
         }
 
         return worldGuardPluginRef;