我只是在测试一些基本的Bukkit插件,试图让它们工作以便我可以测试它们。我的插件(我实际上是从Bukkit wiki复制的)
一直出现同样的错误以下是错误消息:
15:25:18 [INFO] Starting minecraft server version 1.6.2
15:25:18 [INFO] Loading properties
15:25:18 [INFO] Default game type: SURVIVAL
15:25:18 [INFO] Generating keypair
15:25:18 [INFO] Starting Minecraft server on *:25565
15:25:19 [INFO] This server is running CraftBukkit version git-Bukkit-1.6.2-R1.0
-b2879jnks (MC: 1.6.2) (Implementing API version 1.6.2-R1.0)
15:25:19 [SEVERE] Could not load 'plugins\Test-Plugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPlug
inLoader.java:257)
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
.java:132)
at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugins(CraftServer.ja
va:239)
at org.bukkit.craftbukkit.v1_6_R2.CraftServer.<init>(CraftServer.java:21
7)
at net.minecraft.server.v1_6_R2.PlayerList.<init>(PlayerList.java:56)
at net.minecraft.server.v1_6_R2.DedicatedPlayerList.<init>(SourceFile:11
)
at net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.jav
a:106)
at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java
:391)
at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:5
82)
Caused by: while scanning for the next token
found character '\t' that cannot start any token
in "<reader>", line 7, column 1:
usage: /ignite [player]
^
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.ja
va:358)
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:17
9)
at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(Par
serImpl.java:563)
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:161)
at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:146)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java
:230)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:160)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java
:237)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:160)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java
:237)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:160)
at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:12
3)
at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:106)
at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseCons
tructor.java:121)
at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:480)
at org.yaml.snakeyaml.Yaml.load(Yaml.java:411)
at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.
java:188)
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPlug
inLoader.java:252)
... 8 more
现在,我要做的就是让这个插件加载到我的服务器上。这里的主要错误是Invalid plugin.yml
。这是我的plugin.yml文件:
name: Test
main: com.hasherr.bukkit.test.Main
version: 1.0
commands:
ignite:
description: Sets the designated player on fire.
usage: /ignite [player]
permissions: Test.ignite
permission-message: You can't use that command.
关于插件的实际代码,这里是:
public final class Main extends JavaPlugin
{
@Override
public void onEnable()
{
getLogger().info("Test plugin has been enabled.");
}
@Override
public void onDisable()
{
getLogger().info("Test plugin has been disabled.");
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
// Uses equalsIgnoreCase() over equals() to accept "ignite" and "IgNiTe."
if (cmd.getName().equalsIgnoreCase("ignite")) {
// Make sure that the player specified exactly one argument (the name of the player to ignite).
if (args.length != 1) {
// When onCommand() returns false, the help message associated with that command is displayed.
return false;
}
// Make sure the sender is a player.
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can set other players on fire.");
sender.sendMessage("This is an arbitrary requirement for demonstration purposes only.");
return true;
}
// Get the player who should be set on fire. Remember that indecies start with 0, not 1.
Player target = Bukkit.getServer().getPlayer(args[0]);
// Make sure the player is online.
if (target == null) {
sender.sendMessage(args[0] + " is not currently online.");
return true;
}
// Sets the player on fire for 1,000 ticks (there are ~20 ticks in second, so 50 seconds total).
target.setFireTicks(1000);
return true;
}
return false;
}
}
有人可以告诉我为什么我收到的Invalid plugin.yml
消息不允许我的插件运行吗?如果您需要更多详细信息/信息,请告诉我,我很乐意进行编辑。
答案 0 :(得分:3)
你的plugin.yml中有标签,这是不允许的。如果您使用一定数量的空格替换所有选项卡(根据我的经验最常见4个),代码将按预期运行。
如果您在Notepad ++中对其进行编辑,请使用Edit -> Blank Operations -> TAB to Space
自动将所有标签替换为空格。
答案 1 :(得分:0)
您还可以配置每次按TAB键时它会自动转换为空格。 另外,您可以定义按TAB时应插入的空格数。 我个人使用4个空格,在工作中我们使用标准的2个空格。
您可以在NotePad + here
中找到选项 Settings -> Preferences -> Tab Settings
您可以为每种语言和默认值定义它。 只需标记“空格替换”
答案 2 :(得分:0)
name: Test
main: com.hasherr.bukkit.test.Main
version: 1.0
commands:
ignite:
description: Sets the designated player on fire.
usage: /ignite [player]
permissions:
Test.ignite
description: Sets a player on FIRE
default:true
喜欢这个......