Dateien nach "MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard" hochladen
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
package com.trafalcraft.anti_redstone_clock.util.worldGuard;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public interface IWorldGuard {
|
||||||
|
boolean isAllowedRegion(Location loc);
|
||||||
|
|
||||||
|
String getVersion();
|
||||||
|
|
||||||
|
boolean registerFlag ();
|
||||||
|
}
|
@@ -0,0 +1,47 @@
|
|||||||
|
package com.trafalcraft.anti_redstone_clock.util.worldGuard;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.trafalcraft.anti_redstone_clock.Main;
|
||||||
|
|
||||||
|
public class VersionWG {
|
||||||
|
|
||||||
|
private static VersionWG instance = null;
|
||||||
|
private IWorldGuard worldGuard;
|
||||||
|
|
||||||
|
private VersionWG() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized VersionWG getInstance() {
|
||||||
|
if (VersionWG.instance == null) {
|
||||||
|
VersionWG.instance = new VersionWG();
|
||||||
|
VersionWG.instance.init();
|
||||||
|
}
|
||||||
|
return VersionWG.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
if (Main.getInstance().getConfig().getBoolean("worldGuardSupport")) {
|
||||||
|
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
|
if (plugin == null) {
|
||||||
|
Bukkit.getLogger().warning("WorldGuard hasn't been found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String wgVersion = plugin.getDescription().getVersion().split("\\.")[0];
|
||||||
|
try {
|
||||||
|
ClassLoader classLoader = Main.class.getClassLoader();
|
||||||
|
classLoader.loadClass("com.trafalcraft.antiRedstoneClock.util.worldGuard.WorldGuard_" + wgVersion);
|
||||||
|
Class<?> aClass = Class.forName("com.trafalcraft.antiRedstoneClock.util.worldGuard.WorldGuard_" + wgVersion);
|
||||||
|
worldGuard = (IWorldGuard) aClass.getDeclaredConstructors()[0].newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Main.getInstance().getLogger().warning("WorldGuard " + wgVersion + " is not supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IWorldGuard getWG() {
|
||||||
|
return worldGuard;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user