2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2013-09-24 14:13:38 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
|
2013-09-24 14:13:38 +00:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Map;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
|
|
|
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;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.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>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_colorme extends FreedomCommand
|
2013-09-24 14:13:38 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
|
|
|
if (args.length != 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("list".equalsIgnoreCase(args[0]))
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
playerMsg("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();
|
2013-09-24 14:13:38 +00:00
|
|
|
while (it.hasNext())
|
|
|
|
{
|
|
|
|
final Map.Entry<String, ChatColor> entry = it.next();
|
|
|
|
if (entry.getKey().contains(needle))
|
|
|
|
{
|
|
|
|
color = entry.getValue();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (color == null)
|
|
|
|
{
|
|
|
|
playerMsg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-25 00:32:04 +00:00
|
|
|
final String newNick = color + ChatColor.stripColor(sender_p.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
|
|
|
|
|
|
|
playerMsg("Your nickname is now: " + newNick);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|