From d47f37557c4b2c1517761e056c0a5baab600e37e Mon Sep 17 00:00:00 2001 From: lol768 Date: Mon, 22 Oct 2012 12:31:22 +0100 Subject: [PATCH] Fix replace method --- .../net/md_5/bungee/command/CommandAlert.java | 15 +++++++-------- .../java/net/md_5/bungee/command/CommandMotd.java | 8 +++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/md_5/bungee/command/CommandAlert.java b/src/main/java/net/md_5/bungee/command/CommandAlert.java index 1267ed00..270e89c1 100644 --- a/src/main/java/net/md_5/bungee/command/CommandAlert.java +++ b/src/main/java/net/md_5/bungee/command/CommandAlert.java @@ -22,20 +22,19 @@ public class CommandAlert extends Command } else { StringBuilder builder = new StringBuilder(); - if (!args[0].contains("&h")) //They want to hide the alert prefix + if (!args[0].startsWith("&h")) { - builder.append(ChatColor.DARK_PURPLE); - builder.append("[Alert] "); //No space at start. + builder.append(ChatColor.DARK_PURPLE); + builder.append("[Alert] "); } - - + for (String s : args) { - s = s.replaceAll("&h", ""); //Fix replace - builder.append(ChatColor.translateAlternateColorCodes('&', s)); //Allow custom colours + s = s.replace("&h", ""); + builder.append(ChatColor.translateAlternateColorCodes('&', s)); builder.append(" "); } - + String message = builder.substring(0, builder.length() - 1); for (UserConnection con : BungeeCord.instance.connections.values()) { diff --git a/src/main/java/net/md_5/bungee/command/CommandMotd.java b/src/main/java/net/md_5/bungee/command/CommandMotd.java index 5b88fdd7..c9e25185 100644 --- a/src/main/java/net/md_5/bungee/command/CommandMotd.java +++ b/src/main/java/net/md_5/bungee/command/CommandMotd.java @@ -1,10 +1,12 @@ package net.md_5.bungee.command; import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.ChatColor; import net.md_5.bungee.Permission; /** - * Command to set a temp copy of the motd in real-time without stopping the proxy + * Command to set a temp copy of the motd in real-time without stopping the + * proxy. */ public class CommandMotd extends Command { @@ -18,11 +20,11 @@ public class CommandMotd extends Command } else { String newMOTD = ""; - for (String s: args) + for (String s : args) { newMOTD = newMOTD + s + " "; } - newMOTD = newMOTD.substring(0, newMOTD.length()-1); + newMOTD = newMOTD.substring(0, newMOTD.length() - 1); BungeeCord.instance.config.motd = newMOTD; } }