mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Fixed a bug with ViaVersion PluginData that caused Database to lock on /plan reload (Related to #347)
This commit is contained in:
parent
8d8946287c
commit
7af17d6f94
@ -18,6 +18,7 @@ public abstract class ExecStatement {
|
||||
|
||||
public ExecStatement(String sql) {
|
||||
this.sql = sql;
|
||||
// Log.debug("Execute Statement: " + sql);
|
||||
}
|
||||
|
||||
public boolean execute(PreparedStatement statement) throws SQLException {
|
||||
|
@ -24,6 +24,7 @@ public abstract class QueryStatement<T> {
|
||||
|
||||
public QueryStatement(String sql, int fetchSize) {
|
||||
this.sql = sql;
|
||||
// Log.debug("Query Statement: " + sql);
|
||||
this.fetchSize = fetchSize;
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,7 @@ public abstract class Table {
|
||||
connection = getConnection();
|
||||
statement = connection.createStatement();
|
||||
boolean b = statement.execute(statementString);
|
||||
// Log.debug("Execute: " + statementString);
|
||||
commit(connection);
|
||||
return b;
|
||||
} finally {
|
||||
|
@ -7,6 +7,7 @@ package com.djrapitops.pluginbridge.plan.viaversion;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -25,25 +26,23 @@ import java.util.UUID;
|
||||
*/
|
||||
public class PlayerVersionListener implements Listener {
|
||||
|
||||
private final Plan plan;
|
||||
private final ViaAPI viaAPI;
|
||||
private final ProtocolTable table;
|
||||
private ViaAPI viaAPI;
|
||||
|
||||
public PlayerVersionListener(Plan plan, ViaAPI viaAPI, ProtocolTable dbTable) {
|
||||
this.plan = plan;
|
||||
public PlayerVersionListener(ViaAPI viaAPI) {
|
||||
this.viaAPI = viaAPI;
|
||||
this.table = dbTable;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
int playerVersion = viaAPI.getPlayerVersion(uuid);
|
||||
Plan plan = Plan.getInstance();
|
||||
plan.addToProcessQueue(new Processor<UUID>(uuid) {
|
||||
@Override
|
||||
public void process() {
|
||||
try {
|
||||
table.saveProtocolVersion(uuid, playerVersion);
|
||||
|
||||
new ProtocolTable((SQLDB) plan.getDB()).saveProtocolVersion(uuid, playerVersion);
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName() + ":PlanViaVersionJoinListener", e);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ import us.myles.ViaVersion.api.ViaAPI;
|
||||
*/
|
||||
public class ViaVersionHook extends Hook {
|
||||
|
||||
private static PlayerVersionListener listener;
|
||||
|
||||
/**
|
||||
* Hooks the plugin and registers it's PluginData objects.
|
||||
* <p>
|
||||
@ -43,8 +45,10 @@ public class ViaVersionHook extends Hook {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
return;
|
||||
}
|
||||
PlayerVersionListener l = new PlayerVersionListener(plan, api, table);
|
||||
plan.registerListener(l);
|
||||
if (listener == null) {
|
||||
listener = new PlayerVersionListener(api);
|
||||
plan.registerListener(listener);
|
||||
}
|
||||
addPluginDataSource(new ViaVersionVersionTable(table));
|
||||
addPluginDataSource(new ViaVersionVersion(table));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user