Fixed stuck player messages

This commit is contained in:
Jules 2023-11-06 00:37:20 +01:00
parent 7d93031aeb
commit 3c043babd5
2 changed files with 8 additions and 3 deletions

View File

@ -10,20 +10,22 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class ConfigMessage {
private final String key;
private final List<String> lines;
private final List<String> lines = new ArrayList<>();
private final boolean papiPlaceholders, actionbar, raw;
private ConfigMessage(@NotNull String key) {
this.key = key;
final Object obj = MMOCore.plugin.configManager.getMessageObject(key);
this.lines = obj == null ? Arrays.asList("<message_not_found:'" + key + "'>") : obj instanceof List<?> ? (List<String>) obj : Arrays.asList(obj.toString());
if (obj == null) lines.add("<message_not_found:'" + key + "'>");
else if (obj instanceof List<?>) lines.addAll((List<String>) obj);
else lines.add(obj.toString());
// Does message include placeholders
boolean hasPlaceholders = false;

View File

@ -207,6 +207,9 @@ public class ConfigManager {
return messages.getStringList(key);
}
/**
* @return The original object, which should be cloned afterwards!!
*/
@Nullable
public Object getMessageObject(String key) {
return messages.get(key);