Combine two if-statements to hopefully pass code checks

This commit is contained in:
TheLonelyWolf 2023-07-11 18:13:48 +02:00
parent e4c2adc822
commit 8a176ed18b

View File

@ -345,27 +345,25 @@ public class ItemCreation {
} }
} }
// 1.20 Trim Feature for Player Armor // 1.20 Trim Feature for Player Armor
if(plugin.legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20)){ if(plugin.legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && itemSection.contains("trim")){
// trim: <Material> <Pattern> // trim: <Material> <Pattern>
if(itemSection.contains("trim")){ String trim = itemSection.getString("trim");
String trim = itemSection.getString("trim"); String[] trimList = trim.split("\\s");
String[] trimList = trim.split("\\s"); if(trimList.length == 2){
if(trimList.length == 2){ String trimMaterialString = trimList[0].toLowerCase();
String trimMaterialString = trimList[0].toLowerCase(); String trimPatternString = trimList[1].toLowerCase();
String trimPatternString = trimList[1].toLowerCase();
// Check if Material and Pattern are valid and the itemstack is an armor piece // Check if Material and Pattern are valid and the itemstack is an armor piece
if(isTrimMaterial(trimMaterialString) && isTrimPattern(trimPatternString) && isArmor(s)){ if(isTrimMaterial(trimMaterialString) && isTrimPattern(trimPatternString) && isArmor(s)){
// Getting the correct Pattern and Material - Seems to be experimental this way // Getting the correct Pattern and Material - Seems to be experimental this way
// Material and Pattern don't have a valueOf-function to get them the easier way. // Material and Pattern don't have a valueOf-function to get them the easier way.
TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(Objects.requireNonNull(NamespacedKey.fromString("minecraft:" + trimMaterialString))); TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(Objects.requireNonNull(NamespacedKey.fromString("minecraft:" + trimMaterialString)));
TrimPattern trimPattern = Registry.TRIM_PATTERN.get(Objects.requireNonNull(NamespacedKey.fromString("minecraft:" + trimPatternString))); TrimPattern trimPattern = Registry.TRIM_PATTERN.get(Objects.requireNonNull(NamespacedKey.fromString("minecraft:" + trimPatternString)));
ArmorMeta armorMeta = (ArmorMeta) s.getItemMeta(); ArmorMeta armorMeta = (ArmorMeta) s.getItemMeta();
armorMeta.setTrim(new ArmorTrim(trimMaterial, trimPattern)); armorMeta.setTrim(new ArmorTrim(trimMaterial, trimPattern));
s.setItemMeta(armorMeta); s.setItemMeta(armorMeta);
}
} }
} }
} }