mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-27 20:27:37 +00:00
i'm gonna cry this is amazing x2
This commit is contained in:
parent
7d6370da23
commit
eea17a24bc
@ -0,0 +1,76 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
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 = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <hex> <hex> <nick>")
|
||||
public class Command_nickgradient extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String nick = args[2].trim();
|
||||
|
||||
if (nick.length() < 3 || nick.length() > 30)
|
||||
{
|
||||
msg("Your nickname must be between 3 and 30 characters long.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (player == playerSender)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (player.getName().equalsIgnoreCase(nick) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nick))
|
||||
{
|
||||
msg("That nickname is already in use.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
java.awt.Color awt1, awt2;
|
||||
try
|
||||
{
|
||||
awt1 = java.awt.Color.decode(args[0]);
|
||||
awt2 = java.awt.Color.decode(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid hex values.");
|
||||
return true;
|
||||
}
|
||||
Color c1 = FUtil.fromAWT(awt1);
|
||||
Color c2 = FUtil.fromAWT(awt2);
|
||||
List<Color> gradient = FUtil.createColorGradient(c1, c2, nick.length());
|
||||
String[] splitNick = nick.split("");
|
||||
for (int i = 0; i < splitNick.length; i++)
|
||||
{
|
||||
splitNick[i] = net.md_5.bungee.api.ChatColor.of(FUtil.toAWT(gradient.get(i))) + splitNick[i];
|
||||
}
|
||||
nick = StringUtils.join(splitNick, "");
|
||||
final String outputNick = FUtil.colorize(nick);
|
||||
|
||||
plugin.esb.setNickname(sender.getName(), outputNick);
|
||||
|
||||
msg("Your nickname is now: " + outputNick);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user