use of au.com.mineauz.minigames.objects.OfflineMinigamePlayer in project Minigames by AddstarMC.
the class Events method onPlayerConnect.
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerConnect(PlayerJoinEvent event) {
pdata.addMinigamePlayer(event.getPlayer());
File pldata = new File(plugin.getDataFolder() + "/playerdata/inventories/" + event.getPlayer().getUniqueId().toString() + ".yml");
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (pldata.exists()) {
ply.setOfflineMinigamePlayer(new OfflineMinigamePlayer(event.getPlayer().getUniqueId()));
Location floc = ply.getOfflineMinigamePlayer().getLoginLocation();
ply.setRequiredQuit(true);
ply.setQuitPos(floc);
if (!ply.getPlayer().isDead() && ply.isRequiredQuit()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, ply::restorePlayerData);
ply.teleport(ply.getQuitPos());
ply.setRequiredQuit(false);
ply.setQuitPos(null);
}
plugin.getLogger().info(ply.getName() + "'s data has been restored from file.");
}
ply.loadClaimedRewards();
if (Bukkit.getServer().getOnlinePlayers().size() == 1) {
for (Minigame mgm : mdata.getAllMinigames().values()) {
if (mgm != null && mgm.getType() == MinigameType.GLOBAL) {
if (mgm.getMinigameTimer() != null)
mgm.getMinigameTimer().startTimer();
}
}
// for(String mgm : mdata.getAllMinigames().keySet()){
// if(mdata.getMinigame(mgm).getType() == MinigameType.GLOBAL){
// if(minigameManager.getMinigame(mgm).getThTimer() != null){
// minigameManager.getMinigame(mgm).getThTimer().pauseTimer(false);
// }
// if(mdata.getMinigame(mgm).getMinigameTimer() != null)
// mdata.getMinigame(mgm).getMinigameTimer().startTimer();
// }
// }
}
}
Aggregations