mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
compatibility with FAWE ( :| )
This commit is contained in:
parent
e14c53d3ca
commit
101b0671fe
@ -1,6 +1,7 @@
|
|||||||
Version 2.1.108
|
Version 2.1.108
|
||||||
Fixed an amusing exploit for easy leveling in Acrobatics
|
Fixed an amusing exploit for easy leveling in Acrobatics
|
||||||
mcMMO should no longer break if FAWE is being used in conjunction with WG on the server
|
mcMMO should no longer break if FAWE is being used in conjunction with WG on the server
|
||||||
|
Improved WG compatibility, mcMMO will now check if WG has loaded properly before hooking into it, which will prevent mcMMO from breaking if WG could not load properly.
|
||||||
mcMMO now loads after worlds do during start up (which is what it should be doing)
|
mcMMO now loads after worlds do during start up (which is what it should be doing)
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.worldguard;
|
package com.gmail.nossr50.worldguard;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
@ -85,21 +86,25 @@ public class WorldGuardManager {
|
|||||||
|
|
||||||
public void registerFlags()
|
public void registerFlags()
|
||||||
{
|
{
|
||||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// register our flag with the registry
|
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||||
registry.register(WorldGuardFlags.MCMMO_ENABLE_WG_FLAG);
|
|
||||||
registry.register(WorldGuardFlags.MCMMO_XP_WG_FLAG);
|
try {
|
||||||
registry.register(WorldGuardFlags.MCMMO_HARDCORE_WG_FLAG);
|
// register our flag with the registry
|
||||||
System.out.println("mcMMO has registered WG flags successfully!");
|
registry.register(WorldGuardFlags.MCMMO_ENABLE_WG_FLAG);
|
||||||
} catch (FlagConflictException e) {
|
registry.register(WorldGuardFlags.MCMMO_XP_WG_FLAG);
|
||||||
e.printStackTrace();
|
registry.register(WorldGuardFlags.MCMMO_HARDCORE_WG_FLAG);
|
||||||
System.out.println("mcMMO has failed to register WG flags!");
|
System.out.println("mcMMO has registered WG flags successfully!");
|
||||||
// some other plugin registered a flag by the same name already.
|
} catch (FlagConflictException e) {
|
||||||
// you may want to re-register with a different name, but this
|
e.printStackTrace();
|
||||||
// could cause issues with saved flags in region files. it's better
|
System.out.println("mcMMO has failed to register WG flags!");
|
||||||
// to print a message to let the server admin know of the conflict
|
// some other plugin registered a flag by the same name already.
|
||||||
|
// you may want to re-register with a different name, but this
|
||||||
|
// could cause issues with saved flags in region files. it's better
|
||||||
|
// to print a message to let the server admin know of the conflict
|
||||||
|
}
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
System.out.println("[mcMMO] Could not register WG Flags!"); //Don't use the Logger here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.gmail.nossr50.worldguard;
|
package com.gmail.nossr50.worldguard;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -93,23 +95,39 @@ public class WorldGuardUtils {
|
|||||||
*/
|
*/
|
||||||
private static boolean isCompatibleVersion(Plugin plugin) {
|
private static boolean isCompatibleVersion(Plugin plugin) {
|
||||||
//Check that the version of WG is at least version 7.xx
|
//Check that the version of WG is at least version 7.xx
|
||||||
if(!plugin.getDescription().getVersion().startsWith("7")) {
|
boolean allClassesFound = true;
|
||||||
|
|
||||||
|
if (!plugin.getDescription().getVersion().startsWith("7")) {
|
||||||
markWGIncompatible();
|
markWGIncompatible();
|
||||||
} else {
|
} else {
|
||||||
//Use Reflection to check for a class not present in all versions of WG7
|
//Use Reflection to check for a class not present in all versions of WG7
|
||||||
for(String classString : WGClassList) {
|
for(String classString : WGClassList) {
|
||||||
try {
|
try {
|
||||||
Class<?> checkForClass = Class.forName(classString);
|
Class<?> checkForClass = Class.forName(classString);
|
||||||
detectedIncompatibleWG = false; //In case this was set to true previously
|
|
||||||
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
||||||
|
allClassesFound = false;
|
||||||
mcMMO.p.getLogger().severe("Missing WorldGuard class - "+classString);
|
mcMMO.p.getLogger().severe("Missing WorldGuard class - "+classString);
|
||||||
markWGIncompatible();
|
markWGIncompatible();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
mcMMO.p.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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return !detectedIncompatibleWG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user