diff --git a/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanWorldChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanWorldChangeListener.java index 166c87159..413ab793d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanWorldChangeListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanWorldChangeListener.java @@ -1,8 +1,7 @@ package main.java.com.djrapitops.plan.data.listeners; import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.handling.info.InfoType; -import main.java.com.djrapitops.plan.data.handling.info.PlaytimeDependentInfo; +import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.utilities.MiscUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -10,6 +9,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerChangedWorldEvent; +import java.util.Optional; import java.util.UUID; public class PlanWorldChangeListener implements Listener { @@ -22,17 +22,16 @@ public class PlanWorldChangeListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onWorldChange(PlayerChangedWorldEvent event) { Player p = event.getPlayer(); - - String previousWorld = event.getFrom().getName(); String worldName = p.getWorld().getName(); - if (previousWorld.equals(worldName)) { - return; - } UUID uuid = p.getUniqueId(); String gameMode = p.getGameMode().name(); long time = MiscUtils.getTime(); - plugin.addToProcessQueue(new PlaytimeDependentInfo(uuid, InfoType.WORLD, time, gameMode, worldName)); + Optional cachedSession = plugin.getDataCache().getCachedSession(uuid); + if (cachedSession.isPresent()) { + Session session = cachedSession.get(); + session.changeState(worldName, gameMode, time); + } } }