mirror of
https://github.com/TotalFreedomMC/TotalFreedomMod.git
synced 2024-06-21 05:20:37 +00:00
293ea04c56
* rename everything containing staff back to admin (as requested by ryan i've renamed commands like slconfig to saconfig but left "slconfig" as an alias) * format almost every file correctly * a few other improvements
55 lines
1.7 KiB
Java
55 lines
1.7 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import java.util.Map;
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
|
@CommandParameters(description = "Essentials Interface Command - Set your nickname to a certain color.", usage = "/<command> <color>")
|
|
public class Command_colorme extends FreedomCommand
|
|
{
|
|
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
if (args.length != 1)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("list"))
|
|
{
|
|
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
|
|
return true;
|
|
}
|
|
|
|
final String needle = args[0].trim().toLowerCase();
|
|
ChatColor color = null;
|
|
for (Map.Entry<String, ChatColor> entry : FUtil.CHAT_COLOR_NAMES.entrySet())
|
|
{
|
|
if (entry.getKey().contains(needle))
|
|
{
|
|
color = entry.getValue();
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (color == null)
|
|
{
|
|
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
|
|
return true;
|
|
}
|
|
|
|
final String newNick = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE;
|
|
|
|
plugin.esb.setNickname(sender.getName(), newNick);
|
|
|
|
msg("Your nickname is now: " + newNick);
|
|
return true;
|
|
}
|
|
} |