Class O2PlayerCommon

java.lang.Object
net.pottercraft.ollivanders2.player.O2PlayerCommon

public final class O2PlayerCommon extends Object
Player common functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Multiplier for spell casting, when using someone else's wand, strength is halved
    static final double
    Multiplier for spell casting, when using their destined wand, this is 1, so no effect.
    static final double
    Multiplier for spell casting, when using the Elder wand, strength is doubled
  • Constructor Summary

    Constructors
    Constructor
    Description
    O2PlayerCommon(@NotNull Ollivanders2 plugin)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull List<org.bukkit.entity.Player>
    Get a list of all the sorted online players
    @NotNull org.bukkit.entity.EntityType
    getAnimagusForm(@NotNull UUID pid)
    Get the animagus form for this player, check by uuid so this can be run for players who are not online too
    static void
    givePlayerKit(@NotNull org.bukkit.entity.Player player, @NotNull List<org.bukkit.inventory.ItemStack> kit)
    Gives a player an item stack
    static boolean
    hasPotionEffect(@NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.potion.PotionEffectType effectType)
    Does a player have a particular potion effect?
    boolean
    isAllowedAnimagusForm(@NotNull org.bukkit.entity.EntityType form)
    Determine if an EntityType is an allowed Animagus form.
    static boolean
    isInvisible(@NotNull org.bukkit.entity.Player player)
    Is this player invisible?
    static void
    restoreFullHealth(@NotNull org.bukkit.entity.Player player)
    Restore a player to full health
    double
    wandCheck(@NotNull org.bukkit.entity.Player player)
    Checks what kind of wand a player holds in their primary hand.
    double
    wandCheck(@NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.inventory.EquipmentSlot hand)
    Checks what kind of wand a player holds.
    static boolean
    wearingInvisibilityCloak(@NotNull org.bukkit.entity.Player player)
    Does the player have the Cloak of Invisibility

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • rightWand

      public static final double rightWand
      Multiplier for spell casting, when using their destined wand, this is 1, so no effect.
      See Also:
    • wrongWand

      public static final double wrongWand
      Multiplier for spell casting, when using the Elder wand, strength is doubled
      See Also:
    • elderWand

      public static final double elderWand
      Multiplier for spell casting, when using someone else's wand, strength is halved
      See Also:
  • Constructor Details

    • O2PlayerCommon

      public O2PlayerCommon(@NotNull @NotNull Ollivanders2 plugin)
      Constructor
      Parameters:
      plugin - a reference to the MC plugin
  • Method Details

    • getAnimagusForm

      @NotNull public @NotNull org.bukkit.entity.EntityType getAnimagusForm(@NotNull @NotNull UUID pid)
      Get the animagus form for this player, check by uuid so this can be run for players who are not online too
      Parameters:
      pid - the id of the player to check
      Returns:
      the animagus form for this player - should always be the same since it is based on a hash of their PID
    • isAllowedAnimagusForm

      public boolean isAllowedAnimagusForm(@NotNull @NotNull org.bukkit.entity.EntityType form)
      Determine if an EntityType is an allowed Animagus form.
      Parameters:
      form - the animagus form to check
      Returns:
      true if this is an allowed form, false otherwise
    • wandCheck

      public double wandCheck(@NotNull @NotNull org.bukkit.entity.Player player)
      Checks what kind of wand a player holds in their primary hand. Returns a value based on the wand and its relation to the player.

      Assumes:holdsWand has already been checked

      Parameters:
      player - player being checked. The player must be holding a wand.
      Returns:
      2 - the wand is not player's type AND/OR is not allied to player.
      1 - the wand is player's type and is allied to player OR the wand is the elder wand and is not allied to player.
      0.5 - the wand is the elder wand and is allied to player.
    • wandCheck

      public double wandCheck(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.inventory.EquipmentSlot hand)
      Checks what kind of wand a player holds. Returns a value based on the wand and its relation to the player.

      Assumes: player is holding a wand in the equipment slot passed in.

      Parameters:
      player - player being checked. The player must be holding a wand.
      hand - the hand that is holding the wand to check.
      Returns:
      2 - The wand is not player's type AND/OR is not allied to player
      >1 - The wand is player's type and is allied to player OR the wand is the elder wand and is not allied to player
      0.5 - The wand is the elder wand and is allied to player.
    • restoreFullHealth

      public static void restoreFullHealth(@NotNull @NotNull org.bukkit.entity.Player player)
      Restore a player to full health
      Parameters:
      player - the player to restore
    • getAllOnlineSortedPlayers

      @NotNull public @NotNull List<org.bukkit.entity.Player> getAllOnlineSortedPlayers()
      Get a list of all the sorted online players
      Returns:
      the list of sorted online players
    • givePlayerKit

      public static void givePlayerKit(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull List<org.bukkit.inventory.ItemStack> kit)
      Gives a player an item stack
      Parameters:
      player - the player to give the items to
      kit - the items to give
    • hasPotionEffect

      public static boolean hasPotionEffect(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.potion.PotionEffectType effectType)
      Does a player have a particular potion effect?
      Parameters:
      player - the player to check
      effectType - the potion effect type to check for
      Returns:
      true if the player has this potion effect, false otherwise
    • wearingInvisibilityCloak

      public static boolean wearingInvisibilityCloak(@NotNull @NotNull org.bukkit.entity.Player player)
      Does the player have the Cloak of Invisibility
      Parameters:
      player - player to be checked
      Returns:
      true if yes, false if no
    • isInvisible

      public static boolean isInvisible(@NotNull @NotNull org.bukkit.entity.Player player)
      Is this player invisible?
      Parameters:
      player - the player to check
      Returns:
      true if they are either wearing an invisibility cloak or have an invisibility potion effect, false otherwise