gpt4 book ai didi

java - 为什么我的recpie 显示此错误?

转载 作者:太空宇宙 更新时间:2023-11-04 10:44:30 25 4
gpt4 key购买 nike

我尝试为我的 friend 开发 Minecraft 插件,因此我一直在尝试实验项目配方示例,但是当我重新加载时,我的控制台上会显示此错误:

[17:10:41 ERROR]: Error occurred while enabling test vbeta0.1 (Is it up to date?)
java.lang.IllegalArgumentException: Symbol does not appear in the shape:87
at org.apache.commons.lang.Validate.isTrue(Validate.java:93) ~[spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.inventory.ShapedRecipe.setIngredient(ShapedRecipe.java:121) ~[spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.inventory.ShapedRecipe.setIngredient(ShapedRecipe.java:107) ~[spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at codemineman.test.minecraft.CustomRecpie.customItem(CustomRecpie.java:18) ~[?:?]
at codemineman.test.minecraft.Main.onEnable(Main.java:14) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:752) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.Bukkit.reload(Bukkit.java:525) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:634) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot1.12.jar:git-Spigot-4bd94dc-015bda4]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_161]

CustomRecpies.java:

package codemineman.test.minecraft;

import java.util.ArrayList;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;

public class CustomRecpie implements Listener {
public ItemStack item = new ItemStack(Material.ANVIL,3);
public ItemMeta meta;
private Plugin plugin = Main.getPlugin(Main.class);

@SuppressWarnings("deprecation")
public void customItem() {
ItemStack item = new ItemStack(Material.DIAMOND_AXE, 1);
ItemMeta meta = item.getItemMeta();

meta.setDisplayName(ChatColor.AQUA + "AXE OF ZEUS");
ArrayList<String> lore = new ArrayList<String>();
lore.add(ChatColor.WHITE + "Used by Zeus in the great god battle");
meta.setLore(lore);
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
item.setItemMeta(meta);
ShapedRecipe r = new ShapedRecipe(item);

r.shape("#% ", "#$ ", " $ ");
r.setIngredient('#', Material.DIAMOND);
r.setIngredient('%', Material.IRON_INGOT);
r.setIngredient('$', Material.STICK);

plugin.getServer().addRecipe(r);
}
}

Main.java:

package codemineman.test.minecraft;

import org.bukkit.plugin.java.JavaPlugin;

import net.md_5.bungee.api.ChatColor;

public class Main extends JavaPlugin{

public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "\n\nTest plugin have been enabled.\n\n");
getServer().getPluginManager().registerEvents(new EventsClass(), this);

CustomRecpie items = new CustomRecpie();
items.customItem();
}

public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "\n\nTest plugin have been disabled.\n\n");
}
}

我真的找不到出现问题的原因,我在我的家用计算机上托管我的测试服务器,在控制台错误中显示:“它是最新的吗?”我想我可能使用了较旧的外部 spigot jar 文件,我不确定。

最佳答案

查看了一下代码后,我发现了问题:

private Plugin plugin = Main.getPlugin(Main.class); 

recpie 代码没有任何问题,我发现这样做,制作一个新插件会使插件崩溃。不管怎样,感谢您的帮助。

关于java - 为什么我的recpie 显示此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48566160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com