@@ -570,22 +570,39 @@ private static <T> void playInternalSound(final @NotNull Player player, final @N
570
570
571
571
/**
572
572
* Converts the given wrapper {@link Potion} to a Bukkit potion.
573
+ * Because of Bukkit recent changes (1.20.6+), <code>org.bukkit.potion.Potion</code> does not exist anymore.
574
+ * For retro-compatibility reasons, this class will return a {@link PotionWrapper} instead,
575
+ * from which the actual <code>org.bukkit.potion.Potion</code> object can be retrieved.
573
576
*
574
577
* @param potion the potion
575
- * @return the potion
578
+ * @return the wrapped potion
576
579
*/
577
- public static @ NotNull org . bukkit . potion . Potion wPotionToPotion (final @ NotNull Potion potion ) {
578
- return new org . bukkit . potion . Potion (EnumUtils .valueOf (PotionType .class , potion .getName ()),
580
+ public static @ NotNull PotionWrapper wPotionToPotion (final @ NotNull Potion potion ) {
581
+ return new PotionWrapper (EnumUtils .valueOf (PotionType .class , potion .getName ()),
579
582
potion .getLevel (), potion .isSplash (), potion .isExtended ());
580
583
}
581
584
582
585
/**
583
586
* Converts the given Bukkit potion to a wrapper {@link Potion}.
587
+ * Because of Bukkit recent changes (1.20.6+), <code>org.bukkit.potion.Potion</code> does not exist anymore.
588
+ * For retro-compatibility reasons, this class allows a generic parameter to be passed,
589
+ * but it will require an object of type org.bukkit.potion.Potion.
584
590
*
585
- * @param potion the potion
591
+ * @param <P> the type of the potion (org.bukkit.potion.Potion).
592
+ * @param potion the bukkit potion
593
+ * @return the potion
594
+ */
595
+ public static <P > @ NotNull Potion potionToWPotion (final @ NotNull P potion ) {
596
+ return potionToWPotion (new PotionWrapper (potion ));
597
+ }
598
+
599
+ /**
600
+ * Converts the given potion wrapper to a wrapper {@link Potion}.
601
+ *
602
+ * @param potion the potion wrapper
586
603
* @return the potion
587
604
*/
588
- public static @ NotNull Potion potionToWPotion (final @ NotNull org . bukkit . potion . Potion potion ) {
605
+ public static @ NotNull Potion potionToWPotion (final @ NotNull PotionWrapper potion ) {
589
606
return new Potion (potion .getType ().name (), potion .getLevel (), potion .isSplash (), potion .hasExtendedDuration ());
590
607
}
591
608
0 commit comments