patches
This commit is contained in:
parent
5e9c53b5b7
commit
52f28953be
5 changed files with 106 additions and 102 deletions
|
@ -1,113 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 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 497775f7f8fa2eae34555ca0f0c6ba72d6cfab3f..c94e4cdb5785d5dfcb704c4adabda0b19a20ec7d 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());
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 13 Sep 2018 21:39:26 -0400
|
||||
Subject: [PATCH] Add ItemStackRecipeChoice Draft API
|
||||
|
||||
This is based on Spigots Draft API. This is subject to change
|
||||
|
||||
Allows creating recipes that must match isSimilar to full item stack.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/inventory/ItemStackRecipeChoice.java b/src/main/java/com/destroystokyo/paper/inventory/ItemStackRecipeChoice.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..43e6576b1d1bb811f9feb22de0024d9c823cb21a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/inventory/ItemStackRecipeChoice.java
|
||||
@@ -0,0 +1,51 @@
|
||||
+package com.destroystokyo.paper.inventory;
|
||||
+
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.bukkit.inventory.RecipeChoice;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * Allows crafting Items that require full matching itemstacks to complete the recipe for custom items
|
||||
+ * @deprecated Draft API
|
||||
+ */
|
||||
+@Deprecated
|
||||
+public class ItemStackRecipeChoice implements RecipeChoice {
|
||||
+
|
||||
+ protected final List<ItemStack> choices = new ArrayList<>();
|
||||
+
|
||||
+ public ItemStackRecipeChoice(ItemStack choices) {
|
||||
+ this.choices.add(choices);
|
||||
+ }
|
||||
+
|
||||
+ public ItemStackRecipeChoice(List<ItemStack> choices) {
|
||||
+ this.choices.addAll(choices);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack getItemStack() {
|
||||
+ return choices.isEmpty() ? null : choices.get(0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RecipeChoice clone() {
|
||||
+ try {
|
||||
+ ItemStackRecipeChoice clone = (ItemStackRecipeChoice) super.clone();
|
||||
+ clone.choices.addAll(this.choices);
|
||||
+ return clone;
|
||||
+ } catch (CloneNotSupportedException ex) {
|
||||
+ throw new AssertionError(ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean test(ItemStack itemStack) {
|
||||
+ for (ItemStack stack : choices) {
|
||||
+ if (stack.isSimilar(itemStack)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
|
@ -1,38 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tassu <git@tassu.me>
|
||||
Date: Thu, 13 Sep 2018 08:45:01 +0300
|
||||
Subject: [PATCH] Implement furnace cook speed multiplier API
|
||||
|
||||
Signed-off-by: Tassu <git@tassu.me>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/block/Furnace.java b/src/main/java/org/bukkit/block/Furnace.java
|
||||
index c5a8c96fa2204d6b4d2409b1bfc97697d39d964e..9063cf370a0fe66c2a27086e125f9111b77366ae 100644
|
||||
--- a/src/main/java/org/bukkit/block/Furnace.java
|
||||
+++ b/src/main/java/org/bukkit/block/Furnace.java
|
||||
@@ -61,6 +61,26 @@ public interface Furnace extends Container {
|
||||
*/
|
||||
public void setCookTimeTotal(int cookTimeTotal);
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the cook speed multiplier that this {@link Furnace} will cook
|
||||
+ * compared to vanilla.
|
||||
+ *
|
||||
+ * @return the multiplier, a value between 0 and 200
|
||||
+ */
|
||||
+ public double getCookSpeedMultiplier();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the speed multiplier that this {@link Furnace} will cook
|
||||
+ * compared to vanilla.
|
||||
+ *
|
||||
+ * @param multiplier the multiplier to set, a value between 0 and 200
|
||||
+ * @throws IllegalArgumentException if value is less than 0
|
||||
+ * @throws IllegalArgumentException if value is more than 200
|
||||
+ */
|
||||
+ public void setCookSpeedMultiplier(double multiplier);
|
||||
+ // Paper end
|
||||
+
|
||||
@NotNull
|
||||
@Override
|
||||
public FurnaceInventory getInventory();
|
Loading…
Add table
Add a link
Reference in a new issue