use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class DatabaseTest method testRemovalSingleUser.
@Test
default void testRemovalSingleUser() {
saveUserTwo();
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
saveTwoWorlds();
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
execute(DataStoreQueries.storeSession(session));
db().executeTransaction(new NicknameStoreTransaction(playerUUID, new Nickname("TestNick", RandomData.randomTime(), serverUUID()), (uuid, name) -> false));
db().executeTransaction(new GeoInfoStoreTransaction(playerUUID, new GeoInfo("TestLoc", RandomData.randomTime())));
assertTrue(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
db().executeTransaction(new RemovePlayerTransaction(playerUUID));
assertFalse(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
assertFalse(db().query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID())));
assertTrue(db().query(NicknameQueries.fetchNicknameDataOfPlayer(playerUUID)).isEmpty());
assertTrue(db().query(GeoInfoQueries.fetchPlayerGeoInformation(playerUUID)).isEmpty());
assertQueryIsEmpty(db(), SessionQueries.fetchSessionsOfPlayer(playerUUID));
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PlayerOnlineListener method onPlayerLogin.
public void onPlayerLogin(SocketAddress address, GameProfile profile, boolean banned) {
try {
UUID playerUUID = profile.getId();
ServerUUID serverUUID = serverInfo.getServerUUID();
String joinAddress = address.toString();
if (!joinAddress.isEmpty()) {
joinAddresses.put(playerUUID, joinAddress.substring(0, joinAddress.lastIndexOf(':')));
}
dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID, () -> banned));
} catch (Exception e) {
errorLogger.error(e, ErrorContext.builder().related(getClass(), address, profile, banned).build());
}
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ServerQueriesTest method bungeeInformationIsStored.
@Test
default void bungeeInformationIsStored() {
Optional<Server> bungeeInfo = db().query(ServerQueries.fetchProxyServerInformation());
assertFalse(bungeeInfo.isPresent());
ServerUUID bungeeUUID = ServerUUID.randomUUID();
Server bungeeCord = new Server(bungeeUUID, "BungeeCord", "Random:1234");
bungeeCord.setProxy(true);
db().executeTransaction(new StoreServerInformationTransaction(bungeeCord));
forcePersistenceCheck();
bungeeCord.setId(2);
bungeeInfo = db().query(ServerQueries.fetchProxyServerInformation());
assertTrue(bungeeInfo.isPresent());
assertEquals(bungeeCord, bungeeInfo.get());
Optional<Server> found = db().query(ServerQueries.fetchServerMatchingIdentifier(bungeeUUID));
OptionalAssert.equals(bungeeCord.getWebAddress(), found.map(Server::getWebAddress));
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ProxyServerInfo method createServerObject.
private Server createServerObject() {
ServerUUID serverUUID = generateNewUUID();
String accessAddress = addresses.getAccessAddress().orElseThrow(() -> new EnableException("Velocity can not have '0.0.0.0' or '' as an address. Set up 'Server.IP' setting."));
return new Server(-1, serverUUID, "BungeeCord", accessAddress, true);
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ServerFileLoader method load.
@Override
public Optional<Server> load(ServerUUID loaded) {
try {
if (!prepared)
prepare();
String serverUUIDString = getString("Server.UUID");
if (serverUUIDString == null)
return Optional.empty();
Integer id = getInteger("Server.ID");
ServerUUID serverUUID = ServerUUID.fromString(serverUUIDString);
String name = config.getNode(PluginSettings.SERVER_NAME.getPath()).map(ConfigNode::getString).orElse("Proxy");
String address = getString("Server.Web_address");
return Optional.of(new Server(id, serverUUID, name, address, false));
} catch (IOException e) {
throw new EnableException("Failed to read ServerInfoFile.yml: " + e.getMessage());
}
}
Aggregations