Class O2Potion

java.lang.Object
net.pottercraft.ollivanders2.potion.O2Potion
Direct Known Subclasses:
ANIMAGUS_POTION, BABBLING_BEVERAGE, BARUFFIOS_BRAIN_ELIXIR, COMMON_ANTIDOTE_POTION, CURE_FOR_BOILS, DRAUGHT_OF_LIVING_DEATH, FORGETFULNESS_POTION, HUNGER_POTION, ICE_POTION, MEMORY_POTION, O2SplashPotion, OCULUS_FELIS, REGENERATION_POTION, SATIATION_POTION, SHRINKING_SOLUTION, SLEEPING_DRAUGHT, STRENGTHENING_SOLUTION, SWELLING_SOLUTION, WEAKNESS_POTION, WIDEYE_POTION, WIT_SHARPENING_POTION, WOLFSBANE_POTION

public abstract class O2Potion extends Object
Ollivanders2 magical potion.

O2Potions can have either or both of the following types of effects:
PotionEffect - this is a standard Minecraft potion effect such as Night Vision and is set in the item metadata in the brew().
Ollivanders Effect - effects related to the mechanics of the Ollivanders plugin. These are applied on the potion drink action in OllivandersListener in the onPlayerDrink().

See Also:
  • Field Details

    • potionType

      protected O2PotionType potionType
      The type this potion is.
    • ingredients

      protected Map<O2ItemType,Integer> ingredients
      The ingredients list for this potion.
    • text

      protected String text
      The description text for this potion in books. Required or potion cannot be written in a book.
    • flavorText

      protected ArrayList<String> flavorText
      Flavor text for this potion in books, etc. Optional.
    • potionColor

      protected org.bukkit.Color potionColor
      Color of this potion.
    • duration

      protected int duration
      The duration for this potion
    • usesModifier

      public double usesModifier
      The modifier for this potion based on usage.
    • potionSuccessMessage

      protected String potionSuccessMessage
      The success message to send when this potion is consumed
  • Constructor Details

    • O2Potion

      public O2Potion(@NotNull @NotNull Ollivanders2 plugin)
      Constructor
      Parameters:
      plugin - a callback to the plugin
  • Method Details

    • getIngredientsText

      @NotNull protected @NotNull String getIngredientsText()
      Get the ingredients text for this potion
      Returns:
      the recipe text for this ingredient
    • getPotionType

      @NotNull public @NotNull O2PotionType getPotionType()
      Get the type of this potion.
      Returns:
      the type of potion
    • getName

      @NotNull public @NotNull String getName()
      Get the name of this potion
      Returns:
      the name of the potion
    • getIngredients

      @NotNull public @NotNull Map<O2ItemType,Integer> getIngredients()
      Get the ingredients list for this potion
      Returns:
      a Map of the ingredients for this potion
    • getText

      @NotNull public @NotNull String getText()
      Get the description text for this potion. This can be used to write books, for lessons, or other in-game messages. Description text is required for adding a spell to an Ollivanders2 book.
      Returns:
      the description text for this potion
    • getFlavorText

      @Nullable public @Nullable String getFlavorText()
      Get the flavor text for this potion. This can be used to make books, lessons, and other descriptions of spells more interesting. Flavor text is optional.
      Returns:
      the flavor text for this potion.
    • getMagicBranch

      @NotNull public @NotNull O2MagicBranch getMagicBranch()
      Get the branch of magic for this potion
      Returns:
      the branch of magic for this potion
    • getLevel

      @NotNull public @NotNull MagicLevel getLevel()
      Get the level of magic for this potion
      Returns:
      the level of magic for this potion
    • getPotionSuccessMessage

      @NotNull public @NotNull String getPotionSuccessMessage()
      Get the potion success message used in drink()
      Returns:
      the potion success message
    • checkRecipe

      public boolean checkRecipe(@NotNull @NotNull Map<O2ItemType,Integer> cauldronIngredients)
      Check the recipe for this potion against a set of ingredients.
      Parameters:
      cauldronIngredients - the ingredients found in the cauldron
      Returns:
      true if the ingredient list matches this potion recipe exactly, false otherwise
    • brew

      @NotNull public @NotNull org.bukkit.inventory.ItemStack brew(@NotNull @NotNull org.bukkit.entity.Player brewer, boolean checkCanBrew)
      Brew this potion.
      Parameters:
      brewer - the player brewing the potion
      checkCanBrew - should we enforce checking if the brewer can brew or not
      Returns:
      an ItemStack with a single bottle of this potion
    • createPotionItemStack

      public org.bukkit.inventory.ItemStack createPotionItemStack(int amount)
      Create an ItemStack for this potion with the specified amount.

      Sets up the potion metadata including display name, color, custom effects, and NBT tags for potion type identification.

      Parameters:
      amount - the number of potions in the ItemStack
      Returns:
      an ItemStack containing the potion, or a bad potion if metadata creation fails
    • brewBadPotion

      @NotNull public static @NotNull org.bukkit.inventory.ItemStack brewBadPotion()
      Brew a random bad potion.
      Returns:
      a random bad potion
    • drink

      public abstract void drink(@NotNull @NotNull org.bukkit.entity.Player player)
      Drink this potion and do effects
      Parameters:
      player - the player who drank the potion
    • setUsesModifier

      protected void setUsesModifier(@NotNull @NotNull O2Player o2p)
      Sets the uses modifier that takes into account potion brew count and level, if years is enabled.
      Parameters:
      o2p - the player who is brewing the potion