Solved Giving Players Potion/and Potion Effects

Discussion in 'Plugin Development' started by Giorgio, Sep 27, 2012.

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

    Giorgio

    Hello everyone i have 2 quick questions how would i give a player a potion effect like blindness for a short amount of time. Also how would i add so if a player types /harming it gives them a harming potion? thats it thank you for reading and hopefully helping me!
     
  2. Offline

    gregthegeek

    Code:
    <player>.addPotionEffect(new PotionEffect(PotionEffectType.HARM, <duration>, <amplifier>));
     
  3. Offline

    Giorgio

    gregthegeek

    Ok thank you, but how would i add give players pots of potion? Ones that can be placed in there inventory.
     
  4. Offline

    brord

  5. Offline

    Giorgio

  6. Offline

    brord

    glad i could help ;)
     
  7. Offline

    Giorgio

    Brord im still having trouble, i can't seem to place a splash potion of harming "373:16396" when i type this in my code it gives me a syntax error. How would i right this in Java form?
     
  8. Offline

    Muddr

    try something like this.
    Code:
    PlayerInventory inv = player.getInventory();
    ItemStack item = new ItemStack(373, 1, (short) 16396);
    inv.addItem(item);
    player.updateInventory();
     
    kroltan likes this.
  9. Offline

    brord

  10. Offline

    Giorgio

    Muddr
    brord

    Ok perfect, thank you guys!
    but one quick question whats for updating the players inventory?
     
  11. Offline

    Muddr

    the last line of that code I posted. :D
     
  12. Offline

    Giorgio

    yea why did you need to add it?
     
  13. Offline

    Muddr

    so it updates the players inventory, a lot of times when you mess with players inventories it doesn't always update on the client's screen
     
  14. Offline

    Giorgio

    Oh never knew this, thank you for explaing.
     
  15. Offline

    CeramicTitan Retired Staff

    player.updateInventory();
    Got deprecated in the newer versions of the craftbukkit api
     
  16. Offline

    Muddr

    it's been deprecated for awhile now.. but there's no other way of doing it.
     
  17. Offline

    CeramicTitan Retired Staff

    So how can you use it?
     
  18. Offline

    matzefratze123

    player.updateInventory(); still works. Just ignore the deprecation and add an @SuppressWarning to it.
     
  19. Offline

    colony88

    Just use it, ignore the warnings
     
  20. Offline

    CeramicTitan Retired Staff

    But it has a massive dash through it?
     
  21. Offline

    colony88

    Yeah just use @SuppressWarning("deprecated") and ignore the "error"
     
  22. Offline

    Giorgio

    colony88

    Deprecation = disposal of so, maybe there is a new method to get about it?
     
  23. Offline

    colony88

    There is no other method at the moment, so just use it.
     
Thread Status:
Not open for further replies.

Share This Page