mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
Added IPUpdateProcessor to Bungee, deprecated MiscUtils#getTime
This commit is contained in:
parent
601677c593
commit
20eb3d8c3a
@ -83,7 +83,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
NotificationCenter.checkNotifications(player);
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
long time = MiscUtils.getTime();
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
AFKListener.AFK_TRACKER.performedAction(uuid, time);
|
||||
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.listeners.bungee;
|
||||
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.player.BungeePlayerRegisterProcessor;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.system.processing.processors.player.IPUpdateProcessor;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
@ -28,9 +28,12 @@ public class PlayerOnlineListener implements Listener {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
String name = player.getName();
|
||||
long now = MiscUtils.getTime();
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
Processing.submit(new BungeePlayerRegisterProcessor(uuid, name, now));
|
||||
Processing.submit(new BungeePlayerRegisterProcessor(uuid, name, now,
|
||||
new IPUpdateProcessor(uuid, ip, now))
|
||||
);
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ package com.djrapitops.plan.system.processing.processors.player;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.processing.CriticalRunnable;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -21,11 +22,13 @@ public class BungeePlayerRegisterProcessor implements CriticalRunnable {
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
private final long registered;
|
||||
private final Runnable[] afterProcess;
|
||||
|
||||
public BungeePlayerRegisterProcessor(UUID uuid, String name, long registered) {
|
||||
public BungeePlayerRegisterProcessor(UUID uuid, String name, long registered, Runnable... afterProcess) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.registered = registered;
|
||||
this.afterProcess = afterProcess;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,6 +41,11 @@ public class BungeePlayerRegisterProcessor implements CriticalRunnable {
|
||||
database.save().registerNewUser(uuid, registered, name);
|
||||
} catch (DBException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
} finally {
|
||||
for (Runnable process : afterProcess) {
|
||||
Processing.submit(process);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -38,7 +38,8 @@ public class IPUpdateProcessor implements CriticalRunnable {
|
||||
if (Settings.DATA_GEOLOCATIONS.isTrue()) {
|
||||
String country = GeolocationCache.getCountry(ip);
|
||||
try {
|
||||
Database.getActive().save().geoInfo(uuid, new GeoInfo(ip, country, time));
|
||||
GeoInfo geoInfo = new GeoInfo(ip, country, time);
|
||||
Database.getActive().save().geoInfo(uuid, geoInfo);
|
||||
} catch (DBException | UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public class MiscUtils {
|
||||
*
|
||||
* @return Epoch ms.
|
||||
*/
|
||||
@Deprecated
|
||||
public static long getTime() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class GeoInfoTable extends TableContainer {
|
||||
for (GeoInfo info : geoInfo) {
|
||||
long date = info.getLastUsed();
|
||||
addRow(
|
||||
displayIP ? FormatUtils.formatIP(info.getIp()) : "Hidden (Config)",
|
||||
displayIP ? info.getIp() : "Hidden (Config)",
|
||||
info.getGeolocation(),
|
||||
date != 0 ? FormatUtils.formatTimeStampYear(date) : "-"
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user