mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
Added an event when PlayerData is loaded
This commit is contained in:
parent
00571e12fe
commit
2a64aae0f4
@ -0,0 +1,22 @@
|
||||
package net.Indyuce.mmocore.api.event;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public class PlayerDataLoadEvent extends PlayerDataEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public PlayerDataLoadEvent(PlayerData playerData) {
|
||||
super(playerData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.PlayerDataLoadEvent;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
@ -37,10 +38,12 @@ public abstract class PlayerDataManager {
|
||||
map.put(player.getUniqueId(), generated);
|
||||
|
||||
/*
|
||||
* loads player data and ONLY THEN refresh the player statistics
|
||||
* loads player data and ONLY THEN refresh the player statistics and
|
||||
* calls the load event on the MAIN thread
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||
loadData(generated);
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(generated)));
|
||||
generated.getStats().updateStats();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user