Fix typos

This commit is contained in:
GeorgH93 2023-06-29 02:12:24 +02:00
parent 91232339df
commit 8259fd2f4f
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
5 changed files with 22 additions and 21 deletions

View File

@ -51,7 +51,7 @@ public abstract class Database implements Listener
protected boolean useUUIDSeparators, asyncSave = true;
protected long maxAge;
private final Map<UUID, Backpack> backpacks = new ConcurrentHashMap<>();
private final UnCacheStrategy unCacheStrategie;
private final UnCacheStrategy unCacheStrategy;
private final File backupFolder;
public Database(Minepacks mp)
@ -63,7 +63,7 @@ public Database(Minepacks mp)
bungeeCordMode = plugin.getConfiguration().isBungeeCordModeEnabled();
forceSaveOnUnload = plugin.getConfiguration().isForceSaveOnUnloadEnabled();
maxAge = plugin.getConfiguration().getAutoCleanupMaxInactiveDays();
unCacheStrategie = bungeeCordMode ? new OnDisconnect(this) : UnCacheStrategy.getUnCacheStrategie(this);
unCacheStrategy = bungeeCordMode ? new OnDisconnect(this) : UnCacheStrategy.getUnCacheStrategy(this);
backupFolder = new File(this.plugin.getDataFolder(), "backups");
if(!backupFolder.exists() && !backupFolder.mkdirs()) mp.getLogger().info("Failed to create backups folder.");
}
@ -79,7 +79,7 @@ public void close()
asyncSave = false;
backpacks.forEach((key, value) -> { if (forceSaveOnUnload) { value.setChanged(); } value.closeAll(); });
backpacks.clear();
unCacheStrategie.close();
unCacheStrategy.close();
}
public static @Nullable Database getDatabase(Minepacks plugin)

View File

