Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
Fixes - v1.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Defective4 committed Sep 3, 2022
1 parent e1fbddd commit ffe1e11
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 41 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.settings/
bin/
bin
.project
build/
.gradle/
mcc.prefs
pmd.html
# Ignore Gradle project-specific cache directory
Expand Down
2 changes: 2 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java/net/defekt/mc/chatclient/ui/UserPreferences.java=UTF-8
encoding//src/main/java/net/defekt/mc/chatclient/ui/swing/SwingConstants.java=UTF-8
8 changes: 5 additions & 3 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
AMCC Change Log
v1.8.2
v1.8.3

A minor maintenance update
An update containing some bug-fixes

[+] Added:
- Support for more Unicode characters
[+] Fixed:
- Minor code improvements
- Inability to connect to a server during first application run
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ public void run() {
for (final ClientListener ls : cl.getClientListeners())
if (dsIgnore) {
ls.messageReceived(
"§cPacket " + Integer.toHexString(packet.getID()) + ": " + ChatMessages.parse(json),
"\u00a7cPacket " + Integer.toHexString(packet.getID()) + ": " + ChatMessages.parse(json),
Position.CHAT);
} else {
ls.disconnected(ChatMessages.parse(json));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,21 @@ public static StatusInfo legacyServerListPing(final String host, final int port)
String data = new String(stringBytes, "UTF-16LE");
data = data.substring(1, data.length() - 1);

final int paraCount = data.length() - data.replace("§", "").length();
final int paraCount = data.length() - data.replace("\u00a7", "").length();
String playersString = data;
for (int x = 0; x < paraCount - 1; x++) {
playersString = playersString.substring(playersString.indexOf("§") + 1);
playersString = playersString.substring(playersString.indexOf("\u00a7") + 1);
}

final String motd = data.substring(0, data.lastIndexOf(playersString) - 1);

int online = 0;
int max = 0;

final String[] players = playersString.split("§");
final String[] players = playersString.split("\u00a7");
online = Integer.parseInt(players[0]);
max = Integer.parseInt(players[1]);
return new StatusInfo(motd, online, max, "§cLegacy", -1, null, null, new ArrayList<ModInfo>());
return new StatusInfo(motd, online, max, "\u00a7cLegacy", -1, null, null, new ArrayList<ModInfo>());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static Color translateColorCode(final String code) {
public static String translateColorName(String name) {
name = name.toLowerCase();

if (name.contains("#") && name.length() > 1) return "§" + name;
if (name.contains("#") && name.length() > 1) return "\u00a7" + name;

return colorCodes.containsKey(name) ? colorCodes.get(name) : colorCodes.get("white");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
public class ChatMessages {

private static final String pChar = "§";
private static final String pChar = "\u00a7";

private ChatMessages() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,18 +490,18 @@ public void putItem(final int index, final ItemStack item) {
btn.removeMouseListener(ml);
}
if (item.getId() == 0) return;
String label = "§f" + itemInfo.getName();
String label = "\u00a7f" + itemInfo.getName();
try {
if (item.getNbt() != null) {
CompoundMap map = (CompoundMap) item.getNbt().getValue();
if (map.containsKey("display")) {
map = (CompoundMap) map.get("display").getValue();
if (map.containsKey("Name")) {
label = "§f" + ChatMessages.parse((String) map.get("Name").getValue());
label = "\u00a7f" + ChatMessages.parse((String) map.get("Name").getValue());
}
if (map.containsKey("Lore")) {
for (final StringTag lore : (List<StringTag>) map.get("Lore").getValue()) {
label += "\r\n§5" + ChatMessages.parse(lore.getValue());
label += "\r\n\u00a75" + ChatMessages.parse(lore.getValue());
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/net/defekt/mc/chatclient/ui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private Main() {

private static BufferedImage logoImage = null;

public static final String VERSION = "1.8.2";
public static final String VERSION = "1.8.3";
private static final String CHANGELOG_URL = "https://raw.githubusercontent.com/Defective4/Another-Minecraft-Chat-Client/master/Changes";

public static Font mcFont = Font.decode(null);
Expand Down Expand Up @@ -1874,7 +1874,7 @@ public void actionPerformed(final ActionEvent e) {
up.setDisablePacketAnalyzer(disablePacketAnalyzer.isSelected());
up.setResourcePackBehavior(rsBehavior);
up.setShowResourcePackMessages(showResourcePackMessages);
up.setResourcePackMessage(resourcePackMessage.replace("&", "§"));
up.setResourcePackMessage(resourcePackMessage.replace("&", "\u00a7"));
up.setResourcePackMessagePosition(resourcePackMessagePosition);

up.setSkinFetchRule(skinFetchRule);
Expand Down Expand Up @@ -3715,7 +3715,7 @@ public void run() {
}
} catch (final Exception e) {
SwingUtils.appendColoredText(
"§c" + Messages.getString("Main.connectionFailedChatMessage") + e.toString(), pane);
"\u00a7c" + Messages.getString("Main.connectionFailedChatMessage") + e.toString(), pane);
e.printStackTrace();
}
break;
Expand Down Expand Up @@ -3979,7 +3979,7 @@ public void run() {
@Override
public void disconnected(final String reason) {
autoMessagesThread.interrupt();
SwingUtils.appendColoredText("§c" + Messages.getString("Main.connectionLostChatMessage")
SwingUtils.appendColoredText("\u00a7c" + Messages.getString("Main.connectionLostChatMessage")
+ ": \r\n" + reason + "\r\n", jtp);

if (trayIcon != null && up.isTrayShowDisconnectMessages()
Expand Down Expand Up @@ -4275,7 +4275,7 @@ public void actionPerformed(final ActionEvent e) {
cl.sendChatMessage(message);
} catch (final IOException e1) {
SwingUtils.appendColoredText(
"§c" + Messages.getString("Main.connectionLostChatMessage2") + ": \r\n"
"\u00a7c" + Messages.getString("Main.connectionLostChatMessage2") + ": \r\n"
+ e1.toString(),
pane);
e1.printStackTrace();
Expand All @@ -4295,7 +4295,7 @@ public void actionPerformed(final ActionEvent e) {
} catch (

final IOException e) {
SwingUtils.appendColoredText("§c" + Messages.getString("Main.connectionFailedChatMessage2")
SwingUtils.appendColoredText("\u00a7c" + Messages.getString("Main.connectionFailedChatMessage2")
+ "\r\n\r\n" + e.toString(), pane);
e.printStackTrace();
}
Expand Down Expand Up @@ -4337,14 +4337,14 @@ private void showPacketPanel(final Packet packet) {
pane.setEditable(false);

final int compressed = packet.getCompressed();
final String compressedString = compressed == 1 ? "§4No (Disabled)"
: compressed == 2 ? "§4No" : compressed == 3 ? "§2Yes" : "Unknown";
final String encryptedString = packet.isEncrypted() ? "§2Yes" : "§4No";
final String compressedString = compressed == 1 ? "\u00a74No (Disabled)"
: compressed == 2 ? "\u00a74No" : compressed == 3 ? "\u00a72Yes" : "Unknown";
final String encryptedString = packet.isEncrypted() ? "\u00a72Yes" : "\u00a74No";

pane.setText("Packet Name: " + packet.getClass().getSimpleName() + "\n" + "Packet Class: "
+ packet.getClass().getName() + "\nPacket ID: 0x" + Integer.toHexString(packet.getID()) + "\nRegistry: "
+ packet.getReg().getClass().getSimpleName() + "\nPacket Size: " + packet.getSize() + "\nCompressed: ");
SwingUtils.appendColoredText(compressedString + "§0\nEncrypted: " + encryptedString, pane);
SwingUtils.appendColoredText(compressedString + "\u00a70\nEncrypted: " + encryptedString, pane);

infoPanel.add(pane);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/defekt/mc/chatclient/ui/ServerEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ public void run() {
}
}
} catch (final UnknownHostException e) {
info = new StatusInfo("§4" + Messages.getString("ServerEntry.serverEntryUnknownHost"), -1,
info = new StatusInfo("\u00a74" + Messages.getString("ServerEntry.serverEntryUnknownHost"), -1,
-1, "", -1, null, null, null);
error = true;
} catch (final Exception e) {
info = new StatusInfo("§4" + Messages.getString("ServerEntry.serverEntryCantConnect"), -1,
info = new StatusInfo("\u00a74" + Messages.getString("ServerEntry.serverEntryCantConnect"), -1,
-1, "", -1,

null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class UserPreferences implements Serializable {
private static final long serialVersionUID = 5064975536053236721L;

private UserPreferences() {
initDefaults();
}

private void initDefaults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void showUserInfo(final PlayerInfo info) {
jtp.setEditable(false);
jtp.setOpaque(false);
SwingUtils.appendColoredText(
dname.replace("§7", "§8").replace("§f", "§0").replace("§r", "§0"),
dname.replace("\u00a77", "\u00a78").replace("\u00a7f", "\u00a70").replace("\u00a7r", "\u00a70"),
jtp);
add(jtp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ public void actionPerformed(final ActionEvent e) {
modsPane.alignAll();

final JTextPane infoPane = initTextPane();
SwingUtils.appendColoredText(Messages.getString("ServerDetailsDialog.address") + ":§7 " + server.getHost(),
SwingUtils.appendColoredText(Messages.getString("ServerDetailsDialog.address") + ":\u00a77 " + server.getHost(),
infoPane);
SwingUtils.appendColoredText(
"\n" + Messages.getString("ServerDetailsDialog.port") + ":§7 " + server.getPort(), infoPane);
SwingUtils.appendColoredText("\nForge: §7" + server.getForgeMode(), infoPane);
"\n" + Messages.getString("ServerDetailsDialog.port") + ":\u00a77 " + server.getPort(), infoPane);
SwingUtils.appendColoredText("\nForge: \u00a77" + server.getForgeMode(), infoPane);

final JTextPane playersPane = initTextPane();
if (info != null && info.getPlayersList().length > 0) {
for (final String player : info.getPlayersList()) {
SwingUtils.appendColoredText(player + "\n", playersPane);
}
} else {
SwingUtils.appendColoredText("§7" + Messages.getString("ServerDetailsDialog.none"), playersPane);
SwingUtils.appendColoredText("\u00a77" + Messages.getString("ServerDetailsDialog.none"), playersPane);
}

final JTextPane queryPane = initTextPane();
Expand Down Expand Up @@ -188,13 +188,13 @@ private void populateQueryPane(final QueryInfo info, final JTextPane pane) {
}

pane.setText("");
SwingUtils.appendColoredText(Messages.getString("ServerDetailsDialog.motd") + ":§7 " + motd, pane);
SwingUtils.appendColoredText("\n" + Messages.getString("ServerDetailsDialog.gamemode") + ":§7 " + gamemode,
SwingUtils.appendColoredText(Messages.getString("ServerDetailsDialog.motd") + ":\u00a77 " + motd, pane);
SwingUtils.appendColoredText("\n" + Messages.getString("ServerDetailsDialog.gamemode") + ":\u00a77 " + gamemode,
pane);
SwingUtils.appendColoredText("\n" + Messages.getString("ServerDetailsDialog.map") + ":§7 " + map, pane);
SwingUtils.appendColoredText("\n" + Messages.getString("ServerDetailsDialog.online") + ":§7 " + online,
SwingUtils.appendColoredText("\n" + Messages.getString("ServerDetailsDialog.map") + ":\u00a77 " + map, pane);
SwingUtils.appendColoredText("\n" + Messages.getString("ServerDetailsDialog.online") + ":\u00a77 " + online,
pane);
SwingUtils.appendColoredText("\n" + Messages.getString("ServerDetailsDialog.maxPlayers") + ":§7 " + max,
SwingUtils.appendColoredText("\n" + Messages.getString("ServerDetailsDialog.maxPlayers") + ":\u00a77 " + max,
pane);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
@SuppressWarnings("javadoc")
public class SwingConstants {
protected static final char[] minecraftiaChars = "\r\n!@#$%^&*()_+{}:\"|<>?`~,./;'\\[]-= abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZźŹęóąśłżń�ÓĄŚ�Ż�0123456789» ↙�↗↖℅↓↑�→▲△■□●○§♀♂≥≤≠���÷×±”€"
protected static final char[] minecraftiaChars = " \r\n!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƂƃƏƒƵƶƷǤǥǦǧǨǩǪǫǮǯǺǻǼǽǾǿȘșȚțȷəʒˆˇˉˊˋ˘˙˚˛˜˝ʹ͵;΄΅Ά·ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϗЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџѢѣѲѳѴѵҊҋҌҍҎҏҐґҒғҖҗҘҙҚқҜҝҠҡҢңҪҫҮүҰұҲҳҶҷҸҹҺһӀӁӂӅӆӇӈӉӊӍӎӏӒӓӔӕӘәӢӣӤӥӦӧӨөӬӭӮӯӰӱẀẁẂẃẄẅẞỲỳ‘’‚‛“”„‟†‡•‣…‰′″‵‶‹›⁄⁰ⁱ⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉₩€₮₱₴₸₹₺℅ℓ№℗℠™℮⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞←↑→↓↔↕↖↗↘↙∅∆√∞∫∴≈≠≤≥■□▲△▶▷○●♀♂♩♪♫♭♮♯⟨⟩fifl"
.toCharArray();

protected static boolean checkMCSupported(final String s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static void centerWindow(final Window win) {
*
* @param text text to append.<br>
* It follows the same rules defined in Minecraft, for example,
* §4Hello §9World would be
* \u00a74Hello \u00a79World would be
* "<font style="color: aa0000;">Hello</font>
* <font style="color: 5555ff;">World</font>""
* @param pane pane to append text to
Expand All @@ -107,7 +107,7 @@ public static void appendColoredText(final String text, final JTextPane pane) {
final StyleContext ctx = new StyleContext();
final Style style = ctx.addStyle("style", null);

final String[] split = text.split("§");
final String[] split = text.split("\u00a7");
boolean lineSupported = true;
final int ctxIndex = doc.getLength();
for (final String part : split) {
Expand Down

0 comments on commit ffe1e11

Please sign in to comment.