From 33cc304330a8eb5026da1a150a221bcccab71ade Mon Sep 17 00:00:00 2001 From: Robinson Gallego Date: Sat, 28 Dec 2019 21:10:07 -0500 Subject: [PATCH] ok kae --- TotalFreedomMod.iml | 12 +++++ .../command/Command_nickrainbow.java | 52 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java diff --git a/TotalFreedomMod.iml b/TotalFreedomMod.iml index 5ef5de5b..b882e280 100644 --- a/TotalFreedomMod.iml +++ b/TotalFreedomMod.iml @@ -1,5 +1,14 @@ + + + + + SPIGOT + + + + @@ -41,6 +50,9 @@ + + + diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java new file mode 100644 index 00000000..91f4b6c9 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java @@ -0,0 +1,52 @@ +package me.totalfreedom.totalfreedommod.command; + +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 = "Gives you a rainbow nickname", usage = "/ ") +public class Command_nickrainbow 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 nick = ChatColor.stripColor(FUtil.colorize(StringUtils.join(args, " "))); + + if (!plugin.al.isAdmin(sender)) + { + final String rawNick = ChatColor.stripColor(nick).toLowerCase(); + + if (rawNick.length() > 20) + { + msg("That nick is too long (Max is 20 characters)."); + return true; + } + + for (String word : Command_tag.FORBIDDEN_WORDS) + { + if (rawNick.contains(word)) + { + msg("That nick contains a forbidden word."); + return true; + } + } + } + + plugin.pl.getPlayer(playerSender).setTag(FUtil.rainbowify(nick)); + + msg("Set nick to " + nick); + + return true; + } +} \ No newline at end of file