-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy path0028-Performance-Concurrency-Improvements-to-Permissions-.patch
99 lines (84 loc) · 4.45 KB
/
0028-Performance-Concurrency-Improvements-to-Permissions-.patch
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: mechoriet <[email protected]>
Date: Sun, 23 Apr 2023 13:07:05 +0200
Subject: [PATCH] Performance & Concurrency Improvements to Permissions no
double lookup
diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java
index 3b95061aad53083219ca653c1ab5c629c2254e05..aa607fe975b7740238082dc5034ad8556171108e 100644
--- a/src/main/java/org/bukkit/permissions/PermissibleBase.java
+++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java
@@ -68,8 +68,11 @@ public class PermissibleBase implements Permissible {
String name = inName.toLowerCase();
- if (isPermissionSet(name)) {
- return permissions.get(name).getValue();
+ // PandaSpigot start
+ PermissionAttachmentInfo info = permissions.get(name);
+ if(info != null) {
+ return info.getValue();
+ // PandaSpigot end
} else {
Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);
@@ -88,13 +91,16 @@ public class PermissibleBase implements Permissible {
String name = perm.getName().toLowerCase();
- if (isPermissionSet(name)) {
- return permissions.get(name).getValue();
+ // PandaSpigot start
+ PermissionAttachmentInfo info = permissions.get(name);
+ if(info != null) {
+ return info.getValue();
+ // PandaSpigot end
}
return perm.getDefault().getValue(isOp());
}
- public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
+ public synchronized PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) { // PandaSpigot - synchronized
if (name == null) {
throw new IllegalArgumentException("Permission name cannot be null");
} else if (plugin == null) {
@@ -111,7 +117,7 @@ public class PermissibleBase implements Permissible {
return result;
}
- public PermissionAttachment addAttachment(Plugin plugin) {
+ public synchronized PermissionAttachment addAttachment(Plugin plugin) { // PandaSpigot - synchronized
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
} else if (!plugin.isEnabled()) {
@@ -126,7 +132,7 @@ public class PermissibleBase implements Permissible {
return result;
}
- public void removeAttachment(PermissionAttachment attachment) {
+ public synchronized void removeAttachment(PermissionAttachment attachment) { // PandaSpigot - synchronized
if (attachment == null) {
throw new IllegalArgumentException("Attachment cannot be null");
}
@@ -145,7 +151,7 @@ public class PermissibleBase implements Permissible {
}
}
- public void recalculatePermissions() {
+ public synchronized void recalculatePermissions() { // PandaSpigot - synchronized
clearPermissions();
Set<Permission> defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp());
Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent);
@@ -192,7 +198,7 @@ public class PermissibleBase implements Permissible {
}
}
- public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
+ public synchronized PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) { // PandaSpigot - synchronized
if (name == null) {
throw new IllegalArgumentException("Permission name cannot be null");
} else if (plugin == null) {
@@ -210,7 +216,7 @@ public class PermissibleBase implements Permissible {
return result;
}
- public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
+ public synchronized PermissionAttachment addAttachment(Plugin plugin, int ticks) { // PandaSpigot - synchronized
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
} else if (!plugin.isEnabled()) {
@@ -228,7 +234,7 @@ public class PermissibleBase implements Permissible {
}
}
- public Set<PermissionAttachmentInfo> getEffectivePermissions() {
+ public synchronized Set<PermissionAttachmentInfo> getEffectivePermissions() { // PandaSpigot - synchronized
return new HashSet<PermissionAttachmentInfo>(permissions.values());
}