mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 13:26:56 +00:00
Compare commits
3 Commits
v1.9.0-pre1
...
v1.9.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a707b34a3 | |||
| d52648b4ff | |||
| 7d2c41646e |
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.youhavetrouble</groupId>
|
<groupId>me.youhavetrouble</groupId>
|
||||||
<artifactId>PreventStabby</artifactId>
|
<artifactId>PreventStabby</artifactId>
|
||||||
<version>1.8.0</version>
|
<version>1.9.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>PreventStabby</name>
|
<name>PreventStabby</name>
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.24</version>
|
<version>1.18.26</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -76,13 +76,6 @@ public final class PreventStabby extends JavaPlugin {
|
|||||||
pvpCommand.setExecutor(mainCommand);
|
pvpCommand.setExecutor(mainCommand);
|
||||||
pvpCommand.setTabCompleter(mainCommand);
|
pvpCommand.setTabCompleter(mainCommand);
|
||||||
|
|
||||||
try {
|
|
||||||
WorldGuardHook.init();
|
|
||||||
worldGuardHook = true;
|
|
||||||
} catch (NoClassDefFoundError e) {
|
|
||||||
worldGuardHook = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
new PlacoholderApiHook(this).register();
|
new PlacoholderApiHook(this).register();
|
||||||
}
|
}
|
||||||
@@ -90,6 +83,18 @@ public final class PreventStabby extends JavaPlugin {
|
|||||||
Metrics metrics = new Metrics(this, 14074);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean worldGuardHookEnabled() {
|
public static boolean worldGuardHookEnabled() {
|
||||||
return worldGuardHook;
|
return worldGuardHook;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.flags.registry.FlagRegistry;
|
||||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class WorldGuardHook {
|
public class WorldGuardHook {
|
||||||
|
|
||||||
@@ -22,19 +21,18 @@ public class WorldGuardHook {
|
|||||||
public static StateFlag FORCE_PVP_FLAG;
|
public static StateFlag FORCE_PVP_FLAG;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
PreventStabby plugin = PreventStabby.getPlugin();
|
|
||||||
try {
|
try {
|
||||||
Class.forName("com.sk89q.worldguard.protection.flags.registry.FlagRegistry");
|
Class.forName("com.sk89q.worldguard.protection.flags.registry.FlagRegistry");
|
||||||
WorldGuardPlugin worldGuardPlugin = WorldGuardPlugin.inst();
|
WorldGuardPlugin worldGuardPlugin = WorldGuardPlugin.inst();
|
||||||
if (WorldGuard.getInstance() == null || worldGuardPlugin == null) return;
|
if (WorldGuard.getInstance() == null || worldGuardPlugin == null) return;
|
||||||
plugin.getLogger().info("Hooking into WorldGuard");
|
Bukkit.getLogger().info("[PreventStabby] Hooking into WorldGuard");
|
||||||
flagRegistry = WorldGuard.getInstance().getFlagRegistry();
|
flagRegistry = WorldGuard.getInstance().getFlagRegistry();
|
||||||
createForcePvpFlag(plugin);
|
createForcePvpFlag();
|
||||||
} catch (NoClassDefFoundError | ClassNotFoundException ignored) {
|
} catch (NoClassDefFoundError | ClassNotFoundException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createForcePvpFlag(Plugin plugin) {
|
private static void createForcePvpFlag() {
|
||||||
if (flagRegistry == null) return;
|
if (flagRegistry == null) return;
|
||||||
String flagName = "preventstabby-force-pvp";
|
String flagName = "preventstabby-force-pvp";
|
||||||
try {
|
try {
|
||||||
@@ -46,7 +44,7 @@ public class WorldGuardHook {
|
|||||||
if (existing instanceof StateFlag) {
|
if (existing instanceof StateFlag) {
|
||||||
FORCE_PVP_FLAG = (StateFlag) existing;
|
FORCE_PVP_FLAG = (StateFlag) existing;
|
||||||
} else {
|
} 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