use of com.djrapitops.plan.identification.Server in project Plan by plan-player-analytics.
the class PageFactory method inspectPluginTabs.
public PlayerPluginTab inspectPluginTabs(UUID playerUUID) {
Database database = dbSystem.get().getDatabase();
Map<ServerUUID, List<ExtensionData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
if (extensionPlayerData.isEmpty()) {
return new PlayerPluginTab("", Collections.emptyList(), formatters.get());
}
List<PlayerPluginTab> playerPluginTabs = new ArrayList<>();
for (Map.Entry<ServerUUID, Server> entry : database.query(ServerQueries.fetchPlanServerInformation()).entrySet()) {
ServerUUID serverUUID = entry.getKey();
String serverName = entry.getValue().getIdentifiableName();
List<ExtensionData> ofServer = extensionPlayerData.get(serverUUID);
if (ofServer == null) {
continue;
}
playerPluginTabs.add(new PlayerPluginTab(serverName, ofServer, formatters.get()));
}
StringBuilder navs = new StringBuilder();
StringBuilder tabs = new StringBuilder();
playerPluginTabs.stream().sorted().forEach(tab -> {
navs.append(tab.getNav());
tabs.append(tab.getTab());
});
return new PlayerPluginTab(navs.toString(), tabs.toString());
}
use of com.djrapitops.plan.identification.Server in project Plan by plan-player-analytics.
the class MySQLTest method setUp.
@BeforeEach
void setUp() {
TestErrorLogger.throwErrors(true);
db().executeTransaction(new RemoveEverythingTransaction());
db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), TestConstants.SERVER_NAME, "", TestConstants.VERSION)));
assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
use of com.djrapitops.plan.identification.Server in project Plan by plan-player-analytics.
the class SQLiteTest method setUp.
@BeforeEach
void setUp() {
TestErrorLogger.throwErrors(true);
db().executeTransaction(new Patch() {
@Override
public boolean hasBeenApplied() {
return false;
}
@Override
public void applyPatch() {
dropTable("plan_world_times");
dropTable("plan_kills");
dropTable("plan_sessions");
dropTable("plan_worlds");
dropTable("plan_users");
}
});
db().executeTransaction(new CreateTablesTransaction());
db().executeTransaction(new RemoveEverythingTransaction());
db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), "ServerName", "", TestConstants.VERSION)));
assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
use of com.djrapitops.plan.identification.Server in project Plan by plan-player-analytics.
the class ShutdownSaveTest method storeNecessaryInformation.
private void storeNecessaryInformation() throws Exception {
database.executeTransaction(new RemoveEverythingTransaction());
ServerUUID serverUUID = TestConstants.SERVER_UUID;
UUID playerUUID = TestConstants.PLAYER_ONE_UUID;
String worldName = TestConstants.WORLD_ONE_NAME;
database.executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID, "-", "", TestConstants.VERSION)));
database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> 0L, TestConstants.PLAYER_ONE_NAME));
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName)).get();
}
use of com.djrapitops.plan.identification.Server in project Plan by plan-player-analytics.
the class ServerFileLoaderTest method runParallelLoadsAndSaves.
@Test
void runParallelLoadsAndSaves() throws InterruptedException {
ExecutorService executorService = new ScheduledThreadPoolExecutor(6);
AtomicInteger runs = new AtomicInteger(1);
int expected = 1000;
AtomicInteger fails = new AtomicInteger(0);
try {
for (int i = 0; i < expected; i++) {
executorService.submit(() -> {
try {
Optional<Server> load = underTest.load(null);
if (load.isPresent()) {
underTest.save(load.get());
} else {
System.out.println("Failure " + fails.incrementAndGet());
}
} finally {
runs.incrementAndGet();
}
});
}
Awaitility.await().atMost(2, TimeUnit.MINUTES).until(() -> runs.get() >= expected);
} finally {
executorService.shutdown();
if (!executorService.awaitTermination(5, TimeUnit.SECONDS)) {
executorService.shutdownNow();
}
}
assertEquals(0, fails.get());
}
Aggregations