@Override public boolean run( CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length != 1) { return false; } if ("off".equals(args[0])) { TFM_EssentialsBridge.setNickname(sender.getName(), null); playerMsg("Nickname cleared."); return true; } final String nickPlain = ChatColor.stripColor(TFM_Util.colorize(args[0].trim())); if (!nickPlain.matches("^[a-zA-Z_0-9\u00a7]+$")) { playerMsg("That nickname contains invalid characters."); return true; } else if (nickPlain.length() < 4 || nickPlain.length() > 30) { playerMsg("Your nickname must be between 4 and 30 characters long."); return true; } final Player[] onlinePlayers = server.getOnlinePlayers(); for (final Player player : onlinePlayers) { if (player == sender_p) { continue; } if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain)) { playerMsg("That nickname is already in use."); return true; } } final StringBuilder newNick = new StringBuilder(); final char[] chars = nickPlain.toCharArray(); for (char c : chars) { newNick.append(TFM_Util.randomChatColor()).append(c); } newNick.append(ChatColor.WHITE); TFM_EssentialsBridge.setNickname(sender.getName(), newNick.toString()); playerMsg("Your nickname is now: " + newNick.toString()); return true; }
public void setHalted(boolean halted) { this.isHalted = halted; if (halted) { player.setOp(false); player.setGameMode(GameMode.SURVIVAL); TFM_Util.setFlying(player, false); TFM_EssentialsBridge.setNickname(player.getName(), player.getName()); player.closeInventory(); player.setTotalExperience(0); stopOrbiting(); setFrozen(true); setMuted(true); player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!"); } else { player.setOp(true); player.setGameMode(GameMode.CREATIVE); setFrozen(false); setMuted(false); player.sendMessage(ChatColor.GRAY + "You are no longer halted."); } }