Skip to content

Commit

Permalink
Add new settings 'Console Width' for adjusting the width of console o…
Browse files Browse the repository at this point in the history
…utput. Default: 60 (works well with Windows) but can be increased or decreased depending on capabilities of your console.
  • Loading branch information
aufdemrand committed Jul 26, 2013
1 parent 466d63d commit 5d0da9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/main/java/net/aufdemrand/denizen/Settings.java
Expand Up @@ -15,6 +15,11 @@ public static boolean ShowDebug() {
return DenizenAPI.getCurrentInstance().getConfig()
.getBoolean("Debug.Show", false);
}

public static int ConsoleWidth() {
return DenizenAPI.getCurrentInstance().getConfig()
.getInt("Debug.Console Width", 60);
}

/*
Expand Down
Expand Up @@ -112,17 +112,15 @@ public static void sendMessage(String string) {
// 'Hack-fix' for disallowing multiple 'footers' to print in a row
if (string.equals(ChatColor.LIGHT_PURPLE + "+---------------------+")) {
if (!skipFooter) skipFooter = true;
else {
return;
}
else { return; }
} else skipFooter = false;

// Create buffer for wrapping debug text nicely.
String[] words = string.split(" ");
String buffer = "";
int length = 0;
for (String word : words) { // # of total chars * # of lines - timestamp
if (length + ChatColor.stripColor(word).length() + 1 < 60) {
if (length + ChatColor.stripColor(word).length() + 1 < Settings.ConsoleWidth()) {
buffer = buffer + word + " ";
length = length + ChatColor.stripColor(word).length() + 1;
} else {
Expand Down Expand Up @@ -235,7 +233,7 @@ public static void echoApproval(String message, String arg) {

public static void echoApproval(String message) {
if (!debugMode) return;
ConsoleSender.sendMessage(ChatColor.LIGHT_PURPLE + " " + ChatColor.GREEN + "OKAY! " + ChatColor.WHITE + trimMessage(message));
ConsoleSender.sendMessage(ChatColor.LIGHT_PURPLE + " " + ChatColor.GREEN + "OKAY! " + ChatColor.WHITE + message);
}

public static void echoError(String message) {
Expand Down Expand Up @@ -303,7 +301,6 @@ public static void toggle() {
debugMode = !debugMode;
}


private static String trimMessage(String message) {
if (message.length() > 256)
message = message.substring(0, 255) + "... *snip*";
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Expand Up @@ -3,6 +3,7 @@

Debug:
Show: true
Console Width: 60

Scripts:
Queue Speed: 0.5s
Expand Down

0 comments on commit 5d0da9c

Please sign in to comment.