2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2013-09-24 14:13:38 +00:00
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Map;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2014-11-29 19:16:00 +00:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2013-09-24 14:13:38 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
2013-09-24 14:13:38 +00:00
|
|
|
@CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>")
|
2016-05-12 19:40:39 +00:00
|
|
|
public class Command_colorme extends FreedomCommand
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2013-09-24 14:13:38 +00:00
|
|
|
@Override
|
2016-05-12 19:40:39 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
|
|
|
if (args.length != 1)
|
|
|
|
{
|
2013-09-24 14:13:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
if ("list".equalsIgnoreCase(args[0]))
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
|
2013-09-24 14:13:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
final String needle = args[0].trim().toLowerCase();
|
|
|
|
ChatColor color = null;
|
2015-10-19 17:43:46 +00:00
|
|
|
final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator();
|
2016-05-12 19:40:39 +00:00
|
|
|
while (it.hasNext())
|
|
|
|
{
|
2013-09-24 14:13:38 +00:00
|
|
|
final Map.Entry<String, ChatColor> entry = it.next();
|
2016-05-12 19:40:39 +00:00
|
|
|
if (entry.getKey().contains(needle))
|
|
|
|
{
|
2013-09-24 14:13:38 +00:00
|
|
|
color = entry.getValue();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
if (color == null)
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
|
2013-09-24 14:13:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-22 18:26:47 +00:00
|
|
|
final String newNick = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE;
|
2013-09-24 14:13:38 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
plugin.esb.setNickname(sender.getName(), newNick);
|
2013-09-24 14:13:38 +00:00
|
|
|
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Your nickname is now: " + newNick);
|
2013-09-24 14:13:38 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|