Skip to content
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from ModdedMinecraftClub/feature/remove-json
Browse files Browse the repository at this point in the history
Switch to section symbol formatting, fix color NPE
  • Loading branch information
132ikl authored May 24, 2020
2 parents b7188a3 + 77be4ff commit dd83cea
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@

public final class ChatMessage extends AbstractMessage {
protected static final short MESSAGE_TYPE_ID = 1;
private final String username, message, componentJson;
private final String username, message, formattedMessage;

protected ChatMessage(DataInputStream dataInputStream) throws IOException {
username = dataInputStream.readUTF();
message = dataInputStream.readUTF();
componentJson = dataInputStream.readUTF();
formattedMessage = dataInputStream.readUTF();
}

public ChatMessage(String username, String message, String componentJson) {
public ChatMessage(String username, String message, String formattedMessage) {
this.username = username;
this.message = message;
this.componentJson = componentJson;
this.formattedMessage = formattedMessage;
}

public String getUsername() {
return username;
return username;
}

public String getMessage() {
return message;
}

public String getComponentJson() {
return componentJson;
public String getFormattedMessage() {
return formattedMessage;
}

@Override
protected void send(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeShort(MESSAGE_TYPE_ID);
dataOutputStream.writeUTF(username);
dataOutputStream.writeUTF(message);
dataOutputStream.writeUTF(componentJson);
dataOutputStream.writeUTF(formattedMessage);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@

public class PlayerStatusMessage extends AbstractMessage {
protected static final short MESSAGE_TYPE_ID = 3;
private final String userName, serverID, prefixJson;
private final String userName, serverID, formattedPrefix;
private final boolean joined, silent;

public PlayerStatusMessage(String userName, String serverID, String prefixJson, boolean joined, boolean silent) {
this.userName = userName;
this.serverID = serverID;
this.prefixJson = prefixJson;
this.formattedPrefix = prefixJson;
this.joined = joined;
this.silent = silent;
}

public PlayerStatusMessage(DataInputStream istream) throws IOException {
this.userName = istream.readUTF();
this.serverID = istream.readUTF();
this.prefixJson = istream.readUTF();
this.formattedPrefix = istream.readUTF();
this.joined = istream.readBoolean();
this.silent = istream.readBoolean();
}
Expand All @@ -62,16 +62,16 @@ public boolean getSilent() {
return this.silent;
}

public String getPrefixJson() {
return this.prefixJson;
public String getFormattedPrefix() {
return this.formattedPrefix;
}

@Override
protected void send(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeShort(MESSAGE_TYPE_ID);
dataOutputStream.writeUTF(userName);
dataOutputStream.writeUTF(serverID);
dataOutputStream.writeUTF(prefixJson);
dataOutputStream.writeUTF(formattedPrefix);
dataOutputStream.writeBoolean(joined);
dataOutputStream.writeBoolean(silent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
//Used for broadcasting server online/offline events
public class ServerStatusMessage extends AbstractMessage {
protected static final short MESSAGE_TYPE_ID = 2;
private final String serverID, prefixJson;
private final String serverID, formattedPrefix;
private final short state;

public ServerStatusMessage(String serverID, String prefixJson, short state) {
public ServerStatusMessage(String serverID, String formattedId, short state) {
this.serverID = serverID;
this.prefixJson = prefixJson;
this.formattedPrefix = formattedId;
this.state = state;
}

public ServerStatusMessage(DataInputStream istream) throws IOException {
this.serverID = istream.readUTF();
this.prefixJson = istream.readUTF();
this.formattedPrefix = istream.readUTF();
this.state = istream.readShort();
}

Expand All @@ -50,15 +50,15 @@ public short getState() {
return this.state;
}

public String getPrefixJson() {
return this.prefixJson;
public String getFormattedPrefix() {
return this.formattedPrefix;
}

@Override
protected void send(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeShort(MESSAGE_TYPE_ID);
dataOutputStream.writeUTF(serverID);
dataOutputStream.writeUTF(prefixJson);
dataOutputStream.writeUTF(formattedPrefix);
dataOutputStream.writeShort(state);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public class PrintMessageQueue extends ThreadedQueue<MessageData> {
put("7", new Color(0xAAAAAA));
put("8", new Color(0x555555));
put("9", new Color(0x5555FF));
put("a", new Color(0x55FF55));
put("b", new Color(0x55FFFF));
put("c", new Color(0xFF5555));
put("d", new Color(0xFF55FF));
put("e", new Color(0xFFFF55));
put("f", new Color(0xFFFFFF));
put("10", new Color(0x55FF55));
put("11", new Color(0x55FFFF));
put("12", new Color(0xFF5555));
put("13", new Color(0xFF55FF));
put("14", new Color(0xFFFF55));
put("15", new Color(0xFFFFFF));
}};

@Override
Expand Down Expand Up @@ -109,7 +109,6 @@ protected void handle(MessageData messageData) {
embedSpec.setTitle(message.getServerID() + ": " + message.getCommand());
}
embedSpec.setDescription(message.getCommandOutput());
Random random = new Random(System.currentTimeMillis());
embedSpec.setColor(colorHashMap.get(message.getColor()));
}).block();
}
Expand Down

0 comments on commit dd83cea

Please sign in to comment.