Skip to content

Commit

Permalink
Updating how I want to handle things with colors
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Khoury <nick.khry@gmail.com>
  • Loading branch information
Resolude committed Mar 15, 2012
1 parent d2515b5 commit e560acf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Binary file modified Broadcaster/dist/Broadcaster.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.xrevolut1onzx.broadcaster;

import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;

Expand Down Expand Up @@ -166,7 +167,7 @@ public void run()
{
return;
}
String finalMessage = new String(rawMessage.replaceAll("&([0-9a-f])", "\u00A7$1"));
String finalMessage = replaceColors(rawMessage);
for (Player player : getServer().getOnlinePlayers())
{
if (usingSuperPerms)
Expand Down Expand Up @@ -231,9 +232,13 @@ else if (permissionType.equalsIgnoreCase("Op"))
*/
public void manageConfigFile()
{
reloadConfig();
getConfig().options().copyDefaults(true);
saveConfig();
final String CONFIG_FILE_PATH = "plugins/" + this.getName() + "/config.yml";
File file = new File(CONFIG_FILE_PATH);
if (!file.exists())
{
getConfig().options().copyDefaults(true);
saveConfig();
}
permissionType = getConfig().getString("Permission-type");
numberOfMessages = getConfig().getInt("Number-of-messages");

Expand Down Expand Up @@ -347,6 +352,11 @@ public void log(String m)
log.info(LOG_PREFIX + m);
}

public String replaceColors(String message)
{
return message.replaceAll("&([0-9a-f])", "\u00A7$1");
}

/** Returns the number of online players */
public int numberOfOnlinePlayers()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void preview(Player typer, String numberString)
}
if (rawMessage != null)
{
String finalMessage = new String(rawMessage.replaceAll("&([0-9a-f])", "\u00A7$1"));
String finalMessage = plugin.replaceColors(rawMessage);
typer.sendMessage("Preview: " + finalMessage);
}
else
Expand All @@ -95,7 +95,7 @@ else if (plugin.isUsingSuperPerms())
}
if (rawMessage != null)
{
String finalMessage = new String(rawMessage.replaceAll("&([0-9a-f])", "\u00A7$1"));
String finalMessage = plugin.replaceColors(rawMessage);
typer.sendMessage("Preview: " + finalMessage);
}
else
Expand Down Expand Up @@ -131,7 +131,7 @@ public void broadcast(Player typer, String numberString)
}
if (rawMessage != null)
{
String finalMessage = new String(rawMessage.replaceAll("&([0-9a-f])", "\u00A7$1"));
String finalMessage = plugin.replaceColors(rawMessage);
for (Player player : plugin.getServer().getOnlinePlayers())
{
if (broadcastMessage.getOpSeesMessage())
Expand Down Expand Up @@ -174,7 +174,7 @@ else if (plugin.isUsingSuperPerms())
}
if (rawMessage != null)
{
String finalMessage = new String(rawMessage.replaceAll("&([0-9a-f])", "\u00A7$1"));
String finalMessage = plugin.replaceColors(rawMessage);
for (Player player : plugin.getServer().getOnlinePlayers())
{
if (!player.hasPermission("broadcaster.exemptfrommessage" + (number + 1)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void preview(String numberString)
}
if (rawMessage != null)
{
String finalMessage = new String(rawMessage.replaceAll("&([0-9a-f])", "\u00A7$1"));
String finalMessage = plugin.replaceColors(rawMessage);
plugin.log("Preview: " + finalMessage);
}
else
Expand Down Expand Up @@ -77,7 +77,7 @@ public void broadcast(String numberString)
plugin.log("No one online!");
return;
}
String finalMessage = new String(rawMessage.replaceAll("&([0-9a-f])", "\u00A7$1"));
String finalMessage = plugin.replaceColors(rawMessage);
if (plugin.isUsingOp())
{
for (Player player : plugin.getServer().getOnlinePlayers())
Expand Down

0 comments on commit e560acf

Please sign in to comment.