From 4f1084f80e8da4e5c2bcacd7591b4880f0c49a82 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sat, 14 Aug 2021 14:35:57 +0200 Subject: [PATCH] !fixed AsyncPlayerDataLoadEvent --- .../api/event/AsyncPlayerDataEvent.java | 29 +++++++++++++++++++ .../api/event/AsyncPlayerDataLoadEvent.java | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/Indyuce/mmocore/api/event/AsyncPlayerDataEvent.java diff --git a/src/main/java/net/Indyuce/mmocore/api/event/AsyncPlayerDataEvent.java b/src/main/java/net/Indyuce/mmocore/api/event/AsyncPlayerDataEvent.java new file mode 100644 index 00000000..3208f5b3 --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/api/event/AsyncPlayerDataEvent.java @@ -0,0 +1,29 @@ +package net.Indyuce.mmocore.api.event; + +import net.Indyuce.mmocore.api.player.PlayerData; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; + +/** + * In order to create bukkit async events we must call + * the right constructor: + *

+ * {@link Event#Event(boolean)} and have the boolean set to true + */ +public abstract class AsyncPlayerDataEvent extends Event { + private final PlayerData playerData; + + public AsyncPlayerDataEvent(PlayerData playerData) { + super(true); + + this.playerData = playerData; + } + + public PlayerData getData() { + return playerData; + } + + public Player getPlayer() { + return playerData.getPlayer(); + } +} diff --git a/src/main/java/net/Indyuce/mmocore/api/event/AsyncPlayerDataLoadEvent.java b/src/main/java/net/Indyuce/mmocore/api/event/AsyncPlayerDataLoadEvent.java index e2ff20fa..4c8be27a 100644 --- a/src/main/java/net/Indyuce/mmocore/api/event/AsyncPlayerDataLoadEvent.java +++ b/src/main/java/net/Indyuce/mmocore/api/event/AsyncPlayerDataLoadEvent.java @@ -3,7 +3,7 @@ package net.Indyuce.mmocore.api.event; import net.Indyuce.mmocore.api.player.PlayerData; import org.bukkit.event.HandlerList; -public class AsyncPlayerDataLoadEvent extends PlayerDataEvent { +public class AsyncPlayerDataLoadEvent extends AsyncPlayerDataEvent { private static final HandlerList handlers = new HandlerList(); /**