Skip to content

Conversation

@TiagoFar78
Copy link
Contributor

@TiagoFar78 TiagoFar78 commented May 7, 2024

Information

This PR closes #5535.

Details

Proposed feature:

Everytime you create a kit with gear (armor and offhand) equipped, the gear is placed in their respective slots once you retrieve the kit. For example, if you create the kit with a golden helmet equipped, it will be placed in your helmet slot when retrieving the kit.

Environments tested:

OS: Windows 11

Java version: 17

  • Most recent Paper version (1.20.4, git-Paper-BUILD)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8

Demonstration:

Before:

Inventory before creating kit:
image

Execute createkit command:
image

Remove everything from inventory:
image

Retrieving the kit:
image

Inventory result:
image

After:

Inventory before creating kit:
image

Execute createkit command:
image

Remove everything from inventory:
image

Retrieving the kit:
image

Inventory result:
image

Everytime you create a kit with gear (armor and offhand) equipped, the gear is placed in their respective slots once you retrieve the kit. For example, if you create the kit with a golden helmet equipped, it will be placed in your helmet slot when retrieving the kit. Co-authored-by: Catarina Freire <catarina.xie.freire@tecnico.ulisboa.pt>
Copy link
Member

@JRoy JRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, sorry for the delay in review. overall, i think this pr is the wrong approach. we should be adding a slot:<number> into MetaItemStack where expandItems will attempt to add the item to that slot if it is not full.

@TiagoFar78
Copy link
Contributor Author

we should be adding a slot:<number> into MetaItemStack

I like the idea of storing the item slot like that, but it should not live in MetaItemStack. The slot is an inventory attribute, not an item attribute. If you put it in the item metadata, any serialization provider that saves only the item would lose the slot information and be unable to restore it later.

if (kitItem.startsWith("@")) { if (serializationProvider == null) { ess.getLogger().log(Level.WARNING, AdventureUtil.miniToLegacy(tlLiteral("kitError3", kitName, user.getName()))); continue;	} stack = serializationProvider.deserializeItem(Base64Coder.decodeLines(kitItem.substring(1))); } else { final String[] parts = kitItem.split(" +"); final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1); if (parseStack.getType() == Material.AIR) { continue;	} final MetaItemStack metaStack = new MetaItemStack(parseStack); if (parts.length > 2) { // We pass a null sender here because kits should not do perm checks metaStack.parseStringMeta(null, allowUnsafe, parts, 2, ess);	} stack = metaStack.getItemStack(); } itemList.add(stack);

where expandItems will attempt to add the item to that slot if it is not full.

Should expandItems try to place every item from a kit into its assigned slot rather than only armor and offhand, and if it does, should the command include a flag to disable this behavior? Editing the config to remove slot data is technically possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants