mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-15 20:31:40 +01:00
Bugfixes and code cleanup
Fix batch execution for uuid converter Fix last update for SQLite
This commit is contained in:
parent
86ced09103
commit
eef444d0bd
@ -112,12 +112,9 @@ private void checkFiles()
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Use name-based saving
|
||||
else if(len > 16) // Use name-based saving, we only have to rename it if it's name is more than 16 chars (minecraft max player name length)
|
||||
{
|
||||
if(len > 16) // We only have to rename it if it's name is more than 16 chars (minecraft max player name length)
|
||||
{
|
||||
file.renameTo(new File(saveFolder, UUIDConverter.getNameFromUUID(file.getName().substring(0, len)) + EXT));
|
||||
}
|
||||
file.renameTo(new File(saveFolder, UUIDConverter.getNameFromUUID(file.getName().substring(0, len)) + EXT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,9 @@
|
||||
public class MySQL extends SQL
|
||||
{
|
||||
//TODO add cooldown sync table
|
||||
public MySQL(Minepacks mp)
|
||||
public MySQL(Minepacks plugin)
|
||||
{
|
||||
super(mp); // Load Settings
|
||||
super(plugin); // Load Settings
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,9 +31,9 @@ public class MySQLShared extends MySQL
|
||||
{
|
||||
private DatabaseConnectionPool pool;
|
||||
|
||||
protected MySQLShared(Minepacks minepacks, DatabaseConnectionPool pool)
|
||||
protected MySQLShared(Minepacks plugin, DatabaseConnectionPool pool)
|
||||
{
|
||||
super(minepacks);
|
||||
super(plugin);
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
@ -44,8 +44,7 @@ protected HikariConfig getPoolConfig()
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Connection getConnection() throws SQLException
|
||||
public @NotNull Connection getConnection() throws SQLException
|
||||
{
|
||||
return pool.getConnection();
|
||||
}
|
||||
|
@ -35,7 +35,10 @@
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class SQL extends Database
|
||||
{
|
||||
@ -47,9 +50,9 @@ public abstract class SQL extends Database
|
||||
@Language("SQL") protected String queryDeleteOldCooldowns, querySyncCooldown, queryGetCooldown; // DB Querys
|
||||
protected boolean updatePlayer, syncCooldown;
|
||||
|
||||
public SQL(Minepacks mp)
|
||||
public SQL(Minepacks plugin)
|
||||
{
|
||||
super(mp);
|
||||
super(plugin);
|
||||
|
||||
HikariConfig poolConfig = getPoolConfig();
|
||||
if(poolConfig != null)
|
||||
@ -178,8 +181,8 @@ public UpdateData(String uuid, int id)
|
||||
ps.setString(1, updateData.uuid);
|
||||
ps.setInt(2, updateData.id);
|
||||
ps.addBatch();
|
||||
ps.executeBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
}
|
||||
plugin.getLogger().info(String.format(UUIDS_UPDATED, toUpdate.size()));
|
||||
}
|
||||
@ -190,7 +193,7 @@ public UpdateData(String uuid, int id)
|
||||
}
|
||||
}
|
||||
|
||||
protected Connection getConnection() throws SQLException
|
||||
public Connection getConnection() throws SQLException
|
||||
{
|
||||
return dataSource.getConnection();
|
||||
}
|
||||
|
@ -33,9 +33,9 @@
|
||||
public class SQLite extends SQL
|
||||
{
|
||||
//TODO add cooldown sync table
|
||||
public SQLite(Minepacks mp)
|
||||
public SQLite(Minepacks plugin)
|
||||
{
|
||||
super(mp);
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,10 +84,7 @@ protected HikariConfig getPoolConfig()
|
||||
@Override
|
||||
protected void updateQuerysForDialect()
|
||||
{
|
||||
if(maxAge > 0)
|
||||
{
|
||||
queryInsertBp = queryInsertBp.replaceAll("\\) VALUES \\(\\?,\\?,\\?", "{FieldBPLastUpdate}) VALUES (?,?,?,DATE('now')");
|
||||
}
|
||||
queryInsertBp = queryInsertBp.replaceAll("\\) VALUES \\(\\?,\\?,\\?", ",{FieldBPLastUpdate}) VALUES (?,?,?,DATE('now')");
|
||||
queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} < DATE('now', '-{VarMaxAge} days')";
|
||||
queryUpdateBp = queryUpdateBp.replaceAll("\\{NOW}", "DATE('now')");
|
||||
if(useUUIDs)
|
||||
|
@ -32,9 +32,9 @@ public class SQLiteShared extends SQLite
|
||||
{
|
||||
private DatabaseConnectionPool pool;
|
||||
|
||||
protected SQLiteShared(Minepacks minepacks, DatabaseConnectionPool pool)
|
||||
protected SQLiteShared(Minepacks plugin, DatabaseConnectionPool pool)
|
||||
{
|
||||
super(minepacks);
|
||||
super(plugin);
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user