Class LevelManager

java.lang.Object
me.lokka30.levelledmobs.managers.LevelManager
All Implemented Interfaces:
LevelInterface

public class LevelManager extends Object implements LevelInterface
Generates levels and manages other functions related to levelling mobs
Since:
2.4.0
  • Field Details

    • summonedOrSpawnEggs

      public final Map<org.bukkit.entity.LivingEntity,Object> summonedOrSpawnEggs
    • summonedOrSpawnEggs_Lock

      public static final Object summonedOrSpawnEggs_Lock
    • doCheckMobHash

      public boolean doCheckMobHash
    • entitySpawnListener

      public EntitySpawnListener entitySpawnListener
    • FORCED_BLOCKED_ENTITY_TYPES

      public final HashSet<org.bukkit.entity.EntityType> FORCED_BLOCKED_ENTITY_TYPES
      The following entity types *MUST NOT* be levellable.
    • nametagAutoUpdateTask

      public SchedulerResult nametagAutoUpdateTask
  • Constructor Details

    • LevelManager

      public LevelManager(@NotNull @NotNull LevelledMobs main)
  • Method Details

    • clearRandomLevellingCache

      public void clearRandomLevellingCache()
    • generateLevel

      public int generateLevel(@NotNull @NotNull LivingEntityWrapper lmEntity)
      This method generates a level for the mob. It utilises the levelling mode specified by the administrator through the settings.yml configuration.

      Thread-safety intended, but not tested.

      Specified by:
      generateLevel in interface LevelInterface
      Parameters:
      lmEntity - the entity to generate a level for
      Returns:
      a level for the entity
    • generateLevel

      public int generateLevel(@NotNull @NotNull LivingEntityWrapper lmEntity, int minLevel_Pre, int maxLevel_Pre)
      This method generates a level for the mob. It utilises the levelling mode specified by the administrator through the settings.yml configuration.

      Thread-safety intended, but not tested.

      Specified by:
      generateLevel in interface LevelInterface
      Parameters:
      lmEntity - the entity to generate a level for
      minLevel_Pre - the minimum level to be used for the mob
      maxLevel_Pre - the maximum level to be used for the mob
      Returns:
      a level for the entity
    • getPlayerLevelSourceNumber

      @NotNull public @NotNull PlayerLevelSourceResult getPlayerLevelSourceNumber(@Nullable @Nullable org.bukkit.entity.Player player, @NotNull @NotNull LivingEntityWrapper lmEntity, @NotNull @NotNull String variableToUse)
    • getMinAndMaxLevels

      public MinAndMaxHolder getMinAndMaxLevels(@NotNull @NotNull LivingEntityInterface lmInterface)
    • setLevelledItemDrops

      public void setLevelledItemDrops(LivingEntityWrapper lmEntity, @NotNull @NotNull List<org.bukkit.inventory.ItemStack> currentDrops, boolean disableItemBoost)
    • multiplyDrop

      public void multiplyDrop(LivingEntityWrapper lmEntity, @NotNull @NotNull org.bukkit.inventory.ItemStack currentDrop, double addition, boolean isCustomDrop)
    • removeVanillaDrops

      public void removeVanillaDrops(@NotNull @NotNull LivingEntityWrapper lmEntity, List<org.bukkit.inventory.ItemStack> drops)
    • getLevelledExpDrops

      public int getLevelledExpDrops(@NotNull @NotNull LivingEntityWrapper lmEntity, double xp)
    • getNametag

      @NotNull public @NotNull NametagResult getNametag(@NotNull @NotNull LivingEntityWrapper lmEntity, boolean isDeathNametag)
    • getNametag

      @NotNull public @NotNull NametagResult getNametag(@NotNull @NotNull LivingEntityWrapper lmEntity, boolean isDeathNametag, boolean preserveMobName)
    • updateNametag

      @NotNull public @NotNull NametagResult updateNametag(@NotNull @NotNull LivingEntityWrapper lmEntity, @NotNull @NotNull StringReplacer nametag, boolean preserveMobName, String customDeathMessage)
    • replaceStringPlaceholders

      @NotNull public @NotNull String replaceStringPlaceholders(@NotNull @NotNull String text, @NotNull @NotNull LivingEntityWrapper lmEntity, boolean usePAPI, @Nullable @Nullable org.bukkit.entity.Player player, boolean preserveMobName)
    • updateNametagWithDelay

      public void updateNametagWithDelay(@NotNull @NotNull LivingEntityWrapper lmEntity)
    • updateNametag

      public void updateNametag(LivingEntityWrapper lmEntity)
    • updateNametag

      public void updateNametag(@NotNull @NotNull LivingEntityWrapper lmEntity, NametagResult nametag, List<org.bukkit.entity.Player> players)
    • startNametagAutoUpdateTask

      public void startNametagAutoUpdateTask()
    • startNametagTimer

      public void startNametagTimer()
    • stopNametagAutoUpdateTask

      public void stopNametagAutoUpdateTask()
    • getLevellableState

      @NotNull public @NotNull LevellableState getLevellableState(@NotNull @NotNull LivingEntityInterface lmInterface)
      Description copied from interface: LevelInterface
      Check if an existing mob is allowed to be levelled, according to the user's configuration.

      Thread-safety intended, but not tested.

      Specified by:
      getLevellableState in interface LevelInterface
      Parameters:
      lmInterface - target mob
      Returns:
      if the mob is allowed to be levelled (yes/no), with reason
    • applyLevelToMob

      public void applyLevelToMob(@NotNull @NotNull LivingEntityWrapper lmEntity, int level, boolean isSummoned, boolean bypassLimits, @NotNull @NotNull HashSet<AdditionalLevelInformation> additionalLevelInformation)
      This method applies a level to the target mob.

      You can run this method on a mob regardless if they are already levelled or not.

      This method DOES NOT check if it is LEVELLABLE. It is assumed that plugins make sure this is the case (unless they intend otherwise).

      It is highly recommended to leave bypassLimits = false, unless the desired behaviour is to override the user-configured limits.

      Thread-safety intended, but not tested.

      Specified by:
      applyLevelToMob in interface LevelInterface
      Parameters:
      lmEntity - target mob
      level - the level the mob should have
      isSummoned - if the mob was spawned by LevelledMobs, not by the server
      bypassLimits - whether LM should disregard max level, etc.
      additionalLevelInformation - used to determine the source event
    • isLevelled

      public boolean isLevelled(@NotNull @NotNull org.bukkit.entity.LivingEntity livingEntity)
      Check if a LivingEntity is a levelled mob or not. This is determined *after* MobPreLevelEvent.

      Thread-safety intended, but not tested.

      Specified by:
      isLevelled in interface LevelInterface
      Parameters:
      livingEntity - living entity to check
      Returns:
      if the mob is levelled or not
    • getLevelOfMob

      public int getLevelOfMob(@NotNull @NotNull org.bukkit.entity.LivingEntity livingEntity)
      Retrieve the level of a levelled mob.

      Thread-safety intended, but not tested.

      Specified by:
      getLevelOfMob in interface LevelInterface
      Parameters:
      livingEntity - the levelled mob to get the level of
      Returns:
      the mob's level
    • removeLevel

      public void removeLevel(@NotNull @NotNull LivingEntityWrapper lmEntity)
      Un-level a mob.
      Specified by:
      removeLevel in interface LevelInterface
      Parameters:
      lmEntity - levelled mob to un-level