Compare commits

..

3 Commits

Author SHA1 Message Date
YouHaveTrouble 9a707b34a3 bump version 2023-03-26 03:17:46 +02:00
YouHaveTrouble d52648b4ff Merge pull request #13 from YouHaveTrouble/api-changes
Api changes + worldguard flag fix for 1.19.4
2023-03-26 03:15:42 +02:00
YouHaveTrouble 7d2c41646e make worldguard hook register on load 2023-03-26 03:09:07 +02:00
3 changed files with 19 additions and 16 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
<groupId>me.youhavetrouble</groupId>
<artifactId>PreventStabby</artifactId>
<version>1.8.0</version>
<version>1.9.0</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!");
}
}
}