mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-12 06:48:50 +02:00
Moved Player#isBanned call to be executed on an asynchronous thread #616
This commit is contained in:
parent
efa0a2949f
commit
b25acb18c4
@ -41,7 +41,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
UUID uuid = event.getPlayer().getUniqueId();
|
UUID uuid = event.getPlayer().getUniqueId();
|
||||||
boolean op = event.getPlayer().isOp();
|
boolean op = event.getPlayer().isOp();
|
||||||
boolean banned = result == PlayerLoginEvent.Result.KICK_BANNED;
|
boolean banned = result == PlayerLoginEvent.Result.KICK_BANNED;
|
||||||
Processing.submit(new BanAndOpProcessor(uuid, banned, op));
|
Processing.submit(new BanAndOpProcessor(uuid, () -> banned, op));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass(), e);
|
Log.toLog(this.getClass(), e);
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
|
|
||||||
AFKListener.AFK_TRACKER.loggedOut(uuid, time);
|
AFKListener.AFK_TRACKER.loggedOut(uuid, time);
|
||||||
|
|
||||||
Processing.submit(new BanAndOpProcessor(uuid, player.isBanned(), player.isOp()));
|
Processing.submit(new BanAndOpProcessor(uuid, player::isBanned, player.isOp()));
|
||||||
Processing.submit(new EndSessionProcessor(uuid, time));
|
Processing.submit(new EndSessionProcessor(uuid, time));
|
||||||
Processing.submit(new NetworkPageUpdateProcessor());
|
Processing.submit(new NetworkPageUpdateProcessor());
|
||||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||||
|
@ -44,7 +44,7 @@ public class SpongePlayerListener {
|
|||||||
GameProfile profile = event.getProfile();
|
GameProfile profile = event.getProfile();
|
||||||
UUID uuid = profile.getUniqueId();
|
UUID uuid = profile.getUniqueId();
|
||||||
boolean banned = isBanned(profile);
|
boolean banned = isBanned(profile);
|
||||||
Processing.submit(new BanAndOpProcessor(uuid, banned, false));
|
Processing.submit(new BanAndOpProcessor(uuid, () -> banned, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener(order = Order.POST)
|
@Listener(order = Order.POST)
|
||||||
@ -125,7 +125,8 @@ public class SpongePlayerListener {
|
|||||||
|
|
||||||
SpongeAFKListener.AFK_TRACKER.loggedOut(uuid, time);
|
SpongeAFKListener.AFK_TRACKER.loggedOut(uuid, time);
|
||||||
|
|
||||||
Processing.submit(new BanAndOpProcessor(uuid, isBanned(player.getProfile()), false));
|
boolean banned = isBanned(player.getProfile());
|
||||||
|
Processing.submit(new BanAndOpProcessor(uuid, () -> banned, false));
|
||||||
Processing.submit(new EndSessionProcessor(uuid, time));
|
Processing.submit(new EndSessionProcessor(uuid, time));
|
||||||
Processing.submit(new NetworkPageUpdateProcessor());
|
Processing.submit(new NetworkPageUpdateProcessor());
|
||||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||||
|
@ -8,6 +8,7 @@ import com.djrapitops.plan.system.database.databases.Database;
|
|||||||
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
|
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates ban and OP status of the player to the database.
|
* Updates ban and OP status of the player to the database.
|
||||||
@ -17,10 +18,10 @@ import java.util.UUID;
|
|||||||
public class BanAndOpProcessor implements Runnable {
|
public class BanAndOpProcessor implements Runnable {
|
||||||
|
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private final boolean banned;
|
private final Supplier<Boolean> banned;
|
||||||
private final boolean op;
|
private final boolean op;
|
||||||
|
|
||||||
public BanAndOpProcessor(UUID uuid, boolean banned, boolean op) {
|
public BanAndOpProcessor(UUID uuid, Supplier<Boolean> banned, boolean op) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.banned = banned;
|
this.banned = banned;
|
||||||
this.op = op;
|
this.op = op;
|
||||||
@ -29,7 +30,7 @@ public class BanAndOpProcessor implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SaveOperations save = Database.getActive().save();
|
SaveOperations save = Database.getActive().save();
|
||||||
save.banStatus(uuid, banned);
|
save.banStatus(uuid, banned.get());
|
||||||
save.opStatus(uuid, op);
|
save.opStatus(uuid, op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user