Add McMMOPlayerUnarmEvent

This commit is contained in:
NuclearW 2013-01-21 03:53:25 -05:00
parent 06b75386b9
commit 0276294569
3 changed files with 42 additions and 3 deletions

View File

@ -0,0 +1,31 @@
package com.gmail.nossr50.events.skills;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.SkillType;
public class McMMOPlayerUnarmEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
private Player defender;
public McMMOPlayerUnarmEvent(Player defender) {
super(defender, SkillType.UNARMED);
this.defender = defender;
}
public Player getDefender() {
return defender;
}
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -4,6 +4,8 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.skills.McMMOPlayerUnarmEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
@ -34,7 +36,14 @@ public class DisarmEventHandler {
}
protected void handleDisarm() {
Misc.dropItem(defender.getLocation(), inHand);
defender.setItemInHand(new ItemStack(Material.AIR));
McMMOPlayerUnarmEvent event = new McMMOPlayerUnarmEvent(defender);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if(!event.isCancelled()) {
Misc.dropItem(defender.getLocation(), inHand);
defender.setItemInHand(new ItemStack(Material.AIR));
sendAbilityMessage();
}
}
}

View File

@ -42,7 +42,6 @@ public class UnarmedManager extends SkillManager {
if (chance > Misc.getRandom().nextInt(randomChance)) {
if (!hasIronGrip(defender)) {
eventHandler.sendAbilityMessage();
eventHandler.handleDisarm();
}
}