Replaced two ExtensionData class variants with one

This commit is contained in:
Rsl1122 2019-08-27 11:44:50 +03:00
parent 3afc168fec
commit 7feacebbb0
19 changed files with 134 additions and 303 deletions

View File

@ -25,7 +25,7 @@ import com.djrapitops.plan.data.store.Type;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.objects.DateObj;
import com.djrapitops.plan.data.time.WorldTimes;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import java.util.List;
import java.util.Map;
@ -64,5 +64,5 @@ public class ServerKeys {
public static final Key<DateObj<Integer>> ALL_TIME_PEAK_PLAYERS = new Key<>(new Type<DateObj<Integer>>() {}, "all_time_peak_players");
public static final Key<DateObj<Integer>> RECENT_PEAK_PLAYERS = new Key<>(new Type<DateObj<Integer>>() {}, "recent_peak_players");
public static final Key<Map<String, Integer>> COMMAND_USAGE = new Key<>(new Type<Map<String, Integer>>() {}, "command_usage");
public static final Key<List<ExtensionServerData>> EXTENSION_DATA = new Key<>(new Type<List<ExtensionServerData>>() {}, "extension_data");
public static final Key<List<ExtensionData>> EXTENSION_DATA = new Key<>(new Type<List<ExtensionData>>() {}, "extension_data");
}

View File

