mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 08:39:49 +01:00
Add McMMOPlayerUnarmEvent
This commit is contained in:
parent
06b75386b9
commit
0276294569
@ -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;
|
||||
}
|
||||
}
|
@ -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() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ public class UnarmedManager extends SkillManager {
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
||||
if (!hasIronGrip(defender)) {
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.handleDisarm();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user