Skip to content

Commit

Permalink
Merge pull request #819 from TonytheMacaroni/main
Browse files Browse the repository at this point in the history
Check for more names
  • Loading branch information
Chronoken authored Dec 14, 2023
2 parents 50ad10a + d0b4b3e commit f798834
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,17 @@ public static MagicItemData parseMagicItemData(String str) {
JsonArray ignoredAttributeStrings = value.getAsJsonArray();

for (JsonElement element : ignoredAttributeStrings) {
String ignoredAttribute = element.getAsString().toUpperCase();
String attr = element.getAsString();
String attrValue = attr.toUpperCase().replace("-", "_");;

try {
ignoredAttributes.add(MagicItemAttribute.valueOf(ignoredAttribute));
ignoredAttributes.add(MagicItemAttribute.valueOf(attrValue));
} catch (IllegalArgumentException e) {
DebugHandler.debugBadEnumValue(MagicItemAttribute.class, ignoredAttribute);
switch (attrValue) {
case "ENCHANTMENTS" -> ignoredAttributes.add(ENCHANTS);
case "POTION_DATA" -> ignoredAttributes.add(POTION_TYPE);
default -> DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
}
}
}
break;
Expand All @@ -430,11 +436,17 @@ public static MagicItemData parseMagicItemData(String str) {
JsonArray blacklistedAttributeStrings = value.getAsJsonArray();

for (JsonElement element : blacklistedAttributeStrings) {
String blacklistedAttribute = element.getAsString().toUpperCase();
String attr = element.getAsString();
String attrValue = attr.toUpperCase().replace("-", "_");;

try {
blacklistedAttributes.add(MagicItemAttribute.valueOf(blacklistedAttribute));
blacklistedAttributes.add(MagicItemAttribute.valueOf(attrValue));
} catch (IllegalArgumentException e) {
DebugHandler.debugBadEnumValue(MagicItemAttribute.class, blacklistedAttribute);
switch (attrValue) {
case "ENCHANTMENTS" -> blacklistedAttributes.add(ENCHANTS);
case "POTION_DATA" -> blacklistedAttributes.add(POTION_TYPE);
default -> DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
}
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,16 @@ public static MagicItem getMagicItemFromSection(ConfigurationSection section) {
List<String> ignoredAttributeStrings = section.getStringList("ignored-attributes");

for (String attr : ignoredAttributeStrings) {
String attrValue = attr.toUpperCase().replace("-", "_");

try {
ignoredAttributes.add(MagicItemAttribute.valueOf(attr.toUpperCase().replace("-", "_")));
ignoredAttributes.add(MagicItemAttribute.valueOf(attrValue));
} catch (IllegalArgumentException e) {
DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
switch (attrValue) {
case "ENCHANTMENTS" -> ignoredAttributes.add(ENCHANTS);
case "POTION_DATA" -> ignoredAttributes.add(POTION_TYPE);
default -> DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
}
}
}
}
Expand All @@ -320,10 +326,16 @@ public static MagicItem getMagicItemFromSection(ConfigurationSection section) {
List<String> blacklistedAttributeStrings = section.getStringList("blacklisted-attributes");

for (String attr : blacklistedAttributeStrings) {
String attrValue = attr.toUpperCase().replace("-", "_");

try {
blacklistedAttributes.add(MagicItemAttribute.valueOf(attr.toUpperCase().replace("-", "_")));
blacklistedAttributes.add(MagicItemAttribute.valueOf(attrValue));
} catch (IllegalArgumentException e) {
DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
switch (attrValue) {
case "ENCHANTMENTS" -> blacklistedAttributes.add(ENCHANTS);
case "POTION_DATA" -> blacklistedAttributes.add(POTION_TYPE);
default -> DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
}
}
}
}
Expand Down Expand Up @@ -515,10 +527,16 @@ public static MagicItem getMagicItemFromSection(ConfigurationSection section) {
Set<MagicItemAttribute> ignoredAttributes = itemData.getIgnoredAttributes();

for (String attr : ignoredAttributeStrings) {
String attrValue = attr.toUpperCase().replace("-", "_");

try {
ignoredAttributes.add(MagicItemAttribute.valueOf(attr.toUpperCase().replace("-", "_")));
ignoredAttributes.add(MagicItemAttribute.valueOf(attrValue));
} catch (IllegalArgumentException e) {
DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
switch (attrValue) {
case "ENCHANTMENTS" -> ignoredAttributes.add(ENCHANTS);
case "POTION_DATA" -> ignoredAttributes.add(POTION_TYPE);
default -> DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
}
}
}
}
Expand All @@ -528,10 +546,16 @@ public static MagicItem getMagicItemFromSection(ConfigurationSection section) {
Set<MagicItemAttribute> blacklistedAttributes = itemData.getBlacklistedAttributes();

for (String attr : blacklistedAttributeStrings) {
String attrValue = attr.toUpperCase().replace("-", "_");

try {
blacklistedAttributes.add(MagicItemAttribute.valueOf(attr.toUpperCase().replace("-", "_")));
blacklistedAttributes.add(MagicItemAttribute.valueOf(attrValue));
} catch (IllegalArgumentException e) {
DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
switch (attrValue) {
case "ENCHANTMENTS" -> blacklistedAttributes.add(ENCHANTS);
case "POTION_DATA" -> blacklistedAttributes.add(POTION_TYPE);
default -> DebugHandler.debugBadEnumValue(MagicItemAttribute.class, attr);
}
}
}
}
Expand Down

0 comments on commit f798834

Please sign in to comment.