Skip to content

Commit

Permalink
Fixed scoreboard not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Despical committed Nov 10, 2024
1 parent 1b60a9e commit 0f45eb9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main/java/me/despical/tntrun/arena/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.text.MessageFormat;
import java.util.*;
import java.util.function.Predicate;
import java.util.logging.Level;
Expand Down Expand Up @@ -407,7 +406,7 @@ public void broadcastFormattedMessage(final String path, final User user) {
}

public void broadcastMessage(final String path, Object... params) {
this.getPlayers().forEach(user -> user.sendRawMessage(MessageFormat.format(chatManager.message(path, this, user), params)));
this.getPlayers().forEach(user -> user.sendRawMessage(chatManager.message(path, this, user), params));
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ScoreboardManager(Arena arena, Main plugin) {
this.scoreboards = new HashSet<>();
}

public void createScoreboard(final User user) {
public void createScoreboard(User user) {
if (!plugin.getOption(ConfigPreferences.Option.SCOREBOARD_ENABLED)) {
return;
}
Expand Down Expand Up @@ -123,7 +123,7 @@ private String formatScoreboardLine(String line, User user) {
line = line.replace("%double_jumps%", getDoubleJumpColor(jumps, max) + jumps);
line = line.replace("%date%", date);
line = line.replace("%coins_earned%", Integer.toString(user.getStat(LOCAL_COINS)));
return chatManager.message(line, arena);
return chatManager.formatMessage(arena, line);
}

public String getDoubleJumpColor(int amount, int max) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/me/despical/tntrun/handlers/ChatManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public String message(String path, Arena arena, User user) {
public String message(String path, Arena arena) {
String message = this.message(path);

return formatMessage(arena, message);
}

public String formatMessage(Arena arena, String message) {
message = message.replace("%map%", arena.getMapName());
message = message.replace("%time%", Integer.toString(arena.getTimer()));
message = message.replace("%formatted_time%", StringFormatUtils.formatIntoMMSS(arena.getTimer()));
Expand Down

0 comments on commit 0f45eb9

Please sign in to comment.