Make PAPI tag better looking

This commit is contained in:
Bea 2022-10-24 22:55:24 +02:00
parent 6bd4b12f18
commit 81160ce074

View File

@ -1,6 +1,7 @@
package wtf.beatrice.nounspicker.objects;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import wtf.beatrice.nounspicker.NounsPicker;
@ -50,6 +51,11 @@ public class PAPIManager extends PlaceholderExpansion
int pronounId;
// base format is [She/Her]
final String baseFormat = ChatColor.DARK_GRAY + "%main%" + ChatColor.DARK_GRAY + "/" +
"%secondary%" + ChatColor.DARK_GRAY + "]" + ChatColor.RESET;
// todo: this sends query every time we get a papi call, which is horrible for performance.
// todo: we should cache player pronouns too.
@ -65,7 +71,8 @@ public class PAPIManager extends PlaceholderExpansion
String mainPronounFormat = Cache.dbManager.getPronounFormat(pronounId);
pronounId = Cache.dbManager.getPlayerPronounId(player.getName(), 1);
String secondaryPronounFormat = Cache.dbManager.getPronounFormat(pronounId);
return "[" + mainPronounFormat + "/" + secondaryPronounFormat + "]";
return baseFormat.replace("%main%", mainPronounFormat)
.replace("%secondary%", secondaryPronounFormat);
}
return null;