Class CustomDropTypeHandler

java.lang.Object
de.marcely.bedwars.api.game.spawner.CustomDropTypeHandler

public abstract class CustomDropTypeHandler extends Object
Custom implementation for overrding drop and shop capabilities of a drop type.

An example use case: If you want to buy with experience points. They don't exist as items, but they can still be dropped as xp orbs. When picked up, players are able to use their virtual balance to buy items.

  • Constructor Details

    • CustomDropTypeHandler

      public CustomDropTypeHandler(String id, Plugin plugin)
      Parameters:
      id - The id that is later used within the spawners config file
      plugin - Your plugin implementing this handler
  • Method Details

    • handleDrop

      public abstract void handleDrop(Spawner spawner, Location dropLocation)
      Gets called whenever the spawner drops something.

      Being invoked after it has been passed to Bukkit's event pipeline.

      Parameters:
      spawner - The spawner that's being spawned
      dropLocation - The location at which it shall drop the item. Can differ to the one configured inside the spawner
    • getHoldingAmount

      public abstract int getHoldingAmount(Player player)
      Get the amount of items the player is holding within its inventory.

      This is used to i.a. determine whether a player has the balance to buy an item.

      Parameters:
      player - The player to check
      Returns:
      The amount of items the player is holding
    • take

      public abstract void take(Player player, int amount)
      Take a given amount from a player's balance.

      This is used to i.a. remove the items from the player's inventory after buying an item.

      Parameters:
      player - The player to take the items from
      amount - The amount to take
    • give

      public abstract void give(Player player, int amount)
      Give a given amount to a player's balance.

      This is used to i.a. give the items to the player's inventory after buying an item that is a drop type implementing this custom handler.

      Parameters:
      player - The player to give the items to
      amount - The amount to give
    • getId

      public final String getId()
      The id of this custom spawner
      Returns:
      The identifier
    • getPlugin

      public final Plugin getPlugin()
      The plugin that created this handler
      Returns:
      The plugin whose ClassLoader is equal to the one of this class