Solved Can someone explain why it's adding one?

Discussion in 'Plugin Development' started by HeadGam3z, Jul 27, 2014.

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

    HeadGam3z

    I'm trying to add a strength II potion effect to a player, but it always adds one to the amplifier - making it strength III.
    Does anyone know why this is happening? I know I could just subtract the int by 1 to fix this, but I'd really like to know why it's adding one. lol
    Code:java
    1. FileConfiguration co = Main.plugin.getConfig();
    2. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20 * co.getInt("Settings.Potions.Strength.Time"), co.getInt("Settings.Potions.Strength.Amplifier")));

    Code:
    Settings:
      Potions:
        Strength:
          Time: 300
          Cooldown: 1200
          Amplifier: 2
     
  2. Offline

    rfsantos1996

    Amplifier 0 = PotionEffect level 1, so on code, you just use parenthesis (I belive it is more readable, IMO) and substract one
     
  3. Offline

    Garris0n

    Indices start at zero.
     
Thread Status:
Not open for further replies.

Share This Page