mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Fix GM & World Playtime tracking
This commit is contained in:
parent
557c3d2d85
commit
c8154d875b
@ -78,6 +78,11 @@
|
|||||||
<set />
|
<set />
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="$PROJECT_DIR$/src/main/java/com/djrapitops/plan/data/handling/PlaytimeHandling.java">
|
||||||
|
<value>
|
||||||
|
<set />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="$PROJECT_DIR$/src/main/java/com/djrapitops/plan/data/handling/WorldTimeHandling.java">
|
<entry key="$PROJECT_DIR$/src/main/java/com/djrapitops/plan/data/handling/WorldTimeHandling.java">
|
||||||
<value>
|
<value>
|
||||||
<set />
|
<set />
|
||||||
@ -103,6 +108,11 @@
|
|||||||
<set />
|
<set />
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="$PROJECT_DIR$/src/main/java/com/djrapitops/plan/data/handling/info/PlaytimeDependentInfo.java">
|
||||||
|
<value>
|
||||||
|
<set />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="$PROJECT_DIR$/src/main/java/com/djrapitops/plan/data/handling/info/ReloadInfo.java">
|
<entry key="$PROJECT_DIR$/src/main/java/com/djrapitops/plan/data/handling/info/ReloadInfo.java">
|
||||||
<value>
|
<value>
|
||||||
<set />
|
<set />
|
||||||
@ -283,6 +293,11 @@
|
|||||||
<set />
|
<set />
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="$PROJECT_DIR$/src/test/java/main/java/com/djrapitops/plan/utilities/comparators/HandlingInfoTimeComparatorTest.java">
|
||||||
|
<value>
|
||||||
|
<set />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="$PROJECT_DIR$/src/test/java/utils/MockUtils.java">
|
<entry key="$PROJECT_DIR$/src/test/java/utils/MockUtils.java">
|
||||||
<value>
|
<value>
|
||||||
<set />
|
<set />
|
||||||
|
@ -265,7 +265,7 @@ public class DataCacheHandler extends SessionCache {
|
|||||||
UUID uuid = p.getUuid();
|
UUID uuid = p.getUuid();
|
||||||
endSession(uuid);
|
endSession(uuid);
|
||||||
String worldName = ((Player) p.getWrappedPlayerClass()).getWorld().getName();
|
String worldName = ((Player) p.getWrappedPlayerClass()).getWorld().getName();
|
||||||
toProcess.add(new LogoutInfo(uuid, time, p.isBanned(), p.getGamemode(), getSession(uuid), worldName));
|
toProcess.add(new LogoutInfo(uuid, time, p.isBanned(), p.getGamemode().name(), getSession(uuid), worldName));
|
||||||
}
|
}
|
||||||
Log.debug("ToProcess size_AFTER: " + toProcess.size() + " DataCache size: " + dataCache.keySet().size());
|
Log.debug("ToProcess size_AFTER: " + toProcess.size() + " DataCache size: " + dataCache.keySet().size());
|
||||||
toProcess.sort(new HandlingInfoTimeComparator());
|
toProcess.sort(new HandlingInfoTimeComparator());
|
||||||
@ -388,7 +388,7 @@ public class DataCacheHandler extends SessionCache {
|
|||||||
long time = MiscUtils.getTime();
|
long time = MiscUtils.getTime();
|
||||||
UUID uuid = p.getUuid();
|
UUID uuid = p.getUuid();
|
||||||
String worldName = ((Player) p.getWrappedPlayerClass()).getWorld().getName();
|
String worldName = ((Player) p.getWrappedPlayerClass()).getWorld().getName();
|
||||||
ReloadInfo info = new ReloadInfo(uuid, time, p.getAddress().getAddress(), p.isBanned(), p.getDisplayName(), p.getGamemode(), worldName);
|
ReloadInfo info = new ReloadInfo(uuid, time, p.getAddress().getAddress(), p.isBanned(), p.getDisplayName(), p.getGamemode().name(), worldName);
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
UserData data = dataCache.get(uuid);
|
UserData data = dataCache.get(uuid);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
package main.java.com.djrapitops.plan.data.handling;
|
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
|
||||||
import main.java.com.djrapitops.plan.data.time.GMTimes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class containing static methods for processing information contained in a
|
|
||||||
* GamemodeChangeEvent.
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
* @since 3.0.0
|
|
||||||
*/
|
|
||||||
public class GamemodeHandling {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility Class, hides constructor.
|
|
||||||
*/
|
|
||||||
private GamemodeHandling() {
|
|
||||||
throw new IllegalStateException("Utility Class.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes the information of the Event and changes UserData object
|
|
||||||
* accordingly.
|
|
||||||
*
|
|
||||||
* @param data UserData of the player.
|
|
||||||
* @param time Epoch ms the event occurred.
|
|
||||||
* @param newGM The Gamemode the player changed to.
|
|
||||||
*/
|
|
||||||
public static void processGamemodeInfo(UserData data, long time, Gamemode newGM) {
|
|
||||||
if (newGM == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final String newGamemode = newGM.name();
|
|
||||||
|
|
||||||
long diff = time - data.getLastPlayed();
|
|
||||||
long playTime = data.getPlayTime() + diff;
|
|
||||||
data.setPlayTime(playTime);
|
|
||||||
data.setLastPlayed(time);
|
|
||||||
|
|
||||||
GMTimes gmTimes = data.getGmTimes();
|
|
||||||
gmTimes.changeState(newGamemode, playTime);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,25 @@
|
|||||||
|
package main.java.com.djrapitops.plan.data.handling;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
import main.java.com.djrapitops.plan.data.time.GMTimes;
|
||||||
|
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||||
|
|
||||||
|
public class PlaytimeHandling {
|
||||||
|
|
||||||
|
public static void processPlaytimeDependentInfo(UserData data, long time, String gamemode, String worldName) {
|
||||||
|
long diff = time - data.getLastPlayed();
|
||||||
|
long playTime = data.getPlayTime() + diff;
|
||||||
|
data.setPlayTime(playTime);
|
||||||
|
data.setLastPlayed(time);
|
||||||
|
|
||||||
|
GMTimes gmTimes = data.getGmTimes();
|
||||||
|
if (gamemode != null) {
|
||||||
|
gmTimes.changeState(gamemode, playTime);
|
||||||
|
} else {
|
||||||
|
gmTimes.changeState(gmTimes.getState(), playTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldTimes worldTimes = data.getWorldTimes();
|
||||||
|
worldTimes.changeState(worldName, playTime);
|
||||||
|
}
|
||||||
|
}
|
@ -1,42 +0,0 @@
|
|||||||
package main.java.com.djrapitops.plan.data.handling;
|
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
|
||||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for processing World Time related changes.
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
* @since 3.6.0
|
|
||||||
*/
|
|
||||||
public class WorldTimeHandling {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility Class, hides constructor.
|
|
||||||
*/
|
|
||||||
private WorldTimeHandling() {
|
|
||||||
throw new IllegalStateException("Utility Class.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes the information of the Event and changes UserData object
|
|
||||||
* accordingly.
|
|
||||||
*
|
|
||||||
* @param data UserData of the player.
|
|
||||||
* @param time Epoch ms the event occurred.
|
|
||||||
* @param worldName The World the player changed to.
|
|
||||||
*/
|
|
||||||
public static void processWorldChangeInfo(UserData data, long time, String worldName) {
|
|
||||||
if (worldName == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long diff = time - data.getLastPlayed();
|
|
||||||
long playTime = data.getPlayTime() + diff;
|
|
||||||
data.setPlayTime(playTime);
|
|
||||||
data.setLastPlayed(time);
|
|
||||||
|
|
||||||
WorldTimes worldTimes = data.getWorldTimes();
|
|
||||||
worldTimes.changeState(worldName, playTime);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package main.java.com.djrapitops.plan.data.handling.info;
|
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
|
||||||
import main.java.com.djrapitops.plan.data.handling.GamemodeHandling;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HandlingInfo Class for GamemodeChangeEvent information.
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
* @since 3.0.0
|
|
||||||
*/
|
|
||||||
public class GamemodeInfo extends HandlingInfo {
|
|
||||||
|
|
||||||
private final Gamemode currentGamemode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param uuid UUID of the player.
|
|
||||||
* @param time Epoch ms of the event.
|
|
||||||
* @param gm Gamemode the player changed to.
|
|
||||||
*/
|
|
||||||
public GamemodeInfo(UUID uuid, long time, Gamemode gm) {
|
|
||||||
super(uuid, InfoType.GM, time);
|
|
||||||
currentGamemode = gm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean process(UserData uData) {
|
|
||||||
if (currentGamemode == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
GamemodeHandling.processGamemodeInfo(uData, time, currentGamemode);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package main.java.com.djrapitops.plan.data.handling.info;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.data.handling.LoginHandling;
|
import main.java.com.djrapitops.plan.data.handling.LoginHandling;
|
||||||
|
|
||||||
@ -18,8 +17,7 @@ public class LoginInfo extends HandlingInfo {
|
|||||||
private final InetAddress ip;
|
private final InetAddress ip;
|
||||||
private final boolean banned;
|
private final boolean banned;
|
||||||
private final String nickname;
|
private final String nickname;
|
||||||
private final GamemodeInfo gmInfo;
|
private final PlaytimeDependentInfo playtimeDependentInfo;
|
||||||
private final WorldInfo worldInfo;
|
|
||||||
private final int loginTimes;
|
private final int loginTimes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,19 +31,18 @@ public class LoginInfo extends HandlingInfo {
|
|||||||
* @param gm current gamemode of the player
|
* @param gm current gamemode of the player
|
||||||
* @param loginTimes number the loginTimes should be incremented with.
|
* @param loginTimes number the loginTimes should be incremented with.
|
||||||
*/
|
*/
|
||||||
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, Gamemode gm, int loginTimes, String worldName) {
|
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, String gm, int loginTimes, String worldName) {
|
||||||
super(uuid, InfoType.LOGIN, time);
|
super(uuid, InfoType.LOGIN, time);
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.banned = banned;
|
this.banned = banned;
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
this.gmInfo = new GamemodeInfo(uuid, time, gm);
|
this.playtimeDependentInfo = new PlaytimeDependentInfo(uuid, InfoType.OTHER, time, gm, worldName);
|
||||||
worldInfo = new WorldInfo(uuid, time, worldName);
|
|
||||||
this.loginTimes = loginTimes;
|
this.loginTimes = loginTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for not incrementing the loginTimes.
|
* Constructor for not incrementing the loginTimes.
|
||||||
*
|
* <p>
|
||||||
* This constructor is used only by ReloadInfo
|
* This constructor is used only by ReloadInfo
|
||||||
*
|
*
|
||||||
* @param uuid UUID of the player.
|
* @param uuid UUID of the player.
|
||||||
@ -55,13 +52,12 @@ public class LoginInfo extends HandlingInfo {
|
|||||||
* @param nickname Nickname of the player
|
* @param nickname Nickname of the player
|
||||||
* @param gm current gamemode of the player
|
* @param gm current gamemode of the player
|
||||||
*/
|
*/
|
||||||
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, Gamemode gm, String worldName) {
|
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, String gm, String worldName) {
|
||||||
super(uuid, InfoType.RELOAD, time);
|
super(uuid, InfoType.RELOAD, time);
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.banned = banned;
|
this.banned = banned;
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
this.gmInfo = new GamemodeInfo(uuid, time, gm);
|
this.playtimeDependentInfo = new PlaytimeDependentInfo(uuid, InfoType.OTHER, time, gm, worldName);
|
||||||
worldInfo = new WorldInfo(uuid, time, worldName);
|
|
||||||
this.loginTimes = 0;
|
this.loginTimes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,8 +67,7 @@ public class LoginInfo extends HandlingInfo {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LoginHandling.processLoginInfo(uData, time, ip, banned, nickname, loginTimes);
|
LoginHandling.processLoginInfo(uData, time, ip, banned, nickname, loginTimes);
|
||||||
gmInfo.process(uData);
|
playtimeDependentInfo.process(uData);
|
||||||
worldInfo.process(uData);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package main.java.com.djrapitops.plan.data.handling.info;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.SessionData;
|
import main.java.com.djrapitops.plan.data.SessionData;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.data.handling.LogoutHandling;
|
import main.java.com.djrapitops.plan.data.handling.LogoutHandling;
|
||||||
@ -17,8 +16,7 @@ public class LogoutInfo extends HandlingInfo {
|
|||||||
|
|
||||||
private final boolean banned;
|
private final boolean banned;
|
||||||
private final SessionData sData;
|
private final SessionData sData;
|
||||||
private final GamemodeInfo gmInfo;
|
private final PlaytimeDependentInfo playtimeDependentInfo;
|
||||||
private final WorldInfo worldInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -30,12 +28,11 @@ public class LogoutInfo extends HandlingInfo {
|
|||||||
* @param sData session that has been ended at the moment of the logout
|
* @param sData session that has been ended at the moment of the logout
|
||||||
* event.
|
* event.
|
||||||
*/
|
*/
|
||||||
public LogoutInfo(UUID uuid, long time, boolean banned, Gamemode gm, SessionData sData, String worldName) {
|
public LogoutInfo(UUID uuid, long time, boolean banned, String gm, SessionData sData, String worldName) {
|
||||||
super(uuid, InfoType.LOGOUT, time);
|
super(uuid, InfoType.LOGOUT, time);
|
||||||
this.banned = banned;
|
this.banned = banned;
|
||||||
this.sData = sData;
|
this.sData = sData;
|
||||||
this.gmInfo = new GamemodeInfo(uuid, time, gm);
|
this.playtimeDependentInfo = new PlaytimeDependentInfo(uuid, InfoType.OTHER, time, gm, worldName);
|
||||||
worldInfo = new WorldInfo(uuid, time, worldName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -45,8 +42,7 @@ public class LogoutInfo extends HandlingInfo {
|
|||||||
}
|
}
|
||||||
uData.addSession(sData);
|
uData.addSession(sData);
|
||||||
LogoutHandling.processLogoutInfo(uData, time, banned);
|
LogoutHandling.processLogoutInfo(uData, time, banned);
|
||||||
gmInfo.process(uData);
|
playtimeDependentInfo.process(uData);
|
||||||
worldInfo.process(uData);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
import main.java.com.djrapitops.plan.data.handling.PlaytimeHandling;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PlaytimeDependentInfo extends HandlingInfo {
|
||||||
|
|
||||||
|
private final String gamemode;
|
||||||
|
private final String worldName;
|
||||||
|
|
||||||
|
public PlaytimeDependentInfo(UUID uuid, InfoType type, long time, String gm, String worldName) {
|
||||||
|
super(uuid, type, time);
|
||||||
|
this.worldName = worldName;
|
||||||
|
this.gamemode = gm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean process(UserData uData) {
|
||||||
|
if (!uuid.equals(uData.getUuid())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PlaytimeHandling.processPlaytimeDependentInfo(uData, time, gamemode, worldName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package main.java.com.djrapitops.plan.data.handling.info;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -23,7 +21,7 @@ public class ReloadInfo extends LoginInfo {
|
|||||||
* @param nickname Nickname of the player
|
* @param nickname Nickname of the player
|
||||||
* @param gm current gamemode of the player
|
* @param gm current gamemode of the player
|
||||||
*/
|
*/
|
||||||
public ReloadInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, Gamemode gm, String worldName) {
|
public ReloadInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, String gm, String worldName) {
|
||||||
super(uuid, time, ip, banned, nickname, gm, worldName);
|
super(uuid, time, ip, banned, nickname, gm, worldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
package main.java.com.djrapitops.plan.data.handling.info;
|
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
|
||||||
import main.java.com.djrapitops.plan.data.handling.WorldTimeHandling;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HandlingInfo Class for PlayerChangedWorldEvent information.
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
* @since 3.6.0
|
|
||||||
*/
|
|
||||||
public class WorldInfo extends HandlingInfo {
|
|
||||||
|
|
||||||
private final String currentWorld;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param uuid UUID of the player related to the info.
|
|
||||||
* @param time Time the event occurred
|
|
||||||
* @param currentWorld World the player is currently in.
|
|
||||||
*/
|
|
||||||
public WorldInfo(UUID uuid, long time, String currentWorld) {
|
|
||||||
super(uuid, InfoType.WORLD, time);
|
|
||||||
this.currentWorld = currentWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean process(UserData uData) {
|
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
WorldTimeHandling.processWorldChangeInfo(uData, time, currentWorld);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,9 @@
|
|||||||
package main.java.com.djrapitops.plan.data.listeners;
|
package main.java.com.djrapitops.plan.data.listeners;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo;
|
import main.java.com.djrapitops.plan.data.handling.info.InfoType;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.WorldInfo;
|
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;
|
||||||
@ -46,7 +45,6 @@ public class PlanGamemodeChangeListener implements Listener {
|
|||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
long time = MiscUtils.getTime();
|
long time = MiscUtils.getTime();
|
||||||
handler.addToPool(new GamemodeInfo(uuid, time, Gamemode.wrap(event.getNewGameMode())));
|
handler.addToPool(new PlaytimeDependentInfo(uuid, InfoType.GM, time, event.getNewGameMode().name(), p.getWorld().getName()));
|
||||||
handler.addToPool(new WorldInfo(uuid, time, p.getWorld().getName()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class PlanPlayerListener implements Listener {
|
|||||||
InetAddress ip = player.getAddress().getAddress();
|
InetAddress ip = player.getAddress().getAddress();
|
||||||
boolean banned = player.isBanned();
|
boolean banned = player.isBanned();
|
||||||
String displayName = player.getDisplayName();
|
String displayName = player.getDisplayName();
|
||||||
Gamemode gm = Gamemode.wrap(player.getGameMode());
|
String gm = player.getGameMode().name();
|
||||||
String worldName = player.getWorld().getName();
|
String worldName = player.getWorld().getName();
|
||||||
|
|
||||||
LoginInfo loginInfo = new LoginInfo(uuid, time, ip, banned, displayName, gm, 1, worldName);
|
LoginInfo loginInfo = new LoginInfo(uuid, time, ip, banned, displayName, gm, 1, worldName);
|
||||||
@ -114,7 +114,7 @@ public class PlanPlayerListener implements Listener {
|
|||||||
Gamemode gm = Gamemode.wrap(player.getGameMode());
|
Gamemode gm = Gamemode.wrap(player.getGameMode());
|
||||||
String worldName = player.getWorld().getName();
|
String worldName = player.getWorld().getName();
|
||||||
|
|
||||||
handler.addToPool(new LogoutInfo(uuid, time, banned, gm, handler.getSession(uuid), worldName));
|
handler.addToPool(new LogoutInfo(uuid, time, banned, gm.name(), handler.getSession(uuid), worldName));
|
||||||
handler.saveCachedData(uuid);
|
handler.saveCachedData(uuid);
|
||||||
Log.debug(uuid + ": PlayerQuitEvent_END");
|
Log.debug(uuid + ": PlayerQuitEvent_END");
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ public class PlanPlayerListener implements Listener {
|
|||||||
Gamemode gm = Gamemode.wrap(player.getGameMode());
|
Gamemode gm = Gamemode.wrap(player.getGameMode());
|
||||||
String worldName = player.getWorld().getName();
|
String worldName = player.getWorld().getName();
|
||||||
|
|
||||||
handler.addToPool(new LogoutInfo(uuid, time, banned, gm, handler.getSession(uuid), worldName));
|
handler.addToPool(new LogoutInfo(uuid, time, banned, gm.name(), handler.getSession(uuid), worldName));
|
||||||
handler.addToPool(new KickInfo(uuid));
|
handler.addToPool(new KickInfo(uuid));
|
||||||
handler.saveCachedData(uuid);
|
handler.saveCachedData(uuid);
|
||||||
Log.debug(uuid + ": PlayerKickEvent_END");
|
Log.debug(uuid + ": PlayerKickEvent_END");
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package main.java.com.djrapitops.plan.data.listeners;
|
package main.java.com.djrapitops.plan.data.listeners;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo;
|
import main.java.com.djrapitops.plan.data.handling.info.InfoType;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.WorldInfo;
|
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;
|
||||||
@ -31,7 +30,6 @@ public class PlanWorldChangeListener implements Listener {
|
|||||||
}
|
}
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
long time = MiscUtils.getTime();
|
long time = MiscUtils.getTime();
|
||||||
handler.addToPool(new GamemodeInfo(uuid, time, Gamemode.wrap(p.getGameMode())));
|
handler.addToPool(new PlaytimeDependentInfo(uuid, InfoType.GM, time, p.getGameMode().name(), p.getWorld().getName()));
|
||||||
handler.addToPool(new WorldInfo(uuid, time, worldName));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package test.java.main.java.com.djrapitops.plan.data.handling;
|
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
|
||||||
import main.java.com.djrapitops.plan.data.handling.GamemodeHandling;
|
|
||||||
import main.java.com.djrapitops.plan.data.time.GMTimes;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import test.java.utils.MockUtils;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class GamemodeHandlingTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public GamemodeHandlingTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testProcessGamemodeInfo() {
|
|
||||||
UserData data = MockUtils.mockUser();
|
|
||||||
data.setPlayTime(100L);
|
|
||||||
data.setGmTimes(new GMTimes("CREATIVE", 50L));
|
|
||||||
data.setLastPlayed(1000L);
|
|
||||||
long time = 2000L;
|
|
||||||
GamemodeHandling.processGamemodeInfo(data, time, Gamemode.SURVIVAL);
|
|
||||||
Long result = data.getGmTimes().getTime("CREATIVE");
|
|
||||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
|
||||||
result = data.getPlayTime();
|
|
||||||
assertTrue("Playtime was" + result, result == 1100L);
|
|
||||||
result = data.getLastPlayed();
|
|
||||||
assertTrue("Last Played was" + result, result == 2000L);
|
|
||||||
String lastGM = data.getLastGamemode();
|
|
||||||
assertTrue("Last gm not Survival", lastGM.equals("SURVIVAL"));
|
|
||||||
result = data.getLastGmSwapTime();
|
|
||||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testProcessGamemodeInfoSameGM() {
|
|
||||||
UserData data = MockUtils.mockUser();
|
|
||||||
data.setPlayTime(100L);
|
|
||||||
data.setGmTimes(new GMTimes("SURVIVAL", 50L));
|
|
||||||
data.setLastPlayed(1000L);
|
|
||||||
long time = 2000L;
|
|
||||||
GamemodeHandling.processGamemodeInfo(data, time, Gamemode.SURVIVAL);
|
|
||||||
Long result = data.getGmTimes().getTime("SURVIVAL");
|
|
||||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
|
||||||
result = data.getPlayTime();
|
|
||||||
assertTrue("Playtime was" + result, result == 1100L);
|
|
||||||
result = data.getLastPlayed();
|
|
||||||
assertTrue("Last Played was" + result, result == 2000L);
|
|
||||||
String lastGM = data.getLastGamemode();
|
|
||||||
assertTrue("Last gm not Survival", "SURVIVAL".equals(lastGM));
|
|
||||||
result = data.getLastGmSwapTime();
|
|
||||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testProcessGamemodeInfoNullNewGM() {
|
|
||||||
UserData data = MockUtils.mockUser();
|
|
||||||
data.setPlayTime(100L);
|
|
||||||
data.setGmTimes(new GMTimes("SURVIVAL", 50L));
|
|
||||||
data.setLastPlayed(1000L);
|
|
||||||
long time = 2000L;
|
|
||||||
GamemodeHandling.processGamemodeInfo(data, time, null);
|
|
||||||
Long result = data.getGmTimes().getTime("SURVIVAL");
|
|
||||||
assertTrue("Gamemode time was " + result, result == 0L);
|
|
||||||
result = data.getPlayTime();
|
|
||||||
assertTrue("Playtime was" + result, result == 100L);
|
|
||||||
result = data.getLastPlayed();
|
|
||||||
assertTrue("Last Played was" + result, result == 1000L);
|
|
||||||
String lastGM = data.getLastGamemode();
|
|
||||||
assertTrue("Last gm not Survival", "SURVIVAL".equals(lastGM));
|
|
||||||
result = data.getLastGmSwapTime();
|
|
||||||
assertTrue("Last swaptime was " + result, result == 50L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testProcessGamemodeInfoNullOldGM() {
|
|
||||||
UserData data = MockUtils.mockUser();
|
|
||||||
data.setPlayTime(100L);
|
|
||||||
data.setGmTimes(new GMTimes(null, 50L));
|
|
||||||
data.setLastPlayed(1000L);
|
|
||||||
long time = 2000L;
|
|
||||||
GamemodeHandling.processGamemodeInfo(data, time, Gamemode.SURVIVAL);
|
|
||||||
Long result = data.getGmTimes().getTime(Gamemode.SURVIVAL.name());
|
|
||||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
|
||||||
result = data.getPlayTime();
|
|
||||||
assertTrue("Playtime was" + result, result == 1100L);
|
|
||||||
result = data.getLastPlayed();
|
|
||||||
assertTrue("Last Played was" + result, result == 2000L);
|
|
||||||
String lastGM = data.getLastGamemode();
|
|
||||||
assertTrue("Last gm not Survival", "SURVIVAL".equals(lastGM));
|
|
||||||
result = data.getLastGmSwapTime();
|
|
||||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo;
|
|
||||||
import main.java.com.djrapitops.plan.data.time.GMTimes;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import test.java.utils.MockUtils;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class GamemodeInfoTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public GamemodeInfoTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testProcess() {
|
|
||||||
UserData data = MockUtils.mockUser();
|
|
||||||
data.setPlayTime(100L);
|
|
||||||
data.setGmTimes(new GMTimes("CREATIVE", 50L));
|
|
||||||
data.setLastPlayed(1000L);
|
|
||||||
long time = 2000L;
|
|
||||||
GamemodeInfo i = new GamemodeInfo(data.getUuid(), time, Gamemode.SURVIVAL);
|
|
||||||
assertTrue(i.process(data));
|
|
||||||
Long result = data.getGmTimes().getTime(Gamemode.CREATIVE.name());
|
|
||||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
|
||||||
result = data.getPlayTime();
|
|
||||||
assertTrue("Playtime was" + result, result == 1100L);
|
|
||||||
result = data.getLastPlayed();
|
|
||||||
assertTrue("Last Played was" + result, result == 2000L);
|
|
||||||
String lastGM = data.getLastGamemode();
|
|
||||||
assertTrue("Last gm not Survival", "SURVIVAL".equals(lastGM));
|
|
||||||
result = data.getLastGmSwapTime();
|
|
||||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testProcessWrongUUID() {
|
|
||||||
UserData data = MockUtils.mockUser();
|
|
||||||
data.setPlayTime(100L);
|
|
||||||
data.setGmTimes(new GMTimes("CREATIVE", 50L));
|
|
||||||
data.setLastPlayed(1000L);
|
|
||||||
long time = 2000L;
|
|
||||||
GamemodeInfo i = new GamemodeInfo(null, time, Gamemode.SURVIVAL);
|
|
||||||
assertTrue(!i.process(data));
|
|
||||||
Long result = data.getGmTimes().getTime(Gamemode.CREATIVE.name());
|
|
||||||
assertTrue("Gamemode time was " + result, result == 0L);
|
|
||||||
result = data.getPlayTime();
|
|
||||||
assertTrue("Playtime was" + result, result == 100L);
|
|
||||||
result = data.getLastPlayed();
|
|
||||||
assertTrue("Last Played was" + result, result == 1000L);
|
|
||||||
String lastGM = data.getLastGamemode();
|
|
||||||
assertTrue("Last gm not Creative", "CREATIVE".equals(lastGM));
|
|
||||||
result = data.getLastGmSwapTime();
|
|
||||||
assertTrue("Last swaptime was " + result, result == 50L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testProcessNullGM() {
|
|
||||||
UserData data = MockUtils.mockUser();
|
|
||||||
data.setPlayTime(100L);
|
|
||||||
data.setGmTimes(new GMTimes("CREATIVE", 50L));
|
|
||||||
data.setLastPlayed(1000L);
|
|
||||||
long time = 2000L;
|
|
||||||
GamemodeInfo i = new GamemodeInfo(data.getUuid(), time, null);
|
|
||||||
assertTrue(!i.process(data));
|
|
||||||
Long result = data.getGmTimes().getTime(Gamemode.CREATIVE.name());
|
|
||||||
assertTrue("Gamemode time was " + result, result == 0L);
|
|
||||||
result = data.getPlayTime();
|
|
||||||
assertTrue("Playtime was" + result, result == 100L);
|
|
||||||
result = data.getLastPlayed();
|
|
||||||
assertTrue("Last Played was" + result, result == 1000L);
|
|
||||||
String lastGM = data.getLastGamemode();
|
|
||||||
assertTrue("Last gm not Creative", "CREATIVE".equals(lastGM));
|
|
||||||
result = data.getLastGmSwapTime();
|
|
||||||
assertTrue("Last swaptime was " + result, result == 50L);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.LoginInfo;
|
import main.java.com.djrapitops.plan.data.handling.info.LoginInfo;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -54,7 +53,7 @@ public class LoginInfoTest {
|
|||||||
long time = 10L;
|
long time = 10L;
|
||||||
int loginTimes = data.getLoginTimes();
|
int loginTimes = data.getLoginTimes();
|
||||||
String nick = "TestProcessLoginInfo";
|
String nick = "TestProcessLoginInfo";
|
||||||
LoginInfo i = new LoginInfo(data.getUuid(), time, ip, true, nick, Gamemode.CREATIVE, 1, "World");
|
LoginInfo i = new LoginInfo(data.getUuid(), time, ip, true, nick, "CREATIVE", 1, "World");
|
||||||
assertTrue(i.process(data));
|
assertTrue(i.process(data));
|
||||||
assertTrue("LastPlayed wrong: " + data.getLastPlayed(), data.getLastPlayed() == time);
|
assertTrue("LastPlayed wrong: " + data.getLastPlayed(), data.getLastPlayed() == time);
|
||||||
assertTrue("Ip not added", data.getIps().contains(ip));
|
assertTrue("Ip not added", data.getIps().contains(ip));
|
||||||
@ -77,7 +76,7 @@ public class LoginInfoTest {
|
|||||||
InetAddress ip = InetAddress.getByName("137.19.188.146");
|
InetAddress ip = InetAddress.getByName("137.19.188.146");
|
||||||
long time = 10L;
|
long time = 10L;
|
||||||
String nick = "TestProcessLoginInfo";
|
String nick = "TestProcessLoginInfo";
|
||||||
LoginInfo i = new LoginInfo(null, time, ip, true, nick, Gamemode.CREATIVE, 1, "World");
|
LoginInfo i = new LoginInfo(null, time, ip, true, nick, "CREATIVE", 1, "World");
|
||||||
assertTrue(!i.process(data));
|
assertTrue(!i.process(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.SessionData;
|
import main.java.com.djrapitops.plan.data.SessionData;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.LogoutInfo;
|
import main.java.com.djrapitops.plan.data.handling.info.LogoutInfo;
|
||||||
@ -44,7 +43,7 @@ public class LogoutInfoTest {
|
|||||||
data.updateBanned(false);
|
data.updateBanned(false);
|
||||||
long time = 20L;
|
long time = 20L;
|
||||||
data.getGmTimes().setState("SURVIVAL");
|
data.getGmTimes().setState("SURVIVAL");
|
||||||
LogoutInfo i = new LogoutInfo(data.getUuid(), time, true, Gamemode.CREATIVE, new SessionData(0, 1), "World");
|
LogoutInfo i = new LogoutInfo(data.getUuid(), time, true, "CREATIVE", new SessionData(0, 1), "World");
|
||||||
assertTrue(i.process(data));
|
assertTrue(i.process(data));
|
||||||
assertTrue("Last Played wrong", data.getLastPlayed() == 20L);
|
assertTrue("Last Played wrong", data.getLastPlayed() == 20L);
|
||||||
assertTrue("Playtime wrong", data.getPlayTime() == 10L);
|
assertTrue("Playtime wrong", data.getPlayTime() == 10L);
|
||||||
@ -64,7 +63,7 @@ public class LogoutInfoTest {
|
|||||||
data.updateBanned(false);
|
data.updateBanned(false);
|
||||||
long time = 20L;
|
long time = 20L;
|
||||||
Exception ex = null;
|
Exception ex = null;
|
||||||
LogoutInfo i = new LogoutInfo(null, time, true, Gamemode.CREATIVE, new SessionData(0, 1), "World");
|
LogoutInfo i = new LogoutInfo(null, time, true, "CREATIVE", new SessionData(0, 1), "World");
|
||||||
assertTrue(!i.process(data));
|
assertTrue(!i.process(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.ReloadInfo;
|
import main.java.com.djrapitops.plan.data.handling.info.ReloadInfo;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
@ -55,7 +54,7 @@ public class ReloadInfoTest {
|
|||||||
long time = MiscUtils.getTime();
|
long time = MiscUtils.getTime();
|
||||||
int loginTimes = data.getLoginTimes();
|
int loginTimes = data.getLoginTimes();
|
||||||
String nick = "TestProcessLoginInfo";
|
String nick = "TestProcessLoginInfo";
|
||||||
ReloadInfo i = new ReloadInfo(data.getUuid(), time, ip, true, nick, Gamemode.CREATIVE, "World");
|
ReloadInfo i = new ReloadInfo(data.getUuid(), time, ip, true, nick, "CREATIVE", "World");
|
||||||
assertTrue(i.process(data));
|
assertTrue(i.process(data));
|
||||||
assertTrue("LastPlayed wrong: " + data.getLastPlayed(), data.getLastPlayed() == time);
|
assertTrue("LastPlayed wrong: " + data.getLastPlayed(), data.getLastPlayed() == time);
|
||||||
assertTrue("Ip not added", data.getIps().contains(ip));
|
assertTrue("Ip not added", data.getIps().contains(ip));
|
||||||
@ -77,7 +76,7 @@ public class ReloadInfoTest {
|
|||||||
InetAddress ip = InetAddress.getByName("137.19.188.146");
|
InetAddress ip = InetAddress.getByName("137.19.188.146");
|
||||||
long time = 10L;
|
long time = 10L;
|
||||||
String nick = "TestProcessLoginInfo";
|
String nick = "TestProcessLoginInfo";
|
||||||
ReloadInfo i = new ReloadInfo(null, time, ip, true, nick, Gamemode.CREATIVE, "World");
|
ReloadInfo i = new ReloadInfo(null, time, ip, true, nick, "CREATIVE", "World");
|
||||||
assertTrue(!i.process(data));
|
assertTrue(!i.process(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package test.java.main.java.com.djrapitops.plan.utilities.comparators;
|
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo;
|
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.comparators.HandlingInfoTimeComparator;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class HandlingInfoTimeComparatorTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public HandlingInfoTimeComparatorTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testCompare() {
|
|
||||||
List<HandlingInfo> i = new ArrayList<>();
|
|
||||||
GamemodeInfo one = new GamemodeInfo(null, 500L, Gamemode.CREATIVE);
|
|
||||||
i.add(one);
|
|
||||||
GamemodeInfo two = new GamemodeInfo(null, 400L, Gamemode.CREATIVE);
|
|
||||||
i.add(two);
|
|
||||||
GamemodeInfo three = new GamemodeInfo(null, 100L, Gamemode.CREATIVE);
|
|
||||||
i.add(three);
|
|
||||||
GamemodeInfo four = new GamemodeInfo(null, 700L, Gamemode.CREATIVE);
|
|
||||||
i.add(four);
|
|
||||||
i.sort(new HandlingInfoTimeComparator());
|
|
||||||
assertEquals(three, i.get(0));
|
|
||||||
assertEquals(two, i.get(1));
|
|
||||||
assertEquals(one, i.get(2));
|
|
||||||
assertEquals(four, i.get(3));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user