Skip to content

Commit

Permalink
Fix food component error (#8)
Browse files Browse the repository at this point in the history
* Display/Types - fix clashes with Skript 2.10's display syntaxes

* EffApplyPotion - fix error when loading on older servers (pre-components)
  • Loading branch information
ShaneBeee authored Nov 16, 2024
1 parent ff6c99c commit b0560ed
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public class EffApplyPotion extends Effect {
private static Method ADD_EFFECT_METHOD;

static {
Skript.registerEffect(EffApplyPotion.class, "apply [potion[[ ]effect]] %potioneffect% [with probability %-number%]");
if (Skript.methodExists(FoodComponent.class, "addEffect", PotionEffect.class, float.class)) {
if (Skript.classExists("org.bukkit.inventory.meta.components.FoodComponent") &&
Skript.methodExists(FoodComponent.class, "addEffect", PotionEffect.class, float.class)) {
try {
ADD_EFFECT_METHOD = FoodComponent.class.getDeclaredMethod("addEffect", PotionEffect.class, float.class);
Skript.registerEffect(EffApplyPotion.class, "apply [potion[[ ]effect]] %potioneffect% [with probability %-number%]");
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit b0560ed

Please sign in to comment.