Skip to content

Commit

Permalink
fix: error during saving process of questPlayer from newly created pr…
Browse files Browse the repository at this point in the history
…ofile
  • Loading branch information
AlessioGr committed May 5, 2024
1 parent 6ffafcb commit 44d2ab3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public void constructCommands() {
return;
}

main.getQuestPlayerManager().createQuestPlayer(player.getUniqueId(), newProfile, false);
main.getQuestPlayerManager().createQuestPlayer(player.getUniqueId(), newProfile, false, false);

main.sendMessage(context.getSender(),
main.getLanguageManager().getString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void saveSinglePlayerData(final Player player) {
if(!questPlayer.isFinishedLoadingGeneralData()){
main.getLogManager().info("Saving of PlayerData (Player UUID: %s, Player name: %s, Profile: %s) has been skipped, because PlayerData didn't even finish loading yet.",
questPlayer.getUniqueId().toString(),
questPlayer.getPlayer().getName(),
player.getName(),
questPlayer.getProfile()
);
return;
Expand Down Expand Up @@ -213,12 +213,18 @@ public final HashMap<UUID, List<QuestPlayer>> getQuestPlayersForUUIDs() {
return foundQuestPlayer;
}

public String createQuestPlayer(final UUID uuid, final String profile, final boolean setAsCurrentProfile) {
public String createQuestPlayer(final UUID uuid, final String profile, final boolean setAsCurrentProfile, final boolean doNotSetFinishedLoading) {
QuestPlayer questPlayer = getActiveQuestPlayer(uuid);

if (questPlayer == null || !questPlayer.getProfile().equalsIgnoreCase(profile)) {
questPlayer = new QuestPlayer(main, uuid, profile);

if(!doNotSetFinishedLoading){
questPlayer.setFinishedLoadingGeneralData(true);
questPlayer.setFinishedLoadingTags(true);
questPlayer.setCurrentlyLoading(false);
}



if(questPlayersAndUUIDs.containsKey(uuid)){
Expand Down Expand Up @@ -372,7 +378,7 @@ private void loadPlayerDataInternal(final @Nullable UUID playerUUID) {
String currentProfile = "default";
while (currentQuestPlayerProfile.next()) {
currentProfile = currentQuestPlayerProfile.getString("CurrentProfile");
createQuestPlayer(uuid, profile, currentProfile == null || profile.equals(currentProfile) || currentProfile.isBlank());
createQuestPlayer(uuid, profile, currentProfile == null || profile.equals(currentProfile) || currentProfile.isBlank(), true);
final QuestPlayer questPlayer = getQuestPlayer(uuid, profile);

final long questPoints = questPlayerDataResult.getLong("QuestPoints");
Expand Down

0 comments on commit 44d2ab3

Please sign in to comment.