From cc8fcbe5b835354944d93462733476ae5c49f860 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 22 Aug 2017 12:10:37 +0300 Subject: [PATCH] World Change Processing --- .../data/listeners/PlanWorldChangeListener.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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); + } } }