Search code examples
javapluginsserverminecraftbukkit

Bukkit plugin not loaded (only one command)


I'm new in java and bukkit api and server can't load my plugin, error in console: https://pastebin.com/GzgLhHp6. Maybe problem in "private Plugin plugin" whick is not used, eclipse warned. My code:

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>

Solution

  • Your plugin.yml is not valid:

    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)
    

    Somewhere in you plugin.yml is a tab character which must not be used.

    Just read the whole error message. It gives you hints where errors occured.