Solved some issues with Tebex extension

- Sorting of values
- Sorted out package names being weird
- Make sortable over 10 entries
This commit is contained in:
Risto Lahtela 2021-04-27 18:32:32 +03:00
parent b174affb58
commit 322ec3c57c
5 changed files with 65 additions and 4 deletions

View File

@ -99,9 +99,15 @@ public class DynamicHtmlTable implements HtmlTable {
} catch (ParseException e) { } catch (ParseException e) {
if (NumberUtils.isParsable(valueString)) { if (NumberUtils.isParsable(valueString)) {
builtBody.append("<td data-order=\"").append(valueString).append("\">").append(valueString); builtBody.append("<td data-order=\"").append(valueString).append("\">").append(valueString);
} else {
// Removes non numbers from the value
String numbersInValue = valueString.replaceAll("\\D", "");
if (!numbersInValue.isEmpty()) {
builtBody.append("<td data-order=\"").append(numbersInValue).append("\">").append(valueString);
} else { } else {
builtBody.append("<td>").append(valueString); builtBody.append("<td>").append(valueString);
} }
} }
} }
} }
}

View File

@ -29,7 +29,7 @@ public interface HtmlTable {
} }
static HtmlTable fromExtensionTable(Table table, Color tableColor) { static HtmlTable fromExtensionTable(Table table, Color tableColor) {
if (table.getRows().size() > 25) { if (table.getRows().size() > 10) {
return new DynamicHtmlTable(table); return new DynamicHtmlTable(table);
} else { } else {
return new HtmlTableWithColoredHeader(table, tableColor); return new HtmlTableWithColoredHeader(table, tableColor);

View File

@ -30,6 +30,7 @@ import com.djrapitops.plan.storage.database.transactions.Transaction;
import com.djrapitops.plan.storage.database.transactions.init.CreateIndexTransaction; import com.djrapitops.plan.storage.database.transactions.init.CreateIndexTransaction;
import com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction; import com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction;
import com.djrapitops.plan.storage.database.transactions.init.OperationCriticalTransaction; import com.djrapitops.plan.storage.database.transactions.init.OperationCriticalTransaction;
import com.djrapitops.plan.storage.database.transactions.init.RemoveIncorrectTebexPackageDataPatch;
import com.djrapitops.plan.storage.database.transactions.patches.*; import com.djrapitops.plan.storage.database.transactions.patches.*;
import com.djrapitops.plan.utilities.java.ThrowableUtils; import com.djrapitops.plan.utilities.java.ThrowableUtils;
import com.djrapitops.plan.utilities.logging.ErrorContext; import com.djrapitops.plan.utilities.logging.ErrorContext;
@ -181,7 +182,8 @@ public abstract class SQLDB extends AbstractDatabase {
new UserInfoHostnameAllowNullPatch(), new UserInfoHostnameAllowNullPatch(),
new ServerTableRowPatch(), new ServerTableRowPatch(),
new PlayerTableRowPatch(), new PlayerTableRowPatch(),
new ExtensionTableProviderValuesForPatch() new ExtensionTableProviderValuesForPatch(),
new RemoveIncorrectTebexPackageDataPatch()
}; };
} }

View File

@ -0,0 +1,53 @@
/*
* 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.storage.database.transactions.init;
import com.djrapitops.plan.storage.database.queries.HasMoreThanZeroQueryStatement;
import com.djrapitops.plan.storage.database.queries.Query;
import com.djrapitops.plan.storage.database.transactions.patches.Patch;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
/**
* Removes incorrectly formatted package data from the database.
*/
public class RemoveIncorrectTebexPackageDataPatch extends Patch {
@Override
public boolean hasBeenApplied() {
return hasTable("plan_tebex_payments") && !query(hasWrongRows());
}
private Query<Boolean> hasWrongRows() {
return new HasMoreThanZeroQueryStatement(
SELECT + "COUNT(*) as c" + FROM + "plan_tebex_payments" +
WHERE + "packages LIKE 'TebexPackage%'"
) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
}
};
}
@Override
protected void applyPatch() {
execute(DELETE_FROM + "plan_tebex_payments" + WHERE + "packages LIKE 'TebexPackage%'");
}
}

View File

@ -41,7 +41,7 @@ dependencies {
compile 'com.djrapitops:Extension-RedProtect:7.7.3-R0.1' compile 'com.djrapitops:Extension-RedProtect:7.7.3-R0.1'
compile 'com.djrapitops:Extension-Sponge-Economy:7.1.0-R0.3' compile 'com.djrapitops:Extension-Sponge-Economy:7.1.0-R0.3'
compile 'com.djrapitops:Extension-SuperbVote:0.5.4-R0.1' compile 'com.djrapitops:Extension-SuperbVote:0.5.4-R0.1'
compile 'com.djrapitops:Extension-Tebex:R1.1' compile 'com.djrapitops:Extension-Tebex:R1.2'
compile 'com.djrapitops:Extension-Towny:0.96.7.4-R0.2' compile 'com.djrapitops:Extension-Towny:0.96.7.4-R0.2'
compile 'com.djrapitops:Extension-Vault:1.7-R0.3' compile 'com.djrapitops:Extension-Vault:1.7-R0.3'
compile 'com.djrapitops:Extension-ViaVersion:2.1.3-R1.5' compile 'com.djrapitops:Extension-ViaVersion:2.1.3-R1.5'