Respect Essentials Commands on Bukkit Servers

CommandBook compat within WorldGuard was gutted some time ago, but the
commands don't register when CommandBook is present. Make this functionally
identical with the similar-featured and popular plugin Essentials.
This commit is contained in:
Loki Rautio 2023-11-07 10:25:12 -06:00
parent 0a9eb447d6
commit 81daa2f46f
5 changed files with 23 additions and 5 deletions

View File

@ -37,6 +37,7 @@ public class BukkitConfigurationManager extends YamlConfigurationManager {
private boolean hasCommandBookGodMode;
boolean extraStats;
private boolean hasEssentialsGodMode;
/**
* Construct the object.
@ -124,4 +125,12 @@ public class BukkitConfigurationManager extends YamlConfigurationManager {
public boolean hasCommandBookGodMode() {
return hasCommandBookGodMode;
}
public void updateEssentialsGodMode() {
hasEssentialsGodMode = plugin.getServer().getPluginManager().isPluginEnabled("Essentials");
}
public boolean hasEssentialsGodMode() {
return hasEssentialsGodMode;
}
}

View File

@ -160,7 +160,10 @@ public class WorldGuardPlugin extends JavaPlugin {
reg.register(ToggleCommands.class);
reg.register(ProtectionCommands.class);
if (!platform.getGlobalStateManager().hasCommandBookGodMode()) {
platform.getGlobalStateManager().updateCommandBookGodMode();
platform.getGlobalStateManager().updateEssentialsGodMode();
if (!platform.getGlobalStateManager().hasCommandBookGodMode() && !platform.getGlobalStateManager().hasEssentialsGodMode()) {
reg.register(GeneralCommands.class);
}
@ -192,8 +195,6 @@ public class WorldGuardPlugin extends JavaPlugin {
(new DebuggingListener(this, WorldGuard.logger)).registerEvents();
}
platform.getGlobalStateManager().updateCommandBookGodMode();
if (getServer().getPluginManager().isPluginEnabled("CommandBook")) {
getServer().getPluginManager().registerEvents(new WorldGuardCommandBookListener(this), this);
}

View File

@ -35,6 +35,10 @@ public class WorldGuardServerListener extends AbstractListener {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
getConfig().updateCommandBookGodMode();
}
if(event.getPlugin().getDescription().getName().equalsIgnoreCase("Essentials")){
getConfig().updateEssentialsGodMode();
}
}
@EventHandler
@ -42,5 +46,9 @@ public class WorldGuardServerListener extends AbstractListener {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
getConfig().updateCommandBookGodMode();
}
if(event.getPlugin().getDescription().getName().equalsIgnoreCase("Essentials")){
getConfig().updateEssentialsGodMode();
}
}
}

View File

@ -12,7 +12,7 @@
# - If you want to check the format of this file before putting it
# into WorldGuard, paste it into http://yaml-online-parser.appspot.com/
# and see if it gives "ERROR:".
# - Lines starting with # are commentsand so they are ignored.
# - Lines starting with # are comments and so they are ignored.
#
# WARNING:
# Remember to check the compatibility spreadsheet for WorldGuard to see

View File

@ -2,5 +2,5 @@ name: WorldGuard
main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
version: "${internalVersion}"
depend: [WorldEdit]
softdepend: [CommandBook]
softdepend: [CommandBook, Essentials]
api-version: "1.20"