Skip to content

Commit 15ec9a2

Browse files
authored
Fix item components in /give on 26.1+ (#6570)
Fixes #6532
1 parent 38f1b4d commit 15ec9a2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,13 @@ public void parseStringMeta(final CommandSource sender, final boolean allowUnsaf
208208

209209
try {
210210
final String components = Joiner.on(' ').join(Arrays.asList(string).subList(fromArg, string.length));
211-
// modifyItemStack requires that the item namespaced key is prepended to the components for some reason
212-
stack = ess.getServer().getUnsafe().modifyItemStack(stack, stack.getType().getKey() + components);
211+
// From 1.20.6 through 1.21.11, modifyItemStack parses its argument as a full item string, so the item's
212+
// namespaced key must be prepended to the components. As of 26.1, the implementation prepends the item
213+
// key itself, so prepending it here would produce a malformed (double-namespaced) item string.
214+
final String itemString = VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v26_1_R01)
215+
? components
216+
: stack.getType().getKey() + components;
217+
stack = ess.getServer().getUnsafe().modifyItemStack(stack, itemString);
213218
} catch (final NullPointerException npe) {
214219
if (ess.getSettings().isDebug()) {
215220
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);

0 commit comments

Comments
 (0)