Optimized custom item cache
This commit is contained in:
@@ -116,6 +116,13 @@ public interface FastItemStack {
|
||||
*/
|
||||
boolean hasItemFlag(@NotNull ItemFlag flag);
|
||||
|
||||
/**
|
||||
* Get if the item has any nbt data.
|
||||
*
|
||||
* @return If any nbt data is present on the item.
|
||||
*/
|
||||
boolean hasAnyNBT();
|
||||
|
||||
/**
|
||||
* Get the Bukkit ItemStack again.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.eco.core.items;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.willfp.eco.core.fast.FastItemStack;
|
||||
import com.willfp.eco.core.items.args.LookupArgParser;
|
||||
import com.willfp.eco.core.items.provider.ItemProvider;
|
||||
import com.willfp.eco.core.recipe.parts.EmptyTestableItem;
|
||||
@@ -45,6 +46,10 @@ public final class Items {
|
||||
.expireAfterAccess(5, TimeUnit.MINUTES)
|
||||
.build(
|
||||
key -> {
|
||||
if (!FastItemStack.wrap(key.getItem()).hasAnyNBT()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
TestableItem match = null;
|
||||
for (TestableItem item : REGISTRY.values()) {
|
||||
if (item.matches(key.getItem())) {
|
||||
|
||||
Reference in New Issue
Block a user