From 7c42f78426461f0c124d20b4b326c737f5f3d688 Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 27 Nov 2017 12:06:04 +0500 Subject: [PATCH] Add rainbowtag --- .../command/Command_rainbowtag.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java new file mode 100644 index 00000000..b4a13d98 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rainbowtag.java @@ -0,0 +1,48 @@ +package me.totalfreedom.totalfreedommod.command; + +import java.util.Iterator; +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.apache.commons.lang3.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 = "Gives you a rainbow tag", usage = "/ ") +public class Command_rainbowtag extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (args.length < 1) + { + return false; + } + + final String tag = ChatColor.stripColor(FUtil.colorize(StringUtils.join(args, " "))); + + if(tag.length() > 20) + { + msg("That tag is too long (Max is 20 characters)."); + return true; + } + + for (String word : Command_tag.FORBIDDEN_WORDS) + { + if (tag.contains(word)) + { + msg("That tag contains a forbidden word."); + return true; + } + } + + plugin.pl.getPlayer(playerSender).setTag(FUtil.rainbowify(tag)); + + msg("Set tag to " + tag); + + return true; + } +}