Solved Giving a player potion effects on command

Discussion in 'Plugin Development' started by Minermax7, May 10, 2014.

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

    Minermax7

    Hey guys,
    I ran into some trouble, I'm trying to make a quick plugin that makes you invisible on typing a command.. I just don't seem to know to to use the player.addPotionEffects.. I know this is probably super easy to get past but I would still kindly appreciate any help given.
    http://prntscr.com/3hvu29

    Kind regards,
    Dylan.
     
  2. Offline

    aninsanellama

    To add a single potion effect to a specified player, you must simply create an instance of the PotionEffect class:
    Code:java
    1. player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 3*20, 1));


    To add more than one you need to pass in an array of PotionEffects. You're passing in an array of PotionEffectTypes, which the player.addPotionEffects() method does not take. In a similar way to the following, to solve your problem:
    Code:java
    1. player.addPotionEffects(Arrays.asList(new PotionEffect(PotionEffectType.INVISIBILITY, 3*20, 1), /* another potion effect */));
     
Thread Status:
Not open for further replies.

Share This Page