diff --git a/PlanPluginBridge/pom.xml b/PlanPluginBridge/pom.xml index 4224324e0..c53365861 100644 --- a/PlanPluginBridge/pom.xml +++ b/PlanPluginBridge/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.djrapitops PlanPluginBridge - 4.8.8-R0.2 + 4.9.0-R0.1 jar ${project.groupId}:${project.artifactId} @@ -61,10 +61,6 @@ jitpack.io (GriefPrevention) https://jitpack.io - - viaversion-repo - https://repo.viaversion.com - placeholderapi http://repo.extendedclip.com/content/repositories/placeholderapi/ @@ -127,12 +123,6 @@ 2.10.3 provided - - us.myles - viaversion - 1.5.0 - provided - me.lucko.luckperms luckperms-api @@ -141,13 +131,6 @@ - - - me.konsolas - AAC - 4.0.0-b1 - provided - com.massivecraft factions diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatData.java deleted file mode 100644 index 457e0bdde..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatData.java +++ /dev/null @@ -1,91 +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 . - */ -package com.djrapitops.pluginbridge.plan.aac; - -import com.djrapitops.plan.data.element.AnalysisContainer; -import com.djrapitops.plan.data.element.InspectContainer; -import com.djrapitops.plan.data.element.TableContainer; -import com.djrapitops.plan.data.plugin.ContainerSize; -import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.db.Database; -import com.djrapitops.plan.utilities.formatting.Formatter; -import com.djrapitops.plan.utilities.html.icon.Color; -import com.djrapitops.plan.utilities.html.icon.Family; -import com.djrapitops.plan.utilities.html.icon.Icon; -import com.djrapitops.plugin.utilities.Format; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; - -/** - * PluginData for AAC plugin. - * - * @author Rsl1122 - */ -class AdvancedAntiCheatData extends PluginData { - - private final Database database; - private final Formatter timestampFormatter; - - AdvancedAntiCheatData(Database database, Formatter timestampFormatter) { - super(ContainerSize.THIRD, "AdvancedAntiCheat"); - this.timestampFormatter = timestampFormatter; - super.setPluginIcon(Icon.called("heart").of(Color.RED).build()); - this.database = database; - } - - @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { - List hackObjects = database.query(HackerTable.getHackObjects(uuid)); - - inspectContainer.addValue( - getWithIcon("Times Kicked for Possible Hacking", Icon.called("exclamation-triangle").of(Color.RED)), - hackObjects.size() - ); - - TableContainer hackTable = new TableContainer( - getWithIcon("Kicked", Icon.called("calendar").of(Family.REGULAR)), - getWithIcon("Hack", Icon.called("exclamation-triangle")), - getWithIcon("Violation Level", Icon.called("gavel")) - ); - hackTable.setColor("red"); - - for (HackObject hackObject : hackObjects) { - String date = timestampFormatter.apply(hackObject.getDate()); - String hack = new Format(hackObject.getHackType()).capitalize().toString(); - hackTable.addRow(date, hack, hackObject.getViolationLevel()); - } - inspectContainer.addTable("hackTable", hackTable); - - return inspectContainer; - } - - @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { - Map> hackObjects = database.query(HackerTable.getHackObjects()); - - Map violations = hackObjects.entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().size())); - - analysisContainer.addPlayerTableValues(getWithIcon("Kicked for Hacking", Icon.called("exclamation-triangle")), violations); - - return analysisContainer; - } -} \ No newline at end of file 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 deleted file mode 100644 index d26d8b3f4..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java +++ /dev/null @@ -1,72 +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 . - */ -package com.djrapitops.pluginbridge.plan.aac; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.db.Database; -import com.djrapitops.plan.db.access.transactions.Transaction; -import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.plan.utilities.formatting.Formatters; -import com.djrapitops.pluginbridge.plan.Hook; - -import javax.inject.Inject; -import javax.inject.Singleton; - -/** - * Hook for AAC plugin. - * - * @author Rsl1122 - */ -@Singleton -public class AdvancedAntiCheatHook extends Hook { - - private final Plan plugin; - private final DBSystem dbSystem; - private final Formatters formatters; - - @Inject - public AdvancedAntiCheatHook( - Plan plugin, - DBSystem dbSystem, - Formatters formatters - ) { - super("me.konsolas.aac.AAC"); - this.plugin = plugin; - this.dbSystem = dbSystem; - this.formatters = formatters; - } - - @Override - public void hook(HookHandler hookHandler) throws NoClassDefFoundError { - if (!enabled) { - return; - } - - Database database = dbSystem.getDatabase(); - database.executeTransaction(new Transaction() { - @Override - protected void performOperations() { - execute(HackerTable.createTableSQL(database.getType())); - } - }); - database.executeTransaction(new HackerTableMissingDateColumnPatch()); - - plugin.registerListener(new PlayerHackKickListener(database)); - hookHandler.addPluginDataSource(new AdvancedAntiCheatData(database, formatters.yearLong())); - } -} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackObject.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackObject.java deleted file mode 100644 index 4229aada1..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackObject.java +++ /dev/null @@ -1,55 +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 . - */ -package com.djrapitops.pluginbridge.plan.aac; - -import java.util.UUID; - -/** - * Data object for AAC data. - * - * @author Rsl1122 - */ -public class HackObject { - - private final UUID uuid; - private final long date; - private final String hackType; - private final int violationLevel; - - public HackObject(UUID uuid, long date, String hackType, int violationLevel) { - this.uuid = uuid; - this.date = date; - this.hackType = hackType; - this.violationLevel = violationLevel; - } - - public UUID getUuid() { - return uuid; - } - - public long getDate() { - return date; - } - - public String getHackType() { - return hackType; - } - - public int getViolationLevel() { - return violationLevel; - } -} \ No newline at end of file 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 deleted file mode 100644 index 379b17d4f..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java +++ /dev/null @@ -1,102 +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 . - */ -package com.djrapitops.pluginbridge.plan.aac; - -import com.djrapitops.plan.db.DBType; -import com.djrapitops.plan.db.access.Query; -import com.djrapitops.plan.db.access.QueryAllStatement; -import com.djrapitops.plan.db.access.QueryStatement; -import com.djrapitops.plan.db.sql.parsing.CreateTableParser; -import com.djrapitops.plan.db.sql.parsing.Select; -import com.djrapitops.plan.db.sql.parsing.Sql; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.*; - -/** - * Table information about 'plan_aac_hack_table'. - * - * @author Rsl1122 - */ -public class HackerTable { - - public static final String TABLE_NAME = "plan_aac_hack_table"; - public static final String COL_ID = "id"; - public static final String COL_UUID = "uuid"; - public static final String COL_DATE = "date"; - public static final String COL_HACK_TYPE = "hack_type"; - public static final String COL_VIOLATION_LEVEL = "violation_level"; - - private HackerTable() { - /* Static information class */ - } - - public static String createTableSQL(DBType dbType) { - 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(); - } - - public static Query> getHackObjects(UUID uuid) { - String sql = "SELECT * FROM " + TABLE_NAME + " WHERE " + COL_UUID + "=?"; - - return new QueryStatement>(sql) { - @Override - public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, uuid.toString()); - } - - @Override - public List processResults(ResultSet set) throws SQLException { - List hackObjects = new ArrayList<>(); - while (set.next()) { - UUID uuid = UUID.fromString(set.getString(COL_UUID)); - long date = set.getLong(COL_DATE); - String hackType = set.getString(COL_HACK_TYPE); - int violationLevel = set.getInt(COL_VIOLATION_LEVEL); - hackObjects.add(new HackObject(uuid, date, hackType, violationLevel)); - } - return hackObjects; - } - }; - } - - public static Query>> getHackObjects() { - return new QueryAllStatement>>(Select.all(TABLE_NAME).toString(), 5000) { - @Override - public Map> processResults(ResultSet set) throws SQLException { - Map> hackObjects = new HashMap<>(); - while (set.next()) { - UUID uuid = UUID.fromString(set.getString(COL_UUID)); - long date = set.getLong(COL_DATE); - String hackType = set.getString(COL_HACK_TYPE); - int violationLevel = set.getInt(COL_VIOLATION_LEVEL); - List list = hackObjects.getOrDefault(uuid, new ArrayList<>()); - list.add(new HackObject(uuid, date, hackType, violationLevel)); - hackObjects.put(uuid, list); - } - return hackObjects; - } - }; - } -} 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 deleted file mode 100644 index a11d086f1..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTableMissingDateColumnPatch.java +++ /dev/null @@ -1,40 +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 . - */ -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 diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java deleted file mode 100644 index 61375a8e1..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java +++ /dev/null @@ -1,61 +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 . - */ -package com.djrapitops.pluginbridge.plan.aac; - -import com.djrapitops.plan.db.Database; -import me.konsolas.aac.api.AACAPIProvider; -import me.konsolas.aac.api.HackType; -import me.konsolas.aac.api.PlayerViolationCommandEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.util.UUID; - -/** - * Class responsible for listening kick events made by AAC. - * - * @author Rsl1122 - */ -public class PlayerHackKickListener implements Listener { - - private final Database database; - - PlayerHackKickListener(Database database) { - this.database = database; - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onKick(PlayerViolationCommandEvent event) { - if (event.isCancelled()) { - return; - } - - Player player = event.getPlayer(); - UUID uuid = player.getUniqueId(); - HackType hackType = event.getHackType(); - String hackTypeName = hackType.getName(); - long time = System.currentTimeMillis(); - - int violations = new AACAPIProvider().getAPI().getViolationLevel(player, hackType); - - HackObject hackObject = new HackObject(uuid, time, hackTypeName, violations); - - database.executeTransaction(new StoreHackViolationKickTransaction(hackObject)); - } -} diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/StoreHackViolationKickTransaction.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/StoreHackViolationKickTransaction.java deleted file mode 100644 index eeb24fb8a..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/StoreHackViolationKickTransaction.java +++ /dev/null @@ -1,64 +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 . - */ -package com.djrapitops.pluginbridge.plan.aac; - -import com.djrapitops.plan.db.access.ExecStatement; -import com.djrapitops.plan.db.access.Executable; -import com.djrapitops.plan.db.access.transactions.Transaction; - -import java.sql.PreparedStatement; -import java.sql.SQLException; - -import static com.djrapitops.pluginbridge.plan.aac.HackerTable.*; - -/** - * Transaction to store kick information when AAC kicks a player for hacking. - * - * @author Rsl1122 - */ -public class StoreHackViolationKickTransaction extends Transaction { - - private final HackObject info; - - public StoreHackViolationKickTransaction(HackObject info) { - this.info = info; - } - - @Override - protected void performOperations() { - execute(storeViolationKick()); - } - - private Executable storeViolationKick() { - String sql = "INSERT INTO " + TABLE_NAME + " (" - + COL_UUID + ", " - + COL_DATE + ", " - + COL_HACK_TYPE + ", " - + COL_VIOLATION_LEVEL - + ") VALUES (?, ?, ?, ?)"; - - return new ExecStatement(sql) { - @Override - public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, info.getUuid().toString()); - statement.setLong(2, info.getDate()); - statement.setString(3, info.getHackType()); - statement.setInt(4, info.getViolationLevel()); - } - }; - } -} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java index 6b05daed6..cc1a40ac1 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java @@ -17,7 +17,6 @@ package com.djrapitops.pluginbridge.plan.protocolsupport; import com.djrapitops.plan.db.Database; -import com.djrapitops.pluginbridge.plan.viaversion.StoreUsedProtocolTransaction; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportData.java index 7b9c4c599..e9be61119 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportData.java @@ -25,7 +25,6 @@ import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.db.Database; import com.djrapitops.plan.utilities.html.icon.Color; import com.djrapitops.plan.utilities.html.icon.Icon; -import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable; import protocolsupport.api.ProtocolVersion; import java.util.Collection; diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java index bb34ea7a7..b0883325e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java @@ -22,7 +22,6 @@ import com.djrapitops.plan.db.Database; import com.djrapitops.plan.db.access.transactions.Transaction; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.pluginbridge.plan.Hook; -import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolTable.java similarity index 98% rename from PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java rename to PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolTable.java index 6b4d107ac..9227732a4 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolTable.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Plan. If not, see . */ -package com.djrapitops.pluginbridge.plan.viaversion; +package com.djrapitops.pluginbridge.plan.protocolsupport; import com.djrapitops.plan.db.DBType; import com.djrapitops.plan.db.access.Query; diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/StoreUsedProtocolTransaction.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/StoreUsedProtocolTransaction.java similarity index 95% rename from PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/StoreUsedProtocolTransaction.java rename to PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/StoreUsedProtocolTransaction.java index 3ab8df4e2..3f78c9372 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/StoreUsedProtocolTransaction.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/StoreUsedProtocolTransaction.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Plan. If not, see . */ -package com.djrapitops.pluginbridge.plan.viaversion; +package com.djrapitops.pluginbridge.plan.protocolsupport; import com.djrapitops.plan.db.access.ExecStatement; import com.djrapitops.plan.db.access.Executable; @@ -25,7 +25,7 @@ import java.sql.SQLException; import java.util.UUID; import static com.djrapitops.plan.db.sql.parsing.Sql.WHERE; -import static com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable.*; +import static com.djrapitops.pluginbridge.plan.protocolsupport.ProtocolTable.*; /** * Transaction to store used version protocol. diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BukkitPlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BukkitPlayerVersionListener.java deleted file mode 100644 index 65c92944d..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BukkitPlayerVersionListener.java +++ /dev/null @@ -1,54 +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 . - */ -package com.djrapitops.pluginbridge.plan.viaversion; - -import com.djrapitops.plan.db.Database; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import us.myles.ViaVersion.api.ViaAPI; - -import java.util.UUID; - -/** - * Class responsible for listening join events for Version protocol. - * - * @author Rsl1122 - - */ -public class BukkitPlayerVersionListener implements Listener { - - private final ViaAPI viaAPI; - - private final Database database; - - BukkitPlayerVersionListener( - ViaAPI viaAPI, - Database database - ) { - this.viaAPI = viaAPI; - this.database = database; - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onJoin(PlayerJoinEvent event) { - UUID uuid = event.getPlayer().getUniqueId(); - int playerVersion = viaAPI.getPlayerVersion(uuid); - database.executeTransaction(new StoreUsedProtocolTransaction(uuid, playerVersion)); - } -} diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BungeePlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BungeePlayerVersionListener.java deleted file mode 100644 index 159be3e7f..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/BungeePlayerVersionListener.java +++ /dev/null @@ -1,53 +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 . - */ -package com.djrapitops.pluginbridge.plan.viaversion; - -import com.djrapitops.plan.db.Database; -import net.md_5.bungee.api.event.PostLoginEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; -import us.myles.ViaVersion.api.ViaAPI; - -import java.util.UUID; - -/** - * Class responsible for listening join events for Version protocol. - * - * @author Rsl1122 - - */ -public class BungeePlayerVersionListener implements Listener { - - private final ViaAPI viaAPI; - - private final Database database; - - BungeePlayerVersionListener( - ViaAPI viaAPI, - Database database - ) { - this.viaAPI = viaAPI; - this.database = database; - } - - @EventHandler - public void onJoin(PostLoginEvent event) { - UUID uuid = event.getPlayer().getUniqueId(); - int playerVersion = viaAPI.getPlayerVersion(uuid); - database.executeTransaction(new StoreUsedProtocolTransaction(uuid, playerVersion)); - } -} diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBukkitHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBukkitHook.java deleted file mode 100644 index 81b77e175..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBukkitHook.java +++ /dev/null @@ -1,69 +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 . - */ -package com.djrapitops.pluginbridge.plan.viaversion; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.db.Database; -import com.djrapitops.plan.db.access.transactions.Transaction; -import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.pluginbridge.plan.Hook; -import us.myles.ViaVersion.api.Via; -import us.myles.ViaVersion.api.ViaAPI; - -import javax.inject.Inject; -import javax.inject.Singleton; - -/** - * A Class responsible for hooking to ViaVersion and registering data sources. - * - * @author Rsl1122 - - */ -@Singleton -public class ViaVersionBukkitHook extends Hook { - - private final Plan plugin; - private final DBSystem dbSystem; - - @Inject - public ViaVersionBukkitHook( - Plan plugin, - DBSystem dbSystem - ) { - super("us.myles.ViaVersion.ViaVersionPlugin"); - this.plugin = plugin; - this.dbSystem = dbSystem; - } - - public void hook(HookHandler handler) throws NoClassDefFoundError { - if (!enabled) { - return; - } - ViaAPI api = Via.getAPI(); - Database database = dbSystem.getDatabase(); - database.executeTransaction(new Transaction() { - @Override - protected void performOperations() { - execute(ProtocolTable.createTableSQL(database.getType())); - } - }); - - plugin.registerListener(new BukkitPlayerVersionListener(api, database)); - handler.addPluginDataSource(new ViaVersionData(database)); - } -} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBungeeHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBungeeHook.java deleted file mode 100644 index 93c374729..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionBungeeHook.java +++ /dev/null @@ -1,69 +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 . - */ -package com.djrapitops.pluginbridge.plan.viaversion; - -import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.db.Database; -import com.djrapitops.plan.db.access.transactions.Transaction; -import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.pluginbridge.plan.Hook; -import us.myles.ViaVersion.api.Via; -import us.myles.ViaVersion.api.ViaAPI; - -import javax.inject.Inject; -import javax.inject.Singleton; - -/** - * A Class responsible for hooking to ViaVersion and registering data sources. - * - * @author Rsl1122 - - */ -@Singleton -public class ViaVersionBungeeHook extends Hook { - - private final PlanBungee plugin; - private final DBSystem dbSystem; - - @Inject - public ViaVersionBungeeHook( - PlanBungee plugin, - DBSystem dbSystem - ) { - super("us.myles.ViaVersion.BungeePlugin"); - this.plugin = plugin; - this.dbSystem = dbSystem; - } - - public void hook(HookHandler handler) throws NoClassDefFoundError { - if (!enabled) { - return; - } - ViaAPI api = Via.getAPI(); - Database database = dbSystem.getDatabase(); - database.executeTransaction(new Transaction() { - @Override - protected void performOperations() { - execute(ProtocolTable.createTableSQL(database.getType())); - } - }); - - plugin.registerListener(new BungeePlayerVersionListener(api, database)); - handler.addPluginDataSource(new ViaVersionData(database)); - } -} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionData.java deleted file mode 100644 index 7de7f195c..000000000 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionData.java +++ /dev/null @@ -1,109 +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 . - */ -package com.djrapitops.pluginbridge.plan.viaversion; - -import com.djrapitops.plan.api.exceptions.database.DBOpException; -import com.djrapitops.plan.data.element.AnalysisContainer; -import com.djrapitops.plan.data.element.InspectContainer; -import com.djrapitops.plan.data.element.TableContainer; -import com.djrapitops.plan.data.plugin.ContainerSize; -import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.db.Database; -import com.djrapitops.plan.utilities.html.icon.Color; -import com.djrapitops.plan.utilities.html.icon.Icon; -import us.myles.ViaVersion.api.protocol.ProtocolVersion; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; - -/** - * PluginData for ViaVersion plugin. - * - * @author Rsl1122 - */ -class ViaVersionData extends PluginData { - - private final Database database; - - ViaVersionData(Database database) { - super(ContainerSize.THIRD, "ViaVersion"); - setPluginIcon(Icon.called("gamepad").of(Color.LIGHT_GREEN).build()); - this.database = database; - } - - @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { - try { - int version = database.query(ProtocolTable.getProtocolVersion(uuid)); - - inspectContainer.addValue(getWithIcon("Last Join Version", Icon.called("signal").of(Color.LIGHT_GREEN)), - getProtocolVersionString(version)); - } catch (DBOpException ex) { - inspectContainer.addValue("Error", ex.toString()); - } - - return inspectContainer; - } - - private String getProtocolVersionString(int version) { - return version != -1 ? ProtocolVersion.getProtocol(version).getName() : "Not Yet Known"; - } - - @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { - Map versions; - - try { - versions = database.query(ProtocolTable.getProtocolVersions()); - } catch (DBOpException ex) { - analysisContainer.addValue("Error", ex.toString()); - return analysisContainer; - } - - Map userVersions = versions.entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, entry -> getProtocolVersionString(entry.getValue()))); - - analysisContainer.addPlayerTableValues(getWithIcon("Last Version", Icon.called("signal")), userVersions); - - String versionS = getWithIcon("Version", Icon.called("signal")); - String membersS = getWithIcon("Users", Icon.called("users")); - TableContainer versionTable = new TableContainer(versionS, membersS); - versionTable.setColor("light-green"); - Map usersPerVersion = getUsersPerVersion(userVersions); - for (Map.Entry entry : usersPerVersion.entrySet()) { - versionTable.addRow(entry.getKey(), entry.getValue()); - } - analysisContainer.addTable("versionTable", versionTable); - - return analysisContainer; - } - - private Map getUsersPerVersion(Map userVersions) { - Map usersPerVersion = new HashMap<>(); - - for (String version : userVersions.values()) { - if (!usersPerVersion.containsKey(version)) { - usersPerVersion.put(version, 0); - } - usersPerVersion.replace(version, usersPerVersion.get(version) + 1); - } - return usersPerVersion; - } -} \ No newline at end of file