Add Balance Update Event.

This commit is contained in:
iBo3oF 2013-11-26 19:46:23 +02:00 committed by KHobbits
parent f677d6a411
commit caa3ac88aa
2 changed files with 46 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import java.util.GregorianCalendar;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.events.UserBalanceUpdateEvent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -466,6 +467,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
} }
} }
super.setMoney(value); super.setMoney(value);
ess.getServer().getPluginManager().callEvent(new UserBalanceUpdateEvent(this.getBase(), value));
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess); Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
} }

View File

@ -0,0 +1,42 @@
package net.ess3.api.events;
import java.math.BigDecimal;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class UserBalanceUpdateEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final BigDecimal balance;
public UserBalanceUpdateEvent(Player player, BigDecimal balance)
{
this.player = player;
this.balance = balance;
}
@Override
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Player getPlayer()
{
return player;
}
public BigDecimal getNewBalance()
{
return balance;
}
}