From 9a5f1e85e2d23085bbd17176a8655fc450800f5b Mon Sep 17 00:00:00 2001 From: Bonesy Date: Mon, 29 Jan 2024 09:47:20 +0000 Subject: [PATCH] Fixed text for quest cape removal Quest cape can now be retrieved from the wise old man if both inventory and bank are full when quests are implemented --- .../player/LoginValidationPlugin.java | 52 ++++++++++++++----- .../draynor/dialogue/WiseOldManDialogue.java | 27 ++++++++++ 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/Server/src/main/content/global/handlers/player/LoginValidationPlugin.java b/Server/src/main/content/global/handlers/player/LoginValidationPlugin.java index 4cf2dbbf3..642d33f07 100644 --- a/Server/src/main/content/global/handlers/player/LoginValidationPlugin.java +++ b/Server/src/main/content/global/handlers/player/LoginValidationPlugin.java @@ -1,19 +1,21 @@ package content.global.handlers.player; +import core.api.Container; import core.game.activity.ActivityManager; import core.game.node.entity.player.Player; import core.game.node.item.Item; import core.game.system.SystemManager; +import core.game.world.GameWorld; import core.plugin.Initializable; import core.plugin.Plugin; import core.plugin.PluginManifest; import core.plugin.PluginType; -import core.game.world.GameWorld; - -import static core.api.ContentAPIKt.setVarp; +import org.rs09.consts.Items; import java.util.concurrent.TimeUnit; +import static core.api.ContentAPIKt.*; + /** * Validates a player login. * @author Emperor @@ -27,7 +29,7 @@ public final class LoginValidationPlugin implements Plugin { /** * Represents the quest point items to remove. */ - private static final Item[] QUEST_ITEMS = new Item[] { new Item(9813), new Item(9814)}; + private static final Item[] QUEST_ITEMS = new Item[] { new Item(Items.QUEST_POINT_CAPE_9813), new Item(Items.QUEST_POINT_HOOD_9814)}; /** * Constructs a new {@Code LoginValidationPlugin} {@Code Object} @@ -78,19 +80,43 @@ public final class LoginValidationPlugin implements Plugin { * @param player the player. */ private static void checkQuestPointsItems(final Player player) { - if (!player.getQuestRepository().hasCompletedAll() && - (player.getEquipment().contains(9813, 1) || player.getEquipment().contains(9814, 1)) - ) { + if (!player.getQuestRepository().hasCompletedAll() && anyInEquipment(player, Items.QUEST_POINT_CAPE_9813, Items.QUEST_POINT_HOOD_9814)) { + String location1 = null; + String location2 = null; + int item1 = 0; + int item2 = 0; + int amt = 0; for (Item i : QUEST_ITEMS) { - if (player.getEquipment().remove(i)) { - player.getDialogueInterpreter().sendItemMessage(i, "As you no longer have completed all the quests, your " + i.getName() + " unequips itself to your " + (player.getInventory().freeSlots() < 1 ? "bank" : "inventory") + "!"); - if (player.getInventory().freeSlots() < 1) { - player.getBank().add(i); + if (removeItem(player, i, Container.EQUIPMENT)) { + amt++; + String location; + if (addItem(player, i.getId(), i.getAmount(), Container.INVENTORY)) { + location = "your inventory"; + } else if (addItem(player, i.getId(), i.getAmount(), Container.BANK)) { + location = "your bank"; } else { - player.getInventory().add(i); + location = "the Wise Old Man"; + if (i.getId() == Items.QUEST_POINT_CAPE_9813) { + setAttribute(player, "/save:reclaim-qp-cape", true); + } else { + setAttribute(player, "/save:reclaim-qp-hood", true); + } + } + if (amt == 1) { + item1 = i.getId(); + location1 = location; + } + if (amt == 2) { + item2 = i.getId(); + location2 = location; } } } + if (amt == 2) { + sendDoubleItemDialogue(player, item1, item2, "As you no longer have completed all the quests, your " + getItemName(item1) + " unequips itself to " + location1 + " and your " + getItemName(item2) + " unequips itself to " + location2 + "!"); + } else { + sendItemDialogue(player, item1, "As you no longer have completed all the quests, your " + getItemName(item1) + " unequips itself to " + location1 + "!"); + } } } -} +} \ No newline at end of file diff --git a/Server/src/main/content/region/misthalin/draynor/dialogue/WiseOldManDialogue.java b/Server/src/main/content/region/misthalin/draynor/dialogue/WiseOldManDialogue.java index 7c0635fd5..d6c82d58f 100644 --- a/Server/src/main/content/region/misthalin/draynor/dialogue/WiseOldManDialogue.java +++ b/Server/src/main/content/region/misthalin/draynor/dialogue/WiseOldManDialogue.java @@ -1,5 +1,6 @@ package content.region.misthalin.draynor.dialogue; +import core.api.Container; import core.game.dialogue.DialoguePlugin; import core.game.dialogue.FacialExpression; import core.game.node.entity.npc.NPC; @@ -7,6 +8,9 @@ import core.game.node.entity.player.Player; import core.game.node.entity.player.link.diary.DiaryType; import core.plugin.Initializable; import core.game.node.item.Item; +import org.rs09.consts.Items; + +import static core.api.ContentAPIKt.*; /** * Represents the dialogue plugin used for the wise old man. @@ -69,6 +73,29 @@ public final class WiseOldManDialogue extends DialoguePlugin { public boolean handle(int interfaceId, int buttonId) { switch (stage) { case 0: + if (getAttribute(player, "reclaim-qp-cape", false) || getAttribute(player, "reclaim-qp-hood", false)) { + if (getAttribute(player, "reclaim-qp-cape", false) && getAttribute(player, "reclaim-qp-hood", false)) { + npcl(FacialExpression.NEUTRAL, "I assume you're looking for your items? I've placed them " + (freeSlots(player) < 2 ? "at your feet." : "in your inventory.")); + removeAttribute(player, "reclaim-qp-cape"); + removeAttribute(player, "reclaim-qp-hood"); + addItemOrDrop(player, Items.QUEST_POINT_CAPE_9813, 1); + addItemOrDrop(player, Items.QUEST_POINT_HOOD_9814, 1); + stage = 505; + return true; + } else if (getAttribute(player, "reclaim-qp-cape", false)) { + npcl(FacialExpression.NEUTRAL, "I assume you're looking for your Quest Point Cape? I've placed it " + (freeSlots(player) < 1 ? "at your feet." : "in your inventory.")); + removeAttribute(player, "reclaim-qp-cape"); + addItemOrDrop(player, Items.QUEST_POINT_CAPE_9813, 1); + stage = 505; + return true; + } else { + npcl(FacialExpression.NEUTRAL, "I assume you're looking for your Quest Point Hood? I've placed it " + (freeSlots(player) < 1 ? "at your feet." : "in your inventory.")); + removeAttribute(player, "reclaim-qp-hood"); + addItemOrDrop(player, Items.QUEST_POINT_HOOD_9814, 1); + stage = 505; + return true; + } + } if (player.getQuestRepository().hasCompletedAll()) { options("Quest Point Cape.", "Something else."); stage = 500;