9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-19 15:09:15 +00:00

改进调用库的方法

This commit is contained in:
jhqwqmc
2025-12-18 22:12:50 +08:00
parent 664eeeca0a
commit 61433478cf
3 changed files with 7 additions and 7 deletions

View File

@@ -104,9 +104,9 @@ public abstract class BukkitItemFactory<W extends ItemWrapper<ItemStack>> extend
} }
if (this.hasExternalRecipeSource) { if (this.hasExternalRecipeSource) {
for (Provider<ItemStack, Player> source : this.recipeIngredientSources) { for (Provider<ItemStack, Player> source : this.recipeIngredientSources) {
Optional<String> id = source.id(item.getItem()); String id = source.idOrNull(item.getItem());
if (id.isPresent()) { if (id != null) {
return UniqueKey.create(Key.of(source.plugin(), StringUtils.toLowerCase(id.get()))); return UniqueKey.create(Key.of(source.plugin(), StringUtils.toLowerCase(id)));
} }
} }
} }

View File

@@ -62,12 +62,12 @@ public class ExternalModifier<I> implements ItemDataModifier<I> {
try { try {
ItemManager<I> itemManager = CraftEngine.instance().itemManager(); ItemManager<I> itemManager = CraftEngine.instance().itemManager();
Player player = context.player(); Player player = context.player();
Optional<I> another = this.provider.build(this.id, player == null ? null : player.platformPlayer(), adapt(context)); I another = this.provider.buildOrNull(this.id, player == null ? null : player.platformPlayer(), adapt(context));
if (another.isEmpty()) { if (another == null) {
CraftEngine.instance().logger().warn("'" + this.id + "' could not be found in " + provider.plugin()); CraftEngine.instance().logger().warn("'" + this.id + "' could not be found in " + provider.plugin());
return item; return item;
} }
Item<I> anotherWrapped = itemManager.wrap(another.get()); Item<I> anotherWrapped = itemManager.wrap(another);
item.merge(anotherWrapped); item.merge(anotherWrapped);
return item; return item;
} catch (Throwable e) { } catch (Throwable e) {

View File

@@ -57,7 +57,7 @@ jimfs_version=1.3.1
authlib_version=7.0.60 authlib_version=7.0.60
concurrent_util_version=0.0.8-SNAPSHOT concurrent_util_version=0.0.8-SNAPSHOT
bucket4j_version=8.15.0 bucket4j_version=8.15.0
itembridge_version=1.0.10 itembridge_version=1.0.12
# Proxy settings # Proxy settings
systemProp.socks.proxyHost=127.0.0.1 systemProp.socks.proxyHost=127.0.0.1