Bukkit插件未加载(仅一个命令)

时间:2019-03-13 17:17:42

标签: java plugins server minecraft bukkit

我是Java和bukkit api的新手,服务器无法加载我的插件,控制台错误:https://pastebin.com/GzgLhHp6。 Eclipse警告说,也许没有使用“私有插件插件”的问题。我的代码:

Plugin.java

package Iaiao.main;
import org.bukkit.plugin.java.JavaPlugin;

public class Plugin extends JavaPlugin {
    public void onEnable () {
        getCommand("ip").setExecutor(new Commands(this));
        getLogger().info("Enabled!");
    }
}

Commands.java

package Iaiao.main;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Commands implements CommandExecutor {

    private Plugin plugin;

    public Commands(Plugin plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if(args.length == 0) {
            return false;
        }
        String name = args[0];
        Player p = Bukkit.getPlayer(name);
        if(p == null) {
            sender.sendMessage("This player is offline or not registered");
            return true;
        }
        sender.sendMessage("Ip: " + p.getAddress().getAddress());
        return true;
    }
}

plugin.yml

name: Plugin
main: Iaiao.main.Plugin
version: 1.0
commands:
    ip:
        description: Player's IP
        usage: /ip <player>

1 个答案:

答案 0 :(得分:1)

您的plugin.yml无效:

org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token
found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)

plugin.yml在您的某处,是不得使用的制表符。

只需阅读整个错误消息即可。它会提示您发生错误的地方。