forked from Upstream/mmocore
Handling of unlockedItems on MySQLPlayerDataManager when loading/saving playerData.
This commit is contained in:
parent
1deed752f4
commit
713146d9dd
@ -1,9 +1,6 @@
|
||||
package net.Indyuce.mmocore.manager.data.mysql;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.*;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.sql.DataSynchronizer;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
@ -20,8 +17,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MMOCoreDataSynchronizer extends DataSynchronizer {
|
||||
@ -74,8 +70,11 @@ public class MMOCoreDataSynchronizer extends DataSynchronizer {
|
||||
}
|
||||
}
|
||||
data.setupSkillTree();
|
||||
|
||||
|
||||
Set<String> unlockedItems = new HashSet<>();
|
||||
JsonArray unlockedItemsArray = new JsonParser().parse(result.getString("unlocked_items")).getAsJsonArray();
|
||||
for (JsonElement item : unlockedItemsArray)
|
||||
unlockedItems.add(item.getAsString());
|
||||
data.setUnlockedItems(unlockedItems);
|
||||
if (!isEmpty(result.getString("guild"))) {
|
||||
Guild guild = MMOCore.plugin.dataProvider.getGuildManager().getGuild(result.getString("guild"));
|
||||
data.setGuild(guild.hasMember(data.getUniqueId()) ? guild : null);
|
||||
|
@ -21,6 +21,7 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
|
||||
"skill_tree_reallocation_points", "INT(11)",
|
||||
"skill_tree_points", "LONGTEXT",
|
||||
"skill_tree_levels", "LONGTEXT",
|
||||
"unlocked_items","LONGTEXT",
|
||||
"mana","FLOAT",
|
||||
"stamina","FLOAT",
|
||||
"stellium","FLOAT"};
|
||||
@ -56,6 +57,7 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
|
||||
"friends LONGTEXT," +
|
||||
"skills LONGTEXT," +
|
||||
"bound_skills LONGTEXT," +
|
||||
"unlocked_items LONGTEXT," +
|
||||
"class_info LONGTEXT," +
|
||||
"is_saved TINYINT," +
|
||||
"PRIMARY KEY (uuid));");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.manager.data.mysql;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
@ -63,6 +64,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
updater.addData("professions", data.getCollectionSkills().toJsonString());
|
||||
updater.addData("quests", data.getQuestData().toJsonString());
|
||||
updater.addData("class_info", createClassInfoData(data).toString());
|
||||
updater.addJSONArray("unlocked_items", data.getUnlockedItems());
|
||||
if (logout)
|
||||
updater.addData("is_saved", 1);
|
||||
|
||||
@ -88,7 +90,11 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
classinfo.addProperty("mana", info.getMana());
|
||||
classinfo.addProperty("stamina", info.getStamina());
|
||||
classinfo.addProperty("stellium", info.getStellium());
|
||||
|
||||
JsonArray array = new JsonArray();
|
||||
for (String unlockedItem : playerData.getUnlockedItems()) {
|
||||
array.add(unlockedItem);
|
||||
}
|
||||
classinfo.add("unlocked-items", array);
|
||||
JsonObject skillinfo = new JsonObject();
|
||||
for (String skill : info.getSkillKeys())
|
||||
skillinfo.addProperty(skill, info.getSkillLevel(skill));
|
||||
|
Loading…
Reference in New Issue
Block a user