forked from Upstream/mmocore
Fixed temp data loading
This commit is contained in:
parent
60127bcad7
commit
a3c78d5352
@ -4,7 +4,6 @@ import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.player.MMOPlayerData;
|
||||
import io.lumine.mythic.lib.player.cooldown.CooldownMap;
|
||||
import io.lumine.mythic.lib.player.skill.PassiveSkill;
|
||||
import net.Indyuce.mmocore.party.provided.Party;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
@ -31,6 +30,7 @@ import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||
import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import net.Indyuce.mmocore.party.provided.Party;
|
||||
import net.Indyuce.mmocore.player.Unlockable;
|
||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||
@ -125,25 +125,12 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
*/
|
||||
private boolean fullyLoaded = false;
|
||||
|
||||
/**
|
||||
* If the player data was loaded using temporary data.
|
||||
*/
|
||||
private final boolean usingTemporaryData;
|
||||
|
||||
public PlayerData(MMOPlayerData mmoData) {
|
||||
super(mmoData.getUniqueId());
|
||||
|
||||
this.mmoData = mmoData;
|
||||
questData = new PlayerQuests(this);
|
||||
playerStats = new PlayerStats(this);
|
||||
|
||||
// Load temporary data if necessary
|
||||
final @Nullable TemporaryPlayerData tempData = mmoData.getExternalData("mmocore", TemporaryPlayerData.class);
|
||||
if (usingTemporaryData = tempData != null) {
|
||||
mana = tempData.mana;
|
||||
stamina = tempData.stamina;
|
||||
stellium = tempData.stellium;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -190,7 +177,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
|
||||
|
||||
public int getPointSpent(SkillTree skillTree) {
|
||||
return pointSpent.getOrDefault(skillTree,0);
|
||||
return pointSpent.getOrDefault(skillTree, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +186,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
}
|
||||
|
||||
public void giveSkillTreePoints(String id, int val) {
|
||||
skillTreePoints.put(id, skillTreePoints.getOrDefault(id,0) + val);
|
||||
skillTreePoints.put(id, skillTreePoints.getOrDefault(id, 0) + val);
|
||||
}
|
||||
|
||||
public int countSkillTreePoints(SkillTree skillTree) {
|
||||
@ -296,7 +283,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
}
|
||||
|
||||
public int getNodeLevel(SkillTreeNode node) {
|
||||
return nodeLevels.getOrDefault(node,0);
|
||||
return nodeLevels.getOrDefault(node, 0);
|
||||
}
|
||||
|
||||
public void setNodeLevel(SkillTreeNode node, int nodeLevel) {
|
||||
@ -916,10 +903,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
this.fullyLoaded = true;
|
||||
}
|
||||
|
||||
public boolean hasUsedTemporaryData() {
|
||||
return usingTemporaryData;
|
||||
}
|
||||
|
||||
public boolean isCasting() {
|
||||
return skillCasting != null;
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
package net.Indyuce.mmocore.api.player;
|
||||
|
||||
public class TemporaryPlayerData {
|
||||
public final double mana, stamina, stellium;
|
||||
|
||||
public TemporaryPlayerData(PlayerData player) {
|
||||
this.mana = player.getMana();
|
||||
this.stamina = player.getStamina();
|
||||
this.stellium = player.getStellium();
|
||||
}
|
||||
}
|
@ -6,11 +6,11 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||
@ -21,8 +21,10 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -56,11 +58,9 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
MMOCore.sqlDebug("Loading data for: '" + data.getUniqueId() + "'...");
|
||||
|
||||
// Initialize custom resources
|
||||
if (!data.hasUsedTemporaryData()) {
|
||||
data.setMana(result.getFloat("mana"));
|
||||
data.setStellium(result.getFloat("stellium"));
|
||||
data.setStamina(result.getFloat("stamina"));
|
||||
}
|
||||
|
||||
data.setClassPoints(result.getInt("class_points"));
|
||||
data.setSkillPoints(result.getInt("skill_points"));
|
||||
|
@ -1,11 +1,10 @@
|
||||
package net.Indyuce.mmocore.manager.data.yaml;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||
import net.Indyuce.mmocore.manager.data.DataProvider;
|
||||
@ -17,7 +16,9 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -43,11 +44,9 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
if (config.contains("class"))
|
||||
data.setClass(MMOCore.plugin.classManager.get(config.getString("class")));
|
||||
|
||||
if (!data.hasUsedTemporaryData() && data.isOnline()) {
|
||||
data.setMana(config.contains("mana") ? config.getDouble("mana") : data.getStats().getStat("MAX_MANA"));
|
||||
data.setStamina(config.contains("stamina") ? config.getDouble("stamina") : data.getStats().getStat("MAX_STAMINA"));
|
||||
data.setStellium(config.contains("stellium") ? config.getDouble("stellium") : data.getStats().getStat("MAX_STELLIUM"));
|
||||
}
|
||||
|
||||
if (config.contains("guild")) {
|
||||
Guild guild = provider.getGuildManager().getGuild(config.getString("guild"));
|
||||
|
@ -4,7 +4,6 @@ package net.Indyuce.mmocore.listener;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.TemporaryPlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
|
||||
import net.Indyuce.mmocore.gui.api.PluginInventory;
|
||||
@ -74,7 +73,6 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler
|
||||
public void e(PlayerQuitEvent event) {
|
||||
PlayerData playerData = PlayerData.get(event.getPlayer());
|
||||
playerData.getMMOPlayerData().setExternalData("mmocore", new TemporaryPlayerData(playerData));
|
||||
MMOCore.plugin.dataProvider.getDataManager().unregisterSafe(playerData);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user