Applying defined potion effect using config

Discussion in 'Plugin Development' started by Alster551, Jun 13, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Alster551

    So i have this code which ive put together which is meant to give a player a potion effect when they run over a block, i have that bit sorted out (doing something when they run over a block) but i cant get the potion effect to work when getting it from a config.

    code:
    Code:java
    1. player.addPotionEffect(new PotionEffect(PotionEffectType.(getConfig().getString("effect"),getConfig().getString("time"),getConfig().getString("strengh")));
     
  2. Offline

    Mrawesomecookie

  3. Offline

    Alster551

  4. Offline

    Mrawesomecookie

    Alster551
    (PotionEffectType.(getConfig().getString("effect"),getConfig().getString("time"),getConfig().getString("strengh")));
     
  5. Offline

    AoH_Ruthless

    Alster551
    new PotionEffect(PotionEffectType.valueof(getConfig().getString("effect")), getConfig().getInt("time"), getConfig().getInt("strength"));
     
  6. Offline

    Alster551

    AoH_Ruthless i get an error under valueOf:
    The method valueOf(String) is undefined for the type PotionEffectType
     
  7. Offline

    AoH_Ruthless

    Alster551
    Sorry, it's PotionEffectType.getByName(getConfig().getString("effect"))

    Remember that your effect has to be all capitalized!
     
Thread Status:
Not open for further replies.

Share This Page