Class CustomDropTypeHandler
java.lang.Object
de.marcely.bedwars.api.game.spawner.CustomDropTypeHandler
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intgetHoldingAmount(Player player) Get the amount of items the player is holding within its inventory.final StringgetId()The id of this custom spawnerfinal PluginThe plugin that created this handlerabstract voidGive a given amount to a player's balance.abstract voidhandleDrop(Spawner spawner, Location dropLocation) Gets called whenever the spawner drops something.abstract voidTake a given amount from a player's balance.
-
Constructor Details
-
CustomDropTypeHandler
- Parameters:
id- The id that is later used within the spawners config fileplugin- Your plugin implementing this handler
-
-
Method Details
-
handleDrop
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 spawneddropLocation- The location at which it shall drop the item. Can differ to the one configured inside the spawner
-
getHoldingAmount
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
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 fromamount- The amount to take
-
give
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 toamount- The amount to give
-
getId
The id of this custom spawner- Returns:
- The identifier
-
getPlugin
The plugin that created this handler- Returns:
- The plugin whose ClassLoader is equal to the one of this class
-