Fix custom permissions reloading (#1325)

This commit is contained in:
prplz
2018-08-11 09:39:04 -04:00
parent d1f6595317
commit 50d88c817f
5 changed files with 15 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] Allow Reloading of Custom Permissions
https://github.com/PaperMC/Paper/issues/49
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d482589b3..e53f8c58f 100644
index d482589b3b..95345d28be 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
@@ -16,17 +16,20 @@ index d482589b3..e53f8c58f 100644
+
+ @Override
+ public void reloadPermissions() {
+ ((SimplePluginManager) pluginManager).clearPermissions();
+ loadCustomPermissions();
+ pluginManager.clearPermissions();
+ if (com.destroystokyo.paper.PaperConfig.loadPermsBeforePlugins) loadCustomPermissions();
+ for (Plugin plugin : pluginManager.getPlugins()) {
+ plugin.getDescription().getPermissions().forEach((perm) -> {
+ for (Permission perm : plugin.getDescription().getPermissions()) {
+ try {
+ pluginManager.addPermission(perm);
+ } catch (IllegalArgumentException ex) {
+ getLogger().log(Level.WARNING, "Plugin " + plugin.getDescription().getFullName() + " tried to register permission '" + perm.getName() + "' but it's already registered", ex);
+ }
+ });
+ }
+ }
+ if (!com.destroystokyo.paper.PaperConfig.loadPermsBeforePlugins) loadCustomPermissions();
+ DefaultPermissions.registerCorePermissions();
+ CraftDefaultPermissions.registerCorePermissions();
+ }
// Paper end
}