Skip to content
This repository has been archived by the owner on Jul 1, 2018. It is now read-only.

Commit

Permalink
Don't adjust column width for console
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidDev committed Feb 13, 2017
1 parent d328451 commit 0d49c88
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/org/squiddev/cctweaks/core/command/TextTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TextTable {
private static final IChatComponent SEPARATOR = coloured(" | ", EnumChatFormatting.GRAY);
private static final IChatComponent LINE = text("\n");

public static int getWidth(char character, ICommandSender sender) {
private static int getWidth(char character, ICommandSender sender) {
if (sender instanceof EntityPlayerMP && !(sender instanceof FakePlayer)) {
// Use font widths here.
if (character == 167) {
Expand All @@ -57,7 +57,7 @@ public static int getWidth(char character, ICommandSender sender) {
}
}

public static int getWidth(IChatComponent text, ICommandSender sender) {
private static int getWidth(IChatComponent text, ICommandSender sender) {
int sum = 0;
String chars = text.getUnformattedTextForChat();
for (int i = 0; i < chars.length(); i++) {
Expand All @@ -67,8 +67,12 @@ public static int getWidth(IChatComponent text, ICommandSender sender) {
return sum;
}

public static int getMaxWidth(ICommandSender sender) {
return sender instanceof EntityPlayerMP && !(sender instanceof FakePlayer) ? 320 : 80;
private static boolean isPlayer(ICommandSender sender) {
return sender instanceof EntityPlayerMP && !(sender instanceof FakePlayer);
}

private static int getMaxWidth(ICommandSender sender) {
return isPlayer(sender) ? 320 : 80;
}

private int columns = -1;
Expand Down Expand Up @@ -173,7 +177,7 @@ private static void appendFixed(IChatComponent out, ICommandSender sender, IChat
delta = -delta;

// We have to remove some padding as there is a padding added between formatted and unformatted text
if (!entry.getChatStyle().isEmpty()) delta -= 1;
if (!entry.getChatStyle().isEmpty() && isPlayer(sender)) delta -= 1;

out.appendSibling(entry);

Expand All @@ -191,14 +195,14 @@ private static void appendFixed(IChatComponent out, ICommandSender sender, IChat
}

out.appendSibling(component);
} else if (delta < 0) {
} else if (delta > 0) {
out.appendSibling(entry);
} else {
out.appendSibling(entry);

// We have to add some padding as we expect a padding between formatted and unformatted text
// and there won't be.
if (entry.getChatStyle().isEmpty()) out.appendText(" ");
if (entry.getChatStyle().isEmpty() && isPlayer(sender)) out.appendText(" ");
}
}
}

0 comments on commit 0d49c88

Please sign in to comment.