Creating MoneyDrop extensions

Before we begin: the source files are included in the MoneyDrop.jar file. If something here isn't clear, feel free to take a look at the inner workings yourself, or PM me your question.

The basics
In the MoneyDrop class, the following methods are of interest to you:
dropMoney(Location location, double amount, boolean fireEvent) will drop the specified amount of money at the specified location. If fireEvent is set to true, this will trigger an event that can be cancelled. A boolean is returned wether or not the drop succeeded.
markSpecialDrop(LivingEntity entity, double amount, Plugin plugin) will have the specified entity drop the specified amount when it dies instead of the regular amount. Events involving a marked entity have isSpecialDrop() return true. Marked entities lose their custom value on server restart. Please use your own plugin as argument for this method.
getWorldSettings(String world) will return a settings file for the specified world. This will allow you to edit the config at runtime. Changes at runtime are not saved to the file.

Picking up on the custom events
MoneyDrop uses 3 custom events. You can listen to them in the same way you listen to the normal Bukkit events. Check out the wiki if you need more information on this.

MoneyDropEvent
This one is called every time money is dropped, wether it's from a mob, from a player, or a custom drop.
You can cancel this event, edit the stacks of money that will drop and the location where they will drop.
Please keep in mind that getSourceEvent() will return null if this is a custom drop. If the source event is null, getEntity() will be null too. getDropLocation() can also be null, but this unlikely. If the location is null, the event will not be executed.
Keep in mind that entities might have a custom drop amount. If one of these entities is involved, isSpecialDrop() will return true.

PlayerMoneyDropEvent
This event will be called when a player drops money. It has the same methods as MoneyDropEvent, along with the ability to set the amount of money the player will lose. If this amount is negative, the player will gain money.

MoneyPickupEvent
This event will be called when a player picks up money.
This event can be cancelled, and the amount of money the player will gain can be edited. A negative amount will cause the player to lose money.


Comments

Posts Quoted:
Reply
Clear All Quotes