Respawning With Potions

Discussion in 'Plugin Development' started by Jarglax, Aug 5, 2014.

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

    Jarglax

    Ok.. Can someone gimme the code for respawning with potions like
    @EventHandler
    public void OnPlayerRespawn(PlayerRespawnEvent event) {
    event.getplayer().getinventory().additem()



    ^ Example
    But how do i make it where someone respawns with a potion
     
  2. Offline

    Gater12

  3. Offline

    xAstraah

    Jarglax,

    Code:java
    1. @EventHandler
    2. public void onPlayerRespawn(PlayerRespawnEvent event) {
    3. Player p = (Player) event.getPlayer();
    4.  
    5. p.getInventory().addItem(new ItemStack(Material.DIAMOND, 1));
    6. }
    7.  
    8. //Figure the rest out.
     
  4. Offline

    moe097

    Jarglax

    Use this to give a player a potion, put it in a respawn event:
    Code:java
    1. Potion potion = new Potion(PotionType.YOURPOTION, 1, boolean splash, boolean extended);
    2. ItemStack potionstack = potion.toItemStack(AMOUNT OF POTIONS);
    3. player.getInventory().addItem(potionstack);
     
  5. Offline

    Jarglax

    Potion potion = new Potion creats a error on the first potion

    moe097
    http://prntscr.com/49y1wd
    What i find completely weird is this code and only this code when i add the potions it creates this error this is when i take out the boolean which removes the errors but creates this console error and disabled spawning with anything

    Ok got it to work but how do i make it splash potions i feel dumb being so clueless but i just started coding
    Instead of spreading out its one stack of 64 potions -0.0-

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  6. Offline

    moe097

    Jarglax
    Code:java
    1. Potion potion = new Potion(PotionType.YOURPOTION, 1, true, false);
    2. // The 'True' part is weather its splash or not, the 'false' is weather its extended or not.
     
  7. Offline

    Jarglax

    moe097 I know i got that part but the potions Stack like a 64 stack of potions o.o
     
  8. Offline

    moe097

    Jarglax

    Ops, sorry about that,
    Im not sure, but you could try the:
    "setMaxStackSize()" method.
     
Thread Status:
Not open for further replies.

Share This Page