Dateien nach "MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard" hochladen

This commit is contained in:
2025-08-15 16:13:06 +00:00
parent 8034b29ece
commit b5e1f540b5
2 changed files with 58 additions and 0 deletions

View File

@@ -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 ();
}

View File

@@ -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;
}
}