mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
fixed quest objective doubling issue
This commit is contained in:
parent
4c3c3c9dfe
commit
d54ca50451
@ -130,6 +130,12 @@ public class PlayerData extends OfflinePlayerData implements Closable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
||||||
|
// Remove from party
|
||||||
|
if (hasParty())
|
||||||
|
getParty().removeMember(this);
|
||||||
|
|
||||||
|
// Close quest data
|
||||||
questData.close();
|
questData.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,10 +67,7 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void e(PlayerQuitEvent event) {
|
public void e(PlayerQuitEvent event) {
|
||||||
PlayerData playerData = PlayerData.get(event.getPlayer());
|
PlayerData playerData = PlayerData.get(event.getPlayer());
|
||||||
if (playerData.hasParty())
|
MMOCore.plugin.dataProvider.getDataManager().unregisterSafe(playerData);
|
||||||
playerData.getParty().removeMember(playerData);
|
|
||||||
|
|
||||||
MMOCore.plugin.dataProvider.getDataManager().remove(playerData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,12 +35,18 @@ public abstract class PlayerDataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the data map from a certain key
|
* Safely unregisters the player data from the map.
|
||||||
|
* This saves the player data either through SQL or YAML,
|
||||||
|
* then closes the player data and clears it from the data map.
|
||||||
*
|
*
|
||||||
* @param uuid Player UUID to clear
|
* @param playerData PLayer data to unregister
|
||||||
*/
|
*/
|
||||||
protected void unregisterData(UUID uuid) {
|
public void unregisterSafe(PlayerData playerData) {
|
||||||
data.remove(uuid);
|
if (playerData.isFullyLoaded())
|
||||||
|
saveData(playerData);
|
||||||
|
|
||||||
|
playerData.close();
|
||||||
|
this.data.remove(playerData.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,8 +125,6 @@ public abstract class PlayerDataManager {
|
|||||||
*/
|
*/
|
||||||
public abstract void saveData(PlayerData data);
|
public abstract void saveData(PlayerData data);
|
||||||
|
|
||||||
public abstract void remove(PlayerData data);
|
|
||||||
|
|
||||||
public static class DefaultPlayerData {
|
public static class DefaultPlayerData {
|
||||||
private final int level, classPoints, skillPoints, attributePoints, attrReallocPoints;
|
private final int level, classPoints, skillPoints, attributePoints, attrReallocPoints;
|
||||||
|
|
||||||
|
@ -235,13 +235,4 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
|||||||
return lastLogin;
|
return lastLogin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(PlayerData data) {
|
|
||||||
if (data.isFullyLoaded())
|
|
||||||
saveData(data);
|
|
||||||
|
|
||||||
data.close();
|
|
||||||
unregisterData(data.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -127,10 +127,4 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
|||||||
public OfflinePlayerData getOffline(UUID uuid) {
|
public OfflinePlayerData getOffline(UUID uuid) {
|
||||||
return isLoaded(uuid) ? get(uuid) : new YAMLOfflinePlayerData(uuid);
|
return isLoaded(uuid) ? get(uuid) : new YAMLOfflinePlayerData(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(PlayerData data) {
|
|
||||||
data.close();
|
|
||||||
unregisterData(data.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user