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 void updateCommandBookGodMode() {
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 void onEnable() {
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 void onEnable() {
(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 void onPluginEnable(PluginEnableEvent event) {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
getConfig().updateCommandBookGodMode();
}
if(event.getPlugin().getDescription().getName().equalsIgnoreCase("Essentials")){
getConfig().updateEssentialsGodMode();
}
}
@EventHandler
@ -42,5 +46,9 @@ public void onPluginDisable(PluginDisableEvent event) {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
getConfig().updateCommandBookGodMode();
}
if(event.getPlugin().getDescription().getName().equalsIgnoreCase("Essentials")){
getConfig().updateEssentialsGodMode();
}
}
}

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"