Guys my command isn't working still when I type it in-game it says "Usage: /rank"
My command class code
My main class code
My command class code
Code:
package me.YuvMC.testplugin.commands;
import cn.nukkit.Player;
import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;
import cn.nukkit.utils.TextFormat;
public class RankCommand extends Command {
private String ownerprefix = TextFormat.DARK_RED + TextFormat.BOLD.toString() + "OWNER ";
private String defaultprefix = TextFormat.GRAY + TextFormat.BOLD.toString() + "DEFAULT ";
private String prefix = TextFormat.GREEN + "[" + TextFormat.AQUA + "SERVER" + TextFormat.GREEN + "] ";
public RankCommand(String name) {
super(name);
}
public boolean execute(CommandSender sender, String label, String[] strings) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (player.isOp()) {
sender.sendMessage(prefix + TextFormat.GREEN + "Your current rank is: " + ownerprefix);
} else {
sender.sendMessage(prefix + TextFormat.GREEN + "Your current rank is: " + defaultprefix);
}
}else{
sender.sendMessage(TextFormat.RED + "You have to be a player to use this command!");
}
return true;
}
}
Code:
package me.YuvMC.testplugin;
import cn.nukkit.event.Listener;
import cn.nukkit.plugin.PluginBase;
import me.YuvMC.testplugin.commands.RankCommand;
import me.YuvMC.testplugin.events.ChatPrefix;
import me.YuvMC.testplugin.events.JoinAndQuit;
public class Main extends PluginBase implements Listener {
@Override
public void onEnable() {
getLogger().info("Test Plugin has started successfully!");
getServer().getPluginManager().registerEvents(new JoinAndQuit(), this);
getServer().getPluginManager().registerEvents(new ChatPrefix(), this);
this.getServer().getCommandMap().register("rank", new RankCommand("rank"));
}
}