mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 05:16:55 +00:00
make worldguard hook register on load
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.youhavetrouble</groupId>
|
||||
<artifactId>PreventStabby</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<version>1.8.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PreventStabby</name>
|
||||
@@ -100,7 +100,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<version>1.18.26</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -76,18 +76,23 @@ public final class PreventStabby extends JavaPlugin {
|
||||
pvpCommand.setExecutor(mainCommand);
|
||||
pvpCommand.setTabCompleter(mainCommand);
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new PlacoholderApiHook(this).register();
|
||||
}
|
||||
|
||||
Metrics metrics = new Metrics(this, 14074);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
try {
|
||||
WorldGuardHook.init();
|
||||
worldGuardHook = true;
|
||||
} catch (NoClassDefFoundError e) {
|
||||
worldGuardHook = false;
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new PlacoholderApiHook(this).register();
|
||||
}
|
||||
|
||||
Metrics metrics = new Metrics(this, 14074);
|
||||
}
|
||||
|
||||
public static boolean worldGuardHookEnabled() {
|
||||
|
||||
@@ -12,9 +12,8 @@ import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class WorldGuardHook {
|
||||
|
||||
@@ -22,19 +21,18 @@ public class WorldGuardHook {
|
||||
public static StateFlag FORCE_PVP_FLAG;
|
||||
|
||||
public static void init() {
|
||||
PreventStabby plugin = PreventStabby.getPlugin();
|
||||
try {
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.registry.FlagRegistry");
|
||||
WorldGuardPlugin worldGuardPlugin = WorldGuardPlugin.inst();
|
||||
if (WorldGuard.getInstance() == null || worldGuardPlugin == null) return;
|
||||
plugin.getLogger().info("Hooking into WorldGuard");
|
||||
Bukkit.getLogger().info("[PreventStabby] Hooking into WorldGuard");
|
||||
flagRegistry = WorldGuard.getInstance().getFlagRegistry();
|
||||
createForcePvpFlag(plugin);
|
||||
createForcePvpFlag();
|
||||
} catch (NoClassDefFoundError | ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void createForcePvpFlag(Plugin plugin) {
|
||||
private static void createForcePvpFlag() {
|
||||
if (flagRegistry == null) return;
|
||||
String flagName = "preventstabby-force-pvp";
|
||||
try {
|
||||
@@ -46,7 +44,7 @@ public class WorldGuardHook {
|
||||
if (existing instanceof StateFlag) {
|
||||
FORCE_PVP_FLAG = (StateFlag) existing;
|
||||
} else {
|
||||
plugin.getLogger().severe("There is a conflict between flag names!");
|
||||
Bukkit.getLogger().severe("[PreventStabby] There is a conflict between flag names!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user