mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 16:14:26 +08:00
More Login processing.
This commit is contained in:
parent
997ec683ae
commit
b9c9f4d950
@ -478,7 +478,9 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
return tpsCountTimer;
|
||||
}
|
||||
|
||||
public void addToProcessQueue(Processor processor) {
|
||||
processingQueue.addToQueue(processor);
|
||||
public void addToProcessQueue(Processor... processors) {
|
||||
for (Processor processor : processors) {
|
||||
processingQueue.addToQueue(processor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Part responsible for all Player login related analysis.
|
||||
* Part responsible for all Player player related analysis.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.data.handling;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.queue.processing.Processor;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Processor for queueing a Database Commit after changes.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DBCommitProcessor extends Processor<Database> {
|
||||
public DBCommitProcessor(Database object) {
|
||||
super(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
try {
|
||||
object.commit();
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.data.handling.player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class BanProcessor extends PlayerProcessor {
|
||||
|
||||
public BanProcessor(UUID uuid) {
|
||||
super(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
UUID uuid = getUUID();
|
||||
// TODO DB Update Ban status
|
||||
}
|
||||
}
|
@ -2,10 +2,9 @@
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.data.handling.login;
|
||||
package main.java.com.djrapitops.plan.data.handling.player;
|
||||
|
||||
import main.java.com.djrapitops.plan.data.cache.GeolocationCacheHandler;
|
||||
import main.java.com.djrapitops.plan.data.handling.PlayerProcessor;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -26,7 +25,7 @@ public class IPUpdateProcessor extends PlayerProcessor {
|
||||
@Override
|
||||
public void process() {
|
||||
UUID uuid = getUUID();
|
||||
GeolocationCacheHandler.getCountry(ip);
|
||||
String country = GeolocationCacheHandler.getCountry(ip);
|
||||
// TODO DB Update IP & Geolocation
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.data.handling.player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class NameProcessor extends PlayerProcessor {
|
||||
|
||||
private final String playerName;
|
||||
private final String displayName;
|
||||
|
||||
public NameProcessor(UUID uuid, String playerName, String displayName) {
|
||||
super(uuid);
|
||||
this.playerName = playerName;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
UUID uuid = getUUID();
|
||||
// TODO DB Update Name & Nicknames.
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.data.handling;
|
||||
package main.java.com.djrapitops.plan.data.handling.player;
|
||||
|
||||
import main.java.com.djrapitops.plan.queue.processing.Processor;
|
||||
|
@ -2,10 +2,9 @@
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.data.handling.login;
|
||||
package main.java.com.djrapitops.plan.data.handling.player;
|
||||
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.handling.PlayerProcessor;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -8,10 +8,14 @@ import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.data.handling.DBCommitProcessor;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.KickInfo;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.LoginInfo;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.LogoutInfo;
|
||||
import main.java.com.djrapitops.plan.data.handling.login.RegisterProcessor;
|
||||
import main.java.com.djrapitops.plan.data.handling.player.BanProcessor;
|
||||
import main.java.com.djrapitops.plan.data.handling.player.IPUpdateProcessor;
|
||||
import main.java.com.djrapitops.plan.data.handling.player.NameProcessor;
|
||||
import main.java.com.djrapitops.plan.data.handling.player.RegisterProcessor;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.NewPlayerCreator;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -20,6 +24,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.net.InetAddress;
|
||||
@ -48,6 +53,15 @@ public class PlanPlayerListener implements Listener {
|
||||
cache = plugin.getHandler();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
PlayerLoginEvent.Result result = event.getResult();
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
if (result == PlayerLoginEvent.Result.KICK_BANNED) {
|
||||
plugin.addToProcessQueue(new BanProcessor(uuid));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PlayerJoinEvent Listener.
|
||||
* <p>
|
||||
@ -58,22 +72,34 @@ public class PlanPlayerListener implements Listener {
|
||||
* @param event The Fired event.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLogin(PlayerJoinEvent event) {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
IPlayer iPlayer = Fetch.wrapBukkit(player);
|
||||
plugin.getNotificationCenter().checkNotifications(iPlayer);
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
long time = MiscUtils.getTime();
|
||||
|
||||
String world = player.getWorld().getName();
|
||||
String gm = player.getGameMode().name();
|
||||
long time = MiscUtils.getTime();
|
||||
|
||||
String ip = player.getAddress().getAddress().toString();
|
||||
|
||||
String playerName = player.getName();
|
||||
String displayName = player.getDisplayName();
|
||||
|
||||
int playersOnline = plugin.getTpsCountTimer().getLatestPlayersOnline();
|
||||
|
||||
cache.cacheSession(uuid, Session.start(time, world, gm));
|
||||
|
||||
plugin.addToProcessQueue(new RegisterProcessor(uuid, time, playersOnline));
|
||||
plugin.addToProcessQueue(
|
||||
new RegisterProcessor(uuid, time, playersOnline), //TODO Add required variables after UsersTable is done.
|
||||
new IPUpdateProcessor(uuid, ip),
|
||||
new NameProcessor(uuid, playerName, displayName),
|
||||
new DBCommitProcessor(plugin.getDB())
|
||||
);
|
||||
|
||||
|
||||
plugin.getRunnableFactory().createNew(new AbsRunnable("NewPlayerCheckTask") {
|
||||
@Override
|
||||
|
@ -321,4 +321,6 @@ public abstract class Database {
|
||||
public ServerTable getServerTable() {
|
||||
return serverTable;
|
||||
}
|
||||
|
||||
public abstract void commit() throws SQLException;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user