@ -14,11 +14,7 @@
* 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.extension.implementation.results.server;
import com.djrapitops.plan.extension.implementation.results.ExtensionInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTableData;
package com.djrapitops.plan.extension.implementation.results;
import java.util.*;
@ -27,7 +23,7 @@ import java.util.*;
*
* @author Rsl1122
*/
public class ExtensionServerData implements Comparable<ExtensionServerData> {
public class ExtensionData implements Comparable<ExtensionData> {
private final int pluginID;
@ -35,7 +31,7 @@ public class ExtensionServerData implements Comparable<ExtensionServerData> {
private Map<String, ExtensionTabData> tabs;
private ExtensionServerData(int pluginID) {
private ExtensionData(int pluginID) {
this.pluginID = pluginID;
tabs = new HashMap<>();
@ -69,15 +65,15 @@ public class ExtensionServerData implements Comparable<ExtensionServerData> {
}
@Override
public int compareTo(ExtensionServerData o) {
public int compareTo(ExtensionData o) {
return String.CASE_INSENSITIVE_ORDER.compare(this.extensionInformation.getPluginName(), o.extensionInformation.getPluginName());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ExtensionServerData)) return false;
ExtensionServerData that = (ExtensionServerData) o;
if (!(o instanceof ExtensionData)) return false;
ExtensionData that = (ExtensionData) o;
return pluginID == that.pluginID &&
Objects.equals(extensionInformation, that.extensionInformation) &&
Objects.equals(tabs, that.tabs);
@ -90,10 +86,10 @@ public class ExtensionServerData implements Comparable<ExtensionServerData> {
public static class Factory {
private final ExtensionServerData data;
private final ExtensionData data;
public Factory(int pluginId) {
data = new ExtensionServerData(pluginId);
data = new ExtensionData(pluginId);
}
public Factory combine(Factory with) {
@ -127,7 +123,7 @@ public class ExtensionServerData implements Comparable<ExtensionServerData> {
return Optional.ofNullable(data.tabs.get(tabName));
}
public ExtensionServerData build() {
public ExtensionData build() {
return data;
}
}

View File

@ -1,131 +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.extension.implementation.results.player;
import com.djrapitops.plan.extension.implementation.results.ExtensionInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import java.util.*;
/**
* Represents data of a single extension about a player.
*
* @author Rsl1122
*/
public class ExtensionPlayerData implements Comparable<ExtensionPlayerData> {
private final int pluginID;
private ExtensionInformation extensionInformation;
private List<ExtensionTabData> tabs;
private ExtensionPlayerData(int pluginID) {
this.pluginID = pluginID;
tabs = new ArrayList<>();
}
public int getPluginID() {
return pluginID;
}
public ExtensionInformation getExtensionInformation() {
return extensionInformation;
}
public boolean hasOnlyGenericTab() {
return tabs.size() == 1 && tabs.get(0).getTabInformation().getTabName().isEmpty();
}
public List<ExtensionTabData> getTabs() {
return tabs;
}
@Override
public int compareTo(ExtensionPlayerData o) {
return String.CASE_INSENSITIVE_ORDER.compare(this.extensionInformation.getPluginName(), o.extensionInformation.getPluginName());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ExtensionPlayerData)) return false;
ExtensionPlayerData that = (ExtensionPlayerData) o;
return pluginID == that.pluginID &&
extensionInformation.equals(that.extensionInformation) &&
tabs.equals(that.tabs);
}
@Override
public int hashCode() {
return Objects.hash(pluginID, extensionInformation, tabs);
}
public static class Factory {
private final ExtensionPlayerData data;
public Factory(int pluginId) {
data = new ExtensionPlayerData(pluginId);
}
public Factory setInformation(ExtensionInformation information) {
if (information.getId() != data.pluginID) {
throw new IllegalArgumentException("ID mismatch, wanted id: " + data.pluginID + " but got " + information);
}
data.extensionInformation = information;
return this;
}
public Factory addTab(ExtensionTabData tab) {
data.tabs.add(tab);
return this;
}
public ExtensionPlayerData build() {
Collections.sort(data.tabs);
return data;
}
public Factory combine(Factory with) {
if (with != null) {
for (ExtensionTabData tab : with.build().getTabs()) {
Optional<ExtensionTabData> found = getTab(tab.getTabInformation().getTabName());
if (found.isPresent()) {
found.get().combine(tab);
} else {
addTab(tab);
}
}
}
return this;
}
public Optional<ExtensionTabData> getTab(String tabName) {
for (ExtensionTabData tab : data.tabs) {
if (tabName.equals(tab.getTabInformation().getTabName())) {
return Optional.of(tab);
}
}
return Optional.empty();
}
}
}

View File

@ -25,10 +25,10 @@ import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
import com.djrapitops.plan.extension.implementation.results.ExtensionDoubleData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -54,7 +54,7 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
*
* @author Rsl1122
*/
public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, ExtensionServerData.Factory>> {
public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, ExtensionData.Factory>> {
private final UUID serverUUID;
@ -63,7 +63,7 @@ public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, Exten
}
@Override
public Map<Integer, ExtensionServerData.Factory> executeQuery(SQLDB db) {
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
String selectTrueBooleans = SELECT +
ExtensionPlayerValueTable.PROVIDER_ID +
",COUNT(1) as positive" +
@ -106,7 +106,7 @@ public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, Exten
WHERE + ExtensionPluginTable.SERVER_UUID + "=?" +
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
return db.query(new QueryStatement<Map<Integer, ExtensionServerData.Factory>>(sql, 1000) {
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setBoolean(1, true); // selectTrueBooleans parameter
@ -115,8 +115,8 @@ public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, Exten
}
@Override
public Map<Integer, ExtensionServerData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toServerDataByPluginID();
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
}
});
}

View File

@ -25,10 +25,10 @@ import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
import com.djrapitops.plan.extension.implementation.results.ExtensionDoubleData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -54,7 +54,7 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
*
* @author Rsl1122
*/
public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, ExtensionServerData.Factory>> {
public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, ExtensionData.Factory>> {
private final UUID serverUUID;
@ -63,7 +63,7 @@ public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, Extens
}
@Override
public Map<Integer, ExtensionServerData.Factory> executeQuery(SQLDB db) {
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
String selectDoubleAverage = SELECT +
ExtensionPlayerValueTable.PROVIDER_ID +
",AVG(" + ExtensionPlayerValueTable.DOUBLE_VALUE + ") as average" +
@ -106,7 +106,7 @@ public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, Extens
WHERE + ExtensionPluginTable.SERVER_UUID + "=?" +
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
return db.query(new QueryStatement<Map<Integer, ExtensionServerData.Factory>>(sql, 1000) {
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverUUID.toString());
@ -114,8 +114,8 @@ public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, Extens
}
@Override
public Map<Integer, ExtensionServerData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toServerDataByPluginID();
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
}
});
}

View File

@ -26,10 +26,10 @@ import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
import com.djrapitops.plan.extension.implementation.results.ExtensionNumberData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -55,7 +55,7 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
*
* @author Rsl1122
*/
public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, ExtensionServerData.Factory>> {
public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, ExtensionData.Factory>> {
private final UUID serverUUID;
@ -64,7 +64,7 @@ public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, Extens
}
@Override
public Map<Integer, ExtensionServerData.Factory> executeQuery(SQLDB db) {
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
String selectNumberAverage = SELECT +
ExtensionPlayerValueTable.PROVIDER_ID +
",AVG(" + ExtensionPlayerValueTable.LONG_VALUE + ") as average" +
@ -110,7 +110,7 @@ public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, Extens
AND + "p1." + ExtensionProviderTable.FORMAT_TYPE + "!=?" +
AND + "p1." + ExtensionProviderTable.FORMAT_TYPE + "!=?";
return db.query(new QueryStatement<Map<Integer, ExtensionServerData.Factory>>(sql, 1000) {
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverUUID.toString());
@ -120,8 +120,8 @@ public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, Extens
}
@Override
public Map<Integer, ExtensionServerData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toServerDataByPluginID();
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
}
});
}

View File

@ -25,10 +25,10 @@ import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
import com.djrapitops.plan.extension.implementation.results.ExtensionDoubleData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -54,7 +54,7 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
*
* @author Rsl1122
*/
public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, ExtensionServerData.Factory>> {
public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, ExtensionData.Factory>> {
private final UUID serverUUID;
@ -63,7 +63,7 @@ public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, Ex
}
@Override
public Map<Integer, ExtensionServerData.Factory> executeQuery(SQLDB db) {
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
String selectPercentageAverage = SELECT +
ExtensionPlayerValueTable.PROVIDER_ID +
",AVG(" + ExtensionPlayerValueTable.PERCENTAGE_VALUE + ") as average" +
@ -97,7 +97,7 @@ public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, Ex
WHERE + ExtensionPluginTable.SERVER_UUID + "=?" +
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
return db.query(new QueryStatement<Map<Integer, ExtensionServerData.Factory>>(sql, 1000) {
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverUUID.toString());
@ -105,8 +105,8 @@ public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, Ex
}
@Override
public Map<Integer, ExtensionServerData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toServerDataByPluginID();
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
}
});
}

