Implement kits placing items in specific slots#5794
Conversation
JRoy
left a comment
There was a problem hiding this comment.
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.
I like the idea of storing the item slot like that, but it should not live in 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);
Should |
18758ba to
88067f3
Compare
|
hmm you're right, it should stay in expandItems. Instead of an slotList tho, lets do a HashMap<Integer, ItemStack>, if during put() we get a return value (overlapping slot), add it to the regular itemList . then we should do the Inventories#hasSpace check with all items (both regular and slotted) (or isDropItemsIfFull) then we'll have a new method in Inventories that will check isSimilar and if the amount + new amount will be greater than the allowed max size. that method will return a boolean if it can be added to the slot or not. then finally add all the non-slotted items + ones that couldn't be added to the slot they asked for in one go via Inventories#addItem |
88067f3 to
052e396
Compare
|
thank you! |
Closes #5535