Wrong Java?

            PotionEffect potion = **PotionEffect.builder()**.potionType(PotionEffectType.HASTE)
                    .duration(10).amplifier(5).build();

static interface method invocations are not supported on this language level

Whats the problem?

make sure your java-compiler is set to Java 8

what IDE are you using? IntelliJ or Eclipse?

You should be able to specify in your build.gradle

sourceCompatibility = "1.8";
targetCompatibility = "1.8";
1 Like

Thanks for the help :slight_smile:

1 Like

Quick Question:

PotionEffectData effects = player.getOrCreate(PotionEffectData.class).get();
effects.addElement(potion);

The Method “addElement” does not exists, but in Docs is it so?

The method addElement does exist. Did you complete your potion build?

For example:

PotionEffect potion = PotionEffect.builder().potionType(PotionEffectTypes.HASTE)
    .duration(10).amplifier(5).build();

When creating the potion variable, you need to have build at the end to return a PotionEffect rather than a PotionEffectBuilder

I have build it, but there is isnt the effects.addElement Methode

I haven’t tested this, but you may need to use effects.effects().addElement(...)

Thanks, its effects.effects().add()
i was confused about that…

Thanks :slight_smile:

1 Like