mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-07 19:30:34 +01:00
5c7081fecc
* Updated Upstream (Bukkit/CraftBukkit) 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 Bukkit Changes: 45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories CraftBukkit Changes:4090d01f
SPIGOT-5047: Correct slot types for 1.14 inventoriese8c08362
SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.d445af3b
SPIGOT-5067: Add item meta for 1.14 spawn eggs * Bring Chunk load checks in-line with spigot As of the last upstream merge spigot now checks ticket level status when returning loaded chunks for a world from api. Now our checks will respect that decision. * Fix spawn ticket levels Vanilla would keep the inner chunks of spawn available for ticking, however my changes made all chunks non-ticking. Resolve by changing ticket levels for spawn chunks inside the border to respect this behavior. * Make World#getChunkIfLoadedImmediately return only entity ticking chunks Mojang appears to be using chunks with level > 33 (non-ticking chunks) as cached chunks and not actually loaded chunks. * Bring all loaded checks in line with spigot Loaded chunks must be at least border chunks, or level <= 33
117 lines
5.1 KiB
Diff
117 lines
5.1 KiB
Diff
From 03939964d3b449b2f50848f67b7afcef215ed67e 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 497775f7f..c94e4cdb5 100644
|
|
--- a/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
|
+++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
|
@@ -75,8 +75,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);
|
|
|
|
@@ -96,15 +99,18 @@ 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());
|
|
}
|
|
|
|
@Override
|
|
@NotNull
|
|
- public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) {
|
|
+ public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { // Paper - synchronized
|
|
if (name == null) {
|
|
throw new IllegalArgumentException("Permission name cannot be null");
|
|
} else if (plugin == null) {
|
|
@@ -123,7 +129,7 @@ public class PermissibleBase implements Permissible {
|
|
|
|
@Override
|
|
@NotNull
|
|
- public PermissionAttachment addAttachment(@NotNull Plugin plugin) {
|
|
+ public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin) { // Paper - synchronized
|
|
if (plugin == null) {
|
|
throw new IllegalArgumentException("Plugin cannot be null");
|
|
} else if (!plugin.isEnabled()) {
|
|
@@ -139,7 +145,7 @@ public class PermissibleBase implements Permissible {
|
|
}
|
|
|
|
@Override
|
|
- public void removeAttachment(@NotNull PermissionAttachment attachment) {
|
|
+ public synchronized void removeAttachment(@NotNull PermissionAttachment attachment) { // Paper - synchronized
|
|
if (attachment == null) {
|
|
throw new IllegalArgumentException("Attachment cannot be null");
|
|
}
|
|
@@ -159,7 +165,7 @@ public class PermissibleBase implements Permissible {
|
|
}
|
|
|
|
@Override
|
|
- public void recalculatePermissions() {
|
|
+ public synchronized void recalculatePermissions() { // Paper - synchronized
|
|
clearPermissions();
|
|
Set<Permission> defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp());
|
|
Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent);
|
|
@@ -208,7 +214,7 @@ public class PermissibleBase implements Permissible {
|
|
|
|
@Override
|
|
@Nullable
|
|
- public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) {
|
|
+ public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { // Paper
|
|
if (name == null) {
|
|
throw new IllegalArgumentException("Permission name cannot be null");
|
|
} else if (plugin == null) {
|
|
@@ -228,7 +234,7 @@ public class PermissibleBase implements Permissible {
|
|
|
|
@Override
|
|
@Nullable
|
|
- public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) {
|
|
+ public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { // Paper - synchronized
|
|
if (plugin == null) {
|
|
throw new IllegalArgumentException("Plugin cannot be null");
|
|
} else if (!plugin.isEnabled()) {
|
|
@@ -248,7 +254,7 @@ public class PermissibleBase implements Permissible {
|
|
|
|
@Override
|
|
@NotNull
|
|
- public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
|
+ public synchronized Set<PermissionAttachmentInfo> getEffectivePermissions() { // Paper - synchronized
|
|
return new HashSet<PermissionAttachmentInfo>(permissions.values());
|
|
}
|
|
|
|
--
|
|
2.21.0
|
|
|