Fix replace method

This commit is contained in:
lol768 2012-10-22 12:31:22 +01:00 committed by md_5
parent d4122eb5e5
commit d47f37557c
2 changed files with 12 additions and 11 deletions

View File

@ -22,20 +22,19 @@ public class CommandAlert extends Command
} else } else
{ {
StringBuilder builder = new StringBuilder(); 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(ChatColor.DARK_PURPLE);
builder.append("[Alert] "); //No space at start. builder.append("[Alert] ");
} }
for (String s : args) for (String s : args)
{ {
s = s.replaceAll("&h", ""); //Fix replace s = s.replace("&h", "");
builder.append(ChatColor.translateAlternateColorCodes('&', s)); //Allow custom colours builder.append(ChatColor.translateAlternateColorCodes('&', s));
builder.append(" "); builder.append(" ");
} }
String message = builder.substring(0, builder.length() - 1); String message = builder.substring(0, builder.length() - 1);
for (UserConnection con : BungeeCord.instance.connections.values()) for (UserConnection con : BungeeCord.instance.connections.values())
{ {

View File

@ -1,10 +1,12 @@
package net.md_5.bungee.command; package net.md_5.bungee.command;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.ChatColor;
import net.md_5.bungee.Permission; 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 public class CommandMotd extends Command
{ {
@ -18,11 +20,11 @@ public class CommandMotd extends Command
} else } else
{ {
String newMOTD = ""; String newMOTD = "";
for (String s: args) for (String s : args)
{ {
newMOTD = newMOTD + s + " "; newMOTD = newMOTD + s + " ";
} }
newMOTD = newMOTD.substring(0, newMOTD.length()-1); newMOTD = newMOTD.substring(0, newMOTD.length() - 1);
BungeeCord.instance.config.motd = newMOTD; BungeeCord.instance.config.motd = newMOTD;
} }
} }