@@ -282,19 +282,18 @@ public static void spawnEffect(final @NotNull Player player, final @NotNull Part
282
282
@ SuppressWarnings ("unchecked" )
283
283
static @ Nullable Object convertOption (@ NotNull Class <?> dataType , @ NotNull Object option ) {
284
284
if (option instanceof AbstractItem ) return itemToItemStack ((AbstractItem ) option );
285
- if (option instanceof Potion ) return wPotionToPotion ((Potion ) option );
286
- if (dataType .isEnum ()) return EnumUtils .valueOf (dataType , option .toString ());
287
- if (dataType .equals (MaterialData .class )) {
285
+ else if (option instanceof Potion ) return wPotionToPotion ((Potion ) option );
286
+ else if (dataType .isEnum ()) return EnumUtils .valueOf (dataType , option .toString ());
287
+ else if (dataType .equals (MaterialData .class )) {
288
288
if (!(option instanceof Tuple ))
289
289
throw new IllegalArgumentException (String .format ("Expected %s but got %s" ,
290
290
Tuple .class .getSimpleName (), option .getClass ().getSimpleName ()));
291
291
Tuple <String , Integer > tuple = (Tuple <String , Integer >) option ;
292
292
Material material = EnumUtils .valueOf (Material .class , tuple .getKey ());
293
293
Integer data = tuple .getValue ();
294
294
return material .getNewData ((byte ) (data == null ? 0 : data ));
295
- }
296
- if (dataType .getCanonicalName ().equalsIgnoreCase ("org.bukkit.Vibration" )) return option ;
297
- if (dataType .getSimpleName ().equals ("BlockData" )) {
295
+ } else if (dataType .getCanonicalName ().equalsIgnoreCase ("org.bukkit.Vibration" )) return option ;
296
+ else if (dataType .getSimpleName ().equals ("BlockData" )) {
298
297
String raw = option .toString ();
299
298
BlockDataOption blockDataOption = new BlockDataOption (raw );
300
299
Material material = EnumUtils .valueOf (Material .class , blockDataOption .getMaterial ());
@@ -303,18 +302,20 @@ public static void spawnEffect(final @NotNull Player player, final @NotNull Part
303
302
String nbt = blockDataOption .getNBT ().trim ();
304
303
return nbt .isEmpty () ? material .createBlockData () : material .createBlockData (String .format ("[%s]" , nbt ));
305
304
}
306
- if (option instanceof Color ) return wColorToColor ((Color ) option );
307
- final Object finalOption ;
308
- Constructor <?> constructor = dataType .getDeclaredConstructors ()[0 ];
309
- int size = constructor .getParameterCount ();
310
- if (size == 2 ) {
311
- Tuple <?, ?> t = (Tuple <?, ?>) option ;
312
- finalOption = new Refl <>(dataType , prepareParameters (t .getKey (), t .getValue ())).getObject ();
313
- } else if (size == 3 ) {
314
- Triple <?, ?, ?> t = (Triple <?, ?, ?>) option ;
315
- finalOption = new Refl <>(dataType , prepareParameters (t .getFirst (), t .getSecond (), t .getThird ())).getObject ();
316
- } else throw new IllegalArgumentException ("Cannot create option from constructor: " + constructor );
317
- return finalOption ;
305
+ else if (option instanceof Color ) return wColorToColor ((Color ) option );
306
+ else {
307
+ final Object finalOption ;
308
+ Constructor <?> constructor = dataType .getDeclaredConstructors ()[0 ];
309
+ int size = constructor .getParameterCount ();
310
+ if (size == 2 ) {
311
+ Tuple <?, ?> t = (Tuple <?, ?>) option ;
312
+ finalOption = new Refl <>(dataType , prepareParameters (t .getKey (), t .getValue ())).getObject ();
313
+ } else if (size == 3 ) {
314
+ Triple <?, ?, ?> t = (Triple <?, ?, ?>) option ;
315
+ finalOption = new Refl <>(dataType , prepareParameters (t .getFirst (), t .getSecond (), t .getThird ())).getObject ();
316
+ } else throw new IllegalArgumentException ("Cannot create option from constructor: " + constructor );
317
+ return finalOption ;
318
+ }
318
319
}
319
320
320
321
private static Object @ NotNull [] prepareParameters (final Object @ NotNull ... parameters ) {
0 commit comments