diff --git a/Server/src/main/content/global/skill/construction/npc/HouseServantDialogue.java b/Server/src/main/content/global/skill/construction/npc/HouseServantDialogue.java index eb20f613d..152a049d0 100644 --- a/Server/src/main/content/global/skill/construction/npc/HouseServantDialogue.java +++ b/Server/src/main/content/global/skill/construction/npc/HouseServantDialogue.java @@ -16,6 +16,7 @@ import core.game.node.item.Item; import core.game.system.task.Pulse; import core.game.world.GameWorld; import core.game.world.map.Location; +import core.game.world.map.Region; import core.game.world.map.path.Pathfinder; import content.global.handlers.iface.SawmillPlankInterface.Plank; import org.rs09.consts.Items; @@ -27,16 +28,15 @@ import org.rs09.consts.Items; * @version 0.98 (TODO: Missing a few dialogues) */ public class HouseServantDialogue extends DialoguePlugin { + /** + * If using the sawmill or unnoting planks. + */ + private boolean fetchRun; /** - * If using the sawmill. + * The logs or noted planks. */ - private boolean sawmill; - - /** - * The logs - */ - private Item logs; + private Item fetchItem; /** * Constructs a new {@code ServantDialogue} {@code Object}. @@ -66,8 +66,8 @@ public class HouseServantDialogue extends DialoguePlugin { HouseManager manager = player.getHouseManager(); boolean inHouse = manager.isInHouse(player); if (args.length > 1) { //Parse options from our "use-with" handler - sawmill = (boolean) args[1]; - logs = (Item) args[2]; + fetchRun = (boolean) args[1]; + fetchItem = (Item) args[2]; } if (player.getIronmanManager().checkRestriction(IronmanMode.ULTIMATE)) { player.sendMessage("Ultimate Ironmen cannot hire butlers."); @@ -95,7 +95,7 @@ public class HouseServantDialogue extends DialoguePlugin { } if (inHouse) { follow(player, servant); - if (sawmill) { + if (fetchRun) { interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.HALF_GUILTY : null, "Very well, I will take these logs to the mill and", "have them converted into planks."); stage = 110; return true; @@ -197,7 +197,7 @@ public class HouseServantDialogue extends DialoguePlugin { return true; } end(); - sawmillRun(player, (Item) servant.getAttribute("con:lastfetch")); + fetchRun(player, (Item) servant.getAttribute("con:lastfetch")); } break; case 2: @@ -381,7 +381,7 @@ public class HouseServantDialogue extends DialoguePlugin { break; case 110: end(); - sawmillRun(player, logs); + fetchRun(player, fetchItem); break; case 150: if (servant.getItem()== null) { @@ -423,10 +423,10 @@ public class HouseServantDialogue extends DialoguePlugin { * @param item * @return true or false if they have the requirements to use the servant. */ - private boolean prereqs(final Player player, final Item item, boolean sawmill) { + private boolean prereqs(final Player player, final Item item, boolean fetchRun) { HouseManager manager = player.getHouseManager(); Servant servant = manager.getServant(); - if (!sawmill && player.getInventory().freeSlots() < 1) { + if (!fetchRun && player.getInventory().freeSlots() < 1) { interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.HALF_GUILTY : null, "You don't have any space in your inventory."); stage = 100; return false; @@ -449,18 +449,19 @@ public class HouseServantDialogue extends DialoguePlugin { } /** - * Goes to the sawmill. + * Goes to the sawmill or bank. * @param player * @param item */ - private void sawmillRun(final Player player, final Item item) { + private void fetchRun(final Player player, final Item item) { HouseManager manager = player.getHouseManager(); final Servant servant = manager.getServant(); final ServantType type = manager.getServant().getType(); + final boolean sawmill = item.isNoted(); if (servant == null || item == null || !prereqs(player, item, true)) { return; } - if (type == ServantType.MAID || type == ServantType.RICK) { + if (sawmill && (type == ServantType.MAID || type == ServantType.RICK)) { interpreter.sendDialogues(servant, servant.getId() == 4243 ? FacialExpression.HALF_GUILTY : null, "I am unable to take logs to the sawmill."); return; } @@ -482,12 +483,13 @@ public class HouseServantDialogue extends DialoguePlugin { if (player.getInventory().remove(new Item(item.getId(), amt)) && player.getInventory().remove(new Item(Items.COINS_995, amt * plank.getPrice()))) { servant.setInvisible(true); servant.getLocks().lockMovement(100); + int finalAmt = amt; GameWorld.getPulser().submit(new Pulse((int) (type.getTimer() / 0.6)){ @Override public boolean pulse() { servant.setInvisible(false); servant.getLocks().unlockMovement(); - manager.getServant().setItem(new Item(plank.getPlank().getId(), amt)); + manager.getServant().setItem(new Item(plank.getPlank().getId(), finalAmt)); interpreter.open(servant.getId(), servant); servant.setAttribute("con:lastfetch", new Item(item.getId(), 1)); servant.setAttribute("con:lastfetchtype", "sawmill"); @@ -525,9 +527,6 @@ public class HouseServantDialogue extends DialoguePlugin { GameWorld.getPulser().submit(new Pulse((int) (type.getTimer() / 0.6)) { @Override public boolean pulse() { - if (player == null) { - return true; - } Region pr = player.getViewport().getRegion(); Region hr = player.getHouseManager().getHouseRegion(); Region dr = player.getHouseManager().getDungeonRegion(); diff --git a/Server/src/main/content/global/skill/construction/npc/HouseServantPlugin.java b/Server/src/main/content/global/skill/construction/npc/HouseServantPlugin.java index 68af6493e..2a2542eaa 100644 --- a/Server/src/main/content/global/skill/construction/npc/HouseServantPlugin.java +++ b/Server/src/main/content/global/skill/construction/npc/HouseServantPlugin.java @@ -6,6 +6,8 @@ import core.game.interaction.UseWithHandler; import core.plugin.Initializable; import core.plugin.Plugin; import core.plugin.ClassScanner; +import org.rs09.consts.Items; +import org.rs09.consts.NPCs; /** * Handles interaction with the house servant. @@ -19,11 +21,13 @@ import core.plugin.ClassScanner; */ @Initializable public class HouseServantPlugin extends UseWithHandler { - /** * The item IDS to use. */ - final static int[] IDS = { 1511, 1521, 6333, 6332 }; + final static int[] IDS = { + Items.LOGS_1511, Items.OAK_LOGS_1521, Items.TEAK_LOGS_6333, Items.MAHOGANY_LOGS_6332, + Items.PLANK_961, Items.OAK_PLANK_8779, Items.TEAK_PLANK_8781, Items.MAHOGANY_PLANK_8783 //noted planks + }; /** * Constructs a new {@code HouseServantPlugin} {@code Object}. @@ -34,11 +38,11 @@ public class HouseServantPlugin extends UseWithHandler { @Override public Plugin newInstance(Object arg) throws Throwable { - addHandler(4235, NPC_TYPE, this); - addHandler(4237, NPC_TYPE, this); - addHandler(4239, NPC_TYPE, this); - addHandler(4241, NPC_TYPE, this); - addHandler(4243, NPC_TYPE, this); + addHandler(NPCs.RICK_4235, NPC_TYPE, this); + addHandler(NPCs.MAID_4237, NPC_TYPE, this); + addHandler(NPCs.COOK_4239, NPC_TYPE, this); + addHandler(NPCs.BUTLER_4241, NPC_TYPE, this); + addHandler(NPCs.DEMON_BUTLER_4243, NPC_TYPE, this); ClassScanner.definePlugin(new HouseServantDialogue()); return this; } @@ -51,5 +55,4 @@ public class HouseServantPlugin extends UseWithHandler { event.getPlayer().getDialogueInterpreter().open(event.getUsedWith().asNpc().getId(), event.getUsedWith().asNpc(), true, event.getUsedItem()); return true; } - -} \ No newline at end of file +}