forked from Upstream/mmocore
Fixed /mmocore admin exportdata
This commit is contained in:
parent
c94795fc89
commit
2a4e509a8b
@ -374,6 +374,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
||||||
|
health = getPlayer().getHealth();
|
||||||
|
|
||||||
// Close combat handler
|
// Close combat handler
|
||||||
combat.close();
|
combat.close();
|
||||||
|
|
||||||
|
@ -45,13 +45,13 @@ public abstract class PlayerDataManager {
|
|||||||
*/
|
*/
|
||||||
public void unregisterSafe(PlayerData playerData) {
|
public void unregisterSafe(PlayerData playerData) {
|
||||||
|
|
||||||
// Save data async if required
|
|
||||||
if (playerData.isFullyLoaded())
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> saveData(playerData, true));
|
|
||||||
|
|
||||||
// Close and unregister data instantly if no error occured
|
// Close and unregister data instantly if no error occured
|
||||||
playerData.close();
|
playerData.close();
|
||||||
data.remove(playerData.getUniqueId());
|
data.remove(playerData.getUniqueId());
|
||||||
|
|
||||||
|
// Save data async if required
|
||||||
|
if (playerData.isFullyLoaded())
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> saveData(playerData, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,13 +122,17 @@ public class MMOCoreDataSynchronizer extends DataSynchronizer {
|
|||||||
* These should be loaded after to make sure that the
|
* These should be loaded after to make sure that the
|
||||||
* MAX_MANA, MAX_STAMINA & MAX_STELLIUM stats are already loaded.
|
* MAX_MANA, MAX_STAMINA & MAX_STELLIUM stats are already loaded.
|
||||||
*/
|
*/
|
||||||
|
data.setHealth(result.getDouble("health"));
|
||||||
data.setMana(result.getDouble("mana"));
|
data.setMana(result.getDouble("mana"));
|
||||||
data.setStamina(result.getDouble("stamina"));
|
data.setStamina(result.getDouble("stamina"));
|
||||||
data.setStellium(result.getDouble("stellium"));
|
data.setStellium(result.getDouble("stellium"));
|
||||||
double health = result.getDouble("health");
|
|
||||||
health = health == 0 ? data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() : health;
|
if (data.isOnline()) {
|
||||||
health = Math.max(Math.min(health, data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()), 0);
|
double health = data.getHealth();
|
||||||
data.getPlayer().setHealth(health);
|
health = health == 0 ? data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() : health;
|
||||||
|
health = Math.max(Math.min(health, data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()), 0);
|
||||||
|
data.getPlayer().setHealth(health);
|
||||||
|
}
|
||||||
|
|
||||||
UtilityMethods.debug(MMOCore.plugin, "SQL", String.format("{ class: %s, level: %d }", data.getProfess().getId(), data.getLevel()));
|
UtilityMethods.debug(MMOCore.plugin, "SQL", String.format("{ class: %s, level: %d }", data.getProfess().getId(), data.getLevel()));
|
||||||
data.setFullyLoaded();
|
data.setFullyLoaded();
|
||||||
|
@ -120,13 +120,17 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
|||||||
* These should be loaded after to make sure that the
|
* These should be loaded after to make sure that the
|
||||||
* MAX_MANA, MAX_STAMINA & MAX_STELLIUM stats are already loaded.
|
* MAX_MANA, MAX_STAMINA & MAX_STELLIUM stats are already loaded.
|
||||||
*/
|
*/
|
||||||
|
data.setHealth(config.getDouble("health"));
|
||||||
data.setMana(config.contains("mana") ? config.getDouble("mana") : data.getStats().getStat("MAX_MANA"));
|
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.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"));
|
data.setStellium(config.contains("stellium") ? config.getDouble("stellium") : data.getStats().getStat("MAX_STELLIUM"));
|
||||||
double health = config.contains("health") ? config.getDouble("health") : data.getStats().getStat("MAX_HEALTH");
|
|
||||||
health = health == 0 ? 20 : health;
|
if (data.isOnline()) {
|
||||||
health = Math.min(health, data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
double health = config.contains("health") ? config.getDouble("health") : data.getStats().getStat("MAX_HEALTH");
|
||||||
data.getPlayer().setHealth(health);
|
health = health == 0 ? 20 : health;
|
||||||
|
health = Math.min(health, data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
|
data.getPlayer().setHealth(health);
|
||||||
|
}
|
||||||
|
|
||||||
data.setFullyLoaded();
|
data.setFullyLoaded();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user