2017-11-16 22:32:09 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
2017-11-27 07:06:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2017-11-16 22:32:09 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2019-07-31 16:19:23 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2017-11-27 07:06:04 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2017-11-16 22:32:09 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2017-11-27 07:06:04 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2017-11-16 22:32:09 +00:00
|
|
|
|
|
|
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
2020-03-30 23:43:57 +00:00
|
|
|
@CommandParameters(description = "Give yourself a prefix with rainbow colors.", usage = "/<command> <tag>")
|
2018-08-08 00:51:48 +00:00
|
|
|
public class Command_tagrainbow extends FreedomCommand
|
2017-11-16 22:32:09 +00:00
|
|
|
{
|
|
|
|
|
2017-11-27 07:06:04 +00:00
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2017-11-16 22:32:09 +00:00
|
|
|
{
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-07-27 21:54:37 +00:00
|
|
|
|
2017-11-27 07:06:04 +00:00
|
|
|
final String tag = ChatColor.stripColor(FUtil.colorize(StringUtils.join(args, " ")));
|
2018-07-27 21:54:37 +00:00
|
|
|
|
2018-08-08 00:51:48 +00:00
|
|
|
if (!plugin.al.isAdmin(sender))
|
2017-11-16 22:32:09 +00:00
|
|
|
{
|
2018-08-08 00:51:48 +00:00
|
|
|
final String rawTag = ChatColor.stripColor(tag).toLowerCase();
|
2018-07-27 21:54:37 +00:00
|
|
|
|
2018-08-08 00:51:48 +00:00
|
|
|
if (rawTag.length() > 20)
|
2017-11-16 22:32:09 +00:00
|
|
|
{
|
2018-08-08 00:51:48 +00:00
|
|
|
msg("That tag is too long (Max is 20 characters).");
|
2017-11-16 22:32:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-08-08 00:51:48 +00:00
|
|
|
|
|
|
|
for (String word : Command_tag.FORBIDDEN_WORDS)
|
|
|
|
{
|
|
|
|
if (rawTag.contains(word))
|
|
|
|
{
|
|
|
|
msg("That tag contains a forbidden word.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2017-11-16 22:32:09 +00:00
|
|
|
}
|
2017-11-27 07:06:04 +00:00
|
|
|
|
|
|
|
plugin.pl.getPlayer(playerSender).setTag(FUtil.rainbowify(tag));
|
2018-07-27 21:54:37 +00:00
|
|
|
|
2017-11-27 07:06:04 +00:00
|
|
|
msg("Set tag to " + tag);
|
|
|
|
|
2017-11-16 22:32:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-11-27 07:09:54 +00:00
|
|
|
}
|