mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
Add KitClaimEvent (#3197)
Adds an event fired when a kit is expanded for a user. Fixes #3196.
This commit is contained in:
parent
a043de3e44
commit
96590a3389
@ -8,6 +8,8 @@ import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.events.KitClaimEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -149,6 +151,12 @@ public class Kit {
|
||||
IText input = new SimpleTextInput(items);
|
||||
IText output = new KeywordReplacer(input, user.getSource(), ess, true, true);
|
||||
|
||||
KitClaimEvent event = new KitClaimEvent(user, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean spew = false;
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||
final boolean currencyIsSuffix = ess.getSettings().isCurrencySymbolSuffixed();
|
||||
|
55
Essentials/src/net/ess3/api/events/KitClaimEvent.java
Normal file
55
Essentials/src/net/ess3/api/events/KitClaimEvent.java
Normal file
@ -0,0 +1,55 @@
|
||||
package net.ess3.api.events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.earth2me.essentials.Kit;
|
||||
|
||||
import net.ess3.api.IUser;
|
||||
|
||||
/**
|
||||
* Called when the player is given a kit
|
||||
*/
|
||||
public class KitClaimEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Kit kit;
|
||||
private IUser user;
|
||||
private boolean cancelled;
|
||||
|
||||
public KitClaimEvent(IUser user, Kit kit) {
|
||||
super(!Bukkit.getServer().isPrimaryThread());
|
||||
this.user = user;
|
||||
this.kit = kit;
|
||||
}
|
||||
|
||||
public IUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public Kit getKit() {
|
||||
return kit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user