From e429b15911a25d355dbafdf5cd820d1336bd5ee1 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Mon, 27 Jun 2022 14:21:50 +0000 Subject: [PATCH] Fixed exception thrown when invalid fairy ring codes are entered Fixed unhandled hairdresser button that lead to OOB exception Fixed oversight in ::loc that causes exceptions to be thrown in headless environments --- .../thefremenniktrials/SeersHouseListeners.kt | 1 - .../game/interaction/inter/FairyRingInterface.kt | 5 ++++- .../game/interaction/inter/HairDresserInterface.kt | 2 +- .../rs09/game/system/command/sets/MiscCommandSet.kt | 12 +++++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/thefremenniktrials/SeersHouseListeners.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/thefremenniktrials/SeersHouseListeners.kt index 847115c80..bc3ebac4c 100644 --- a/Server/src/main/kotlin/rs09/game/content/quest/members/thefremenniktrials/SeersHouseListeners.kt +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/thefremenniktrials/SeersHouseListeners.kt @@ -14,7 +14,6 @@ import core.game.world.update.flag.context.Animation import org.rs09.consts.Items import rs09.game.content.dialogue.DialogueFile import rs09.game.interaction.InteractionListener -import rs09.tools.stringtools.RED class SeersHouseListeners : InteractionListener { diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt index 4bc6945c7..db0ca8efb 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt @@ -108,7 +108,10 @@ class FairyRingInterface : InterfaceListener{ val ring2index = player.getAttribute("fr:ring2",0) val ring3index = player.getAttribute("fr:ring3",0) val code = "${RING_1[ring1index]}${RING_2[ring2index]}${RING_3[ring3index]}" - val ring: FairyRing? = FairyRing.valueOf(code.toUpperCase()) + val ring: FairyRing? = try { + FairyRing.valueOf(code.uppercase()) + } catch (e: Exception) { null } + var tile = ring?.tile if(ring == FairyRing.CIP){ sendDialogue(player, "The ring seems to reject you.") diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/HairDresserInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/HairDresserInterface.kt index ed7abf8a9..755f01796 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/HairDresserInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/HairDresserInterface.kt @@ -174,7 +174,7 @@ class HairDresserInterface : ComponentPlugin(){ when(button){ 199 -> player.setAttribute("beard-setting",false) 200 -> player.setAttribute("beard-setting",true) - 68,196 -> pay(player) + 68,196,274 -> pay(player) else -> when(component?.id){ 592 -> { //Female if(femaleColorButtonRange.contains(button)){ diff --git a/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt b/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt index 829e6f46a..f298c4bed 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/sets/MiscCommandSet.kt @@ -31,6 +31,7 @@ import rs09.game.system.command.CommandMapping import rs09.game.system.command.Privilege import rs09.game.world.repository.Repository import rs09.tools.stringtools.colorize +import java.awt.HeadlessException import java.awt.Toolkit import java.awt.datatransfer.StringSelection import java.util.* @@ -76,9 +77,14 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){ SystemLogger.logInfo("Viewport: " + l.getSceneX(player.playerFlags.lastSceneGraph) + "," + l.getSceneY(player.playerFlags.lastSceneGraph)) val loc = "Location.create(" + l.x + ", " + l.y + ", " + l.z + ")" SystemLogger.logInfo(loc + "; " + player.playerFlags.lastSceneGraph + ", " + l.localX + ", " + l.localY) - val stringSelection = StringSelection(loc) - val clpbrd = Toolkit.getDefaultToolkit().systemClipboard - clpbrd.setContents(stringSelection, null) + try { + val stringSelection = StringSelection(loc) + val clpbrd = Toolkit.getDefaultToolkit().systemClipboard + clpbrd.setContents(stringSelection, null) + notify(player, "Coordinates copied to clipboard.") + } catch (e: HeadlessException) { + reject(player, "NOTE: Paste will not be available due to remote server.") + } } /**