45 lines
1.6 KiB
Java
45 lines
1.6 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import net.kyori.adventure.text.Component;
|
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@CommandPermissions(permission = "nickmm", source = SourceType.ONLY_IN_GAME)
|
|
@CommandParameters(description = """
|
|
Essentials Interface Command - Colorify your nickname.
|
|
For Example: /nickmm <red><name> will color your name red.
|
|
You can also use tags like <gradient> and <rainbow>.
|
|
For example: /nickmm <gradient:red:green:blue><name>""", usage = "/<command> <nickname>")
|
|
public class Command_nickmm extends FreedomCommand
|
|
{
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
if (!server.getPluginManager().isPluginEnabled("Essentials"))
|
|
{
|
|
msg("Essentials is not enabled on this server.");
|
|
return true;
|
|
}
|
|
|
|
if (args[0].isEmpty()) {
|
|
return false;
|
|
}
|
|
|
|
if (args[0].matches(ChatColor.COLOR_CHAR + "[0-9a-fkm-o]"))
|
|
{
|
|
msgNew("<red>That nickname contains invalid characters.");
|
|
return true;
|
|
}
|
|
|
|
Component parsed = FUtil.miniMessage(args[0], Placeholder.unparsed("name", sender.getName()));
|
|
plugin.esb.setNickname(sender.getName(), FUtil.miniMessage(parsed));
|
|
msgNew("Your nickname is now: " + FUtil.miniMessage(parsed));
|
|
|
|
return false;
|
|
}
|
|
}
|