Skip to content

Commit

Permalink
there will no empty brackets when someone has no status and sends a m…
Browse files Browse the repository at this point in the history
…essage when chatformatter is turned on

Took 49 minutes
  • Loading branch information
TubYoub committed Dec 15, 2024
1 parent fe7f787 commit d23a320
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ public void onPlayerChat(PlayerChatEvent event) {
status = PlaceholderAPI.setPlaceholders(player, status);
}

// message = plugin.getStatusManager().translateColorsAndFormatting(message,player);

// Format the broadcast message
String broadcastMessage;
if (status == null) {
broadcastMessage = player.getName() + ": " + message;
if (status.isEmpty()) {
broadcastMessage = player.getName() + ": " + plugin.getStatusManager().translateColorsAndFormatting(message,event.getPlayer());
} else {
broadcastMessage = "[" + ColourUtils.format(status) + ChatColor.RESET + "] " + player.getName() + ": " + message;
broadcastMessage = configManager.getOpeningCharacter() + ColourUtils.format(status) + ChatColor.RESET + configManager.getClosingCharacter() + " " + player.getName() + ": " + plugin.getStatusManager().translateColorsAndFormatting(message,player);;
}

// Broadcast the message and cancel the original event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public String getStatus(Player player) {
public void updateDisplayName(Player player) {
String status = getStatus(player);

if (status != "") {
if (status.isEmpty()) {
String translatedStatus = translateColorsAndFormatting(status, player);
if (plugin.isLuckPermsPresent() && player.hasPermission("StatusPlugin.placeholders")) {
translatedStatus.replace("%LP_prefix%", Objects.requireNonNull(plugin.getLuckPerms().getPlayerAdapter(Player.class).getUser(player).getCachedData().getMetaData().getPrefix()));
Expand Down Expand Up @@ -216,7 +216,7 @@ public String translateColorsAndFormatting(String status, CommandSender sender)
status = status.replace(codes[i], "");
}
}
return ChatColor.translateAlternateColorCodes('§', status);
return ChatColor.translateAlternateColorCodes('&', status);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public String getVersion(){
@Override
public String onPlaceholderRequest(Player player, String identifier){
if(player == null){
return "";
return null;
}
if (Objects.equals(identifier, "status")){
return plugin.getStatusManager().getStatus(player);
Expand Down

0 comments on commit d23a320

Please sign in to comment.