mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
!fixed some SQL things
This commit is contained in:
parent
2302743961
commit
54ba6b89b8
BIN
lib/MMOLib.jar
BIN
lib/MMOLib.jar
Binary file not shown.
@ -165,8 +165,8 @@ public class MMOCore extends JavaPlugin {
|
||||
new Metrics(this);
|
||||
saveDefaultConfig();
|
||||
|
||||
if (getConfig().contains("mysql") && getConfig().getBoolean("mysql.enabled"))
|
||||
dataProvider = new MySQLDataProvider();
|
||||
if (getConfig().isConfigurationSection("mysql") && getConfig().getBoolean("mysql.enabled"))
|
||||
dataProvider = new MySQLDataProvider(getConfig());
|
||||
|
||||
if(getConfig().isConfigurationSection("default-playerdata"))
|
||||
dataProvider.getDataManager().loadDefaultData(getConfig().getConfigurationSection("default-playerdata"));
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.Indyuce.mmocore.manager.data.mysql;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import net.Indyuce.mmocore.manager.data.DataProvider;
|
||||
import net.Indyuce.mmocore.manager.data.GuildDataManager;
|
||||
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
@ -9,15 +11,20 @@ import net.mmogroup.mmolib.sql.MMODataSource;
|
||||
public class MySQLDataProvider extends MMODataSource implements DataProvider {
|
||||
private final MySQLPlayerDataManager playerManager = new MySQLPlayerDataManager(this);
|
||||
private final YAMLGuildDataManager guildManager = new YAMLGuildDataManager();
|
||||
|
||||
|
||||
public MySQLDataProvider(FileConfiguration config) {
|
||||
this.setup(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
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,experience INT(11) DEFAULT 0,class VARCHAR(20),"
|
||||
+ "guild VARCHAR(20),last_login LONG,attributes JSON,professions JSON,quests JSON,waypoints"
|
||||
+ "JSON,friends JSON,skills JSON,bound_skills JSON,class_info JSON,PRIMARY KEY (uuid));");
|
||||
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,"
|
||||
+ "experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG,"
|
||||
+ "attributes LONGTEXT,professions LONGTEXT,quests LONGTEXT,waypoints LONGTEXT,"
|
||||
+ "friends LONGTEXT,skills LONGTEXT,bound_skills LONGTEXT,class_info LONGTEXT,PRIMARY KEY (uuid));");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,7 +206,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
@Override
|
||||
public void removeFriend(UUID uuid) {
|
||||
friends.remove(uuid);
|
||||
new MySQLTableEditor(Table.PLAYERDATA, uuid).updateData("friends",
|
||||
new MySQLTableEditor(Table.PLAYERDATA, uuid).updateDataAsync("friends",
|
||||
friends.stream().map(friend -> friend.toString()).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,11 @@ public class MySQLTableEditor {
|
||||
}
|
||||
|
||||
public void updateData(String key, Object value) {
|
||||
((MySQLDataProvider) MMOCore.plugin.dataProvider).executeUpdate("INSERT INTO " + table + "(uuid, " + key
|
||||
+ ") VALUES('" + uuid + "', '" + value + "') ON DUPLICATE KEY UPDATE " + key + "='" + value + "';");
|
||||
}
|
||||
|
||||
public void updateDataAsync(String key, Object value) {
|
||||
try {
|
||||
((MySQLDataProvider) MMOCore.plugin.dataProvider).executeUpdateAsync("INSERT INTO " + table + "(uuid, " + key
|
||||
+ ") VALUES('" + uuid + "', '" + value + "') ON DUPLICATE KEY UPDATE " + key + "='" + value + "';").get();
|
||||
|
Loading…
Reference in New Issue
Block a user