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

View File

@@ -245,7 +245,7 @@ public class ConfigTools {
List<Component> finalLore = new ArrayList<>(); List<Component> finalLore = new ArrayList<>();
for (String line : raw) { for (String line : raw) {
if (line.contains("{levels}")) { 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 // will return 0 if it doesn't exist
if (levels != 0) { if (levels != 0) {
line = line.replace("{levels}", String.valueOf(levels)); line = line.replace("{levels}", String.valueOf(levels));