Rename DataCache to NicknameCache:

- Some errors were encountered with removal of DataCache,
  turns out if a dependency that has dagger modules that use some
  class, a compile error occurs.
  Thus the DataCache class was left in place until the uses are
  removed from the PluginBridge.
This commit is contained in:
Rsl1122 2019-02-02 10:41:58 +02:00
parent 4f3296b416
commit 95d14ed73f
18 changed files with 233 additions and 167 deletions

View File

@ -17,7 +17,10 @@
package com.djrapitops.plan;
import com.djrapitops.plan.command.PlanCommand;
import com.djrapitops.plan.modules.*;
import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.ServerSuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectProvidingModule;
import com.djrapitops.plan.modules.bukkit.BukkitPlanModule;
import com.djrapitops.plan.modules.bukkit.BukkitServerPropertiesModule;
import com.djrapitops.plan.modules.bukkit.BukkitSuperClassBindingModule;
@ -36,7 +39,6 @@ import javax.inject.Singleton;
@Singleton
@Component(modules = {
BukkitPlanModule.class,
SuperClassBindingModule.class,
SystemObjectProvidingModule.class,
APFModule.class,
FilesModule.class,

View File

@ -22,6 +22,7 @@ import com.djrapitops.plan.db.access.transactions.events.GeoInfoStoreTransaction
import com.djrapitops.plan.db.access.transactions.events.PlayerServerRegisterTransaction;
import com.djrapitops.plan.db.access.transactions.events.WorldNameStoreTransaction;
import com.djrapitops.plan.system.cache.GeolocationCache;
import com.djrapitops.plan.system.cache.NicknameCache;
import com.djrapitops.plan.system.cache.SessionCache;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
@ -32,7 +33,6 @@ import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
import com.djrapitops.plan.system.status.Status;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.task.RunnableFactory;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -59,10 +59,10 @@ public class PlayerOnlineListener implements Listener {
private final ServerInfo serverInfo;
private final DBSystem dbSystem;
private final GeolocationCache geolocationCache;
private final NicknameCache nicknameCache;
private final SessionCache sessionCache;
private final ErrorHandler errorHandler;
private final Status status;
private final RunnableFactory runnableFactory;
@Inject
public PlayerOnlineListener(
@ -72,9 +72,9 @@ public class PlayerOnlineListener implements Listener {
ServerInfo serverInfo,
DBSystem dbSystem,
GeolocationCache geolocationCache,
NicknameCache nicknameCache,
SessionCache sessionCache,
Status status,
RunnableFactory runnableFactory,
ErrorHandler errorHandler
) {
this.config = config;
@ -83,9 +83,9 @@ public class PlayerOnlineListener implements Listener {
this.serverInfo = serverInfo;
this.dbSystem = dbSystem;
this.geolocationCache = geolocationCache;
this.nicknameCache = nicknameCache;
this.sessionCache = sessionCache;
this.status = status;
this.runnableFactory = runnableFactory;
this.errorHandler = errorHandler;
}
@ -185,6 +185,8 @@ public class PlayerOnlineListener implements Listener {
AFKListener.AFK_TRACKER.loggedOut(uuid, time);
nicknameCache.removeDisplayName(uuid);
processing.submit(processors.player().banAndOpProcessor(uuid, player::isBanned, player.isOp()));
processing.submit(processors.player().endSessionProcessor(uuid, time));
processing.submit(processors.info().playerPageUpdateProcessor(uuid));

View File

@ -17,7 +17,10 @@
package com.djrapitops.plan;
import com.djrapitops.plan.command.PlanProxyCommand;
import com.djrapitops.plan.modules.*;
import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.ProxySuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectProvidingModule;
import com.djrapitops.plan.modules.bungee.BungeeCommandModule;
import com.djrapitops.plan.modules.bungee.BungeePlanModule;
import com.djrapitops.plan.modules.bungee.BungeeServerPropertiesModule;
@ -38,7 +41,6 @@ import javax.inject.Singleton;
@Component(modules = {
BungeePlanModule.class,
BungeeCommandModule.class,
SuperClassBindingModule.class,
SystemObjectProvidingModule.class,
APFModule.class,
FilesModule.class,

View File

@ -19,13 +19,11 @@ package com.djrapitops.plan.db.access.queries;
import com.djrapitops.plan.data.container.GeoInfo;
import com.djrapitops.plan.data.container.Ping;
import com.djrapitops.plan.data.container.UserInfo;
import com.djrapitops.plan.data.store.objects.Nickname;
import com.djrapitops.plan.db.access.HasMoreThanZeroQueryStatement;
import com.djrapitops.plan.db.access.Query;
import com.djrapitops.plan.db.access.QueryStatement;
import com.djrapitops.plan.db.sql.tables.GeoInfoTable;
import com.djrapitops.plan.db.sql.tables.PingTable;
import com.djrapitops.plan.db.sql.tables.UserInfoTable;
import com.djrapitops.plan.db.sql.tables.UsersTable;
import com.djrapitops.plan.db.sql.tables.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -199,4 +197,37 @@ public class PlayerFetchQueries {
}
};
}
public static Query<Optional<Nickname>> playersLastSeenNickname(UUID playerUUID, UUID serverUUID) {
String subQuery = "SELECT MAX(" + NicknamesTable.LAST_USED + ") FROM " + NicknamesTable.TABLE_NAME +
" WHERE " + NicknamesTable.USER_UUID + "=?" +
" AND " + NicknamesTable.SERVER_UUID + "=?" +
" GROUP BY " + NicknamesTable.USER_UUID;
String sql = "SELECT " + NicknamesTable.LAST_USED + ", " +
NicknamesTable.NICKNAME + " FROM " + NicknamesTable.TABLE_NAME +
" WHERE " + NicknamesTable.USER_UUID + "=?" +
" AND " + NicknamesTable.SERVER_UUID + "=?" +
" AND " + NicknamesTable.LAST_USED + "=(" + subQuery + ")";
return new QueryStatement<Optional<Nickname>>(sql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, playerUUID.toString());
statement.setString(2, serverUUID.toString());
statement.setString(3, playerUUID.toString());
statement.setString(4, serverUUID.toString());
}
@Override
public Optional<Nickname> processResults(ResultSet set) throws SQLException {
if (set.next()) {
return Optional.of(new Nickname(
set.getString(NicknamesTable.NICKNAME),
set.getLong(NicknamesTable.LAST_USED),
serverUUID
));
}
return Optional.empty();
}
};
}
}

View File

@ -18,8 +18,8 @@ package com.djrapitops.plan.modules;
import com.djrapitops.plan.api.PlanAPI;
import com.djrapitops.plan.api.ProxyAPI;
import com.djrapitops.plan.system.cache.DataCache;
import com.djrapitops.plan.system.cache.ProxyDataCache;
import com.djrapitops.plan.system.cache.ProxySessionCache;
import com.djrapitops.plan.system.cache.SessionCache;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.ProxyDBSystem;
import com.djrapitops.plan.system.importing.EmptyImportSystem;
@ -57,7 +57,7 @@ public interface ProxySuperClassBindingModule {
ConnectionSystem bindProxyConnectionSystem(ProxyConnectionSystem proxyConnectionSystem);
@Binds
DataCache bindProxyDataCache(ProxyDataCache proxyDataCache);
SessionCache bindProxySessionCache(ProxySessionCache proxySessionCache);
@Binds
ImportSystem bindImportSystem(EmptyImportSystem emptyImportSystem);

View File

@ -1,35 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.modules;
import com.djrapitops.plan.system.cache.DataCache;
import com.djrapitops.plan.system.cache.SessionCache;
import dagger.Binds;
import dagger.Module;
/**
* Module for binding instances of implementations to super classes.
*
* @author Rsl1122
*/
@Module
public interface SuperClassBindingModule {
@Binds
SessionCache bindSessionCache(DataCache cache);
}

View File

@ -30,18 +30,18 @@ import javax.inject.Singleton;
@Singleton
public class CacheSystem implements SubSystem {
private final DataCache dataCache;
private final NicknameCache nicknameCache;
private final GeolocationCache geolocationCache;
@Inject
public CacheSystem(DataCache dataCache, GeolocationCache geolocationCache) {
this.dataCache = dataCache;
public CacheSystem(NicknameCache nicknameCache, GeolocationCache geolocationCache) {
this.nicknameCache = nicknameCache;
this.geolocationCache = geolocationCache;
}
@Override
public void enable() throws EnableException {
dataCache.enable();
nicknameCache.enable();
geolocationCache.enable();
}
@ -50,8 +50,8 @@ public class CacheSystem implements SubSystem {
geolocationCache.clearCache();
}
public DataCache getDataCache() {
return dataCache;
public NicknameCache getNicknameCache() {
return nicknameCache;
}
public GeolocationCache getGeolocationCache() {

View File

@ -16,90 +16,21 @@
*/
package com.djrapitops.plan.system.cache;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* This Class contains the Cache.
* <p>
* Contains:
* <ul>
* <li>PlayerName cache, used for reducing database calls on chat events</li>
* <li>DisplayName cache, used for reducing database calls on chat events</li>
* </ul>
* This class is present to not break compiling as some PlanPluginBridge dagger components inject DataCache.
*
* @author Rsl1122
*/
@Singleton
public class DataCache extends SessionCache implements SubSystem {
private final ErrorHandler errorHandler;
private final Map<UUID, String> displayNames;
@Deprecated
public class DataCache {
@Inject
public DataCache(
DBSystem dbSystem,
ErrorHandler errorHandler
) {
super(dbSystem);
this.errorHandler = errorHandler;
displayNames = new HashMap<>();
public DataCache() {
}
@Override
public void enable() {
// Nothing to enable
}
@Override
public void disable() {
displayNames.clear();
}
/**
* Used to update PlayerName and DisplayName caches.
*
* @param uuid UUID of the player.
* @param displayName DisplayName of the player.
*/
public void updateDisplayName(UUID uuid, String displayName) {
if (displayName != null) {
displayNames.put(uuid, displayName);
}
}
/**
* Used to get the player display name in the cache.
* <p>
* If not cached, one from the database will be cached.
*
* @param uuid UUID of the player.
* @return latest displayName or null if none are saved.
*/
public String getDisplayName(UUID uuid) {
String cached = displayNames.get(uuid);
if (cached == null) {
List<String> nicknames;
try {
nicknames = dbSystem.getDatabase().fetch().getNicknames(uuid);
if (!nicknames.isEmpty()) {
return nicknames.get(nicknames.size() - 1);
}
} catch (DBOpException e) {
errorHandler.log(L.ERROR, this.getClass(), e);
}
}
return cached;
}
}
}

View File

@ -0,0 +1,118 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.system.cache;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.data.store.objects.Nickname;
import com.djrapitops.plan.db.access.queries.PlayerFetchQueries;
import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
/**
* Used for caching nicknames when the player is online.
*
* @author Rsl1122
*/
@Singleton
public class NicknameCache implements SubSystem {
private final DBSystem dbSystem;
private final ServerInfo serverInfo;
private final ErrorHandler errorHandler;
private final Map<UUID, String> displayNames;
@Inject
public NicknameCache(
DBSystem dbSystem,
ServerInfo serverInfo,
ErrorHandler errorHandler
) {
this.dbSystem = dbSystem;
this.serverInfo = serverInfo;
this.errorHandler = errorHandler;
displayNames = new HashMap<>();
}
@Override
public void enable() {
// Nothing to enable
}
@Override
public void disable() {
displayNames.clear();
}
/**
* Used to update PlayerName and DisplayName caches.
*
* @param uuid UUID of the player.
* @param displayName DisplayName of the player.
*/
public void updateDisplayName(UUID uuid, String displayName) {
if (displayName != null) {
displayNames.put(uuid, displayName);
}
}
public void removeDisplayName(UUID uuid) {
displayNames.remove(uuid);
}
/**
* Used to get the player display name in the cache.
* <p>
* If not cached, one from the database will be cached.
*
* @param uuid UUID of the player.
* @return latest displayName or null if none are saved.
*/
public String getDisplayName(UUID uuid) {
String cached = displayNames.get(uuid);
if (cached == null) {
cached = updateFromDatabase(uuid, cached);
}
return cached;
}
private String updateFromDatabase(UUID uuid, String cached) {
try {
Optional<Nickname> latest = dbSystem.getDatabase().query(
PlayerFetchQueries.playersLastSeenNickname(uuid, serverInfo.getServerUUID())
);
if (latest.isPresent()) {
cached = latest.get().getName();
displayNames.put(uuid, cached);
}
} catch (DBOpException e) {
errorHandler.log(L.ERROR, this.getClass(), e);
}
return cached;
}
}

View File

@ -18,7 +18,6 @@ package com.djrapitops.plan.system.cache;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -26,18 +25,18 @@ import java.util.Optional;
import java.util.UUID;
/**
* Proxy server specific DataCache.
* Proxy server specific SessionCache.
* <p>
* Used for overriding {@link SessionCache#endSession(UUID, long)}.
*
* @author Rsl1122
*/
@Singleton
public class ProxyDataCache extends DataCache {
public class ProxySessionCache extends SessionCache {
@Inject
public ProxyDataCache(DBSystem dbSystem, ErrorHandler errorHandler) {
super(dbSystem, errorHandler);
public ProxySessionCache(DBSystem dbSystem) {
super(dbSystem);
}
@Override

View File

@ -20,6 +20,8 @@ import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.keys.SessionKeys;
import com.djrapitops.plan.system.database.DBSystem;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@ -30,26 +32,28 @@ import java.util.UUID;
*
* @author Rsl1122
*/
@Singleton
public class SessionCache {
private static final Map<UUID, Session> activeSessions = new HashMap<>();
private static final Map<UUID, Session> ACTIVE_SESSIONS = new HashMap<>();
protected final DBSystem dbSystem;
@Inject
public SessionCache(DBSystem dbSystem) {
this.dbSystem = dbSystem;
}
public static Map<UUID, Session> getActiveSessions() {
return activeSessions;
return ACTIVE_SESSIONS;
}
public static void clear() {
activeSessions.clear();
ACTIVE_SESSIONS.clear();
}
public static void refreshActiveSessionsState() {
for (Session session : activeSessions.values()) {
for (Session session : ACTIVE_SESSIONS.values()) {
session.getUnsafe(SessionKeys.WORLD_TIMES).updateState(System.currentTimeMillis());
}
}
@ -61,14 +65,14 @@ public class SessionCache {
* @return Optional with the session inside it if found.
*/
public static Optional<Session> getCachedSession(UUID uuid) {
return Optional.ofNullable(activeSessions.get(uuid));
return Optional.ofNullable(ACTIVE_SESSIONS.get(uuid));
}
public void cacheSession(UUID uuid, Session session) {
if (getCachedSession(uuid).isPresent()) {
endSession(uuid, System.currentTimeMillis());
}
activeSessions.put(uuid, session);
ACTIVE_SESSIONS.put(uuid, session);
}
/**
@ -79,7 +83,7 @@ public class SessionCache {
* @throws com.djrapitops.plan.api.exceptions.database.DBOpException If saving failed.
*/
public Optional<Session> endSession(UUID uuid, long time) {
Session session = activeSessions.get(uuid);
Session session = ACTIVE_SESSIONS.get(uuid);
if (session == null || session.getUnsafe(SessionKeys.START) > time) {
return Optional.empty();
}
@ -95,6 +99,6 @@ public class SessionCache {
}
protected void removeSessionFromCache(UUID uuid) {
activeSessions.remove(uuid);
ACTIVE_SESSIONS.remove(uuid);
}
}

View File

@ -18,7 +18,7 @@ package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.data.store.objects.Nickname;
import com.djrapitops.plan.db.Database;
import com.djrapitops.plan.system.cache.DataCache;
import com.djrapitops.plan.system.cache.NicknameCache;
import com.djrapitops.plan.system.processing.CriticalRunnable;
import java.util.UUID;
@ -34,29 +34,29 @@ public class NameProcessor implements CriticalRunnable {
private final Nickname nickname;
private final Database database;
private final DataCache dataCache;
private final NicknameCache nicknameCache;
NameProcessor(
UUID uuid, Nickname nickname,
Database database,
DataCache dataCache
NicknameCache nicknameCache
) {
this.uuid = uuid;
this.nickname = nickname;
this.database = database;
this.dataCache = dataCache;
this.nicknameCache = nicknameCache;
}
@Override
public void run() {
String cachedDisplayName = dataCache.getDisplayName(uuid);
String cachedDisplayName = nicknameCache.getDisplayName(uuid);
boolean sameAsCached = nickname.getName().equals(cachedDisplayName);
if (sameAsCached) {
return;
}
dataCache.updateDisplayName(uuid, nickname.getName());
nicknameCache.updateDisplayName(uuid, nickname.getName());
database.save().playerDisplayName(uuid, nickname);
}

View File

@ -17,7 +17,8 @@
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.data.store.objects.Nickname;
import com.djrapitops.plan.system.cache.DataCache;
import com.djrapitops.plan.system.cache.NicknameCache;
import com.djrapitops.plan.system.cache.SessionCache;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
import dagger.Lazy;
@ -37,17 +38,20 @@ public class PlayerProcessors {
private final Lazy<ServerInfo> serverInfo;
private final Lazy<DBSystem> dbSystem;
private final Lazy<DataCache> dataCache;
private final Lazy<SessionCache> sessionCache;
private final Lazy<NicknameCache> nicknameCache;
@Inject
public PlayerProcessors(
Lazy<ServerInfo> serverInfo,
Lazy<DBSystem> dbSystem,
Lazy<DataCache> dataCache
Lazy<SessionCache> sessionCache,
Lazy<NicknameCache> nicknameCache
) {
this.serverInfo = serverInfo;
this.dbSystem = dbSystem;
this.dataCache = dataCache;
this.sessionCache = sessionCache;
this.nicknameCache = nicknameCache;
}
public BanAndOpProcessor banAndOpProcessor(UUID uuid, BooleanSupplier banned, boolean op) {
@ -55,7 +59,7 @@ public class PlayerProcessors {
}
public EndSessionProcessor endSessionProcessor(UUID uuid, long time) {
return new EndSessionProcessor(uuid, time, dataCache.get());
return new EndSessionProcessor(uuid, time, sessionCache.get());
}
public KickProcessor kickProcessor(UUID uuid) {
@ -64,6 +68,6 @@ public class PlayerProcessors {
public NameProcessor nameProcessor(UUID uuid, String displayName) {
Nickname nickname = new Nickname(displayName, System.currentTimeMillis(), serverInfo.get().getServerUUID());
return new NameProcessor(uuid, nickname, dbSystem.get().getDatabase(), dataCache.get());
return new NameProcessor(uuid, nickname, dbSystem.get().getDatabase(), nicknameCache.get());
}
}

View File

@ -56,7 +56,7 @@ public class SessionCacheTest {
@Test
public void testBungeeReCaching() {
SessionCache cache = new ProxyDataCache(null, null);
SessionCache cache = new ProxySessionCache(null);
cache.cacheSession(uuid, session);
Session expected = new Session(uuid, serverUUID, 0, "", "");
cache.cacheSession(uuid, expected);

View File

@ -18,7 +18,10 @@ package utilities.dagger;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.command.PlanCommand;
import com.djrapitops.plan.modules.*;
import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.ServerSuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectProvidingModule;
import com.djrapitops.plan.system.PlanSystem;
import dagger.BindsInstance;
import dagger.Component;
@ -33,7 +36,6 @@ import javax.inject.Singleton;
@Singleton
@Component(modules = {
PlanPluginModule.class,
SuperClassBindingModule.class,
SystemObjectProvidingModule.class,
APFModule.class,
FilesModule.class,

View File

@ -17,7 +17,10 @@
package com.djrapitops.plan;
import com.djrapitops.plan.command.PlanCommand;
import com.djrapitops.plan.modules.*;
import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.ServerSuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectProvidingModule;
import com.djrapitops.plan.modules.sponge.SpongePlanModule;
import com.djrapitops.plan.modules.sponge.SpongeServerPropertiesModule;
import com.djrapitops.plan.modules.sponge.SpongeSuperClassBindingModule;
@ -36,7 +39,6 @@ import javax.inject.Singleton;
@Singleton
@Component(modules = {
SpongePlanModule.class,
SuperClassBindingModule.class,
SystemObjectProvidingModule.class,
APFModule.class,
FilesModule.class,

View File

@ -22,6 +22,7 @@ import com.djrapitops.plan.db.access.transactions.events.GeoInfoStoreTransaction
import com.djrapitops.plan.db.access.transactions.events.PlayerServerRegisterTransaction;
import com.djrapitops.plan.db.access.transactions.events.WorldNameStoreTransaction;
import com.djrapitops.plan.system.cache.GeolocationCache;
import com.djrapitops.plan.system.cache.NicknameCache;
import com.djrapitops.plan.system.cache.SessionCache;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
@ -32,7 +33,6 @@ import com.djrapitops.plan.system.settings.paths.DataGatheringSettings;
import com.djrapitops.plan.system.status.Status;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.task.RunnableFactory;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.entity.living.player.Player;
@ -63,9 +63,9 @@ public class SpongePlayerListener {
private final ServerInfo serverInfo;
private final DBSystem dbSystem;
private final GeolocationCache geolocationCache;
private final NicknameCache nicknameCache;
private final SessionCache sessionCache;
private final Status status;
private final RunnableFactory runnableFactory;
private final ErrorHandler errorHandler;
@Inject
@ -76,9 +76,9 @@ public class SpongePlayerListener {
ServerInfo serverInfo,
DBSystem dbSystem,
GeolocationCache geolocationCache,
NicknameCache nicknameCache,
SessionCache sessionCache,
Status status,
RunnableFactory runnableFactory,
ErrorHandler errorHandler
) {
this.config = config;
@ -87,9 +87,9 @@ public class SpongePlayerListener {
this.serverInfo = serverInfo;
this.dbSystem = dbSystem;
this.geolocationCache = geolocationCache;
this.nicknameCache = nicknameCache;
this.sessionCache = sessionCache;
this.status = status;
this.runnableFactory = runnableFactory;
this.errorHandler = errorHandler;
}
@ -190,6 +190,8 @@ public class SpongePlayerListener {
SpongeAFKListener.AFK_TRACKER.loggedOut(uuid, time);
nicknameCache.removeDisplayName(uuid);
boolean banned = isBanned(player.getProfile());
processing.submit(processors.player().banAndOpProcessor(uuid, () -> banned, false));
processing.submit(processors.player().endSessionProcessor(uuid, time));

View File

@ -17,7 +17,10 @@
package com.djrapitops.plan;
import com.djrapitops.plan.command.PlanProxyCommand;
import com.djrapitops.plan.modules.*;
import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.ProxySuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectProvidingModule;
import com.djrapitops.plan.modules.velocity.VelocityCommandModule;
import com.djrapitops.plan.modules.velocity.VelocityPlanModule;
import com.djrapitops.plan.modules.velocity.VelocityServerPropertiesModule;
@ -38,7 +41,6 @@ import javax.inject.Singleton;
@Component(modules = {
VelocityPlanModule.class,
VelocityCommandModule.class,
SuperClassBindingModule.class,
SystemObjectProvidingModule.class,
APFModule.class,
FilesModule.class,