mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-16 15:45:16 +01:00
Hide player tables from server page with a special field
- values_for differentiates between different table server and player tables It is an INT field because Groups might get their tables at some point. 0 for player 1 for server (2 for group) Affects issues: - Fixed #1722
This commit is contained in:
parent
148ee6ae57
commit
1a19ec85f6
@ -153,7 +153,8 @@ public class ExtensionServerTablesQuery implements Query<Map<Integer, ExtensionD
|
||||
LEFT_JOIN + ExtensionIconTable.TABLE_NAME + " i4 on i4." + ExtensionIconTable.ID + "=p1." + ExtensionTableProviderTable.ICON_4_ID +
|
||||
LEFT_JOIN + ExtensionIconTable.TABLE_NAME + " i5 on i5." + ExtensionIconTable.ID + "=p1." + ExtensionTableProviderTable.ICON_5_ID +
|
||||
LEFT_JOIN + ExtensionIconTable.TABLE_NAME + " i6 on i6." + ExtensionIconTable.ID + "=t1." + ExtensionTabTable.ICON_ID +
|
||||
WHERE + "p2." + ExtensionPluginTable.SERVER_UUID + "=?";
|
||||
WHERE + "p2." + ExtensionPluginTable.SERVER_UUID + "=?" +
|
||||
AND + "p1." + ExtensionTableProviderTable.VALUES_FOR + '=' + ExtensionTableProviderTable.VALUES_FOR_SERVER;
|
||||
|
||||
return new QueryStatement<QueriedTables>(selectTables, 100) {
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.djrapitops.plan.extension.implementation.storage.transactions.providers;
|
||||
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.MethodType;
|
||||
import com.djrapitops.plan.extension.implementation.ProviderInformation;
|
||||
import com.djrapitops.plan.extension.implementation.providers.Parameters;
|
||||
import com.djrapitops.plan.extension.table.Table;
|
||||
@ -46,15 +47,17 @@ public class StoreTableProviderTransaction extends ThrowawayTransaction {
|
||||
private final ServerUUID serverUUID;
|
||||
private final ProviderInformation information;
|
||||
private final Table table;
|
||||
private final boolean forPlayer;
|
||||
|
||||
public StoreTableProviderTransaction(ProviderInformation information, Parameters parameters, Table table) {
|
||||
this(parameters.getServerUUID(), information, table);
|
||||
this(parameters.getServerUUID(), information, table, parameters.getMethodType() == MethodType.PLAYER);
|
||||
}
|
||||
|
||||
public StoreTableProviderTransaction(ServerUUID serverUUID, ProviderInformation information, Table table) {
|
||||
public StoreTableProviderTransaction(ServerUUID serverUUID, ProviderInformation information, Table table, boolean forPlayer) {
|
||||
this.information = information;
|
||||
this.table = table;
|
||||
this.serverUUID = serverUUID;
|
||||
this.forPlayer = forPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,7 +91,8 @@ public class StoreTableProviderTransaction extends ThrowawayTransaction {
|
||||
ICON_2_ID + '=' + ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ',' +
|
||||
ICON_3_ID + '=' + ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ',' +
|
||||
ICON_4_ID + '=' + ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ',' +
|
||||
ICON_5_ID + '=' + ExtensionIconTable.STATEMENT_SELECT_ICON_ID +
|
||||
ICON_5_ID + '=' + ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ',' +
|
||||
VALUES_FOR + "=?" +
|
||||
WHERE + PROVIDER_NAME + "=?" +
|
||||
AND + PLUGIN_ID + '=' + ExtensionPluginTable.STATEMENT_SELECT_PLUGIN_ID;
|
||||
|
||||
@ -108,8 +112,9 @@ public class StoreTableProviderTransaction extends ThrowawayTransaction {
|
||||
ExtensionIconTable.set3IconValuesToStatement(statement, 17, icons[2]);
|
||||
ExtensionIconTable.set3IconValuesToStatement(statement, 20, icons[3]);
|
||||
ExtensionIconTable.set3IconValuesToStatement(statement, 23, icons[4]);
|
||||
statement.setString(26, information.getName());
|
||||
ExtensionPluginTable.set2PluginValuesToStatement(statement, 27, information.getPluginName(), serverUUID);
|
||||
statement.setInt(26, forPlayer ? VALUES_FOR_PLAYER : VALUES_FOR_SERVER);
|
||||
statement.setString(27, information.getName());
|
||||
ExtensionPluginTable.set2PluginValuesToStatement(statement, 28, information.getPluginName(), serverUUID);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -133,7 +138,8 @@ public class StoreTableProviderTransaction extends ThrowawayTransaction {
|
||||
ICON_2_ID + ',' +
|
||||
ICON_3_ID + ',' +
|
||||
ICON_4_ID + ',' +
|
||||
ICON_5_ID +
|
||||
ICON_5_ID + ',' +
|
||||
VALUES_FOR +
|
||||
") VALUES (?,?,?,?,?,?,?,?," +
|
||||
ExtensionTabTable.STATEMENT_SELECT_TAB_ID + ',' +
|
||||
ExtensionPluginTable.STATEMENT_SELECT_PLUGIN_ID + ',' +
|
||||
@ -141,7 +147,8 @@ public class StoreTableProviderTransaction extends ThrowawayTransaction {
|
||||
ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ',' +
|
||||
ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ',' +
|
||||
ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ',' +
|
||||
ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ')';
|
||||
ExtensionIconTable.STATEMENT_SELECT_ICON_ID + ',' +
|
||||
"?)";
|
||||
|
||||
return new ExecStatement(sql) {
|
||||
@Override
|
||||
@ -161,6 +168,7 @@ public class StoreTableProviderTransaction extends ThrowawayTransaction {
|
||||
ExtensionIconTable.set3IconValuesToStatement(statement, 20, icons[2]);
|
||||
ExtensionIconTable.set3IconValuesToStatement(statement, 23, icons[3]);
|
||||
ExtensionIconTable.set3IconValuesToStatement(statement, 26, icons[4]);
|
||||
statement.setInt(29, forPlayer ? VALUES_FOR_PLAYER : VALUES_FOR_SERVER);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -180,7 +180,8 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
new ServerIsProxyPatch(),
|
||||
new UserInfoHostnameAllowNullPatch(),
|
||||
new ServerTableValuesRowNumberPatch(),
|
||||
new PlayerTableValuesRowNumberPatch()
|
||||
new PlayerTableValuesRowNumberPatch(),
|
||||
new ExtensionTableProviderValuesForPatch()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ public class ExtensionTableProviderTable {
|
||||
public static final String ID = "id";
|
||||
public static final String PROVIDER_NAME = "name";
|
||||
public static final String COLOR = "color";
|
||||
public static final String VALUES_FOR = "values_for";
|
||||
public static final String CONDITION = "condition_name"; // Can be null, related to @Conditional
|
||||
public static final String PLUGIN_ID = "plugin_id";
|
||||
public static final String TAB_ID = "tab_id"; // Can be null, related to @Tab
|
||||
@ -57,6 +58,9 @@ public class ExtensionTableProviderTable {
|
||||
public static final String ICON_4_ID = "icon_4_id";
|
||||
public static final String ICON_5_ID = "icon_5_id";
|
||||
|
||||
public static final int VALUES_FOR_PLAYER = 0;
|
||||
public static final int VALUES_FOR_SERVER = 1;
|
||||
|
||||
public static final String STATEMENT_SELECT_TABLE_ID = '(' + SELECT + ID + FROM + TABLE_NAME +
|
||||
WHERE + PROVIDER_NAME + "=?" +
|
||||
AND + PLUGIN_ID + "=" + ExtensionPluginTable.STATEMENT_SELECT_PLUGIN_ID + " LIMIT 1)";
|
||||
@ -75,6 +79,7 @@ public class ExtensionTableProviderTable {
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(PROVIDER_NAME, Sql.varchar(50)).notNull()
|
||||
.column(COLOR, Sql.varchar(25)).notNull().defaultValue("'" + Color.NONE.name() + "'")
|
||||
.column(VALUES_FOR, INT)
|
||||
.column(CONDITION, Sql.varchar(54)) // 50 + 4 for "not_"
|
||||
.column(COL_1, Sql.varchar(50))
|
||||
.column(COL_2, Sql.varchar(50))
|
||||
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.patches;
|
||||
|
||||
import com.djrapitops.plan.storage.database.sql.building.Sql;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionTableProviderTable;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionTableProviderTable.*;
|
||||
|
||||
/**
|
||||
* Adds values_for field to plan_extension_tables
|
||||
*/
|
||||
public class ExtensionTableProviderValuesForPatch extends Patch {
|
||||
|
||||
@Override
|
||||
public boolean hasBeenApplied() {
|
||||
return hasColumn(
|
||||
TABLE_NAME,
|
||||
VALUES_FOR
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyPatch() {
|
||||
addColumn(TABLE_NAME, VALUES_FOR + " " + Sql.INT + " DEFAULT " + VALUES_FOR_PLAYER);
|
||||
|
||||
String selectServerTableIDs = SELECT + DISTINCT +
|
||||
ExtensionServerTableValueTable.TABLE_ID +
|
||||
FROM + ExtensionServerTableValueTable.TABLE_NAME;
|
||||
|
||||
String updateSql = "UPDATE " + TABLE_NAME + " SET " + VALUES_FOR + "=" + VALUES_FOR_SERVER +
|
||||
WHERE + ExtensionTableProviderTable.ID + " IN (" + selectServerTableIDs + ")";
|
||||
|
||||
execute(updateSql);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user