Skip to content

Commit

Permalink
Fixed duplicated messages in servers and color coding AGAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro270707 committed Jan 20, 2024
1 parent 45275af commit 6dc4981
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public boolean messageMayBeMultiline() {

@Override
public void sendMessage(String message) {
this.mc.ingameGUI.addChatMessage(message);
if (!this.mc.isMultiplayerWorld()) this.mc.ingameGUI.addChatMessage(message);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private void finishUpdatingSuggestions() {
} else {
suggestion = new Suggestion(new StringRange(jsonSuggestion.getAsJsonObject().get(CommandManagerPacketKeys.RANGE).getAsJsonObject().get(CommandManagerPacketKeys.RANGE_START).getAsInt(), jsonSuggestion.getAsJsonObject().get(CommandManagerPacketKeys.RANGE).getAsJsonObject().get(CommandManagerPacketKeys.RANGE_END).getAsInt()), jsonSuggestion.getAsJsonObject().get(CommandManagerPacketKeys.VALUE).getAsString());
}
if (suggestion.getRange().getStart() > 0 && this.tablessCursor <= this.tablessMessage.length() && suggestion.getText().startsWith(this.tablessMessage.substring(Math.min(suggestion.getRange().getStart(), this.tablessMessage.length()), Math.min(this.tablessMessage.length(), this.tablessCursor)))) {
if (suggestion.getRange().getStart() > 0 && this.tablessCursor <= this.tablessMessage.length() && suggestion.getText().startsWith(this.tablessMessage.substring(Math.min(suggestion.getRange().getStart(), this.tablessMessage.length()), Math.min(Math.min(suggestion.getRange().getStart(), this.tablessMessage.length()), this.tablessCursor)))) {
this.suggestions.add(suggestion);
}
}
Expand Down Expand Up @@ -403,11 +403,9 @@ public String colorCodeText(String text, boolean requireSlash) {
boolean isCommand = (stringReader.canRead() && stringReader.peek() == '/') || !requireSlash;
if (!isCommand || text.isEmpty()) return text;
if (!Commander.serverSuggestions.isEmpty() && Commander.serverSuggestions.get(CommandManagerPacketKeys.LAST_CHILD) != null && Commander.serverSuggestions.get(CommandManagerPacketKeys.LAST_CHILD).getAsJsonObject().get(CommandManagerPacketKeys.ARGUMENTS) != null) {
if (stringReader.canRead() && stringReader.peek() == '/') stringReader.skip();
StringBuilder stringToDrawBuilder = new StringBuilder();
int currentArgumentEnd = 0;
int currentColor = 0;
stringToDrawBuilder.append(TextFormatting.LIGHT_GRAY).append(text.charAt(0));
for (JsonElement jsonElement : Commander.serverSuggestions.getAsJsonObject(CommandManagerPacketKeys.LAST_CHILD).getAsJsonArray(CommandManagerPacketKeys.ARGUMENTS)) {
int rangeStart = jsonElement.getAsJsonObject().getAsJsonObject(CommandManagerPacketKeys.RANGE).get(CommandManagerPacketKeys.RANGE_START).getAsInt();
int rangeEnd = jsonElement.getAsJsonObject().getAsJsonObject(CommandManagerPacketKeys.RANGE).get(CommandManagerPacketKeys.RANGE_END).getAsInt();
Expand All @@ -428,6 +426,7 @@ public String colorCodeText(String text, boolean requireSlash) {
}
stringToDrawBuilder.append(TextFormatting.LIGHT_GRAY).append(text.substring(Math.min(currentArgumentEnd, text.length())));

System.out.println(stringToDrawBuilder);
return stringToDrawBuilder.toString();
} else {
if (stringReader.canRead() && stringReader.peek() == '/') stringReader.skip();
Expand Down

0 comments on commit 6dc4981

Please sign in to comment.