Potions... How to create it.

Discussion in 'Plugin Development' started by bfgbfggf, May 12, 2013.

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

    bfgbfggf

    How to create potion?
    And i can set different time for every effect of potion?
    That code start with string:
    Code:
    PotionEffect#Power#Time:PotionEffect#Power#Time.... 
    Code:java
    1.  
    2. PotionMeta ItemMeta = (PotionMeta) Item.getItemMeta();
    3. for (String Potions : ItemAndEffects[1].split(":")) {
    4. String[] PotionAndTime = Potions.split("#");
    5. String PotionName = PotionAndTime[0];
    6. int Power = Integer.parseInt(PotionAndTime[1]);
    7. int Time = Integer.parseInt(PotionAndTime[2]);
    8. //and... I don't know how next.
    9. }
     
  2. You can't create "new" potions because the client would not recognize it, but yes you can set diffrent times per potion using a runnable.
     
  3. Offline

    crushh87

    Okay, the only way to really create a new potion is by using one of the unused potions

    I created a 2 of them at one point and if you would like to see the class you can here

    http://pastebin.com/UFaw9yC8
     
  4. bfgbfggf
    I see you want to parse a string into an effect, loaded from a config or something I take it ?
    Well, to avoid having to explain alot of stuff, I've already made this for my plugin and here's the class that holds the code: https://github.com/THDigi/RecipeMan...thehunters/digi/recipeManager/Tools.java#L740
    The parsePotion() and parsePotionEffect() methods.
    They're obviously specially designed for my plugin but you should be able to understand what you need to do to create a potion and a potion effect.
    And you can set diferent time for each effect since you're creating a new object and adding it to the list of effects.

    crushh87
    Not really, you can have potions with mixed effects.
     
Thread Status:
Not open for further replies.

Share This Page