Tweaks to Command_tag

This commit is contained in:
StevenLawson 2013-08-12 14:19:17 -04:00
parent 4603dc5613
commit a59e6added

View File

@ -6,6 +6,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -18,10 +19,9 @@ public class Command_tag extends TFM_Command
{ {
"admin", "owner", "moderator", "developer" "admin", "owner", "moderator", "developer"
}); });
public static final List<String> FORBIDDEN_CODE = Arrays.asList(new String[] public static final List<String> FORBIDDEN_CODE = Arrays.asList(new String[]
{ {
"&k" "&k", (ChatColor.COLOR_CHAR + "k")
}); });
@Override @Override
@ -29,7 +29,6 @@ public class Command_tag extends TFM_Command
{ {
if (args.length == 1) if (args.length == 1)
{ {
if ("clearall".equals(args[0])) if ("clearall".equals(args[0]))
{ {
if (!TFM_SuperadminList.isUserSuperadmin(sender)) if (!TFM_SuperadminList.isUserSuperadmin(sender))
@ -56,14 +55,14 @@ public class Command_tag extends TFM_Command
if (senderIsConsole) if (senderIsConsole)
{ {
playerMsg("This can only be used by players."); playerMsg("Only in-game players can set tags. Use \"/tag clearall\" to reset all tags.");
return true; return true;
} }
if (TFM_Util.isStopCommand(args[0])) if (TFM_Util.isStopCommand(args[0]))
{ {
TFM_PlayerData.getPlayerData(sender_p).setTag(null); TFM_PlayerData.getPlayerData(sender_p).setTag(null);
playerMsg("Removed your tag."); playerMsg("Your tag has been removed.");
return true; return true;
} }
@ -77,27 +76,23 @@ public class Command_tag extends TFM_Command
{ {
for (String word : FORBIDDEN_WORDS) for (String word : FORBIDDEN_WORDS)
{ {
if (args[0].toLowerCase().contains(word)) if (args[0].toLowerCase().contains(word.toLowerCase()))
{ {
playerMsg("That tag contains a forbidden word."); playerMsg("That tag contains a forbidden word.");
return true; return true;
} }
} }
}
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
for (String word : FORBIDDEN_CODE) for (String word : FORBIDDEN_CODE)
{ {
if (args[0].toLowerCase().contains(word)) if (args[0].toLowerCase().contains(word.toLowerCase()))
{ {
playerMsg("You may not include the colour code you have attempted to use in your tag") playerMsg("That tag contains a forbidden color code.");
return true; return true;
} }
} }
} }
TFM_PlayerData.getPlayerData(sender_p).setTag(args[0]); TFM_PlayerData.getPlayerData(sender_p).setTag(args[0]);
playerMsg("Tag set."); playerMsg("Tag set.");