【问题标题】:Bukkit plugin not loaded (only one command)Bukkit 插件未加载(只有一个命令)
【发布时间】:2019-03-13 17:17:41
【问题描述】:

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

插件.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>

【问题讨论】:

  • 我投了反对票,因为您似乎没有付出任何努力来正确阅读您的错误。

标签: java plugins server minecraft bukkit


【解决方案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 中的某个地方是一个不能使用的制表符。

只需阅读整个错误消息。它会提示您发生错误的位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 2014-04-20
    • 1970-01-01
    • 1970-01-01
    • 2017-03-27
    相关资源
    最近更新 更多