mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +01:00
Make ability events separate from skill events
This commit is contained in:
parent
badabeb8e4
commit
d5fb19a7db
@ -777,7 +777,7 @@ public class McMMOPlayer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
|
||||
if (EventUtils.callPlayerAbilityActivateEvent(player, ability).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,25 @@
|
||||
package com.gmail.nossr50.events.skills.abilities;
|
||||
package com.gmail.nossr50.events.abilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
@Deprecated
|
||||
public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
cancelled = false;
|
||||
}
|
||||
|
||||
public McMMOPlayerAbilityActivateEvent(Player player, AbilityType ability) {
|
||||
super(player, ability);
|
||||
cancelled = false;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
@ -1,11 +1,17 @@
|
||||
package com.gmail.nossr50.events.skills.abilities;
|
||||
package com.gmail.nossr50.events.abilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
|
||||
@Deprecated
|
||||
public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
}
|
||||
|
||||
public McMMOPlayerAbilityDeactivateEvent(Player player, AbilityType ability) {
|
||||
super(player, ability);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.gmail.nossr50.events.abilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public abstract class McMMOPlayerAbilityEvent extends PlayerEvent {
|
||||
private AbilityType ability;
|
||||
|
||||
@Deprecated
|
||||
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
ability = skill.getAbility();
|
||||
}
|
||||
|
||||
protected McMMOPlayerAbilityEvent(Player player, AbilityType ability) {
|
||||
super(player);
|
||||
this.ability = ability;
|
||||
}
|
||||
|
||||
public AbilityType getAbility() {
|
||||
return ability;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.gmail.nossr50.events.skills.abilities;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||
|
||||
public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
|
||||
private AbilityType ability;
|
||||
|
||||
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
ability = skill.getAbility();
|
||||
}
|
||||
|
||||
public AbilityType getAbility() {
|
||||
return ability;
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.abilities.McMMOPlayerAbilityActivateEvent;
|
||||
import com.gmail.nossr50.events.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||
import com.gmail.nossr50.events.experience.levels.McMMOPlayerLevelChangeEvent;
|
||||
import com.gmail.nossr50.events.experience.levels.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.events.experience.levels.McMMOPlayerLevelUpEvent;
|
||||
@ -27,8 +29,6 @@ import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
|
||||
import com.gmail.nossr50.events.hardcore.McMMOPlayerDeathPenaltyEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
@ -37,8 +37,8 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class EventUtils {
|
||||
public static McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, SkillType skill) {
|
||||
McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, skill);
|
||||
public static McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, AbilityType ability) {
|
||||
McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, ability);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
@ -125,7 +125,7 @@ public class EventUtils {
|
||||
}
|
||||
|
||||
public static McMMOPlayerAbilityDeactivateEvent callAbilityDeactivateEvent(Player player, AbilityType ability) {
|
||||
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, SkillType.byAbility(ability));
|
||||
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, ability);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
|
Loading…
Reference in New Issue
Block a user