mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-02-16 13:41:40 +01:00
Cleanup i guess
This commit is contained in:
parent
95ea032dfa
commit
056d1f57ec
@ -24,12 +24,22 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
|
||||
executeUpdateAsync(
|
||||
"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) "
|
||||
+ "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,"
|
||||
+ "attributes LONGTEXT,professions LONGTEXT,times_claimed LONGTEXT,quests LONGTEXT,"
|
||||
+ "waypoints LONGTEXT,friends LONGTEXT,skills LONGTEXT,bound_skills LONGTEXT,"
|
||||
+ "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
|
||||
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'times_claimed'", result -> {
|
||||
try {
|
||||
|
@ -1,56 +1,55 @@
|
||||
package net.Indyuce.mmocore.manager.data.mysql;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class MySQLTableEditor {
|
||||
private final Table table;
|
||||
private final UUID uuid;
|
||||
private final Table table;
|
||||
private final UUID uuid;
|
||||
private final MySQLDataProvider provider;
|
||||
|
||||
private final MySQLDataProvider provider;
|
||||
public MySQLTableEditor(Table table, UUID uuid, MySQLDataProvider provider) {
|
||||
this.table = table;
|
||||
this.uuid = uuid;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public MySQLTableEditor(Table table, UUID uuid,MySQLDataProvider provider) {
|
||||
this.table = table;
|
||||
this.uuid = uuid;
|
||||
this.provider=provider;
|
||||
}
|
||||
public void updateData(String key, Object value) {
|
||||
provider.executeUpdate("INSERT INTO " + table + "(uuid, " + key
|
||||
+ ") VALUES('" + uuid + "', '" + value + "') ON DUPLICATE KEY UPDATE " + key + "='" + value + "';");
|
||||
}
|
||||
|
||||
public void updateData(String key, Object value) {
|
||||
provider.executeUpdate("INSERT INTO " + table + "(uuid, " + key
|
||||
+ ") VALUES('" + uuid + "', '" + value + "') ON DUPLICATE KEY UPDATE " + key + "='" + value + "';");
|
||||
}
|
||||
public void updateJSONArray(String key, Collection<String> collection) {
|
||||
JsonArray json = new JsonArray();
|
||||
for (String s : collection)
|
||||
json.add(s);
|
||||
updateData(key, json.toString());
|
||||
}
|
||||
|
||||
public void updateJSONArray(String key, Collection<String> collection) {
|
||||
JsonArray json = new JsonArray();
|
||||
for (String s : collection)
|
||||
json.add(s);
|
||||
updateData(key, json.toString());
|
||||
}
|
||||
public void updateJSONObject(String key, Set<Entry<String, Integer>> collection) {
|
||||
JsonObject json = new JsonObject();
|
||||
for (Entry<String, Integer> entry : collection)
|
||||
json.addProperty(entry.getKey(), entry.getValue());
|
||||
updateData(key, json.toString());
|
||||
}
|
||||
|
||||
public void updateJSONObject(String key, Set<Entry<String, Integer>> collection) {
|
||||
JsonObject json = new JsonObject();
|
||||
for (Entry<String, Integer> entry : collection)
|
||||
json.addProperty(entry.getKey(), entry.getValue());
|
||||
updateData(key, json.toString());
|
||||
}
|
||||
public enum Table {
|
||||
PLAYERDATA("mmocore_playerdata"), GUILDDATA("mmocore_guilddata");
|
||||
|
||||
public enum Table {
|
||||
PLAYERDATA("mmocore_playerdata"), GUILDDATA("mmocore_guilddata");
|
||||
final String tableName;
|
||||
|
||||
final String tableName;
|
||||
Table(String tN) {
|
||||
tableName = tN;
|
||||
}
|
||||
|
||||
Table(String tN) {
|
||||
tableName = tN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return tableName;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return tableName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user