aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0068-Allow-Reloading-of-Custom-Permissions.patch
blob: 8205a118dd47b75c86d4d9ae26704b8989dce40f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William <admin@domnian.com>
Date: Fri, 18 Mar 2016 03:30:17 -0400
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 d581bfad059e60a693bc27285a723979e7d7dd34..2b4c1c3cc4b740d5aceb483c4066f23433c175d9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2808,5 +2808,23 @@ public final class CraftServer implements Server {
         }
         return this.adventure$audiences;
     }
+
+    @Override
+    public void reloadPermissions() {
+        pluginManager.clearPermissions();
+        if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) loadCustomPermissions();
+        for (Plugin plugin : pluginManager.getPlugins()) {
+            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 (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) loadCustomPermissions();
+        DefaultPermissions.registerCorePermissions();
+        CraftDefaultPermissions.registerCorePermissions();
+    }
     // Paper end
 }