Bukkit - 插件未加载 - major.minor错误

时间:2016-07-22 21:21:23

标签: java bukkit

我制作了一个bukkit插件,由于某种原因不起作用。 以下是我认为有用的一些内容: 1.插件没有出现在/ plugins中 2.控制台发出了一个major.minor错误 3.命令不会出错;他们只是说!sosex.mln。 这是我的代码:

unknown command

Plugin.yml:

package me.Orion31.broadcaster;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {
    @Override
    public void onEnable() {
        getLogger().info("Enabled Broadcaster by Orion version " + getDescription().getVersion());
        getConfig().options().copyDefaults(false);
    } 
    @Override
    public void onDisable() {
        getLogger().info("Disabled Broadcaster!");
    }
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player player = (Player) sender;
        if (command.getName().equalsIgnoreCase("bc") || command.getName().equalsIgnoreCase("broadcast")) {
            if (player.hasPermission("broadcast.bc")) {
                if (args.length == 1) {
                    Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&',
                            getConfig().getString("Tag") + getConfig().getString("Color") + " " + args[0]));
                    return true;
                } else {
                    player.sendMessage(ChatColor.DARK_RED + "Invalid Arguments!");
                    player.sendMessage(ChatColor.RED + "Usage: /broadcast <message>");
                    return true;
                }
            } else
                player.sendMessage(ChatColor.DARK_RED + "You don't have permissions!");
            return true;
        } else if (command.getName().equalsIgnoreCase("bcset")) {
            if (args.length == 2) {
                if (player.hasPermission("broadcast.bc")) {
                    if (args[0].equalsIgnoreCase("tag")) {
                        getConfig().set("Tag", args[1]);
                        saveConfig();
                    } else if(args[0].equalsIgnoreCase("color")){
                        getConfig().set("Color", args[1]);
                        saveConfig();
                    }
                } else
                    player.sendMessage(ChatColor.DARK_RED + "You don't have permissions!");

            } else {
                player.sendMessage(ChatColor.DARK_RED + "Invalid usage!");
                player.sendMessage(ChatColor.RED + "Usage: /bctag tag,color <new value>");
            }
        }
        return false;
    }
}

感谢您的时间!

1 个答案:

答案 0 :(得分:0)

简单的错误,即使是我自己也经常忘记这样做。

public class Main extends JavaPlugin更改为public class Main extends JavaPlugin implements CommandExecutor

一旦你这样做,你应该是好的。