mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 03:27:37 +01:00
World Change Processing
This commit is contained in:
parent
a5eb08e39d
commit
cc8fcbe5b8
@ -1,8 +1,7 @@
|
|||||||
package main.java.com.djrapitops.plan.data.listeners;
|
package main.java.com.djrapitops.plan.data.listeners;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.InfoType;
|
import main.java.com.djrapitops.plan.data.Session;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.PlaytimeDependentInfo;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -10,6 +9,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlanWorldChangeListener implements Listener {
|
public class PlanWorldChangeListener implements Listener {
|
||||||
@ -22,17 +22,16 @@ public class PlanWorldChangeListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onWorldChange(PlayerChangedWorldEvent event) {
|
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
String previousWorld = event.getFrom().getName();
|
|
||||||
String worldName = p.getWorld().getName();
|
String worldName = p.getWorld().getName();
|
||||||
if (previousWorld.equals(worldName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
String gameMode = p.getGameMode().name();
|
String gameMode = p.getGameMode().name();
|
||||||
long time = MiscUtils.getTime();
|
long time = MiscUtils.getTime();
|
||||||
|
|
||||||
plugin.addToProcessQueue(new PlaytimeDependentInfo(uuid, InfoType.WORLD, time, gameMode, worldName));
|
Optional<Session> cachedSession = plugin.getDataCache().getCachedSession(uuid);
|
||||||
|
if (cachedSession.isPresent()) {
|
||||||
|
Session session = cachedSession.get();
|
||||||
|
session.changeState(worldName, gameMode, time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user