mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Moved Player#getFirstPlayed call to asynchronous execution #659
This commit is contained in:
parent
397f1dd81b
commit
5b4ae5ba36
Plan/src
main/java/com/djrapitops/plan/system
listeners
processing/processors/player
test/java/com/djrapitops/plan/system/database/databases
@ -97,7 +97,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, time, world, gm));
|
||||
|
||||
Processing.submit(
|
||||
new RegisterProcessor(uuid, player.getFirstPlayed(), playerName,
|
||||
new RegisterProcessor(uuid, player::getFirstPlayed, playerName,
|
||||
new IPUpdateProcessor(uuid, address, time),
|
||||
new NameProcessor(uuid, playerName, displayName),
|
||||
new PlayerPageUpdateProcessor(uuid)
|
||||
|
@ -100,7 +100,7 @@ public class SpongePlayerListener {
|
||||
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, time, world, gm));
|
||||
|
||||
Processing.submit(
|
||||
new RegisterProcessor(uuid, time, playerName,
|
||||
new RegisterProcessor(uuid, () -> time, playerName,
|
||||
new IPUpdateProcessor(uuid, address, time),
|
||||
new NameProcessor(uuid, playerName, displayName),
|
||||
new PlayerPageUpdateProcessor(uuid)
|
||||
|
@ -10,6 +10,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Registers the user to the database and marks first session if the user has no actions.
|
||||
@ -19,11 +20,11 @@ import java.util.UUID;
|
||||
public class RegisterProcessor implements CriticalRunnable {
|
||||
|
||||
private final UUID uuid;
|
||||
private final long registered;
|
||||
private final Supplier<Long> registered;
|
||||
private final String name;
|
||||
private final Runnable[] afterProcess;
|
||||
|
||||
public RegisterProcessor(UUID uuid, long registered, String name, Runnable... afterProcess) {
|
||||
public RegisterProcessor(UUID uuid, Supplier<Long> registered, String name, Runnable... afterProcess) {
|
||||
this.uuid = uuid;
|
||||
this.registered = registered;
|
||||
this.name = name;
|
||||
@ -36,10 +37,10 @@ public class RegisterProcessor implements CriticalRunnable {
|
||||
Verify.nullCheck(uuid, () -> new IllegalStateException("UUID was null"));
|
||||
try {
|
||||
if (!db.check().isPlayerRegistered(uuid)) {
|
||||
db.save().registerNewUser(uuid, registered, name);
|
||||
db.save().registerNewUser(uuid, registered.get(), name);
|
||||
}
|
||||
if (!db.check().isPlayerRegisteredOnThisServer(uuid)) {
|
||||
db.save().registerNewUserOnThisServer(uuid, registered);
|
||||
db.save().registerNewUserOnThisServer(uuid, registered.get());
|
||||
}
|
||||
} finally {
|
||||
for (Runnable runnable : afterProcess) {
|
||||
|
@ -594,7 +594,7 @@ public class SQLiteTest {
|
||||
assertTrue(securityTable.getUsers().isEmpty());
|
||||
}
|
||||
|
||||
private void saveAllData(SQLDB database) throws UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
private void saveAllData(SQLDB database) throws NoSuchAlgorithmException {
|
||||
System.out.println("Saving all possible data to the Database..");
|
||||
UserInfoTable userInfoTable = database.getUserInfoTable();
|
||||
UsersTable usersTable = database.getUsersTable();
|
||||
@ -864,7 +864,7 @@ public class SQLiteTest {
|
||||
System.out.println("\n- Running RegisterProcessors -");
|
||||
List<RegisterProcessor> processors = new ArrayList<>();
|
||||
for (int i = 0; i < 200; i++) {
|
||||
processors.add(new RegisterProcessor(playerUUID, 500L, "name"));
|
||||
processors.add(new RegisterProcessor(playerUUID, () -> 500L, "name"));
|
||||
}
|
||||
for (RegisterProcessor processor : processors) {
|
||||
processor.run();
|
||||
|
Loading…
Reference in New Issue
Block a user