2013-10-20 111 views
1

我只是測試一些基本的Bukkit插件,試圖讓他們工作,以便我可以測試它們。我一直得到與我的插件同樣的錯誤(我幾乎從Bukkit wiki複製)Bukkit無效的plugin.yml異常

這裏的錯誤消息:

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消息不允許我的插件運行?如果您需要更多詳情/信息,請告知我,我很樂意編輯。

回答

3

你的plugin.yml中有標籤,這是不允許的。如果您將所有選項卡替換爲一定數量的空格(根據我的經驗,最常見的是4),代碼將按預期運行。

如果您在Notepad ++中編輯它,請使用Edit -> Blank Operations -> TAB to Space自動將空格替換爲空格。

+0

我想通過http://yaml-online-parser.appspot.com/檢查所有.yml文件。它有助於查找那些討厭的選項卡和其他間距問題。 – Brendan

0

您還可以配置每次按TAB時自動轉換爲空格。 另外,您可以定義在按TAB時應該插入多少個空格。 我個人使用4個空格,在工作中我們使用2個空格標準。

您可以在記事本中選擇+這裏

Settings -> Preferences -> Tab Settings

,你可以將其定義爲每種語言和默認值。 只需註明「由空格替換」

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 

就像這個...