few fixes

This commit is contained in:
hyperdefined
2025-05-15 18:33:27 -04:00
parent 0efc07b12b
commit 364859bc0a
2 changed files with 12 additions and 18 deletions

View File

@@ -176,6 +176,10 @@ public class TokenData {
tokenMeta.displayName(title);
tokenMeta.lore(lore);
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, tokenType);
token.setItemMeta(tokenMeta);
// set the custom model data
if (tokenConfig.getBoolean("custom-model-data.enabled")) {
String type = tokenConfig.getString("custom-model-data.type");
@@ -194,36 +198,26 @@ public class TokenData {
}
}
// set the PDC
tokenData.set(toolStats.tokenType, PersistentDataType.STRING, tokenType);
token.setItemMeta(tokenMeta);
return token;
}
private CustomModelData setData(String type, Object data) {
switch (type.toLowerCase(Locale.ROOT)) {
case "float": {
Float f;
if (data instanceof Float) {
f = (Float) data;
} else {
toolStats.logger.info(type + " is not a valid float!");
float f;
try {
f = Float.parseFloat(data.toString());
} catch (NumberFormatException e) {
toolStats.logger.info(data + " is not a valid float!");
return null;
}
return CustomModelData.customModelData().addFloat(f).build();
}
case "string": {
String s;
if (data instanceof String) {
s = (String) data;
} else {
toolStats.logger.info(type + " is not a valid string!");
return null;
}
return CustomModelData.customModelData().addString(s).build();
return CustomModelData.customModelData().addString(data.toString()).build();
}
default: {
toolStats.logger.info(type + " is not a valid data type!");
toolStats.logger.info(data + " is not a valid data type!");
return null;
}
}

View File

@@ -245,7 +245,7 @@ public class ConfigTools {
List<Component> finalLore = new ArrayList<>();
for (String line : raw) {
if (line.contains("{levels}")) {
Integer levels = toolStats.config.getInt("tokes.data." + tokenType + ".levels");
Integer levels = toolStats.config.getInt("tokens.data." + tokenType + ".levels");
// will return 0 if it doesn't exist
if (levels != 0) {
line = line.replace("{levels}", String.valueOf(levels));