9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2026-01-04 15:31:47 +00:00

Added smallfont Placeholder

This commit is contained in:
XiaoMoMi
2025-02-24 16:26:48 +08:00
parent 4e5dcad309
commit fd19b99e77
2 changed files with 83 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=3.0.22
project_version=3.0.23
config_version=36
project_group=net.momirealms

View File

@@ -34,10 +34,77 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
public class NameplatesExtraExpansion extends PlaceholderExpansion {
private static final Map<Character, Character> CHAR_CONVERTOR = new HashMap<>();
static {
CHAR_CONVERTOR.put('A', 'ᴀ');
CHAR_CONVERTOR.put('a', 'ᴀ');
CHAR_CONVERTOR.put('B', 'ʙ');
CHAR_CONVERTOR.put('b', 'ʙ');
CHAR_CONVERTOR.put('C', '');
CHAR_CONVERTOR.put('c', '');
CHAR_CONVERTOR.put('D', 'ᴅ');
CHAR_CONVERTOR.put('d', 'ᴅ');
CHAR_CONVERTOR.put('E', 'ᴇ');
CHAR_CONVERTOR.put('e', 'ᴇ');
CHAR_CONVERTOR.put('F', 'ꜰ');
CHAR_CONVERTOR.put('f', 'ꜰ');
CHAR_CONVERTOR.put('G', 'ɢ');
CHAR_CONVERTOR.put('g', 'ɢ');
CHAR_CONVERTOR.put('H', 'ʜ');
CHAR_CONVERTOR.put('h', 'ʜ');
CHAR_CONVERTOR.put('I', 'ɪ');
CHAR_CONVERTOR.put('i', 'ɪ');
CHAR_CONVERTOR.put('J', 'ᴊ');
CHAR_CONVERTOR.put('j', 'ᴊ');
CHAR_CONVERTOR.put('K', 'ᴋ');
CHAR_CONVERTOR.put('k', 'ᴋ');
CHAR_CONVERTOR.put('L', 'ʟ');
CHAR_CONVERTOR.put('l', 'ʟ');
CHAR_CONVERTOR.put('M', 'ᴍ');
CHAR_CONVERTOR.put('m', 'ᴍ');
CHAR_CONVERTOR.put('N', 'ɴ');
CHAR_CONVERTOR.put('n', 'ɴ');
CHAR_CONVERTOR.put('O', '');
CHAR_CONVERTOR.put('o', '');
CHAR_CONVERTOR.put('P', 'ᴘ');
CHAR_CONVERTOR.put('p', 'ᴘ');
CHAR_CONVERTOR.put('Q', 'ꞯ');
CHAR_CONVERTOR.put('q', 'ꞯ');
CHAR_CONVERTOR.put('R', 'ʀ');
CHAR_CONVERTOR.put('r', 'ʀ');
CHAR_CONVERTOR.put('S', '');
CHAR_CONVERTOR.put('s', '');
CHAR_CONVERTOR.put('T', 'ᴛ');
CHAR_CONVERTOR.put('t', 'ᴛ');
CHAR_CONVERTOR.put('U', '');
CHAR_CONVERTOR.put('u', '');
CHAR_CONVERTOR.put('V', '');
CHAR_CONVERTOR.put('v', '');
CHAR_CONVERTOR.put('W', '');
CHAR_CONVERTOR.put('w', '');
CHAR_CONVERTOR.put('X', 'x');
CHAR_CONVERTOR.put('x', 'x');
CHAR_CONVERTOR.put('Y', 'ʏ');
CHAR_CONVERTOR.put('y', 'ʏ');
CHAR_CONVERTOR.put('Z', '');
CHAR_CONVERTOR.put('z', '');
CHAR_CONVERTOR.put('0', '₀');
CHAR_CONVERTOR.put('1', '₁');
CHAR_CONVERTOR.put('2', '₂');
CHAR_CONVERTOR.put('3', '₃');
CHAR_CONVERTOR.put('4', '₄');
CHAR_CONVERTOR.put('5', '₅');
CHAR_CONVERTOR.put('6', '₆');
CHAR_CONVERTOR.put('7', '₇');
CHAR_CONVERTOR.put('8', '₈');
CHAR_CONVERTOR.put('9', '₉');
}
private final CustomNameplates plugin;
@@ -238,6 +305,21 @@ public class NameplatesExtraExpansion extends PlaceholderExpansion {
case "newline" -> {
return "\n";
}
case "smallfont" -> {
if (split.length != 2) {
return null;
}
String anotherPlaceholder = PlaceholderAPI.setPlaceholders(player, "%" + split[1] + "%");
StringBuilder builder = new StringBuilder();
for (char c : anotherPlaceholder.toCharArray()) {
builder.append(CHAR_CONVERTOR.getOrDefault(c, c));
}
String finalString = builder.toString();
if (finalString.length() == split[1].length() + 2 && finalString.charAt(0) == '%' && finalString.charAt(finalString.length() - 1) == '%') {
return finalString.substring(1, finalString.length() - 1);
}
return finalString;
}
}
return null;
}