@@ -206,26 +206,22 @@ public void applyArmorTrim(Profile profile) {
206206 ItemStack chestplate = player .getInventory ().getChestplate ();
207207 ItemStack leggings = player .getInventory ().getLeggings ();
208208 ItemStack boots = player .getInventory ().getBoots ();
209- if (helmet != null ) {
210- ArmorMeta helmetMeta = (ArmorMeta ) helmet .getItemMeta ();
209+ if (helmet != null && (helmet .getItemMeta () instanceof ArmorMeta helmetMeta )) {
211210 if (trimPackage .getHelmetTrim () != null ) helmetMeta .setTrim (trimPackage .getHelmetTrim ());
212211 helmet .setItemMeta (helmetMeta );
213212 player .getInventory ().setHelmet (helmet );
214213 }
215- if (chestplate != null ) {
216- ArmorMeta chestplateMeta = (ArmorMeta ) chestplate .getItemMeta ();
214+ if (chestplate != null && (chestplate .getItemMeta () instanceof ArmorMeta chestplateMeta )) {
217215 if (trimPackage .getHelmetTrim () != null ) chestplateMeta .setTrim (trimPackage .getChestplateTrim ());
218216 chestplate .setItemMeta (chestplateMeta );
219217 player .getInventory ().setChestplate (chestplate );
220218 }
221- if (leggings != null ) {
222- ArmorMeta leggingsMeta = (ArmorMeta ) leggings .getItemMeta ();
219+ if (leggings != null && (leggings .getItemMeta () instanceof ArmorMeta leggingsMeta )) {
223220 if (trimPackage .getHelmetTrim () != null ) leggingsMeta .setTrim (trimPackage .getLeggingsTrim ());
224221 leggings .setItemMeta (leggingsMeta );
225222 player .getInventory ().setLeggings (leggings );
226223 }
227- if (boots != null ) {
228- ArmorMeta bootsMeta = (ArmorMeta ) boots .getItemMeta ();
224+ if (boots != null && (boots .getItemMeta () instanceof ArmorMeta bootsMeta )) {
229225 if (trimPackage .getHelmetTrim () != null ) bootsMeta .setTrim (trimPackage .getBootsTrim ());
230226 boots .setItemMeta (bootsMeta );
231227 player .getInventory ().setBoots (boots );
0 commit comments