Fix duplicate extension's help command permission registration on Paper (#4079)

* Fix duplicate permission registration

* Register /<extensionid> help (and aliased ?) commands under the "geyser.command.exthelp.id" permission

* Fix: Show correct header for /geyser help vs /<extensionid> help
This commit is contained in:
chris 2023-08-27 14:48:14 +02:00 committed by GitHub
parent 48ecde0f19
commit 00def3b0c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View file

@ -165,13 +165,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
return;
}
// Remove this in like a year
if (Bukkit.getPluginManager().getPlugin("floodgate-bukkit") != null) {
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.outdated", Constants.FLOODGATE_DOWNLOAD_LOCATION));
this.getPluginLoader().disablePlugin(this);
return;
}
this.geyserCommandManager = new GeyserSpigotCommandManager(geyser);
this.geyserCommandManager.init();
@ -323,6 +316,12 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
continue;
}
// Avoid registering the same permission twice, e.g. for the extension help commands
if (Bukkit.getPluginManager().getPermission(command.permission()) != null) {
GeyserImpl.getInstance().getLogger().debug("Skipping permission " + command.permission() + " as it is already registered");
continue;
}
Bukkit.getPluginManager().addPermission(new Permission(command.permission(),
GeyserLocale.getLocaleStringLog(command.description()),
command.isSuggestedOpOnly() ? PermissionDefault.OP : PermissionDefault.TRUE));