Cleanup i guess

This commit is contained in:
Indyuce 2022-08-17 13:25:02 +02:00
parent 95ea032dfa
commit 056d1f57ec
2 changed files with 49 additions and 40 deletions

View File

@ -24,12 +24,22 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
executeUpdateAsync( executeUpdateAsync(
"CREATE TABLE IF NOT EXISTS mmocore_playerdata(uuid VARCHAR(36),class_points " "CREATE TABLE IF NOT EXISTS mmocore_playerdata(uuid VARCHAR(36),class_points "
+ "INT(11) DEFAULT 0,skill_points INT(11) DEFAULT 0,attribute_points INT(11) " + "INT(11) DEFAULT 0,skill_points INT(11) DEFAULT 0,attribute_points INT(11) "
+ "DEFAULT 0,attribute_realloc_points INT(11) DEFAULT 0,level INT(11) DEFAULT 1," + "DEFAULT 0,attribute_realloc_points INT(11) DEFAULT 0,skill_reallocation_points INT(11) DEFAULT 0,level INT(11) DEFAULT 1,"
+ "experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG," + "experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG,"
+ "attributes LONGTEXT,professions LONGTEXT,times_claimed LONGTEXT,quests LONGTEXT," + "attributes LONGTEXT,professions LONGTEXT,times_claimed LONGTEXT,quests LONGTEXT,"
+ "waypoints LONGTEXT,friends LONGTEXT,skills LONGTEXT,bound_skills LONGTEXT," + "waypoints LONGTEXT,friends LONGTEXT,skills LONGTEXT,bound_skills LONGTEXT,"
+ "class_info LONGTEXT, is_saved TINYINT, PRIMARY KEY (uuid));"); + "class_info LONGTEXT, is_saved TINYINT, PRIMARY KEY (uuid));");
// Add 'skill_reallocation_points' if it doesn't exist
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'skill_reallocation_points'", result -> {
try {
if (!result.next())
executeUpdateAsync("ALTER TABLE mmocore_playerdata ADD COLUMN skill_reallocation_points INT(11) DEFAULT 0");
} catch (SQLException exception) {
exception.printStackTrace();
}
});
// Add 'times_claimed' if it doesn't exist // Add 'times_claimed' if it doesn't exist
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'times_claimed'", result -> { getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'times_claimed'", result -> {
try { try {

View File

@ -1,23 +1,22 @@
package net.Indyuce.mmocore.manager.data.mysql; package net.Indyuce.mmocore.manager.data.mysql;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.Collection; import java.util.Collection;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
public class MySQLTableEditor { public class MySQLTableEditor {
private final Table table; private final Table table;
private final UUID uuid; private final UUID uuid;
private final MySQLDataProvider provider; private final MySQLDataProvider provider;
public MySQLTableEditor(Table table, UUID uuid,MySQLDataProvider provider) { public MySQLTableEditor(Table table, UUID uuid, MySQLDataProvider provider) {
this.table = table; this.table = table;
this.uuid = uuid; this.uuid = uuid;
this.provider=provider; this.provider = provider;
} }
public void updateData(String key, Object value) { public void updateData(String key, Object value) {