mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
Events for Casting Mode
This commit is contained in:
parent
90e0c349a4
commit
222fbfc833
@ -0,0 +1,38 @@
|
|||||||
|
package net.Indyuce.mmocore.api.event;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class PlayerEnterCastingModeEvent extends PlayerEvent implements Cancellable {
|
||||||
|
private static HandlerList handlerList = new HandlerList();
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
public PlayerEnterCastingModeEvent(@NotNull Player who) {
|
||||||
|
super(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return getHandlerList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList(){
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package net.Indyuce.mmocore.api.event;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class PlayerExitCastingModeEvent extends PlayerEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlerList = new HandlerList();
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
public PlayerExitCastingModeEvent(@NotNull Player who) {
|
||||||
|
super(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
}
|
@ -9,9 +9,7 @@ import io.lumine.mythic.lib.player.cooldown.CooldownMap;
|
|||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||||
import net.Indyuce.mmocore.api.SoundEvent;
|
import net.Indyuce.mmocore.api.SoundEvent;
|
||||||
import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent;
|
import net.Indyuce.mmocore.api.event.*;
|
||||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
|
||||||
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
|
||||||
import net.Indyuce.mmocore.api.event.unlocking.ItemLockedEvent;
|
import net.Indyuce.mmocore.api.event.unlocking.ItemLockedEvent;
|
||||||
import net.Indyuce.mmocore.api.event.unlocking.ItemUnlockedEvent;
|
import net.Indyuce.mmocore.api.event.unlocking.ItemUnlockedEvent;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||||
@ -1007,6 +1005,12 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
|||||||
|
|
||||||
public void setSkillCasting(@NotNull SkillCastingInstance skillCasting) {
|
public void setSkillCasting(@NotNull SkillCastingInstance skillCasting) {
|
||||||
Validate.isTrue(!isCasting(), "Player already in casting mode");
|
Validate.isTrue(!isCasting(), "Player already in casting mode");
|
||||||
|
PlayerEnterCastingModeEvent event = new PlayerEnterCastingModeEvent(getPlayer());
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.skillCasting = skillCasting;
|
this.skillCasting = skillCasting;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1025,6 +1029,13 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
|||||||
|
|
||||||
public void leaveSkillCasting() {
|
public void leaveSkillCasting() {
|
||||||
Validate.isTrue(isCasting(), "Player not in casting mode");
|
Validate.isTrue(isCasting(), "Player not in casting mode");
|
||||||
|
PlayerExitCastingModeEvent event = new PlayerExitCastingModeEvent(getPlayer());
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
skillCasting.close();
|
skillCasting.close();
|
||||||
this.skillCasting = null;
|
this.skillCasting = null;
|
||||||
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE, 0); // Reset action bar
|
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE, 0); // Reset action bar
|
||||||
|
Loading…
Reference in New Issue
Block a user