From 255fc9eca6cf3dd34a8ec04d011a961e7cf34df3 Mon Sep 17 00:00:00 2001 From: Player Name Date: Wed, 2 Aug 2023 07:39:45 +0000 Subject: [PATCH] Fixed Teleport to House to teleport the player inside the house, rather than outside the entrance portal Removed HouseTeleportPlugin.java deadcode --- .../item/HouseTeleTabOptionListener.kt | 9 ++-- .../skill/construction/HouseManager.java | 22 +++++++- .../magic/modern/HouseTeleportPlugin.java | 54 ------------------- .../skill/magic/modern/ModernListeners.kt | 10 ++-- 4 files changed, 32 insertions(+), 63 deletions(-) delete mode 100644 Server/src/main/content/global/skill/magic/modern/HouseTeleportPlugin.java diff --git a/Server/src/main/content/global/handlers/item/HouseTeleTabOptionListener.kt b/Server/src/main/content/global/handlers/item/HouseTeleTabOptionListener.kt index 12388a8dd..61ac1b029 100644 --- a/Server/src/main/content/global/handlers/item/HouseTeleTabOptionListener.kt +++ b/Server/src/main/content/global/handlers/item/HouseTeleTabOptionListener.kt @@ -10,19 +10,22 @@ class HouseTeleTabOptionListener : InteractionListener { override fun defineListeners() { val homeTabID = 8013 on(homeTabID, IntType.ITEM, "break") {player, node -> - var location = player.houseManager.location.exitLocation - if (location == null) { + var hasHouse = player.houseManager.location.exitLocation != null + if (!hasHouse) { sendMessage( player, "You must have a house to teleport to before attempting that.") return@on false } closeInterface(player) lock(player, 5) if (inInventory(player, node.id)) { + player.houseManager.preEnter(player, false) + val location = player.houseManager.getEnterLocation() if (teleport(player, location, TeleportManager.TeleportType.TELETABS)) { removeItem(player, Item(node.id, 1)) + player.houseManager.postEnter(player, false) } } return@on true } } -} \ No newline at end of file +} diff --git a/Server/src/main/content/global/skill/construction/HouseManager.java b/Server/src/main/content/global/skill/construction/HouseManager.java index 0c7f3f406..3a93bbf06 100644 --- a/Server/src/main/content/global/skill/construction/HouseManager.java +++ b/Server/src/main/content/global/skill/construction/HouseManager.java @@ -185,11 +185,11 @@ public final class HouseManager { } /** - * Enter's the player's house. + * Prepares for entering the player's house. * @param player * @param buildingMode */ - public void enter(final Player player, boolean buildingMode) { + public void preEnter(final Player player, boolean buildingMode) { if (this.buildingMode != buildingMode || !isLoaded()) { this.buildingMode = buildingMode; construct(); @@ -197,8 +197,26 @@ public final class HouseManager { player.setAttribute("poh_entry", HouseManager.this); player.lock(1); player.sendMessage("House location: " + houseRegion.getBaseLocation() + ", entry: " + getEnterLocation()); + } + + /** + * Enters the player's house and plays the ding sound. + * @param player + * @param buildingMode + */ + public void enter(final Player player, boolean buildingMode) { + preEnter(player, buildingMode); player.getProperties().setTeleportLocation(getEnterLocation()); openLoadInterface(player); + postEnter(player, buildingMode); + } + + /** + * Performs post-house-enter administration. + * @param player + * @param buildingMode + */ + public void postEnter(final Player player, boolean buildingMode) { checkForAndSpawnServant(player); updateVarbits(player, buildingMode); unlockMusicTrack(player); diff --git a/Server/src/main/content/global/skill/magic/modern/HouseTeleportPlugin.java b/Server/src/main/content/global/skill/magic/modern/HouseTeleportPlugin.java deleted file mode 100644 index 37bce8a90..000000000 --- a/Server/src/main/content/global/skill/magic/modern/HouseTeleportPlugin.java +++ /dev/null @@ -1,54 +0,0 @@ -package content.global.skill.magic.modern; - -import core.game.node.Node; -import core.game.node.entity.Entity; -import core.game.node.entity.combat.spell.SpellType; -import core.game.node.entity.combat.spell.MagicSpell; -import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.SpellBookManager.SpellBook; -import core.game.node.entity.player.link.TeleportManager.TeleportType; -import core.game.node.item.Item; -import core.game.world.GameWorld; -import core.game.world.map.Location; -import core.plugin.Plugin; -import core.tools.RandomFunction; - -/** - * - * For house teleportation. - * - * @author Jamix77 - * - */ -public class HouseTeleportPlugin extends MagicSpell { - - public HouseTeleportPlugin(final int level, final double experience, final Item... items) { - super(SpellBook.MODERN, level, experience, null, null, null, items); - } - - @Override - public Plugin newInstance(SpellType arg) throws Throwable { - - return this; - } - - @Override - public boolean cast(Entity entity, Node target) { - if (((Player)entity).getHouseManager().getLocation().getExitLocation() == null) { - ((Player)entity).sendMessage("You must have a house to teleport to before attempting that."); - return false; - } - Location location = ((Player)entity).getHouseManager().getLocation().getExitLocation(); - if (entity.getLocks().isTeleportLocked() || !super.meetsRequirements(entity, true, false)) { - return false; - } - if (entity.getTeleporter().send(location.transform(0, RandomFunction.random(3), 0), TeleportType.NORMAL)) { - entity.setAttribute("teleport:items", super.runes); - entity.setAttribute("magic-delay", GameWorld.getTicks() + 5); - ((Player) entity).getInventory().remove(super.runes); - return true; - } - return false; - } - -} diff --git a/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt b/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt index 4277651a9..cd5bced35 100644 --- a/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt +++ b/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt @@ -294,15 +294,17 @@ class ModernListeners : SpellListener("modern"){ player.sendMessage("A magical force prevents you from teleporting.") return } - val loc = player.houseManager.location.exitLocation - if(loc == null){ - player.sendMessage("You do not have a house whose portal you can teleport to.") + val hasHouse = player.houseManager.location.exitLocation != null + if(!hasHouse){ + player.sendMessage("You do not have a house you can teleport to.") return } + player.houseManager.preEnter(player, false) val teleType = TeleportManager.TeleportType.NORMAL - + val loc = player.houseManager.getEnterLocation() player.teleporter.send(loc, teleType) + player.houseManager.postEnter(player, false) //this actually runs when the teleport is SUBMITTED rather than EXECUTED, but this is fine removeRunes(player) addXP(player,30.0) setDelay(player,true)