9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-26 10:29:09 +00:00

Added generate option for bitmaps

This commit is contained in:
XiaoMoMi
2024-11-21 02:14:49 +08:00
parent ed2fb60748
commit fccaa059ff
9 changed files with 126 additions and 6 deletions

View File

@@ -522,6 +522,8 @@ public class AdvanceManagerImpl implements AdvanceManager {
String codePoints = requireNonNull(section.getString("codepoints", ""), "codepoints should be NonNull");
int height = section.getInt("height", 8);
boolean custom = section.getBoolean("custom", false);
boolean copy = section.getBoolean("generate", false);
String namespace = section.getString("namespace", ConfigManager.namespace());
File bitmapCache = new File(plugin.getDataDirectory().toFile(), "tmp" + File.separator + id + ".tmp");
if (!bitmapCache.exists()) {
@@ -586,9 +588,25 @@ public class AdvanceManagerImpl implements AdvanceManager {
}
registerCharacterFontData(id, bitmapCache, (properties) -> {
int ascent = (int) properties.get("shift_y");
String filePath = custom ? ConfigManager.namespace() + ":font/" + file : "minecraft:font/" + codePoints + ".png";
String filePath = custom ? namespace + ":font/" + file : "minecraft:font/" + codePoints + ".png";
plugin.getConfigManager().saveResource("tmp/" + codePoints + ".json");
StringBuilder jsonContent = new StringBuilder();
if (copy) {
File pngFile = new File(plugin.getDataDirectory().toFile(), "font" + File.separator + file);
File destination = new File(plugin.getDataDirectory().toFile(),
"ResourcePack"
+ File.separator + "assets"
+ File.separator + (custom ? namespace : "minecraft")
+ File.separator + "textures"
+ File.separator + "font"
+ File.separator + (custom ? file : codePoints + ".png")
);
try {
FileUtils.copyFile(pngFile, destination);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
try (BufferedReader reader = new BufferedReader(new FileReader(new File(plugin.getDataDirectory().toFile(), "tmp" + File.separator + codePoints + ".json")))) {
String line;
while ((line = reader.readLine()) != null) {

View File

@@ -33,6 +33,7 @@ integrations:
CarbonChat: false # Integration with CarbonChat
AdvancedChat: false # Integration with AdvancedChat
Essentials: false # Integration with Essentials chat
ChatControlRed: false # Integration with ChatControlRed
# Resource Pack Generation Settings: Configure resource pack generation behavior.
resource-pack:
@@ -72,6 +73,7 @@ other-settings:
"%player_name%": 100
"%vault_prefix%": 20
# Font Templates: Define different fonts and their settings.
# Requires a restart to apply because it can be laggy to read thousands of character
font-templates:
space:
space:
@@ -80,7 +82,7 @@ other-settings:
unihex:
unifont:
file: unifont.zip # Load font from unifont.zip
generate: false # Don't include font in the generated resource pack
generate: false # Should this unihex file be included in the generated pack
size_overrides: # Override size for specific Unicode ranges
- from: "\\u3001"
to: "\\u30FF"
@@ -120,7 +122,7 @@ other-settings:
right: 15
unifont_jp:
file: unifont_jp.zip # Load Japanese unifont
generate: false # Don't generate in the resource pack
generate: false # Should this unihex file be included in the generated pack
filter:
"jp": true # Apply to Japanese characters only
size_overrides:
@@ -137,7 +139,9 @@ other-settings:
codepoints: ascii # Define ASCII bitmap font
file: ascii.png # Use ascii.png file for the font
height: 8 # Font height is 8 units
custom: false # Not a custom font (default Minecraft)
custom: false # Does this png path point to a non-default font path??
generate: false # Should this png file be included in the generated pack
# namespace: custom # Optional namespace if you don't want to use the global namespace set in config.yml
ascii_sga:
codepoints: ascii_sga
file: ascii_sga.png