mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-15 07:01:36 +08:00
b68b282439
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes:c4a67eed
SPIGOT-4556: Fix plugins closing inventory during drop events5be2ddcb
Replace version constants with methods to prevent compiler inlininga5b9c7b3
Use API method to create offset command completions2bc7d1df
SPIGOT-3747: Add API for force loaded chunksa408f375
SPIGOT-3538: Add getHitBlockFace for ProjectileHitEventb54b9409
SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock79ded7a8
SPIGOT-1811: Death message not shown on respawn screenb4a4f15d
SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory0afed592
SPIGOT-794: Call EntityPlaceEvent for Minecart placement2b2d084a
Add InventoryView#getSlotType01a9959a
Do not use deprecated ItemSpawnEvent constructor9642498d
SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event963f4a5f
Add PlayerItemDamageEvent63db0445
Add API to get / set base arrow damage531c25d7
Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS pluginsd05c8b14
Mappings Updatebd36e200
SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
115 lines
4.9 KiB
Diff
115 lines
4.9 KiB
Diff
From 64ae4c1416201184004acc97e8973c304b5382e7 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 13 Sep 2018 20:51:50 -0400
|
|
Subject: [PATCH] Performance & Concurrency Improvements to Permissions
|
|
|
|
Modifying of permissions was only half protected, enabling concurrency
|
|
issues to occur if permissions were modified async.
|
|
|
|
While no plugin really should be doing that, modifying operations
|
|
are not heavily called, so they are safe to add synchronization to.
|
|
|
|
Now, all modification API's will be synchronized ensuring safety.
|
|
|
|
Additionally, hasPermission was victim to a common java newbie mistake
|
|
of calling if (containsKey(k)) return get(k), resulting in 2 map lookups.
|
|
|
|
Optimized it to simply be a single get call cutting permission map
|
|
lookups in half.
|
|
|
|
diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
|
index d4cb00a8..486f69f8 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(java.util.Locale.ENGLISH);
|
|
|
|
- if (isPermissionSet(name)) {
|
|
- return permissions.get(name).getValue();
|
|
+ // Paper start
|
|
+ PermissionAttachmentInfo info = permissions.get(name);
|
|
+ if (info != null) {
|
|
+ return info.getValue();
|
|
+ // Paper end
|
|
} else {
|
|
Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);
|
|
|
|
@@ -88,13 +91,16 @@ public class PermissibleBase implements Permissible {
|
|
|
|
String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH);
|
|
|
|
- if (isPermissionSet(name)) {
|
|
- return permissions.get(name).getValue();
|
|
+ // Paper start
|
|
+ PermissionAttachmentInfo info = permissions.get(name);
|
|
+ if (info != null) {
|
|
+ return info.getValue();
|
|
}
|
|
+ // Paper 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) { // Paper - 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) { // Paper - 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) { // Paper - 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() { // Paper - 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) { // Paper - 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) { // Paper - 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() { // Paper - synchronized
|
|
return new HashSet<PermissionAttachmentInfo>(permissions.values());
|
|
}
|
|
|
|
--
|
|
2.20.1
|
|
|