mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 16:14:26 +08:00
GameMode change Processing
This commit is contained in:
parent
8002864c73
commit
a5eb08e39d
@ -60,7 +60,7 @@ public class SessionCache {
|
||||
* @param uuid UUID of the player.
|
||||
* @return Session or null if not cached.
|
||||
*/
|
||||
public Optional<Session> getSession(UUID uuid) {
|
||||
public Optional<Session> getCachedSession(UUID uuid) {
|
||||
Session session = activeSessions.get(uuid);
|
||||
if (session != null) {
|
||||
return Optional.of(session);
|
||||
|
@ -12,6 +12,8 @@ import java.util.UUID;
|
||||
/**
|
||||
* Processor Class for KillEvent information when the killer is a
|
||||
* player.
|
||||
* <p>
|
||||
* Adds KillData or a Mob kill to the active Session.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 4.0.0
|
||||
@ -43,7 +45,7 @@ public class KillProcessor extends PlayerProcessor {
|
||||
|
||||
Plan plugin = Plan.getInstance();
|
||||
|
||||
Optional<Session> cachedSession = plugin.getDataCache().getSession(uuid);
|
||||
Optional<Session> cachedSession = plugin.getDataCache().getCachedSession(uuid);
|
||||
if (!cachedSession.isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
@ -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.PlayerGameModeChangeEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -40,13 +40,16 @@ public class PlanGamemodeChangeListener implements Listener {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = event.getPlayer();
|
||||
UUID uuid = p.getUniqueId();
|
||||
long time = MiscUtils.getTime();
|
||||
String gameMode = event.getNewGameMode().name();
|
||||
String worldName = p.getWorld().getName();
|
||||
|
||||
plugin.addToProcessQueue(new PlaytimeDependentInfo(uuid, InfoType.GM, 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