mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-26 02:19:23 +00:00
@@ -4,20 +4,28 @@ import net.momirealms.craftengine.core.item.ExternalItemProvider;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CustomFishingProvider implements ExternalItemProvider<ItemStack> {
|
||||
@Override
|
||||
public String plugin() {
|
||||
return "CustomFishing";
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack build(String id, ItemBuildContext context) {
|
||||
return BukkitCustomFishingPlugin.getInstance().getItemManager()
|
||||
.buildInternal(Context.player(((Player) context.player().platformPlayer())), id);
|
||||
Context<Player> ctx = Context.player(
|
||||
(Player) Optional.ofNullable(context.player())
|
||||
.map(net.momirealms.craftengine.core.entity.player.Player::platformPlayer)
|
||||
.orElse(null)
|
||||
);
|
||||
return BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(ctx.arg(ContextKeys.ID, id), id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user