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