View File

@ -30,7 +30,6 @@ import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.*;
import com.djrapitops.plan.extension.implementation.results.player.ExtensionPlayerData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -40,22 +39,22 @@ import java.util.*;
import static com.djrapitops.plan.db.sql.parsing.Sql.*;
/**
* Query all ExtensionPlayerData by Server UUIDs.
* Query all ExtensionData by Server UUIDs.
* <p>
* Returns Map: Server UUID - List of ExtensionPlayerData.
* Returns Map: Server UUID - List of ExtensionData.
* <p>
* How it is done:
* - Two queries are run, one that fetches all extensions and one that fetches all data of the player.
* - Data query is sorted into a multi-map: PluginID - Tab Name - Tab Data
* - (Tab Name can be empty.)
* - Multi-map is sorted into ExtensionPlayerData objects by PluginID, one per ID
* - This map is sorted into final Map: Server UUID - List of ExtensionPlayerData at the highest level.
* - Multi-map is sorted into ExtensionData objects by PluginID, one per ID
* - This map is sorted into final Map: Server UUID - List of ExtensionData at the highest level.
* <p>
* There are multiple data extraction methods to make extracting the value query easier.
*
* @author Rsl1122
*/
public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionPlayerData>>> {
public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionData>>> {
private final UUID playerUUID;
@ -64,9 +63,9 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionP
}
@Override
public Map<UUID, List<ExtensionPlayerData>> executeQuery(SQLDB db) {
public Map<UUID, List<ExtensionData>> executeQuery(SQLDB db) {
Map<UUID, List<ExtensionInformation>> extensionsByServerUUID = db.query(ExtensionInformationQueries.allExtensions());
Map<Integer, ExtensionPlayerData.Factory> extensionDataByPluginID = db.query(fetchIncompletePlayerDataByPluginID());
Map<Integer, ExtensionData.Factory> extensionDataByPluginID = db.query(fetchIncompletePlayerDataByPluginID());
combine(extensionDataByPluginID, db.query(new ExtensionPlayerTablesQuery(playerUUID)));
combine(extensionDataByPluginID, db.query(new ExtensionPlayerGroupsQuery(playerUUID)));
@ -75,14 +74,14 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionP
}
private void combine(
Map<Integer, ExtensionPlayerData.Factory> extensionDataByPluginID,
Map<Integer, ExtensionPlayerData.Factory> aggregates
Map<Integer, ExtensionData.Factory> extensionDataByPluginID,
Map<Integer, ExtensionData.Factory> aggregates
) {
for (Map.Entry<Integer, ExtensionPlayerData.Factory> entry : aggregates.entrySet()) {
for (Map.Entry<Integer, ExtensionData.Factory> entry : aggregates.entrySet()) {
Integer pluginID = entry.getKey();
ExtensionPlayerData.Factory data = entry.getValue();
ExtensionData.Factory data = entry.getValue();
ExtensionPlayerData.Factory found = extensionDataByPluginID.get(pluginID);
ExtensionData.Factory found = extensionDataByPluginID.get(pluginID);
if (found == null) {
extensionDataByPluginID.put(pluginID, data);
} else {
@ -91,17 +90,17 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionP
}
}
private Map<UUID, List<ExtensionPlayerData>> flatMapByServerUUID(Map<UUID, List<ExtensionInformation>> extensionsByServerUUID, Map<Integer, ExtensionPlayerData.Factory> extensionDataByPluginID) {
Map<UUID, List<ExtensionPlayerData>> extensionDataByServerUUID = new HashMap<>();
private Map<UUID, List<ExtensionData>> flatMapByServerUUID(Map<UUID, List<ExtensionInformation>> extensionsByServerUUID, Map<Integer, ExtensionData.Factory> extensionDataByPluginID) {
Map<UUID, List<ExtensionData>> extensionDataByServerUUID = new HashMap<>();
for (Map.Entry<UUID, List<ExtensionInformation>> entry : extensionsByServerUUID.entrySet()) {
UUID serverUUID = entry.getKey();
for (ExtensionInformation extensionInformation : entry.getValue()) {
ExtensionPlayerData.Factory data = extensionDataByPluginID.get(extensionInformation.getId());
ExtensionData.Factory data = extensionDataByPluginID.get(extensionInformation.getId());
if (data == null) {
continue;
}
List<ExtensionPlayerData> list = extensionDataByServerUUID.getOrDefault(serverUUID, new ArrayList<>());
List<ExtensionData> list = extensionDataByServerUUID.getOrDefault(serverUUID, new ArrayList<>());
list.add(data.setInformation(extensionInformation).build());
extensionDataByServerUUID.put(serverUUID, list);
}
@ -109,7 +108,7 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionP
return extensionDataByServerUUID;
}
private Query<Map<Integer, ExtensionPlayerData.Factory>> fetchIncompletePlayerDataByPluginID() {
private Query<Map<Integer, ExtensionData.Factory>> fetchIncompletePlayerDataByPluginID() {
String sql = SELECT +
"v1." + ExtensionPlayerValueTable.BOOLEAN_VALUE + " as boolean_value," +
"v1." + ExtensionPlayerValueTable.DOUBLE_VALUE + " as double_value," +
@ -140,7 +139,7 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionP
WHERE + ExtensionPlayerValueTable.USER_UUID + "=?" +
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
return new QueryStatement<Map<Integer, ExtensionPlayerData.Factory>>(sql, 1000) {
return new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, playerUUID.toString());
@ -148,8 +147,8 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionP
}
@Override
public Map<Integer, ExtensionPlayerData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toPlayerDataByPluginID();
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
}
};
}

View File

@ -25,10 +25,10 @@ import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
import com.djrapitops.plan.extension.implementation.results.ExtensionStringData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.player.ExtensionPlayerData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -40,7 +40,7 @@ import java.util.UUID;
import static com.djrapitops.plan.db.sql.parsing.Sql.*;
/**
* Query player's Groups by Plugin ID inside ExtensionPlayerData objects.
* Query player's Groups by Plugin ID inside ExtensionData objects.
* <p>
* - Group names are represented as a String value, concatenated to a single one.
* - String values are placed into Tabs they belong to
@ -49,7 +49,7 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
*
* @author Rsl1122
*/
public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionPlayerData.Factory>> {
public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionData.Factory>> {
private final UUID playerUUID;
@ -58,11 +58,11 @@ public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionP
}
@Override
public Map<Integer, ExtensionPlayerData.Factory> executeQuery(SQLDB db) {
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
return db.query(fetchGroupsByPluginID());
}
private Query<Map<Integer, ExtensionPlayerData.Factory>> fetchGroupsByPluginID() {
private Query<Map<Integer, ExtensionData.Factory>> fetchGroupsByPluginID() {
String sql = SELECT +
"v1." + ExtensionGroupsTable.GROUP_NAME + " as group_name," +
"p1." + ExtensionProviderTable.PLUGIN_ID + " as plugin_id," +
@ -86,7 +86,7 @@ public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionP
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?" +
ORDER_BY + ExtensionGroupsTable.GROUP_NAME + " ASC";
return new QueryStatement<Map<Integer, ExtensionPlayerData.Factory>>(sql, 1000) {
return new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, playerUUID.toString());
@ -94,8 +94,8 @@ public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionP
}
@Override
public Map<Integer, ExtensionPlayerData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toPlayerDataByPluginID();
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
}
};
}

View File

@ -27,7 +27,7 @@ import com.djrapitops.plan.extension.ElementOrder;
import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.results.player.ExtensionPlayerData;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.table.Table;
import com.djrapitops.plan.extension.table.TableAccessor;
@ -41,20 +41,20 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
/**
* Query player tables from tableprovider table.
* <p>
* Returns Map: PluginID - ExtensionPlayerData.Factory.
* Returns Map: PluginID - ExtensionData.Factory.
* <p>
* How it is done:
* - TableProviders are queried and formed into Table.Factory objects sorted into a multi-map: PluginID - TableID - Table.Factory
* - Table values are queried and merged into the above multimap
* - Data query is sorted into a multi-map: PluginID - Tab Name - Tab Data
* - (Tab Name can be empty.)
* - Multi-map is sorted into ExtensionPlayerData objects by PluginID, one per ID
* - Multi-map is sorted into ExtensionData objects by PluginID, one per ID
* <p>
* There are multiple data extraction methods to make extracting the value query easier.
*
* @author Rsl1122
*/
public class ExtensionPlayerTablesQuery implements Query<Map<Integer, ExtensionPlayerData.Factory>> {
public class ExtensionPlayerTablesQuery implements Query<Map<Integer, ExtensionData.Factory>> {
private final UUID playerUUID;
@ -63,9 +63,9 @@ public class ExtensionPlayerTablesQuery implements Query<Map<Integer, ExtensionP
}
@Override
public Map<Integer, ExtensionPlayerData.Factory> executeQuery(SQLDB db) {
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
QueriedTables tablesWithValues = db.query(placeValuesToTables(db.query(queryTableProviders())));
return tablesWithValues.toQueriedTabs().toPlayerDataByPluginID();
return tablesWithValues.toQueriedTabs().toExtensionDataByPluginID();
}
private Query<QueriedTables> placeValuesToTables(QueriedTables tables) {

View File

@ -27,7 +27,6 @@ import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.*;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -53,7 +52,7 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
*
* @author Rsl1122
*/
public class ExtensionServerDataQuery implements Query<List<ExtensionServerData>> {
public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
private final UUID serverUUID;
@ -62,9 +61,9 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionServerData>
}
@Override
public List<ExtensionServerData> executeQuery(SQLDB db) {
public List<ExtensionData> executeQuery(SQLDB db) {
List<ExtensionInformation> extensionsOfServer = db.query(ExtensionInformationQueries.extensionsOfServer(serverUUID));
Map<Integer, ExtensionServerData.Factory> extensionDataByPluginID = db.query(fetchIncompleteServerDataByPluginID());
Map<Integer, ExtensionData.Factory> extensionDataByPluginID = db.query(fetchIncompleteServerDataByPluginID());
combine(extensionDataByPluginID, db.query(new ExtensionAggregateBooleansQuery(serverUUID)));
combine(extensionDataByPluginID, db.query(new ExtensionAggregateDoublesQuery(serverUUID)));
@ -76,14 +75,14 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionServerData>
}
private void combine(
Map<Integer, ExtensionServerData.Factory> extensionDataByPluginID,
Map<Integer, ExtensionServerData.Factory> aggregates
Map<Integer, ExtensionData.Factory> extensionDataByPluginID,
Map<Integer, ExtensionData.Factory> aggregates
) {
for (Map.Entry<Integer, ExtensionServerData.Factory> entry : aggregates.entrySet()) {
for (Map.Entry<Integer, ExtensionData.Factory> entry : aggregates.entrySet()) {
Integer pluginID = entry.getKey();
ExtensionServerData.Factory data = entry.getValue();
ExtensionData.Factory data = entry.getValue();
ExtensionServerData.Factory found = extensionDataByPluginID.get(pluginID);
ExtensionData.Factory found = extensionDataByPluginID.get(pluginID);
if (found == null) {
extensionDataByPluginID.put(pluginID, data);
} else {
@ -92,23 +91,23 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionServerData>
}
}
private List<ExtensionServerData> combineWithExtensionInfo(
private List<ExtensionData> combineWithExtensionInfo(
List<ExtensionInformation> extensionsOfServer,
Map<Integer, ExtensionServerData.Factory> extensionDataByPluginID
Map<Integer, ExtensionData.Factory> extensionDataByPluginID
) {
List<ExtensionServerData> extensionServerData = new ArrayList<>();
List<ExtensionData> extensionData = new ArrayList<>();
for (ExtensionInformation extensionInformation : extensionsOfServer) {
ExtensionServerData.Factory data = extensionDataByPluginID.get(extensionInformation.getId());
ExtensionData.Factory data = extensionDataByPluginID.get(extensionInformation.getId());
if (data == null) {
continue;
}
extensionServerData.add(data.setInformation(extensionInformation).build());
extensionData.add(data.setInformation(extensionInformation).build());
}
return extensionServerData;
return extensionData;
}
private Query<Map<Integer, ExtensionServerData.Factory>> fetchIncompleteServerDataByPluginID() {
private Query<Map<Integer, ExtensionData.Factory>> fetchIncompleteServerDataByPluginID() {
String sql = SELECT +
"v1." + ExtensionServerValueTable.BOOLEAN_VALUE + " as boolean_value," +
"v1." + ExtensionServerValueTable.DOUBLE_VALUE + " as double_value," +
@ -140,7 +139,7 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionServerData>
WHERE + ExtensionPluginTable.SERVER_UUID + "=?" +
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
return new QueryStatement<Map<Integer, ExtensionServerData.Factory>>(sql, 1000) {
return new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverUUID.toString());
@ -148,8 +147,8 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionServerData>
}
@Override
public Map<Integer, ExtensionServerData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toServerDataByPluginID();
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
}
};
}

View File

@ -24,7 +24,7 @@ import com.djrapitops.plan.extension.ElementOrder;
import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.table.Table;
import com.djrapitops.plan.extension.table.TableAccessor;
@ -51,7 +51,7 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
*
* @author Rsl1122
*/
public class ExtensionServerTablesQuery implements Query<Map<Integer, ExtensionServerData.Factory>> {
public class ExtensionServerTablesQuery implements Query<Map<Integer, ExtensionData.Factory>> {
private final UUID serverUUID;
@ -60,9 +60,9 @@ public class ExtensionServerTablesQuery implements Query<Map<Integer, ExtensionS
}
@Override
public Map<Integer, ExtensionServerData.Factory> executeQuery(SQLDB db) {
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
QueriedTables tablesWithValues = db.query(queryTableValues(db.query(queryTableProviders())));
return tablesWithValues.toQueriedTabs().toServerDataByPluginID();
return tablesWithValues.toQueriedTabs().toExtensionDataByPluginID();
}
private Query<QueriedTables> queryTableValues(QueriedTables tables) {

View File

@ -17,9 +17,8 @@
package com.djrapitops.plan.extension.implementation.storage.queries;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.player.ExtensionPlayerData;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import com.djrapitops.plan.utilities.java.ThrowingSupplier;
import java.util.HashMap;
@ -51,32 +50,14 @@ public class QueriedTabData {
return tab;
}
public Map<Integer, ExtensionServerData.Factory> toServerDataByPluginID() {
Map<Integer, ExtensionServerData.Factory> dataByPluginID = new HashMap<>();
public Map<Integer, ExtensionData.Factory> toExtensionDataByPluginID() {
Map<Integer, ExtensionData.Factory> dataByPluginID = new HashMap<>();
for (Map.Entry<Integer, Map<String, ExtensionTabData.Factory>> entry : byPluginID.entrySet()) {
Integer pluginID = entry.getKey();
ExtensionServerData.Factory data = dataByPluginID.get(pluginID);
ExtensionData.Factory data = dataByPluginID.get(pluginID);
if (data == null) {
data = new ExtensionServerData.Factory(pluginID);
}
for (ExtensionTabData.Factory tabData : entry.getValue().values()) {
data.addTab(tabData.build());
}
dataByPluginID.put(pluginID, data);
}
return dataByPluginID;
}
public Map<Integer, ExtensionPlayerData.Factory> toPlayerDataByPluginID() {
Map<Integer, ExtensionPlayerData.Factory> dataByPluginID = new HashMap<>();
for (Map.Entry<Integer, Map<String, ExtensionTabData.Factory>> entry : byPluginID.entrySet()) {
Integer pluginID = entry.getKey();
ExtensionPlayerData.Factory data = dataByPluginID.get(pluginID);
if (data == null) {
data = new ExtensionPlayerData.Factory(pluginID);
data = new ExtensionData.Factory(pluginID);
}
for (ExtensionTabData.Factory tabData : entry.getValue().values()) {

View File

@ -17,7 +17,7 @@
package com.djrapitops.plan.utilities.html.pages;
import com.djrapitops.plan.api.exceptions.ParseException;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.file.PlanFiles;
@ -88,7 +88,7 @@ public class NetworkPage implements Page {
placeholders.put("version", versionCheckSystem.getUpdateButton().orElse(versionCheckSystem.getCurrentVersionButton()));
placeholders.put("updateModal", versionCheckSystem.getUpdateModal());
List<ExtensionServerData> extensionData = dbSystem.getDatabase()
List<ExtensionData> extensionData = dbSystem.getDatabase()
.query(new ExtensionServerDataQuery(serverUUID));
ServerPluginTabs pluginTabs = new ServerPluginTabs(extensionData, formatters);

View File

@ -21,7 +21,7 @@ import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.db.Database;
import com.djrapitops.plan.db.access.queries.containers.ContainerFetchQueries;
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
import com.djrapitops.plan.extension.implementation.results.player.ExtensionPlayerData;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.file.PlanFiles;
@ -123,7 +123,7 @@ public class PageFactory {
public PlayerPluginTab inspectPluginTabs(UUID playerUUID) {
Database database = dbSystem.get().getDatabase();
Map<UUID, List<ExtensionPlayerData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
Map<UUID, List<ExtensionData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
if (extensionPlayerData.isEmpty()) {
return new PlayerPluginTab("", Collections.emptyList(), formatters.get());
@ -134,7 +134,7 @@ public class PageFactory {
UUID serverUUID = entry.getKey();
String serverName = entry.getValue().getIdentifiableName();
List<ExtensionPlayerData> ofServer = extensionPlayerData.get(serverUUID);
List<ExtensionData> ofServer = extensionPlayerData.get(serverUUID);
if (ofServer == null) {
continue;
}

View File

@ -19,11 +19,7 @@ package com.djrapitops.plan.utilities.html.pages;
import com.djrapitops.plan.extension.ElementOrder;
import com.djrapitops.plan.extension.FormatType;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
import com.djrapitops.plan.extension.implementation.results.ExtensionInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTableData;
import com.djrapitops.plan.extension.implementation.results.player.ExtensionPlayerData;
import com.djrapitops.plan.extension.implementation.results.*;
import com.djrapitops.plan.utilities.formatting.Formatter;
import com.djrapitops.plan.utilities.formatting.Formatters;
import com.djrapitops.plan.utilities.html.icon.Icon;
@ -40,7 +36,7 @@ import java.util.*;
public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
private String serverName;
private List<ExtensionPlayerData> playerData;
private List<ExtensionData> playerData;
private Map<FormatType, Formatter<Long>> numberFormatters;
@ -59,7 +55,7 @@ public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
public PlayerPluginTab(
String serverName,
List<ExtensionPlayerData> playerData,
List<ExtensionData> playerData,
Formatters formatters
) {
this.serverName = serverName;
@ -104,7 +100,7 @@ public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
StringBuilder tabBuilder = new StringBuilder();
for (ExtensionPlayerData datum : playerData) {
for (ExtensionData datum : playerData) {
ExtensionInformation extensionInformation = datum.getExtensionInformation();
boolean onlyGeneric = datum.hasOnlyGenericTab();

View File

@ -20,7 +20,7 @@ import com.djrapitops.plan.api.exceptions.ParseException;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.containers.RawDataContainer;
import com.djrapitops.plan.data.store.keys.AnalysisKeys;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.file.PlanFiles;
@ -122,7 +122,7 @@ public class ServerPage implements Page {
placeholders.put("version", versionCheckSystem.getUpdateButton().orElse(versionCheckSystem.getCurrentVersionButton()));
placeholders.put("updateModal", versionCheckSystem.getUpdateModal());
List<ExtensionServerData> extensionData = dbSystem.getDatabase()
List<ExtensionData> extensionData = dbSystem.getDatabase()
.query(new ExtensionServerDataQuery(server.getUuid()));
ServerPluginTabs pluginTabs = new ServerPluginTabs(extensionData, formatters);

View File

@ -19,11 +19,7 @@ package com.djrapitops.plan.utilities.html.pages;
import com.djrapitops.plan.extension.ElementOrder;
import com.djrapitops.plan.extension.FormatType;
import com.djrapitops.plan.extension.implementation.TabInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
import com.djrapitops.plan.extension.implementation.results.ExtensionInformation;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTableData;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import com.djrapitops.plan.extension.implementation.results.*;
import com.djrapitops.plan.utilities.formatting.Formatter;
import com.djrapitops.plan.utilities.formatting.Formatters;
import com.djrapitops.plan.utilities.html.icon.Icon;
@ -43,8 +39,8 @@ import java.util.stream.Collectors;
*/
public class ServerPluginTabs {
private List<ExtensionServerData> serverData;
private List<ExtensionServerData> extraTabServerData;
private List<ExtensionData> serverData;
private List<ExtensionData> extraTabServerData;
private Map<FormatType, Formatter<Long>> numberFormatters;
@ -60,12 +56,12 @@ public class ServerPluginTabs {
}
public ServerPluginTabs(
List<ExtensionServerData> serverData,
List<ExtensionData> serverData,
Formatters formatters
) {
this.serverData = serverData;
this.extraTabServerData = serverData.stream()
.filter(ExtensionServerData::doesNeedWiderSpace)
.filter(ExtensionData::doesNeedWiderSpace)
.collect(Collectors.toList());
this.serverData.removeAll(extraTabServerData);
@ -113,7 +109,7 @@ public class ServerPluginTabs {
private String generateExtraTabs() {
StringBuilder tabBuilder = new StringBuilder();
for (ExtensionServerData datum : extraTabServerData) {
for (ExtensionData datum : extraTabServerData) {
ExtensionInformation extensionInformation = datum.getExtensionInformation();
boolean onlyGeneric = datum.hasOnlyGenericTab();
@ -137,7 +133,7 @@ public class ServerPluginTabs {
private String generateOverviewTab() {
StringBuilder tabBuilder = new StringBuilder();
for (ExtensionServerData datum : serverData) {
for (ExtensionData datum : serverData) {
ExtensionInformation extensionInformation = datum.getExtensionInformation();
boolean onlyGeneric = datum.hasOnlyGenericTab();

View File

@ -55,12 +55,7 @@ import com.djrapitops.plan.extension.*;
import com.djrapitops.plan.extension.annotation.*;
import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Icon;
import com.djrapitops.plan.extension.implementation.results.ExtensionBooleanData;
import com.djrapitops.plan.extension.implementation.results.ExtensionStringData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
import com.djrapitops.plan.extension.implementation.results.ExtensionTableData;
import com.djrapitops.plan.extension.implementation.results.player.ExtensionPlayerData;
import com.djrapitops.plan.extension.implementation.results.server.ExtensionServerData;
import com.djrapitops.plan.extension.implementation.results.*;
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery;
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery;
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerPlayerDataTableQuery;
@ -1151,12 +1146,12 @@ public interface DatabaseTest {
extensionService.register(new PlayerExtension());
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
Map<UUID, List<ExtensionPlayerData>> playerDataByServerUUID = db().query(new ExtensionPlayerDataQuery(playerUUID));
List<ExtensionPlayerData> ofServer = playerDataByServerUUID.get(serverUUID());
Map<UUID, List<ExtensionData>> playerDataByServerUUID = db().query(new ExtensionPlayerDataQuery(playerUUID));
List<ExtensionData> ofServer = playerDataByServerUUID.get(serverUUID());
assertNotNull(ofServer);
assertFalse(ofServer.isEmpty());
ExtensionPlayerData extensionPlayerData = ofServer.get(0);
ExtensionData extensionPlayerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionPlayerData.getTabs();
assertEquals(1, tabs.size()); // No tab defined, should contain 1 tab
ExtensionTabData tabData = tabs.get(0);
@ -1201,11 +1196,11 @@ public interface DatabaseTest {
extensionService.register(new ServerExtension());
extensionService.updateServerValues(CallEvents.SERVER_EXTENSION_REGISTER);
List<ExtensionServerData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
List<ExtensionData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
assertFalse(ofServer.isEmpty());
ExtensionServerData extensionServerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionServerData.getTabs();
ExtensionData extensionData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionData.getTabs();
assertEquals(1, tabs.size()); // No tab defined, should contain 1 tab
ExtensionTabData tabData = tabs.get(0);
@ -1223,11 +1218,11 @@ public interface DatabaseTest {
extensionService.register(new PlayerExtension());
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
List<ExtensionServerData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
List<ExtensionData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
assertFalse(ofServer.isEmpty());
ExtensionServerData extensionServerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionServerData.getTabs();
ExtensionData extensionData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionData.getTabs();
assertEquals(1, tabs.size()); // No tab defined, should contain 1 tab
ExtensionTabData tabData = tabs.get(0);
@ -1275,7 +1270,7 @@ public interface DatabaseTest {
default void checkThatPlayerDataExists(boolean condition) {
// TODO Add Group data to this test
if (condition) { // Condition is true, conditional values exist
List<ExtensionPlayerData> ofServer = db().query(new ExtensionPlayerDataQuery(playerUUID)).get(serverUUID());
List<ExtensionData> ofServer = db().query(new ExtensionPlayerDataQuery(playerUUID)).get(serverUUID());
assertTrue(ofServer != null && !ofServer.isEmpty() && !ofServer.get(0).getTabs().isEmpty(), "There was no data left");
ExtensionTabData tabData = ofServer.get(0).getTabs().get(0);
@ -1284,7 +1279,7 @@ public interface DatabaseTest {
OptionalAssert.equals("unconditional", tabData.getString("unconditional").map(ExtensionStringData::getFormattedValue)); // Was not removed
assertFalse(tabData.getString("reversedConditionalValue").isPresent(), "Value was not removed: reversedConditionalValue");
} else { // Condition is false, reversed conditional values exist
List<ExtensionPlayerData> ofServer = db().query(new ExtensionPlayerDataQuery(playerUUID)).get(serverUUID());
List<ExtensionData> ofServer = db().query(new ExtensionPlayerDataQuery(playerUUID)).get(serverUUID());
assertTrue(ofServer != null && !ofServer.isEmpty() && !ofServer.get(0).getTabs().isEmpty(), "There was no data left");
ExtensionTabData tabData = ofServer.get(0).getTabs().get(0);
OptionalAssert.equals("No", tabData.getBoolean("isCondition").map(ExtensionBooleanData::getFormattedValue));
@ -1326,7 +1321,7 @@ public interface DatabaseTest {
default void checkThatServerDataExists(boolean condition) {
if (condition) { // Condition is true, conditional values exist
List<ExtensionServerData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
List<ExtensionData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
assertTrue(ofServer != null && !ofServer.isEmpty() && !ofServer.get(0).getTabs().isEmpty(), "There was no data left");
ExtensionTabData tabData = ofServer.get(0).getTabs().get(0);
@ -1335,7 +1330,7 @@ public interface DatabaseTest {
OptionalAssert.equals("unconditional", tabData.getString("unconditional").map(ExtensionStringData::getFormattedValue)); // Was not removed
assertFalse(tabData.getString("reversedConditionalValue").isPresent(), "Value was not removed: reversedConditionalValue");
} else { // Condition is false, reversed conditional values exist
List<ExtensionServerData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
List<ExtensionData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
assertTrue(ofServer != null && !ofServer.isEmpty() && !ofServer.get(0).getTabs().isEmpty(), "There was no data left");
ExtensionTabData tabData = ofServer.get(0).getTabs().get(0);
OptionalAssert.equals("No", tabData.getBoolean("isCondition").map(ExtensionBooleanData::getFormattedValue));
@ -1353,11 +1348,11 @@ public interface DatabaseTest {
extensionService.updateServerValues(CallEvents.MANUAL);
extensionService.updateServerValues(CallEvents.MANUAL);
List<ExtensionServerData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
List<ExtensionData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
assertFalse(ofServer.isEmpty());
ExtensionServerData extensionServerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionServerData.getTabs();
ExtensionData extensionData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionData.getTabs();
assertEquals(1, tabs.size()); // No tab defined, should contain 1 tab
ExtensionTabData tabData = tabs.get(0);
@ -1384,12 +1379,12 @@ public interface DatabaseTest {
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
Map<UUID, List<ExtensionPlayerData>> ofPlayer = db().query(new ExtensionPlayerDataQuery(playerUUID));
Map<UUID, List<ExtensionData>> ofPlayer = db().query(new ExtensionPlayerDataQuery(playerUUID));
assertFalse(ofPlayer.isEmpty());
List<ExtensionPlayerData> ofServer = ofPlayer.get(serverUUID());
List<ExtensionData> ofServer = ofPlayer.get(serverUUID());
assertEquals(1, ofServer.size());
ExtensionPlayerData extensionServerData = ofServer.get(0);
ExtensionData extensionServerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionServerData.getTabs();
assertEquals(1, tabs.size()); // No tab defined, should contain 1 tab
ExtensionTabData tabData = tabs.get(0);