Core/src/main/java/eu/univento/core/commands/Nick.java

67 lines
1.8 KiB
Java

package eu.univento.core.commands;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.Perms.Ranks;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.List;
/**
* nick command
* @author joethei
* @version 1.0
*/
public class Nick extends AutoCommand<Core>{
/**
* @param plugin main class
* @param command command to execute
* @param description describes the command
* @param aliases aliases of command
*/
public Nick(Core plugin, String command, String description, String... aliases) {
super(plugin, command, description, aliases);
}
@SuppressWarnings("deprecation")
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if(sender instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
Messages msgs = new Messages(p);
if(p.isAllowed(Ranks.Youtuber)) {
if(p.isNicked()) {
p.getTeam().removeEntry(p.getDisplayName());
p.setNicked(false);
p.setDisplayName(p.getName());
p.getTeam().addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_OFF());
p.unnick();
}else {
p.getTeam().removeEntry(p.getDisplayName());
p.setNicked(true);
p.setDisplayName(p.getNick());
p.getTeam().addEntry(p.getDisplayName());
p.sendMessage(msgs.PREFIX() + msgs.Core_NICK_ON());
p.nick(p.getNick());
}
}else {
p.sendMessage(msgs.NO_PERMS());
}
}else {
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
}
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
return null;
}
}