use of com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery 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.extension.implementation.storage.queries.ExtensionPlayerDataQuery in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionPlayerValuesAreStored.
@Test
default void extensionPlayerValuesAreStored() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new PlayerExtension());
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
Map<ServerUUID, List<ExtensionData>> playerDataByServerUUID = db().query(new ExtensionPlayerDataQuery(playerUUID));
List<ExtensionData> ofServer = playerDataByServerUUID.get(serverUUID());
assertNotNull(ofServer);
assertFalse(ofServer.isEmpty());
ExtensionData extensionPlayerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionPlayerData.getTabs();
// No tab defined, should contain 1 tab
assertEquals(1, tabs.size());
ExtensionTabData tabData = tabs.get(0);
OptionalAssert.equals("5", tabData.getNumber("value").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("No", tabData.getBoolean("boolVal").map(ExtensionBooleanData::getFormattedValue));
OptionalAssert.equals("0.5", tabData.getDouble("doubleVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("0.5", tabData.getPercentage("percentageVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("Something", tabData.getString("stringVal").map(ExtensionStringData::getFormattedValue));
OptionalAssert.equals("Group", tabData.getString("groupVal").map(ExtensionStringData::getFormattedValue));
}
use of com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method removeEverythingRemovesPlayerExtensionData.
@Test
default void removeEverythingRemovesPlayerExtensionData() {
extensionPlayerValuesAreStored();
db().executeTransaction(new RemoveEverythingTransaction());
assertTrue(db().query(new ExtensionPlayerDataQuery(playerUUID)).isEmpty());
}
use of com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionPlayerTableValuesAreInserted.
@Test
default void extensionPlayerTableValuesAreInserted() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new TableExtension());
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
Map<ServerUUID, List<ExtensionData>> ofPlayer = db().query(new ExtensionPlayerDataQuery(playerUUID));
assertFalse(ofPlayer.isEmpty());
List<ExtensionData> ofServer = ofPlayer.get(serverUUID());
assertEquals(1, ofServer.size());
ExtensionData extensionServerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionServerData.getTabs();
// No tab defined, should contain 1 tab
assertEquals(1, tabs.size());
ExtensionTabData tabData = tabs.get(0);
List<ExtensionTableData> tableData = tabData.getTableData();
assertEquals(1, tableData.size());
ExtensionTableData table = tableData.get(0);
HtmlTable expected = HtmlTable.fromExtensionTable(Table.builder().columnOne("first", Icon.called("gavel").build()).columnTwo("second", Icon.called("what").build()).columnThree("third", Icon.called("question").build()).addRow("value", 3, 0.5, 400L).build(), com.djrapitops.plan.delivery.rendering.html.icon.Color.AMBER);
assertEquals(expected.toHtml(), table.getHtmlTable().toHtml());
}
Aggregations