mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 09:34:46 +00:00
Made tracked quest a private field, clearer intent in code for bug fixing.
This commit is contained in:
1 parent
f5bae9099d
commit
e0360f9a6e
6 files changed
+69
-67
No files matched your search
@@ -88,7 +88,7 @@ public class PacketHandlerServer{
|
||||
EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer)));
|
||||
return;
|
||||
} else if (type == EnumPacketServer.QuestLogToServer) {
|
||||
updateQuestLogData(buffer, player);
|
||||
NoppesUtilPlayer.updateQuestLogData(buffer, player);
|
||||
return;
|
||||
} else if(type == EnumPacketServer.DimensionsGet){
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
@@ -157,55 +157,6 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
|
||||
private Quest getQuestFromString(String string) {
|
||||
if (string != null && string.contains(":")) {
|
||||
String[] splitString = string.split(":");
|
||||
if(splitString.length < 2){
|
||||
return null;
|
||||
}
|
||||
String categoryName = splitString[0];
|
||||
String questName = splitString[1];
|
||||
|
||||
for (QuestCategory category : QuestController.instance.categories.values()) {
|
||||
if (category.title.equals(categoryName)) {
|
||||
for (Quest quest : category.quests.values()) {
|
||||
if (quest.title.equals(questName)) {
|
||||
return quest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
HashMap<String,String> questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
|
||||
for (Map.Entry<String,String> entry : questAlerts.entrySet()) {
|
||||
Quest quest = this.getQuestFromString(entry.getKey());
|
||||
if (quest != null) {
|
||||
playerData.questData.activeQuests.get(quest.id).sendAlerts = Boolean.parseBoolean(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
String trackedQuestString = Server.readString(buffer);
|
||||
Quest prevTracked = (Quest) playerData.questData.trackedQuest;
|
||||
Quest trackedQuest = this.getQuestFromString(trackedQuestString);
|
||||
if (trackedQuest != null) {
|
||||
playerData.questData.trackedQuest = trackedQuest;
|
||||
NoppesUtilPlayer.sendTrackedQuestData(player, trackedQuest);
|
||||
if (prevTracked != playerData.questData.trackedQuest) {
|
||||
NoppesUtilPlayer.sendTrackedQuestData(player, (Quest) playerData.questData.trackedQuest);
|
||||
}
|
||||
} else {
|
||||
playerData.questData.trackedQuest = null;
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.OVERLAY_QUEST_TRACKING);
|
||||
}
|
||||
}
|
||||
|
||||
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
NoppesUtilServer.isGUIOpen(buffer, player);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user