mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Resolves FS-320 and fixes FS-471
This commit is contained in:
parent
94d6f0a872
commit
47445933f3
@ -15,10 +15,15 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <hex> <hex> <nick>", aliases = "nickgr")
|
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <hex> <hex> <nick>", aliases = "nickgr")
|
||||||
public class Command_nickgradient extends FreedomCommand
|
public class Command_nickgradient extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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.length != 3)
|
if (args.length != 3)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,20 +2,25 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Essentials Interface Command - Randomize the colors of your nickname.", usage = "/<command> <<nick> | off>")
|
@CommandParameters(description = "Essentials Interface Command - Randomize the colors of your nickname.", usage = "/<command> <<nick> | off>")
|
||||||
public class Command_nicknyan extends FreedomCommand
|
public class Command_nicknyan extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -41,32 +46,24 @@ public class Command_nicknyan extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
|
if (server.getOnlinePlayers().stream().anyMatch(player -> player != playerSender
|
||||||
|
&& (player.getName().equalsIgnoreCase(nickPlain)
|
||||||
|
|| ChatColor.stripColor(plugin.esb.getNickname(player.getName())).trim().equalsIgnoreCase(nickPlain))))
|
||||||
{
|
{
|
||||||
if (player == playerSender)
|
msg("That nickname is already in use.");
|
||||||
{
|
return true;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain))
|
|
||||||
{
|
|
||||||
msg("That nickname is already in use.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder newNick = new StringBuilder();
|
final StringBuilder newNick = new StringBuilder();
|
||||||
|
Arrays.stream(nickPlain.chars().toArray()).forEach(character -> newNick.append(FUtil.randomChatColor())
|
||||||
final char[] chars = nickPlain.toCharArray();
|
.append(Character.toString(character)));
|
||||||
for (char c : chars)
|
|
||||||
{
|
|
||||||
newNick.append(FUtil.randomChatColor()).append(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
newNick.append(ChatColor.WHITE);
|
newNick.append(ChatColor.WHITE);
|
||||||
|
|
||||||
plugin.esb.setNickname(sender.getName(), newNick.toString());
|
plugin.esb.setNickname(sender.getName(), newNick.toString());
|
||||||
|
|
||||||
msg("Your nickname is now: " + newNick.toString());
|
msg("Your nickname is now: " + newNick);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,10 +12,15 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <nick>")
|
@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/<command> <nick>")
|
||||||
public class Command_nickrainbow extends FreedomCommand
|
public class Command_nickrainbow extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user