public String command(final CommandSender sender, Command command, String[] args) { try { BufferedWriter banlist = new BufferedWriter(new FileWriter("banned-players.txt", true)); for (String p : plugin.cache.keySet()) { for (BanInfo info : plugin.cache.get(p)) { if (info.getType() == BanType.BAN.getId()) { banlist.newLine(); banlist.write(g(p, info.getAdmin(), info.getReason())); } } } banlist.close(); BufferedWriter iplist = new BufferedWriter(new FileWriter("banned-ips.txt", true)); for (String p : plugin.cacheIP.keySet()) { for (BanInfo info : plugin.cacheIP.get(p)) { if (info.getType() == BanType.IPBAN.getId()) { iplist.newLine(); iplist.write(g(p, info.getAdmin(), info.getReason())); } } } iplist.close(); } catch (IOException e) { String msg = ChatColor.translateAlternateColorCodes('&', lang.getString("Export.Failed")); if (plugin.getLog()) plugin.getLogger().severe(ChatColor.stripColor(msg)); e.printStackTrace(); return msg; } String msg = ChatColor.translateAlternateColorCodes('&', lang.getString("Export.Completed")); if (plugin.getLog()) plugin.getLogger().info(ChatColor.stripColor(msg)); return msg; }
@Override public boolean equals(final Object object) { if (!(object instanceof User)) { return false; } return ChatColor.stripColor(this.getDisplayName()) .equalsIgnoreCase(ChatColor.stripColor(((User) object).getDisplayName())); }
@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; }
@Override public boolean isExplosionsEnabled(Location loc) { Faction faction = Board.getFactionAt(new FLocation(loc)); if (ChatColor.stripColor(faction.getTag()).equalsIgnoreCase("safezone") || ChatColor.stripColor(faction.getTag()).equalsIgnoreCase("warzone")) { // ObsidianDestroyer.debug("Factions18x.isExplosionsEnabled: false"); return false; } // ObsidianDestroyer.debug("Factions18x.isExplosionsEnabled: " + // faction.getFlag(FFlag.EXPLOSIONS)); return faction.getFlag(FFlag.EXPLOSIONS); }
@Override public boolean isFactionOffline(Location loc) { Faction faction = Board.getFactionAt(new FLocation(loc)); if (faction.isNone()) { return false; } else if ((ChatColor.stripColor(faction.getTag()).equalsIgnoreCase("wilderness") || ChatColor.stripColor(faction.getTag()).equalsIgnoreCase("safezone") || ChatColor.stripColor(faction.getTag()).equalsIgnoreCase("warzone"))) { // ObsidianDestroyer.debug("Factions18x.isFactionOffline: false"); return false; } // ObsidianDestroyer.debug("Factions18x.isFactionOffline: " + // faction.hasOfflineExplosionProtection()); return faction.hasOfflineExplosionProtection(); }
public void send(CommandSender sender, String message) { if (sender instanceof Player) { sender.sendMessage(message); } else { sender.sendMessage(ChatColor.stripColor(message)); } }
@Override public void perform() { Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; UPlayer from = this.arg(1, ARUPlayer.getStartAny(sender)); if (from == null) return; Faction to = this.arg(2, ARFaction.get(sender)); if (to == null) return; boolean success = Econ.transferMoney(usender, from, to, amount); if (success && MConf.get().logMoneyTransactions) { Factions.get() .log( ChatColor.stripColor( Txt.parse( "%s transferred %s from the player \"%s\" to the faction \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null)))); } }
private String colorize(String string) { if (string.indexOf(ChatColor.COLOR_CHAR) < 0) { return string; // no colors in the message } else if ((!jLine || !reader.getTerminal().isAnsiSupported()) && jTerminal == null) { return ChatColor.stripColor(string); // color not supported } else { return string .replace(ChatColor.RED.toString(), "\033[1;31m") .replace(ChatColor.YELLOW.toString(), "\033[1;33m") .replace(ChatColor.GREEN.toString(), "\033[1;32m") .replace(ChatColor.AQUA.toString(), "\033[1;36m") .replace(ChatColor.BLUE.toString(), "\033[1;34m") .replace(ChatColor.LIGHT_PURPLE.toString(), "\033[1;35m") .replace(ChatColor.BLACK.toString(), "\033[0;0m") .replace(ChatColor.DARK_GRAY.toString(), "\033[1;30m") .replace(ChatColor.DARK_RED.toString(), "\033[0;31m") .replace(ChatColor.GOLD.toString(), "\033[0;33m") .replace(ChatColor.DARK_GREEN.toString(), "\033[0;32m") .replace(ChatColor.DARK_AQUA.toString(), "\033[0;36m") .replace(ChatColor.DARK_BLUE.toString(), "\033[0;34m") .replace(ChatColor.DARK_PURPLE.toString(), "\033[0;35m") .replace(ChatColor.GRAY.toString(), "\033[0;37m") .replace(ChatColor.WHITE.toString(), "\033[1;37m") + "\033[0m"; } }
@Override public void log(String message) { if (message == null) { return; } message = message.replaceAll("\u00B2", "2"); if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) { System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message))); } else { message = ChatColor.translateAlternateColorCodes('&', message); if (!Settings.CONSOLE_COLOR) { message = ChatColor.stripColor(message); } Bukkit.getServer().getConsoleSender().sendMessage(message); } }
public String colorize(String string) { if (!string.contains("\u00A7")) { return string; } else if ((!jLine || !reader.getTerminal().isANSISupported()) && jTerminal == null) { return ChatColor.stripColor(string); } else { return string .replace(ChatColor.RED.toString(), "\033[1;31m") .replace(ChatColor.YELLOW.toString(), "\033[1;33m") .replace(ChatColor.GREEN.toString(), "\033[1;32m") .replace(ChatColor.AQUA.toString(), "\033[1;36m") .replace(ChatColor.BLUE.toString(), "\033[1;34m") .replace(ChatColor.LIGHT_PURPLE.toString(), "\033[1;35m") .replace(ChatColor.BLACK.toString(), "\033[0;0m") .replace(ChatColor.DARK_GRAY.toString(), "\033[1;30m") .replace(ChatColor.DARK_RED.toString(), "\033[0;31m") .replace(ChatColor.GOLD.toString(), "\033[0;33m") .replace(ChatColor.DARK_GREEN.toString(), "\033[0;32m") .replace(ChatColor.DARK_AQUA.toString(), "\033[0;36m") .replace(ChatColor.DARK_BLUE.toString(), "\033[0;34m") .replace(ChatColor.DARK_PURPLE.toString(), "\033[0;35m") .replace(ChatColor.GRAY.toString(), "\033[0;37m") .replace(ChatColor.WHITE.toString(), "\033[1;37m") + "\033[0m"; } }
@EventHandler(priority = EventPriority.LOW) public void monsterDied(EntityDeathEvent event) { if (item == null) return; LivingEntity died = event.getEntity(); if (died == null) return; Player killer = died.getKiller(); if (killer == null) return; RaCPlayer racKiller = RaCPlayerManager.get().getPlayer(killer); if (racKiller == null) return; // Check for the name. if (!neededName.isEmpty()) { String monsterName = ChatColor.stripColor(died.getCustomName()); if (!neededName.equalsIgnoreCase(monsterName)) return; } // If not in this trait -> break. if (!TraitHolderCombinder.checkContainer(racKiller, this)) return; EventWrapper wrapper = EventWrapperFactory.buildOnlyWithplayer(racKiller); boolean canBeTriggered = super.checkRestrictions(wrapper) == TraitRestriction.None; if (!canBeTriggered) return; ItemStack drop = playerKilled(died.getType()); event.getDrops().add(drop); }
/* * Добавлене сообщения в список * Убираются цвета. * Параметры: * key - ключ сообщения * txt - текст сообщения */ public void addMSG(String key, String txt) { msg.put( key, ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', lng.getString(key, txt)))); if (msglist.isEmpty()) msglist = key; else msglist = msglist + "," + key; }
@Override public void perform() throws MassiveException { // Args MPlayer you = this.readArg(); String newTitle = this.readArg(""); newTitle = Txt.parse(newTitle); if (!Perm.TITLE_COLOR.has(sender, false)) { newTitle = ChatColor.stripColor(newTitle); } // MPerm if (!MPerm.getPermTitle().has(msender, you.getFaction(), true)) return; // Rank Check if (!msender.isUsingAdminMode() && you.getRole().isMoreThan(msender.getRole())) { msg("<b>You can not edit titles for higher ranks."); return; } // Event EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle); event.run(); if (event.isCancelled()) return; newTitle = event.getNewTitle(); // Apply you.setTitle(newTitle); // Inform msenderFaction.msg( "%s<i> changed a title: %s", msender.describeTo(msenderFaction, true), you.describeTo(msenderFaction, true)); }
@Override public String getListName(String senderId) { if (senderId == null) return null; // Try Our Map String ret = this.idToListName.get(senderId); // Try Bukkit if (ret == null) { Player player = Bukkit.getPlayerExact(senderId); if (player != null) { ret = player.getPlayerListName(); } } // Try Fixed Id if (ret == null) { ret = Mixin.tryFix(senderId); } // Ensure Colored if (ChatColor.stripColor(ret).equals(ret)) { ret = DEFAULT_COLOR.toString() + ret; } return ret; }
/** * Fired when a control is clicked. This is the equivalent of * ActionListener.actionPerformed(ActionEvent e). */ protected void actionPerformed(GuiButton par1GuiButton) { if (!par1GuiButton.enabled) { return; } if (par1GuiButton.id == 0) { if (!Spoutcraft.hasPermission("spout.client.signcolors")) { for (int i = 0; i < entitySign.signText.length; i++) { entitySign.signText[i] = ChatColor.stripColor(entitySign.signText[i]); } } entitySign.onInventoryChanged(); mc.displayGuiScreen(null); } // Spout start else if (par1GuiButton.id == 1 && unicode.enabled) { ConfigReader.sendColorsAsUnicode = !ConfigReader.sendColorsAsUnicode; if (ConfigReader.sendColorsAsUnicode) { unicode.displayString = "Send As Unicode"; } else { unicode.displayString = "Send As Plain Text"; } } // Spout end }
public String itemToString(ItemStack item) { String str = ""; String n = item.getItemMeta().hasDisplayName() ? ChatColor.stripColor(item.getItemMeta().getDisplayName()) : item.getType().name(); String a = item.getAmount() > 1 ? "*" + item.getAmount() : ""; str = n + a; return str; }
public Player getPlayerExact(String name) { String lname = name.toLowerCase(); for (Player player : getPlayers()) { if (ChatColor.stripColor(player.getName()).equalsIgnoreCase(lname)) { return player; } } return null; }
@Override public String getSkinName() { MetadataStore meta = npc.data(); String skinName = meta.get(NPC.PLAYER_SKIN_UUID_METADATA); if (skinName == null) { skinName = ChatColor.stripColor(getName()); } return skinName.toLowerCase(); }
/** * Get a string that will be centered in a player's chat * * @param text - The text to be centered * @return The centered string */ public static final String centerText(String text) { int maxWidth = 80, spaces = (int) Math.round((maxWidth - 1.4 * ChatColor.stripColor(text).length()) / 2); String complete = ""; for (int i = 1; i <= spaces; i++) { complete = complete + " "; } complete = complete + text; return complete; }
@EventHandler void ircQuit(IRCQuitEvent event) { String format = "[%t] &c* %m"; String target = plugin.getChannelManager().getGlobalChannel().getName(); format = format.replaceAll("%t", plugin.getChannelManager().getGlobalChannel().getColoredName()); format = format.replaceAll("%m", event.getMessage()); format = format.replaceAll("&([a-fA-F0-9])", "\u00A7$1"); plugin.getChannelManager().getGlobalChannel().sendMessage(format); plugin.getChannelManager().log(target, ChatColor.stripColor(format)); }
@EventHandler(priority = EventPriority.LOWEST) public void preLogin(PlayerLoginEvent e) { if (!modeset && !e.getPlayer().isOp()) { e.setKickMessage( ChatColor.stripColor( SkyApi.getMessageManager().getErrorMessage("system.kickJoinNoPerm"))); e.disallow(PlayerLoginEvent.Result.KICK_OTHER, e.getKickMessage()); e.setResult(PlayerLoginEvent.Result.KICK_OTHER); } else e.allow(); }
public void setSharedColor() { sign.setLine( 0, ChatColor.GOLD + "" + ChatColor.BOLD + ChatColor.stripColor(sign.getLine(0)) + ChatColor.RED + "" + ChatColor.BOLD); sign.update(); }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerChat(PlayerChatEvent event) { if (event.isCancelled()) return; Player me = event.getPlayer(); VPlayer vme = VPlayers.i.get(me); if (Conf.nameColorize == false) return; if (!vme.isVampire()) return; me.setDisplayName("" + Conf.nameColor + ChatColor.stripColor(me.getDisplayName())); }
private String completeNames(String message) { tabHelp = null; String[] words = message.split(" "); if (words.length > 0) { String lastWord = words[words.length - 1]; if (lastWord.endsWith("_")) { lastWord = lastWord.substring(0, lastWord.length() - 1); } if (lastWord.length() > 2) { // Check nearby players Player p = SpoutClient.getInstance().getPlayer(lastWord); String playerName = p != null ? p.getName() : null; // Check server player list if (playerName == null && SpoutClient.getHandle().isMultiplayerWorld()) { int delta = Integer.MAX_VALUE; String best = null; final List<GuiPlayerInfo> players = ((EntityClientPlayerMP) SpoutClient.getHandle().thePlayer).sendQueue.playerNames; final String toLower = lastWord.toLowerCase(); for (GuiPlayerInfo info : players) { String name = ChatColor.stripColor(info.name); if (name.toLowerCase().startsWith(toLower)) { int curDelta = info.name.length() - lastWord.length(); if (curDelta < delta) { best = name; delta = curDelta; } if (curDelta == 0) { break; } } } if (best != null) { playerName = best; } } // Autocomplete if (playerName != null && playerName.length() > lastWord.length()) { message = message.substring(0, message.length() - 1) + "|" + ChatColor.YELLOW + playerName.substring(lastWord.length()) + ChatColor.RESET; tabHelp = playerName.substring(lastWord.length()); } } } return message; }
public void setBoughtColor(Player player) { sign.setLine( 0, ChatColor.RED + "" + ChatColor.BOLD + ChatColor.stripColor(sign.getLine(0)) + ChatColor.RED + "" + ChatColor.BOLD); sign.setLine(3, ChatColor.BOLD + player.getName() + ChatColor.BOLD); sign.update(); }
@EventHandler void ircMessage(IRCMessageEvent event) { String format = plugin.getConfig().getString("format.message", "[%t] &d* %m"); String target = plugin.getChannelManager().getGlobalChannel().getName(); format = format.replaceAll("%t", plugin.getChannelManager().getGlobalChannel().getColoredName()); format = format.replaceAll("%p", event.getTag()); format = format.replaceAll("%n|%dn|%fn", event.getNickname()); format = format.replaceAll("%m", event.getMessage()); format = format.replaceAll("&([a-fA-F0-9])", "\u00A7$1"); plugin.getChannelManager().getGlobalChannel().sendMessage(format); plugin.getChannelManager().log(target, ChatColor.stripColor(format)); }
@EventHandler public void onPlayerDeath(PlayerDeathEvent event) { Player player = event.getEntity(); String playerName = ChatColor.stripColor(player.getDisplayName()); int playerDeathX = player.getLocation().getBlockX(); int playerDeathY = player.getLocation().getBlockY(); int playerDeathZ = player.getLocation().getBlockZ(); String deathLocation = "X:" + playerDeathX + " Y:" + playerDeathY + " Z:" + playerDeathZ; if (player.hasPermission("CordsOfDeath.sendCordsOnDeath")) { player.sendMessage("You died at:" + " " + deathLocation); this.plugin.getLogger().info(playerName + " " + "died at:" + " " + deathLocation); } }
public MinigameTool(ItemStack tool) { this.tool = tool; ItemMeta meta = tool.getItemMeta(); if (meta.getLore() != null) { String mg = ChatColor.stripColor(meta.getLore().get(0)).replace("Minigame: ", ""); if (Minigames.plugin.mdata.hasMinigame(mg)) minigame = Minigames.plugin.mdata.getMinigame(mg); String md = ChatColor.stripColor(meta.getLore().get(1)).replace("Mode: ", ""); if (MinigameToolMode.getByName(md) != null) mode = MinigameToolMode.getByName(md); if (mode == MinigameToolMode.START && meta.getLore().size() == 3) { team = ChatColor.stripColor(meta.getLore().get(2).replace("Team: ", "")).toLowerCase(); } } else { meta.setDisplayName(ChatColor.GREEN + "Minigame Tool"); List<String> lore = new ArrayList<String>(); lore.add(ChatColor.AQUA + "Minigame: " + ChatColor.WHITE + "None"); lore.add(ChatColor.AQUA + "Mode: " + ChatColor.WHITE + "None"); meta.setLore(lore); tool.setItemMeta(meta); } }
public void inviteDuel(Player p1, Player p2, String s) { if (p1.getName().equals(p2.getName())) { p1.sendMessage(ChatColor.RED + "Vous ne pouvez pas vous inviter vous m�me!"); return; } boolean alreadyInvited = true; Iterator<Invite> it = this.invites.iterator(); while (it.hasNext()) { Invite i = (Invite) it.next(); String inviter = i.getInviter(); String invited = i.getInvited(); if ((invited.equals(p1.getName())) && (inviter.equals(p2.getName()))) { String s2 = (String) this.mode.get(p2.getName()); if (s2.equalsIgnoreCase( ChatColor.stripColor(p1.getItemInHand().getItemMeta().getDisplayName()))) { acceptDuel(p1, s); return; } alreadyInvited = false; } if ((inviter.equals(p1.getName())) && (invited.equals(p2.getName()))) { alreadyInvited = false; } } if (alreadyInvited) { this.invites.add(new Invite(p1.getName(), p2.getName())); p1.sendMessage( ChatColor.GOLD + ">>> Vous avez invit� " + ChatColor.AQUA + p2.getName() + ChatColor.GOLD + ", pour un training de " + ChatColor.AQUA + s + ChatColor.GOLD + "."); this.mode.put(p1.getName(), s); p2.sendMessage( ChatColor.AQUA + p1.getName() + ChatColor.GOLD + " vous � invit� pour un training de " + ChatColor.AQUA + s + ChatColor.GOLD + ", Cliquez droit sur lui avec la bonne �p�e pour accepter !"); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) void playerChatMonitor(AsyncPlayerChatEvent event) { if (plugin.getIRCBot() == null) { return; } final String message = ChatColor.stripColor( replaceAllLiteral( event.getFormat(), "%2$s", replaceAll(event.getMessage(), '$', "\\\\$"))); ChatPlayer player = plugin.getPlayerManager().getPlayer(event.getPlayer().getName()); if (player.getTarget() instanceof Channel) { ((Channel) player.getTarget()).sendToIRC(message); } }