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; private boolean hasCommandBookGodMode;
boolean extraStats; boolean extraStats;
private boolean hasEssentialsGodMode;
/** /**
* Construct the object. * Construct the object.
@ -124,4 +125,12 @@ public void updateCommandBookGodMode() {
public boolean hasCommandBookGodMode() { public boolean hasCommandBookGodMode() {
return hasCommandBookGodMode; return hasCommandBookGodMode;
} }
public void updateEssentialsGodMode() {
hasEssentialsGodMode = plugin.getServer().getPluginManager().isPluginEnabled("Essentials");
}
public boolean hasEssentialsGodMode() {
return hasEssentialsGodMode;
}
} }

View File

@ -160,7 +160,10 @@ public void onEnable() {
reg.register(ToggleCommands.class); reg.register(ToggleCommands.class);
reg.register(ProtectionCommands.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); reg.register(GeneralCommands.class);
} }
@ -192,8 +195,6 @@ public void onEnable() {
(new DebuggingListener(this, WorldGuard.logger)).registerEvents(); (new DebuggingListener(this, WorldGuard.logger)).registerEvents();
} }
platform.getGlobalStateManager().updateCommandBookGodMode();
if (getServer().getPluginManager().isPluginEnabled("CommandBook")) { if (getServer().getPluginManager().isPluginEnabled("CommandBook")) {
getServer().getPluginManager().registerEvents(new WorldGuardCommandBookListener(this), this); getServer().getPluginManager().registerEvents(new WorldGuardCommandBookListener(this), this);
} }

View File

@ -35,6 +35,10 @@ public void onPluginEnable(PluginEnableEvent event) {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) { if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
getConfig().updateCommandBookGodMode(); getConfig().updateCommandBookGodMode();
} }
if(event.getPlugin().getDescription().getName().equalsIgnoreCase("Essentials")){
getConfig().updateEssentialsGodMode();
}
} }
@EventHandler @EventHandler
@ -42,5 +46,9 @@ public void onPluginDisable(PluginDisableEvent event) {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) { if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
getConfig().updateCommandBookGodMode(); 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 # - If you want to check the format of this file before putting it
# into WorldGuard, paste it into http://yaml-online-parser.appspot.com/ # into WorldGuard, paste it into http://yaml-online-parser.appspot.com/
# and see if it gives "ERROR:". # 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: # WARNING:
# Remember to check the compatibility spreadsheet for WorldGuard to see # Remember to check the compatibility spreadsheet for WorldGuard to see

View File

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