Interface Spawner


public interface Spawner
Represents a single (existing) spawner inside an arena. This is used to periodically spawn items.
  • Method Details

    • getArena

      Arena getArena()
      Returns the arena in which the spawner was added.
      Returns:
      The arena on which the spawner has been added
    • getLocation

      XYZ getLocation()
      Returns where the spawner has been added.
      Returns:
      The location of the spawner
    • getDropType

      DropType getDropType()
      Returns the type of the spawner.
      Returns:
      The drop type
    • getCurrentDropDuration

      double getCurrentDropDuration()
      Returns the time in seconds it takes until it drops something again.
      Returns:
      Duration in seconds until it drops something
    • getDropDurationModifiers

      List<SpawnerDurationModifier> getDropDurationModifiers()
      Use SpawnerDurationModifiers to modify the time until something gets dropped. Plugin goes through them from bottom to top to calculate getCurrentDropDuration().

      It's NOT safe to modify this List.

      Default ones only initiate with the start of a match.

      Returns:
      The list containing all modifiers for calculating the drop duration
    • addDropDurationModifier

      SpawnerDurationModifier addDropDurationModifier(String id, Plugin plugin, SpawnerDurationModifier.Operation operation, double value)
      Adds a new modifier to the top of getDropDurationModifiers(). Through this you're able to change the duration until something gets dropped.

      It's safe to have multiple modifiers with the same name, but it's not recommended to do so. Additionally it's not a must for the id to follow a specific format. It's recommended to follow plugin:action_name

      Keep in mind that they get reset with every start of a match

      Parameters:
      id - The unique id of what this spawner is doing
      plugin - The plugin that's invoking this
      operation - What mathematical operation shall be done with the previous number to obtain the new one
      value - Used in combination with operation to calculate the final number (in seconds)
      Returns:
      The new modifier that has been to the top of getDropDurationModifiers()
    • removeDropDurationModifier

      boolean removeDropDurationModifier(SpawnerDurationModifier modifier)
      Removes an existing modifier.

      Modifiers are being used to modify the time until something gets dropped.

      Parameters:
      modifier - The modifier instance that shall be removed
      Returns:
      true if has been found and removed
    • getDropDurationModifier

      @Nullable @Nullable SpawnerDurationModifier getDropDurationModifier(String id)
      Tries to locate a modifier that has been added to this spawner by it's id.

      It's possible that there are multiple modifiers with an id, this method will only return one of them.

      Default ones only initiate with the start of a match.

      Parameters:
      id - The id that the modifier has
      Returns:
      The modifier instance that has the given id. null if none has been found
    • getInternalClock

      int getInternalClock()
      Returns the time in ticks of the internal clock that's being used for this spawner. The returned value might differ from other spawners. It's being used to determinate when the next drop should occur. It does not increase when the game is not running and gets reset when the game end.
      Returns:
      The internal time of this spawner in ticks
    • getRemainingNextDropTime

      int getRemainingNextDropTime()
      Returns the time in ticks until the spawner drops something again
      Returns:
      The time in ticks that needs to pass until something drops
    • getOverridingHologramLines

      @Nullable @Nullable String[] getOverridingHologramLines()
      While generally all hologram lines are basically the same you may make them unique per spawner using this spawner using setOverridingHologramLines(String[]). This method returns the currently set ones, or null if none has been set.
      Returns:
      The lines that (possibly) will be shown above the spawners during a game instead of the global variant
    • setOverridingHologramLines

      void setOverridingHologramLines(@Nullable @Nullable String[] lines)
      While generally all hologram lines are basically the same you may make them unique per spawner using this spawner using this method. You may pass null to instead again use the default one.

      Keep in mind that these are specific to this spawner and that they'll disappear after the arena or the spawner gets unloaded.

      Parameters:
      lines - The new lines that (possibly) will be shown above the spawners during a game instead of the global variant
    • drop

      default void drop()
      Make the spawner do its thing.

      This will do the exact same thing as if the game would drop it naturally. By this SpawnerDropEvent and everything else is also getting called.

      Keep in mind that properties, such as DropType.getMaxNearbyItems(), can prevent the thing from being spawned

    • drop

      default void drop(boolean overrideLimit)
      Make the spawner do its thing.

      This will do the exact same thing as if the game would drop it naturally. By this SpawnerDropEvent and everything else is also getting called.

      Keep in mind that properties, such as DropType.getMaxNearbyItems(), can prevent the thing from being spawned

      Parameters:
      overrideLimit - weather or not the spawn limit should be overridden
    • drop

      void drop(boolean overrideLimit, @Nullable @Nullable ItemStack[] droppingMaterials)
      Make the spawner do its thing.

      This will do the exact same thing as if the game would drop it naturally. By this SpawnerDropEvent and everything else is also getting called. *

      Keep in mind that properties, such as DropType.getMaxNearbyItems(), can prevent the thing from being spawned

      Parameters:
      overrideLimit - weather or not the spawn limit should be overridden
      droppingMaterials - an array of ItemStacks the spawner should drop. Note that only ItemStacks native to the spawner will count towards the maxNearbyItems count (or gen cap) of this spawner
    • getNearbyItemsCount

      int getNearbyItemsCount()
      Counts all the items that are currently uncollected in the spawner.

      Note: this count only includes items native to this spawner that have never been picked up by a player before.

      Returns:
      return the number of items in the spawner waiting for pickup
    • setMaxNearbyItems

      void setMaxNearbyItems(int max)
      Change the max nearby items for this spawner. By default, the spawner is using the value attached to the DropType, but you can change it with this method
      Parameters:
      max - The number of items that can be in the spawner at the same time.
    • getMaxNearbyItems

      int getMaxNearbyItems()
      Returns the max amount of spawner items that can be in this spawner before it stops spawning new items
      Returns:
      The max amount of items that can be in a spawner at once.
    • getHologram

      @Nullable @Nullable HologramEntity getHologram()
      Gets the hologram that is used to display i.a. the remaining time and the block.

      May be null if e.g. the round hasn't started yet or it has been disabled.

      Returns:
      Get the visual hologram of this spawner. May be null
    • exists

      boolean exists()
      Returns if the spawner still exists on the arena.
      Returns:
      It's existence
    • remove

      boolean remove()
      Tries to remove the spawner from the arena.

      Can fail when the spawner already doesn't exist.

      Returns:
      true if it was successful