Code for potions?

Discussion in 'Plugin Development' started by bionicangel1098, Feb 3, 2014.

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

    bionicangel1098

    How would i get the code for a potion, i got this:
    Code:java
    1. pInv.addItem(new ItemStack(Material.POTION, 16));

    how would i make that 16 slash healing potions?
    Also how would i do this:
    Code:java
    1. evtPlayer.setGameMode();

    what do i have to put in the () to make their gamemode survival?
     
  2. Offline

    XpertHax

    Iroh Move this to Plugin development section?
     
  3. Offline

    Iroh

    Moved to plugin dev.
    XpertHax reports are a better way to get things moved I check those as well.
     
  4. Offline

    Cryices

    Code:
    Potion speed_potion = new Potion(PotionType.SPEED, 1); //Creates a new Speed 1 potion
    ItemStack stack = speed_potion.toItemStack(1);//converts potion to item stack
    player.getInventory().addItem(stack);//adds item to players inventory
    or

    Code:
    ItemStack potion = new ItemStack(Material.POTION, <amount>, <subtype>)
    //Example
    ItemStack potion = new ItemStack(Material.POTION, 1, 8289);
     
  5. Offline

    Superckl1

    bionicangel1098

    Code:java
    1. new Potion(PotionType.INSTANT_HEAL).toItemStack(1);


    Use this code to generate your required potion. The PotionType may be off a bit, I wrote that without eclipse.

    I believe it's just:
    Code:java
    1. Player.setGameMode(GameMode.SURVIVAL);

    to set a player's gamemode.
     
Thread Status:
Not open for further replies.

Share This Page