Skip to content

Commit

Permalink
Fix slimefunItem + TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
Intybyte committed Nov 12, 2024
1 parent 8c25fff commit a85442f
Showing 1 changed file with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,11 @@ public void register(@Nonnull SlimefunAddon addon) {
this.itemHandlers.clear();
}

// TODO find a way to lock the item or maybe clone the item everytime it is obtained
// Lock the SlimefunItemStack from any accidental manipulations
if (itemStackTemplate instanceof SlimefunItemStack stack && isItemStackImmutable()) {
stack.lock();
}
//if (itemStackTemplate instanceof SlimefunItemStack stack && isItemStackImmutable()) {
// stack.lock();
//}

postRegister();

Expand Down Expand Up @@ -773,11 +774,6 @@ public boolean isItem(@Nullable ItemStack item) {
return false;
}

// If the given item is a SlimefunitemStack, simply compare the id
if (item instanceof SlimefunItemStack stack) {
return getId().equals(stack.getItemId());
}

if (item.hasItemMeta()) {
Optional<String> itemId = Slimefun.getItemDataService().getItemData(item);

Expand Down Expand Up @@ -912,12 +908,10 @@ public final void addOfficialWikipage(@Nonnull String page) {
* @return This item's name in {@link ItemStack} form
*/
public final @Nonnull String getItemName() {
if (itemStackTemplate instanceof SlimefunItemStack) {
Optional<String> name = ((SlimefunItemStack) itemStackTemplate).getItemMetaSnapshot().getDisplayName();

if (name.isPresent()) {
return name.get();
}
SlimefunItem slimefunItem = getByItem(itemStackTemplate);
if (slimefunItem != null) {
return slimefunItem.getItemName();
}

return ItemUtils.getItemName(itemStackTemplate);
Expand Down Expand Up @@ -1210,10 +1204,6 @@ public final int hashCode() {
return null;
}

if (item instanceof SlimefunItemStack stack) {
return getById(stack.getItemId());
}

Optional<String> itemID = Slimefun.getItemDataService().getItemData(item);

return itemID.map(SlimefunItem::getById).orElse(null);
Expand Down

0 comments on commit a85442f

Please sign in to comment.