Skip to content

Commit

Permalink
Fix chat error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessioDP committed Dec 20, 2023
1 parent 7e86125 commit 3f15ca4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
import com.alessiodp.parties.common.parties.objects.PartyImpl;
import com.alessiodp.parties.common.players.objects.PartyPlayerImpl;
import com.alessiodp.parties.common.utils.MessageUtils;
import org.jetbrains.annotations.NotNull;

public class BukkitMessageUtils extends MessageUtils {

public BukkitMessageUtils(PartiesPlugin plugin) {
super(plugin);
}

@NotNull
@Override
public String convertPlaceholders(String message, PartyPlayerImpl player, PartyImpl party, String emptyPlaceholder) {
public String convertPlaceholders(@NotNull String message, PartyPlayerImpl player, PartyImpl party, @NotNull String emptyPlaceholder) {
String ret = super.convertPlaceholders(message, player, party, emptyPlaceholder);
// PlaceholderAPI
if (player != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ public void init() {
}
}

@NotNull
public static String parsePlaceholders(@NotNull String text, @NotNull PartyPlayerImpl player) {
String ret = null;
String ret = text;
if (active) {
Matcher matcher = PLACEHOLDER_PATTERN.matcher(text);
Matcher matcher = PLACEHOLDER_PATTERN.matcher(ret);
while (matcher.find()) {
String identifier = matcher.group(1);
switch (CommonUtils.toLowerCase(identifier)) {
case "%luckperms_prefix%":
ret = text.replace(identifier, hook.getPlayerPrefix(player.getPlayerUUID()));
ret = ret.replace(identifier, hook.getPlayerPrefix(player.getPlayerUUID()));
break;
case "%luckperms_suffix%":
ret = text.replace(identifier, hook.getPlayerSuffix(player.getPlayerUUID()));
ret = ret.replace(identifier, hook.getPlayerSuffix(player.getPlayerUUID()));
break;
default: // Nothing to do
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.alessiodp.parties.common.parties.objects.PartyImpl;
import com.alessiodp.parties.common.players.objects.PartyPlayerImpl;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -21,11 +22,13 @@ public abstract class MessageUtils {
private static final int[] ROMAN_VALUES = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
private static final String[] ROMAN_LITERALS = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };

public String convertPlaceholders(String message, PartyPlayerImpl player, PartyImpl party) {
@NotNull
public String convertPlaceholders(@NotNull String message, PartyPlayerImpl player, PartyImpl party) {
return convertPlaceholders(message, player, party, "");
}

public String convertPlaceholders(String message, PartyPlayerImpl player, PartyImpl party, String emptyPlaceholder) {
@NotNull
public String convertPlaceholders(@NotNull String message, PartyPlayerImpl player, PartyImpl party, @NotNull String emptyPlaceholder) {
String ret = message;
String replacement;
Matcher matcher = PLACEHOLDER_PATTERN.matcher(ret);
Expand Down

0 comments on commit 3f15ca4

Please sign in to comment.