diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/DataProviderExtractor.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/DataProviderExtractor.java index 89876790c..f3445aa88 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/DataProviderExtractor.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/DataProviderExtractor.java @@ -69,7 +69,7 @@ public class DataProviderExtractor { return new Icon(pluginInfo.iconFamily(), pluginInfo.iconName(), pluginInfo.color()); } - public Collection getPluginTabs() { + public Collection getPluginTabs() { Map tabInformation = extensionExtractor.getTabInformation() .stream().collect(Collectors.toMap(TabInfo::tab, Function.identity(), (one, two) -> one)); @@ -81,7 +81,7 @@ public class DataProviderExtractor { .distinct() .map(tabName -> { Optional tabInfo = Optional.ofNullable(tabInformation.get(tabName)); - return new PluginTab( + return new TabInformation( tabName, tabInfo.map(info -> new Icon(info.iconFamily(), info.iconName(), Color.NONE)).orElse(null), tabInfo.map(TabInfo::elementOrder).orElse(null), diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/ProviderInformation.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/ProviderInformation.java index b8c1c5ba4..ffcddc4ac 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/ProviderInformation.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/ProviderInformation.java @@ -17,6 +17,7 @@ package com.djrapitops.plan.extension.implementation; import com.djrapitops.plan.extension.icon.Icon; +import com.djrapitops.plan.extension.implementation.results.player.ExtensionDescriptive; import org.apache.commons.lang3.StringUtils; import java.util.Optional; @@ -26,26 +27,17 @@ import java.util.Optional; * * @author Rsl1122 */ -public class ProviderInformation { +public class ProviderInformation extends ExtensionDescriptive { private final String pluginName; - private final String name; - private final String text; - private final String description; // can be null - private final Icon icon; - private final int priority; private final String tab; // can be null private final String condition; // can be null public ProviderInformation( String pluginName, String name, String text, String description, Icon icon, int priority, String tab, String condition ) { + super(name, text, description, icon, priority); this.pluginName = pluginName; - this.name = name; - this.text = text; - this.description = description; - this.icon = icon; - this.priority = priority; this.tab = tab; this.condition = condition; } @@ -54,26 +46,6 @@ public class ProviderInformation { return StringUtils.truncate(pluginName, 50); } - public String getName() { - return StringUtils.truncate(name, 50); - } - - public String getText() { - return StringUtils.truncate(text, 50); - } - - public Optional getDescription() { - return description == null || description.isEmpty() ? Optional.empty() : Optional.of(StringUtils.truncate(description, 150)); - } - - public Icon getIcon() { - return icon; - } - - public int getPriority() { - return priority; - } - public Optional getTab() { return tab == null || tab.isEmpty() ? Optional.empty() : Optional.of(StringUtils.truncate(tab, 50)); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/PluginTab.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/TabInformation.java similarity index 95% rename from Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/PluginTab.java rename to Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/TabInformation.java index 0391e50db..f591020b6 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/PluginTab.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/TabInformation.java @@ -32,14 +32,14 @@ import java.util.Optional; * * @author Rsl1122 */ -public class PluginTab { +public class TabInformation { private final String tabName; private final Icon icon; // can be null private ElementOrder[] elementOrder; // can be null / miss values private int tabPriority; - public PluginTab(String tabName, Icon icon, ElementOrder[] elementOrder, int tabPriority) { + public TabInformation(String tabName, Icon icon, ElementOrder[] elementOrder, int tabPriority) { this.tabName = tabName; this.icon = icon; this.elementOrder = elementOrder; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/gathering/ProviderValueGatherer.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/gathering/ProviderValueGatherer.java index 2155bd358..86a774596 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/gathering/ProviderValueGatherer.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/gathering/ProviderValueGatherer.java @@ -20,10 +20,10 @@ import com.djrapitops.plan.db.Database; import com.djrapitops.plan.extension.DataExtension; import com.djrapitops.plan.extension.icon.Icon; import com.djrapitops.plan.extension.implementation.DataProviderExtractor; -import com.djrapitops.plan.extension.implementation.PluginTab; +import com.djrapitops.plan.extension.implementation.TabInformation; import com.djrapitops.plan.extension.implementation.storage.transactions.StoreIconTransaction; -import com.djrapitops.plan.extension.implementation.storage.transactions.StorePluginTabTransaction; import com.djrapitops.plan.extension.implementation.storage.transactions.StorePluginTransaction; +import com.djrapitops.plan.extension.implementation.storage.transactions.StoreTabInformationTransaction; import com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveInvalidResultsTransaction; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.info.server.ServerInfo; @@ -69,9 +69,9 @@ public class ProviderValueGatherer { Database database = dbSystem.getDatabase(); database.executeTransaction(new StoreIconTransaction(pluginIcon)); database.executeTransaction(new StorePluginTransaction(pluginName, time, serverUUID, pluginIcon)); - for (PluginTab tab : extractor.getPluginTabs()) { + for (TabInformation tab : extractor.getPluginTabs()) { database.executeTransaction(new StoreIconTransaction(tab.getTabIcon())); - database.executeTransaction(new StorePluginTabTransaction(pluginName, serverUUID, tab)); + database.executeTransaction(new StoreTabInformationTransaction(pluginName, serverUUID, tab)); } database.executeTransaction(new RemoveInvalidResultsTransaction(pluginName, serverUUID, extractor.getInvalidatedMethods())); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionBooleanData.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionBooleanData.java new file mode 100644 index 000000000..50f31f5ca --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionBooleanData.java @@ -0,0 +1,41 @@ +/* + * 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 . + */ +package com.djrapitops.plan.extension.implementation.results.player; + +/** + * Represents boolean data returned by a BooleanProvider method. + * + * @author Rsl1122 + */ +public class ExtensionBooleanData implements ExtensionData { + + private ExtensionDescriptive descriptive; + private boolean value; + + public ExtensionBooleanData(ExtensionDescriptive descriptive, boolean value) { + this.descriptive = descriptive; + this.value = value; + } + + public ExtensionDescriptive getDescriptive() { + return descriptive; + } + + public String getFormattedValue() { + return value ? "Yes" : "No"; + } +} \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionData.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionData.java new file mode 100644 index 000000000..499fbafb7 --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionData.java @@ -0,0 +1,17 @@ +package com.djrapitops.plan.extension.implementation.results.player; + +/** + * Represents a data-point given by a Provider method of a DataExtension. + * + * @author Rsl1122 + */ +public interface ExtensionData { + + /** + * Get Descriptive information about the data point. + * + * @return a {@link ExtensionDescriptive}. + */ + ExtensionDescriptive getDescriptive(); + +} diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionDescriptive.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionDescriptive.java new file mode 100644 index 000000000..fb71ff62e --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionDescriptive.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package com.djrapitops.plan.extension.implementation.results.player; + +import com.djrapitops.plan.extension.icon.Icon; +import org.apache.commons.lang3.StringUtils; + +import java.util.Optional; + +/** + * Describes information about an extension value given by a Provider method. + * + * @author Rsl1122 + */ +public class ExtensionDescriptive implements Comparable { + + private final String name; + private final String text; + private final String description; // can be null + private final Icon icon; + private final int priority; + + public ExtensionDescriptive(String name, String text, String description, Icon icon, int priority) { + this.name = name; + this.text = text; + this.description = description; + this.icon = icon; + this.priority = priority; + } + + public String getName() { + return StringUtils.truncate(name, 50); + } + + public String getText() { + return StringUtils.truncate(text, 50); + } + + public Optional getDescription() { + return description == null || description.isEmpty() ? Optional.empty() : Optional.of(StringUtils.truncate(description, 150)); + } + + public Icon getIcon() { + return icon; + } + + public int getPriority() { + return priority; + } + + @Override + public int compareTo(ExtensionDescriptive other) { + Integer.compare(other.priority, this.priority); // Higher is first + } +} \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionDoubleData.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionDoubleData.java new file mode 100644 index 000000000..31025a93a --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionDoubleData.java @@ -0,0 +1,43 @@ +/* + * 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 . + */ +package com.djrapitops.plan.extension.implementation.results.player; + +import com.djrapitops.plan.utilities.formatting.Formatter; + +/** + * Represents double data returned by a DoubleProvider or PercentageProvider method. + * + * @author Rsl1122 + */ +public class ExtensionDoubleData implements ExtensionData { + + private ExtensionDescriptive descriptive; + private double value; + + public ExtensionDoubleData(ExtensionDescriptive descriptive, double value) { + this.descriptive = descriptive; + this.value = value; + } + + public ExtensionDescriptive getDescriptive() { + return descriptive; + } + + public String getFormattedValue(Formatter formatter) { + return formatter.apply(value); + } +} \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionNumberData.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionNumberData.java new file mode 100644 index 000000000..60dbd8680 --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionNumberData.java @@ -0,0 +1,50 @@ +/* + * 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 . + */ +package com.djrapitops.plan.extension.implementation.results.player; + +import com.djrapitops.plan.extension.FormatType; +import com.djrapitops.plan.utilities.formatting.Formatter; + +/** + * Represents double data returned by a DoubleProvider or PercentageProvider method. + * + * @author Rsl1122 + */ +public class ExtensionNumberData implements ExtensionData { + + private final ExtensionDescriptive descriptive; + private final FormatType formatType; + private final long value; + + public ExtensionNumberData(ExtensionDescriptive descriptive, FormatType formatType, long value) { + this.descriptive = descriptive; + this.formatType = formatType; + this.value = value; + } + + public ExtensionDescriptive getDescriptive() { + return descriptive; + } + + public FormatType getFormatType() { + return formatType; + } + + public String getFormattedValue(Formatter formatter) { + return formatter.apply(value); + } +} \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionPlayerData.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionPlayerData.java new file mode 100644 index 000000000..e836a9451 --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionPlayerData.java @@ -0,0 +1,67 @@ +/* + * 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 . + */ +package com.djrapitops.plan.extension.implementation.results.player; + +import com.djrapitops.plan.extension.icon.Icon; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Represents data of a single extension about a player. + * + * @author Rsl1122 + */ +public class ExtensionPlayerData { + + private String pluginName; + private Icon pluginIcon; + + private List tabs; + + public ExtensionPlayerData(String pluginName, Icon pluginIcon) { + this.pluginName = pluginName; + this.pluginIcon = pluginIcon; + + tabs = new ArrayList<>(); + } + + public List getTabs() { + return tabs; + } + + public class Factory { + + private final ExtensionPlayerData data; + + public Factory() { + data = new ExtensionPlayerData(pluginName, pluginIcon); + } + + public Factory addTab(ExtensionTabData tab) { + data.tabs.add(tab); + return this; + } + + public ExtensionPlayerData build() { + Collections.sort(data.tabs); + return data; + } + } + +} \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionStringData.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionStringData.java new file mode 100644 index 000000000..17c0bc645 --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionStringData.java @@ -0,0 +1,46 @@ +/* + * 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 . + */ +package com.djrapitops.plan.extension.implementation.results.player; + +import com.djrapitops.plan.api.PlanAPI; +import com.djrapitops.plan.utilities.html.Html; + +/** + * Represents double data returned by a DoubleProvider or PercentageProvider method. + * + * @author Rsl1122 + */ +public class ExtensionStringData implements ExtensionData { + + private final ExtensionDescriptive descriptive; + private final boolean playerName; + private final String value; + + public ExtensionStringData(ExtensionDescriptive descriptive, boolean playerName, String value) { + this.descriptive = descriptive; + this.playerName = playerName; + this.value = value; + } + + public ExtensionDescriptive getDescriptive() { + return descriptive; + } + + public String getFormattedValue() { + return !playerName ? value : Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(value), value); + } +} \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionTabData.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionTabData.java new file mode 100644 index 000000000..b6b16bc41 --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/results/player/ExtensionTabData.java @@ -0,0 +1,134 @@ +/* + * 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 . + */ +package com.djrapitops.plan.extension.implementation.results.player; + +import com.djrapitops.plan.extension.implementation.TabInformation; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * Represents data on an extension tab. + * + * @author Rsl1122 + */ +public class ExtensionTabData implements Comparable { + + private final TabInformation tabInformation; // Can be null in case where no tab was defined for provider. + + private final Map booleanData; + private final Map doubleData; + private final Map percentageData; + private final Map numberData; + private final Map stringData; + + private List order; + + // Table and Graph data will be added later. + + public ExtensionTabData(TabInformation tabInformation) { + this.tabInformation = tabInformation; + + booleanData = new HashMap<>(); + doubleData = new HashMap<>(); + percentageData = new HashMap<>(); + numberData = new HashMap<>(); + stringData = new HashMap<>(); + } + + public List getValueOrder() { + return order; + } + + public Optional getBoolean(String providerName) { + return Optional.ofNullable(booleanData.get(providerName)); + } + + public Optional getDouble(String providerName) { + return Optional.ofNullable(doubleData.get(providerName)); + } + + public Optional getPercentage(String providerName) { + return Optional.ofNullable(percentageData.get(providerName)); + } + + public Optional getNumber(String providerName) { + return Optional.ofNullable(numberData.get(providerName)); + } + + public Optional getString(String providerName) { + return Optional.ofNullable(stringData.get(providerName)); + } + + private void createOrderingList() { + List descriptives = new ArrayList<>(); + booleanData.values().stream().map(ExtensionData::getDescriptive).forEach(descriptives::add); + doubleData.values().stream().map(ExtensionData::getDescriptive).forEach(descriptives::add); + percentageData.values().stream().map(ExtensionData::getDescriptive).forEach(descriptives::add); + numberData.values().stream().map(ExtensionData::getDescriptive).forEach(descriptives::add); + stringData.values().stream().map(ExtensionData::getDescriptive).forEach(descriptives::add); + + order = descriptives.stream().sorted() + .map(ExtensionDescriptive::getName) + .distinct()// Method names are usually different, but in case someone had same method name with different parameters. + .collect(Collectors.toList()); + } + + @Override + public int compareTo(ExtensionTabData other) { + return Integer.compare(this.tabInformation.getTabPriority(), other.tabInformation.getTabPriority()); // Lower is first + } + + public class Factory { + + private final ExtensionTabData data; + + Factory(TabInformation tabInformation) { + data = new ExtensionTabData(tabInformation); + } + + public Factory putBooleanData(ExtensionBooleanData extensionBooleanData) { + data.booleanData.put(extensionBooleanData.getDescriptive().getName(), extensionBooleanData); + return this; + } + + public Factory putDoubleData(ExtensionDoubleData extensionDoubleData) { + data.doubleData.put(extensionDoubleData.getDescriptive().getName(), extensionDoubleData); + return this; + } + + public Factory putPercentageData(ExtensionDoubleData extensionDoubleData) { + data.percentageData.put(extensionDoubleData.getDescriptive().getName(), extensionDoubleData); + return this; + } + + public Factory putNumberData(ExtensionNumberData extensionNumberData) { + data.numberData.put(extensionNumberData.getDescriptive().getName(), extensionNumberData); + return this; + } + + public Factory putStringData(ExtensionStringData extensionStringData) { + data.stringData.put(extensionStringData.getDescriptive().getName(), extensionStringData); + return this; + } + + public ExtensionTabData build() { + data.createOrderingList(); + return data; + } + } +} \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StorePluginTabTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StoreTabInformationTransaction.java similarity index 78% rename from Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StorePluginTabTransaction.java rename to Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StoreTabInformationTransaction.java index df278d680..0ad9c8509 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StorePluginTabTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StoreTabInformationTransaction.java @@ -23,7 +23,7 @@ import com.djrapitops.plan.db.sql.tables.ExtensionIconTable; import com.djrapitops.plan.db.sql.tables.ExtensionPluginTable; import com.djrapitops.plan.db.sql.tables.ExtensionTabTable; import com.djrapitops.plan.extension.ElementOrder; -import com.djrapitops.plan.extension.implementation.PluginTab; +import com.djrapitops.plan.extension.implementation.TabInformation; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -33,20 +33,20 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.AND; import static com.djrapitops.plan.db.sql.parsing.Sql.WHERE; /** - * Transaction for storing {@link com.djrapitops.plan.extension.implementation.PluginTab}s. + * Transaction for storing {@link TabInformation}s. * * @author Rsl1122 */ -public class StorePluginTabTransaction extends Transaction { +public class StoreTabInformationTransaction extends Transaction { private final String pluginName; private final UUID serverUUID; - private final PluginTab pluginTab; + private final TabInformation tabInformation; - public StorePluginTabTransaction(String pluginName, UUID serverUUID, PluginTab pluginTab) { + public StoreTabInformationTransaction(String pluginName, UUID serverUUID, TabInformation tabInformation) { this.pluginName = pluginName; this.serverUUID = serverUUID; - this.pluginTab = pluginTab; + this.tabInformation = tabInformation; } @Override @@ -74,11 +74,11 @@ public class StorePluginTabTransaction extends Transaction { return new ExecStatement(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { - statement.setInt(1, pluginTab.getTabPriority()); - statement.setString(2, pluginTab.getTabElementOrder().map(ElementOrder::serialize).orElse(null)); - ExtensionIconTable.set3IconValuesToStatement(statement, 3, pluginTab.getTabIcon()); + statement.setInt(1, tabInformation.getTabPriority()); + statement.setString(2, tabInformation.getTabElementOrder().map(ElementOrder::serialize).orElse(null)); + ExtensionIconTable.set3IconValuesToStatement(statement, 3, tabInformation.getTabIcon()); ExtensionPluginTable.set2PluginValuesToStatement(statement, 6, pluginName, serverUUID); - statement.setString(8, pluginTab.getTabName()); + statement.setString(8, tabInformation.getTabName()); } }; } @@ -94,10 +94,10 @@ public class StorePluginTabTransaction extends Transaction { return new ExecStatement(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, pluginTab.getTabName()); - statement.setString(2, pluginTab.getTabElementOrder().map(ElementOrder::serialize).orElse(null)); - statement.setInt(3, pluginTab.getTabPriority()); - ExtensionIconTable.set3IconValuesToStatement(statement, 4, pluginTab.getTabIcon()); + statement.setString(1, tabInformation.getTabName()); + statement.setString(2, tabInformation.getTabElementOrder().map(ElementOrder::serialize).orElse(null)); + statement.setInt(3, tabInformation.getTabPriority()); + ExtensionIconTable.set3IconValuesToStatement(statement, 4, tabInformation.getTabIcon()); ExtensionPluginTable.set2PluginValuesToStatement(statement, 7, pluginName, serverUUID); } };