mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-01 01:23:25 +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);
|
new Metrics(this);
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
if (getConfig().contains("mysql") && getConfig().getBoolean("mysql.enabled"))
|
if (getConfig().isConfigurationSection("mysql") && getConfig().getBoolean("mysql.enabled"))
|
||||||
dataProvider = new MySQLDataProvider();
|
dataProvider = new MySQLDataProvider(getConfig());
|
||||||
|
|
||||||
if(getConfig().isConfigurationSection("default-playerdata"))
|
if(getConfig().isConfigurationSection("default-playerdata"))
|
||||||
dataProvider.getDataManager().loadDefaultData(getConfig().getConfigurationSection("default-playerdata"));
|
dataProvider.getDataManager().loadDefaultData(getConfig().getConfigurationSection("default-playerdata"));
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.Indyuce.mmocore.manager.data.mysql;
|
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.DataProvider;
|
||||||
import net.Indyuce.mmocore.manager.data.GuildDataManager;
|
import net.Indyuce.mmocore.manager.data.GuildDataManager;
|
||||||
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||||
@ -10,14 +12,19 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
|
|||||||
private final MySQLPlayerDataManager playerManager = new MySQLPlayerDataManager(this);
|
private final MySQLPlayerDataManager playerManager = new MySQLPlayerDataManager(this);
|
||||||
private final YAMLGuildDataManager guildManager = new YAMLGuildDataManager();
|
private final YAMLGuildDataManager guildManager = new YAMLGuildDataManager();
|
||||||
|
|
||||||
|
public MySQLDataProvider(FileConfiguration config) {
|
||||||
|
this.setup(config);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
executeUpdateAsync("CREATE TABLE IF NOT EXISTS mmocore_playerdata"
|
executeUpdateAsync(
|
||||||
+ "(uuid VARCHAR(36),class_points INT(11) DEFAULT 0,skill_points INT(11)"
|
"CREATE TABLE IF NOT EXISTS mmocore_playerdata(uuid VARCHAR(36),class_points "
|
||||||
+ "DEFAULT 0,attribute_points INT(11) DEFAULT 0,attribute_realloc_points INT(11)"
|
+ "INT(11) DEFAULT 0,skill_points INT(11) DEFAULT 0,attribute_points INT(11) "
|
||||||
+ "DEFAULT 0,level INT(11) DEFAULT 1,experience INT(11) DEFAULT 0,class VARCHAR(20),"
|
+ "DEFAULT 0,attribute_realloc_points INT(11) DEFAULT 0,level INT(11) DEFAULT 1,"
|
||||||
+ "guild VARCHAR(20),last_login LONG,attributes JSON,professions JSON,quests JSON,waypoints"
|
+ "experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG,"
|
||||||
+ "JSON,friends JSON,skills JSON,bound_skills JSON,class_info JSON,PRIMARY KEY (uuid));");
|
+ "attributes LONGTEXT,professions LONGTEXT,quests LONGTEXT,waypoints LONGTEXT,"
|
||||||
|
+ "friends LONGTEXT,skills LONGTEXT,bound_skills LONGTEXT,class_info LONGTEXT,PRIMARY KEY (uuid));");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -206,7 +206,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
|||||||
@Override
|
@Override
|
||||||
public void removeFriend(UUID uuid) {
|
public void removeFriend(UUID uuid) {
|
||||||
friends.remove(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()));
|
friends.stream().map(friend -> friend.toString()).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,11 @@ public class MySQLTableEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateData(String key, Object value) {
|
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 {
|
try {
|
||||||
((MySQLDataProvider) MMOCore.plugin.dataProvider).executeUpdateAsync("INSERT INTO " + table + "(uuid, " + key
|
((MySQLDataProvider) MMOCore.plugin.dataProvider).executeUpdateAsync("INSERT INTO " + table + "(uuid, " + key
|
||||||
+ ") VALUES('" + uuid + "', '" + value + "') ON DUPLICATE KEY UPDATE " + key + "='" + value + "';").get();
|
+ ") VALUES('" + uuid + "', '" + value + "') ON DUPLICATE KEY UPDATE " + key + "='" + value + "';").get();
|
||||||
|
Loading…
Reference in New Issue
Block a user