Merge branch 'master' into pre/1.13
* master: Fix ItemStack.removeEnchantment returning wrong value
This commit is contained in:
commit
3cc52119fa
3 changed files with 23 additions and 26 deletions
|
@ -1,4 +1,4 @@
|
|||
From b89cf5dd57e6e06e406830e4438f1e164c83d8a3 Mon Sep 17 00:00:00 2001
|
||||
From 0e6cf5edaab921a3d54b27009c13a0a304e4db41 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 28 May 2015 23:00:19 -0400
|
||||
Subject: [PATCH] Handle Item Meta Inconsistencies
|
||||
|
@ -78,7 +78,7 @@ index 0c54eaa529..c7ef9c6890 100644
|
|||
|
||||
public boolean hasEnchantments() {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index f4672b9a48..e2699564af 100644
|
||||
index f4672b9a48..8c0409797e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -4,6 +4,7 @@ import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS;
|
||||
|
@ -123,7 +123,7 @@ index f4672b9a48..e2699564af 100644
|
|||
}
|
||||
|
||||
static boolean makeTag(net.minecraft.server.ItemStack item) {
|
||||
@@ -224,66 +208,35 @@ public final class CraftItemStack extends ItemStack {
|
||||
@@ -224,66 +208,32 @@ public final class CraftItemStack extends ItemStack {
|
||||
|
||||
@Override
|
||||
public boolean containsEnchantment(Enchantment ench) {
|
||||
|
@ -148,7 +148,13 @@ index f4672b9a48..e2699564af 100644
|
|||
- NBTTagList list = getEnchantmentList(handle), listCopy;
|
||||
- if (list == null) {
|
||||
- return 0;
|
||||
- }
|
||||
+ // Paper start - replace entire method
|
||||
+ final ItemMeta itemMeta = getItemMeta();
|
||||
+ int level = itemMeta.getEnchantLevel(ench);
|
||||
+ if (level > 0) {
|
||||
+ itemMeta.removeEnchant(ench);
|
||||
+ setItemMeta(itemMeta);
|
||||
}
|
||||
- int index = Integer.MIN_VALUE;
|
||||
- int level = Integer.MIN_VALUE;
|
||||
- int size = list.size();
|
||||
|
@ -170,17 +176,9 @@ index f4672b9a48..e2699564af 100644
|
|||
- handle.getTag().remove(ENCHANTMENTS.NBT);
|
||||
- if (handle.getTag().isEmpty()) {
|
||||
- handle.setTag(null);
|
||||
+ // Paper start - replace entire method, maintain backwards compat of returning previous level.
|
||||
+ final ItemMeta itemMeta = getItemMeta();
|
||||
+ final Iterator<Enchantment> iterator = itemMeta.getEnchants().keySet().iterator();
|
||||
+ for (int i = 0; iterator.hasNext(); i++) {
|
||||
+ if (iterator.next().equals(ench)) {
|
||||
+ itemMeta.removeEnchant(ench);
|
||||
+ setItemMeta(itemMeta);
|
||||
+ return i;
|
||||
}
|
||||
- }
|
||||
- return level;
|
||||
}
|
||||
- }
|
||||
-
|
||||
- // This is workaround for not having an index removal
|
||||
- listCopy = new NBTTagList();
|
||||
|
@ -191,9 +189,8 @@ index f4672b9a48..e2699564af 100644
|
|||
- }
|
||||
- handle.getTag().set(ENCHANTMENTS.NBT, listCopy);
|
||||
-
|
||||
- return level;
|
||||
return level;
|
||||
+ // Paper end
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From ca412bfa3f41d52e4dc3fa2b21e6f4375c6aa7bb Mon Sep 17 00:00:00 2001
|
||||
From fe0e0b94143faddc431dfd3c8b400605f0de0069 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Sat, 27 Jan 2018 17:04:14 -0500
|
||||
Subject: [PATCH] Add ArmorStand Item Meta
|
||||
|
@ -13,7 +13,7 @@ starting point for future additions in this area.
|
|||
Fixes GH-559
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
index 1df2b463a..abdbd4989 100644
|
||||
index 35eb3181dd..a69f98cd63 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
@@ -183,6 +183,8 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
|
@ -26,10 +26,10 @@ index 1df2b463a..abdbd4989 100644
|
|||
case CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index e2699564a..aad380c3b 100644
|
||||
index 8c0409797e..83f89a2365 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -395,6 +395,8 @@ public final class CraftItemStack extends ItemStack {
|
||||
@@ -392,6 +392,8 @@ public final class CraftItemStack extends ItemStack {
|
||||
return new CraftMetaSpawnEgg(item.getTag());
|
||||
case KNOWLEDGE_BOOK:
|
||||
return new CraftMetaKnowledgeBook(item.getTag());
|
||||
|
@ -40,7 +40,7 @@ index e2699564a..aad380c3b 100644
|
|||
case TRAPPED_CHEST:
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
||||
new file mode 100644
|
||||
index 000000000..0e8acf12e
|
||||
index 0000000000..0e8acf12e4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
||||
@@ -0,0 +1,309 @@
|
||||
|
@ -354,7 +354,7 @@ index 000000000..0e8acf12e
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index f21c1e846..a5fcf6bd5 100644
|
||||
index 94b19d1095..683593a0b4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -136,6 +136,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
|
@ -383,7 +383,7 @@ index f21c1e846..a5fcf6bd5 100644
|
|||
}
|
||||
return HANDLED_TAGS;
|
||||
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
index f66cc81d9..eb6cf1bb3 100644
|
||||
index f66cc81d9e..eb6cf1bb33 100644
|
||||
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
+++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
@@ -6,6 +6,7 @@ import static org.hamcrest.Matchers.*;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
From c2a830260250be91d01455db5c8bf2f168451ea8 Mon Sep 17 00:00:00 2001
|
||||
From 61eb7432605c0b3780d1a9ecfd95a0112be202f7 Mon Sep 17 00:00:00 2001
|
||||
From: Hugo Manrique <hugmanrique@gmail.com>
|
||||
Date: Thu, 26 Jul 2018 14:10:23 +0200
|
||||
Subject: [PATCH] Don't call getItemMeta on hasItemMeta
|
||||
|
@ -11,10 +11,10 @@ Returns true if getDamage() == 0 or has damage tag or other tag is set.
|
|||
Check the `ItemMetaTest#testTaggedButNotMeta` method to see how this method behaves.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index 5f3331de13..ae21780964 100644
|
||||
index 8ca161f0ed..e9bef85c8b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -517,7 +517,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
@@ -514,7 +514,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
|
||||
@Override
|
||||
public boolean hasItemMeta() {
|
||||
|
|
Loading…
Reference in a new issue