@ -12,7 +12,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
@ -35,7 +35,7 @@ public MySQL(@NotNull Minepacks plugin, @Nullable ConnectionProvider connectionP
}
@Override
protected void updateQuerysForDialect()
protected void updateQueriesForDialect()
{
queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} + INTERVAL {VarMaxAge} day < NOW()";
queryUpdateBp = queryUpdateBp.replaceAll("\\{NOW}", "NOW()");

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 GeorgH93
* Copyright (C) 2023 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -12,7 +12,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
@ -23,6 +23,7 @@
import at.pcgamingfreaks.Minepacks.Bukkit.Backpack;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import at.pcgamingfreaks.Utils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -38,8 +39,8 @@ public abstract class SQL extends Database
protected String tablePlayers, tableBackpacks, tableCooldowns; // Table Names
protected String fieldPlayerName, fieldPlayerID, fieldPlayerUUID, fieldBpOwner, fieldBpIts, fieldBpVersion, fieldBpLastUpdate, fieldCdPlayer, fieldCdTime; // Table Fields
@Language("SQL") protected String queryUpdatePlayerAdd, queryGetPlayerID, queryInsertBp, queryUpdateBp, queryGetBP, queryDeleteOldBackpacks; // DB Querys
@Language("SQL") protected String queryDeleteOldCooldowns, querySyncCooldown, queryGetCooldown; // DB Querys
@Language("SQL") protected String queryUpdatePlayerAdd, queryGetPlayerID, queryInsertBp, queryUpdateBp, queryGetBP, queryDeleteOldBackpacks; // DB Queries
@Language("SQL") protected String queryDeleteOldCooldowns, querySyncCooldown, queryGetCooldown; // DB Queries
protected boolean syncCooldown;
public SQL(@NotNull Minepacks plugin, @NotNull ConnectionProvider connectionProvider)
@ -50,7 +51,7 @@ public SQL(@NotNull Minepacks plugin, @NotNull ConnectionProvider connectionProv
if(!dataSource.isAvailable()) throw new IllegalStateException("Failed to initialize database connection!");
loadSettings();
buildQuerys();
buildQueries();
checkDB();
checkUUIDs(); // Check if there are user accounts without UUID
@ -125,9 +126,9 @@ public Connection getConnection() throws SQLException
protected abstract void checkDB();
protected final void buildQuerys()
protected final void buildQueries()
{
// Build the SQL querys with placeholders for the table and field names
// Build the SQL queries with placeholders for the table and field names
queryGetBP = "SELECT {FieldBPOwner},{FieldBPITS},{FieldBPVersion} FROM {TableBackpacks} INNER JOIN {TablePlayers} ON {TableBackpacks}.{FieldBPOwner}={TablePlayers}.{FieldPlayerID} WHERE {FieldUUID}=?;";
querySyncCooldown = "INSERT INTO {TableCooldowns} ({FieldCDPlayer},{FieldCDTime}) SELECT {FieldPlayerID},? FROM {TablePlayers} WHERE {FieldUUID}=? ON DUPLICATE KEY UPDATE {FieldCDTime}=?;";
queryUpdatePlayerAdd = "INSERT INTO {TablePlayers} ({FieldName},{FieldUUID}) VALUES (?,?) ON DUPLICATE KEY UPDATE {FieldName}=?;";
@ -138,7 +139,7 @@ protected final void buildQuerys()
queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} < DATE('now', '-{VarMaxAge} days')";
queryDeleteOldCooldowns = "DELETE FROM {TableCooldowns} WHERE {FieldCDTime}<?;";
updateQuerysForDialect();
updateQueriesForDialect();
setTableAndFieldNames();
}
@ -151,13 +152,13 @@ protected void setTableAndFieldNames()
queryGetBP = replacePlaceholders(queryGetBP);
queryInsertBp = replacePlaceholders(queryInsertBp);
queryUpdateBp = replacePlaceholders(queryUpdateBp);
queryDeleteOldBackpacks = replacePlaceholders(queryDeleteOldBackpacks.replaceAll("\\{VarMaxAge}", maxAge + ""));
queryDeleteOldBackpacks = replacePlaceholders(queryDeleteOldBackpacks.replace("{VarMaxAge}", String.valueOf(maxAge)));
querySyncCooldown = replacePlaceholders(querySyncCooldown);
queryGetCooldown = replacePlaceholders(queryGetCooldown);
queryDeleteOldCooldowns = replacePlaceholders(queryDeleteOldCooldowns);
}
protected abstract void updateQuerysForDialect();
protected abstract void updateQueriesForDialect();
protected String replacePlaceholders(@Language("SQL") String query)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 GeorgH93
* Copyright (C) 2023 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -12,7 +12,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package at.pcgamingfreaks.Minepacks.Bukkit.Database;
@ -69,7 +69,7 @@ protected void loadSettings()
}
@Override
protected void updateQuerysForDialect()
protected void updateQueriesForDialect()
{
queryInsertBp = queryInsertBp.replaceAll("\\) VALUES \\(\\?,\\?,\\?", ",{FieldBPLastUpdate}) VALUES (?,?,?,DATE('now')");
queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} < DATE('now', '-{VarMaxAge} days')";

View File

@ -12,7 +12,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package at.pcgamingfreaks.Minepacks.Bukkit.Database.UnCacheStrategies;
@ -29,13 +29,13 @@ public UnCacheStrategy(Database cache)
this.cache = cache;
}
public static UnCacheStrategy getUnCacheStrategie(Database cache)
public static UnCacheStrategy getUnCacheStrategy(Database cache)
{
switch(Minepacks.getInstance().getConfiguration().getUnCacheStrategy())
{
case "ondisconnect": return new OnDisconnect(cache);
case "ondisconnectdelayed": return new OnDisconnectDelayed(cache);
case "intervalChecked": return new IntervalChecked(cache);
case "intervalchecked": return new IntervalChecked(cache);
case "interval": default: return new Interval(cache);
}
}