From 2a2e0e57a939a8ea35529072ee4e6fb41f18466c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 5 May 2019 17:02:27 +0300 Subject: [PATCH] [#1027] Patch broken 'plan_aac_hack_table's --- .../plan/aac/AdvancedAntiCheatHook.java | 1 + .../pluginbridge/plan/aac/HackerTable.java | 1 + .../HackerTableMissingDateColumnPatch.java | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTableMissingDateColumnPatch.java diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java index ec3c5b998..d26d8b3f4 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java @@ -64,6 +64,7 @@ public class AdvancedAntiCheatHook extends Hook { execute(HackerTable.createTableSQL(database.getType())); } }); + database.executeTransaction(new HackerTableMissingDateColumnPatch()); plugin.registerListener(new PlayerHackKickListener(database)); hookHandler.addPluginDataSource(new AdvancedAntiCheatData(database, formatters.yearLong())); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java index e29575e9f..379b17d4f 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java @@ -51,6 +51,7 @@ public class HackerTable { return CreateTableParser.create(TABLE_NAME, dbType) .column(COL_ID, Sql.INT).primaryKey() .column(COL_UUID, Sql.varchar(36)).notNull() + .column(COL_DATE, Sql.LONG).notNull() .column(COL_HACK_TYPE, Sql.varchar(100)).notNull() .column(COL_VIOLATION_LEVEL, Sql.INT).notNull() .build(); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTableMissingDateColumnPatch.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTableMissingDateColumnPatch.java new file mode 100644 index 000000000..a11d086f1 --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTableMissingDateColumnPatch.java @@ -0,0 +1,40 @@ +/* + * 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.pluginbridge.plan.aac; + +import com.djrapitops.plan.db.patches.Patch; + +/** + * Patch to fix a bug + * https://github.com/plan-player-analytics/Plan/issues/1027 + * introduced in commit 530c4a2 + * https://github.com/plan-player-analytics/Plan/commit/530c4a2ea6fd56fd9a7aa3382f7571f31971dc1a#commitcomment-33415938 + * + * @author Rsl1122 + */ +public class HackerTableMissingDateColumnPatch extends Patch { + + @Override + public boolean hasBeenApplied() { + return hasColumn(HackerTable.TABLE_NAME, HackerTable.COL_DATE); + } + + @Override + protected void applyPatch() { + addColumn(HackerTable.TABLE_NAME, HackerTable.COL_DATE + " bigint NOT NULL DEFAULT 0"); + } +} \ No newline at end of file