fixed quest objective doubling issue

This commit is contained in:
Jules 2021-11-01 19:42:41 +01:00
parent 4c3c3c9dfe
commit d54ca50451
5 changed files with 17 additions and 25 deletions

View File

@ -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();
} }

View File

@ -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);
} }
/** /**

View File

@ -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;

View File

@ -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());
}
} }

View File

@ -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());
}
} }