Added /tag clearall and /tag clear <name>

This commit is contained in:
JeromSar 2013-08-12 12:50:39 +02:00
parent f3ac19a616
commit 69fd3566af
3 changed files with 91 additions and 31 deletions

View File

@ -1,5 +1,5 @@
#Mon, 12 Aug 2013 12:25:56 +0200
#Mon, 12 Aug 2013 12:49:58 +0200
program.VERSION=2.22
program.BUILDNUM=400
program.BUILDDATE=08/12/2013 12\:25 PM
program.BUILDNUM=403
program.BUILDDATE=08/12/2013 12\:49 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Aug 12 12:25:56 CEST 2013
build.number=401
#Mon Aug 12 12:49:58 CEST 2013
build.number=404

View File

@ -5,12 +5,13 @@ import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Sets yourself a prefix", usage = "/<command> [<prefix> | off]")
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
@CommandParameters(description = "Sets yourself a prefix", usage = "/<command> <<prefix> | off | clear <player> | clearall>")
public class Command_tag extends TFM_Command
{
@ -19,40 +20,99 @@ public class Command_tag extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
if (args.length == 1)
{
if ("clearall".equals(args[0]))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
int count = 0;
for (Player p : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
if (playerdata.getTag() != null)
{
count++;
TFM_PlayerData.getPlayerData(p).setTag(null);
}
}
playerMsg(count + " tag(s) removed.");
return true;
}
if (senderIsConsole)
{
playerMsg("This can only be used by players.");
return true;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_PlayerData.getPlayerData(sender_p).setTag(null);
playerMsg("Removed your tag.");
return true;
}
if (args[0].length() > 15)
{
playerMsg("That tag is too long.");
return true;
}
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
for (String word : FORBIDDEN_WORDS)
{
if (args[0].toLowerCase().contains(word))
{
playerMsg("That tag contains a forbidden word.");
return true;
}
}
}
TFM_PlayerData.getPlayerData(sender_p).setTag(args[0]);
playerMsg("Tag set.");
return true;
}
else if (args.length == 2)
{
if ("clear".equals(args[0]))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
final Player p;
try
{
p = getPlayer(args[1]);
}
catch (CantFindPlayerException ex)
{
playerMsg(ex.getMessage());
return true;
}
TFM_PlayerData.getPlayerData(p).setTag(null);
playerMsg("Removed " + p.getName() + "'s tag.");
return true;
}
return false;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_PlayerData.getPlayerData(sender_p).setTag(null);
playerMsg("Removed your tag.");
return true;
}
if (args[0].length() > 15)
{
playerMsg("That tag is too long.");
return true;
}
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
for (String word : FORBIDDEN_WORDS)
{
if (args[0].toLowerCase().contains(word))
{
playerMsg("That tag contains a forbidden word.");
return true;
}
}
}
TFM_PlayerData.getPlayerData(sender_p).setTag(args[0]);
playerMsg("Tag set.");
return true;
return false;
}
}