我正在尝试创建简单的蹦极绳命令插件

vuktfyat  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(212)

问题是,当我将jar文件放入plugins文件夹并运行服务器时,我总是从控制台收到以下消息: Enabled plugin FirstCommand version 1.0-SNAPSHOT by null 我的代码由两个类组成:

public final class FirstCommand extends Plugin {

    @Override
    public void onEnable() {
        // Plugin startup logic
        getLogger().info("has loaded");
        getProxy().getPluginManager().registerCommand(this, new PingCommand());
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }
}

public class PingCommand extends Command {

    public PingCommand() {
        super("ping");
    }

    @Override
    public void execute(CommandSender sender, String[] args) {
        if (sender instanceof ProxiedPlayer) {
            ProxiedPlayer player = (ProxiedPlayer) sender;
            int ping = player.getPing();
            player.sendMessage(new TextComponent(ChatColor.GRAY + "Your ping is: " + ChatColor.GREEN + ping));
        }
    }
}
bungee.yml : 
name: FirstCommand
version: ${project.version}
main: org.example.firstcommand.FirstCommand

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题