Profile Sync Quest Data Crash Fix

This commit is contained in:
Kam committed 2026-03-11 21:42:27 -04:00
1 parent 5cf9b26a2e
commit 15749c8ad7
10 files changed
+179 -8

No files matched your search

@@ -2,6 +2,8 @@ package noppes.npcs.controllers;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.profile.Profile;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.ProfileClientConfig;
import kamkeel.npcs.network.packets.data.AchievementPacket;
import kamkeel.npcs.network.packets.data.ChatAlertPacket;
import net.minecraft.entity.player.EntityPlayer;
@@ -131,9 +133,17 @@ public class PlayerQuestController {
boolean finishedLocally = data.finishedQuests.containsKey(quest.id);
boolean completedShared = false;
boolean hasCooldownShared = false;
if (ConfigMain.ProfilesEnabled && quest.profileOptions.enableOptions) {
Profile profile = ProfileController.Instance.getProfile(player);
if (profile != null && profile.sharedQuestTimestamps.containsKey(quest.id)) {
if (quest.profileOptions.enableOptions) {
boolean hasSharedTimestamp = false;
if (ProfileController.Instance != null) {
if (ConfigMain.ProfilesEnabled) {
Profile profile = ProfileController.Instance.getProfile(player);
hasSharedTimestamp = profile != null && profile.sharedQuestTimestamps.containsKey(quest.id);
}
} else if (ClientCacheHandler.allowProfiles) {
hasSharedTimestamp = ProfileClientConfig.hasSharedQuest(quest.id);
}
if (hasSharedTimestamp) {
if (quest.profileOptions.completeControl == EnumProfileSync.Shared)
completedShared = true;
if (quest.profileOptions.cooldownControl == EnumProfileSync.Shared)
@@ -0,0 +1,34 @@
package noppes.npcs.controllers;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.profile.Profile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.config.ConfigMain;
import java.util.Map;
public class ProfileConfigSync {
public static NBTTagCompound writeToNBT(EntityPlayer player) {
NBTTagCompound compound = new NBTTagCompound();
if (!ConfigMain.ProfilesEnabled || ProfileController.Instance == null) {
return compound;
}
Profile profile = ProfileController.Instance.getProfile(player);
if (profile == null) {
return compound;
}
NBTTagList questList = new NBTTagList();
for (Map.Entry<Integer, Long> entry : profile.sharedQuestTimestamps.entrySet()) {
NBTTagCompound questEntry = new NBTTagCompound();
questEntry.setInteger("Quest", entry.getKey());
questEntry.setLong("Date", entry.getValue());
questList.appendTag(questEntry);
}
compound.setTag("SharedQuestTimestamps", questList);
return compound;
}
}
@@ -2,6 +2,8 @@ package noppes.npcs.controllers.data;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.profile.Profile;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.ProfileClientConfig;
import kamkeel.npcs.network.packets.data.QuestCompletionPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -176,13 +178,22 @@ public class Quest implements ICompatibilty, IQuest {
}
public long getTimeUntilRepeat(EntityPlayer player) {
if (ConfigMain.ProfilesEnabled && profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared) {
Profile profile = ProfileController.Instance.getProfile(player);
if (profile != null) {
Long questTime = profile.sharedQuestTimestamps.get(this.id);
if (questTime == null) return 0L;
if (profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared) {
Long questTime = null;
if (ProfileController.Instance != null) {
if (ConfigMain.ProfilesEnabled) {
Profile profile = ProfileController.Instance.getProfile(player);
if (profile != null) {
questTime = profile.sharedQuestTimestamps.get(this.id);
}
}
} else if (ClientCacheHandler.allowProfiles) {
questTime = ProfileClientConfig.getSharedQuestTimestamp(this.id);
}
if (questTime != null) {
return calculateRemainingCooldown(player, questTime);
}
return 0L;
}
IPlayerQuestData questData = PlayerData.get(player).getQuestData();
return getTimeUntilRepeatQuestData(player, questData);