From b5e1f540b5b38d7cc98bb381edda89b7a7f4dcd2 Mon Sep 17 00:00:00 2001 From: M_Viper Date: Fri, 15 Aug 2025 16:13:06 +0000 Subject: [PATCH] Dateien nach "MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard" hochladen --- .../util/worldGuard/IWorldGuard.java | 11 +++++ .../util/worldGuard/VersionWG.java | 47 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard/IWorldGuard.java create mode 100644 MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard/VersionWG.java diff --git a/MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard/IWorldGuard.java b/MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard/IWorldGuard.java new file mode 100644 index 0000000..c7063ef --- /dev/null +++ b/MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard/IWorldGuard.java @@ -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 (); +} diff --git a/MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard/VersionWG.java b/MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard/VersionWG.java new file mode 100644 index 0000000..9082e07 --- /dev/null +++ b/MAIN/src/main/java/com/trafalcraft/anti_redstone_clock/util/worldGuard/VersionWG.java @@ -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; + } +}