From 6856d75d88b6722eed60f205ac679f874a020892 Mon Sep 17 00:00:00 2001 From: Oven Bread Date: Sat, 16 Mar 2024 12:10:19 +0000 Subject: [PATCH] Corrected contents of Varrock newspaper and refactored related code --- .../global/handlers/item/NewsPaperPlugin.java | 45 ----------- .../global/handlers/item/NewspaperListener.kt | 80 +++++++++++++++++++ 2 files changed, 80 insertions(+), 45 deletions(-) delete mode 100644 Server/src/main/content/global/handlers/item/NewsPaperPlugin.java create mode 100644 Server/src/main/content/global/handlers/item/NewspaperListener.kt diff --git a/Server/src/main/content/global/handlers/item/NewsPaperPlugin.java b/Server/src/main/content/global/handlers/item/NewsPaperPlugin.java deleted file mode 100644 index 0e28fcabe..000000000 --- a/Server/src/main/content/global/handlers/item/NewsPaperPlugin.java +++ /dev/null @@ -1,45 +0,0 @@ -package content.global.handlers.item; - -import core.cache.def.impl.ItemDefinition; -import core.game.component.Component; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.node.item.Item; -import core.plugin.Initializable; -import core.plugin.Plugin; - -/** - * Handles the news paper. - * @author 'Vexia - */ -@Initializable -public class NewsPaperPlugin extends OptionHandler { - - @Override - public boolean handle(Player player, Node node, String option) { - int id = ((Item) node).getId(); - if (id == 11169) { - player.getInterfaceManager().open(new Component(530)); - final String page1 = "Varrock gets Makeover! The city of Varrock is the latest recipient of a complete makeover. When interviewed, King Roald said, 'In order to keep visitors coming to see the sights of our beautiful capital, we felt that tidying-up the city would be more effective than just issuing a decree - make sure you visit the new museum while you are here.'"; - final String page2 = "Obituaries Goblin-Died Giant Rat-Died Unicorn-Died Varrock Guard-Died Varrock Guard-Died Bear-Died. Classifieds."; - player.getPacketDispatch().sendString(page1, 530, 7); - player.getPacketDispatch().sendString(page2, 530, 8); - return true; - } else - player.getDialogueInterpreter().open(70099, "Come to the Al Kharid Market place! Highquality", "produce at low, low prices! Show this flyer to a", "merchant for money off your next purchase,", "courtesy of Ali Morrisane!"); - return true; - } - - @Override - public boolean isWalk() { - return false; - } - - @Override - public Plugin newInstance(Object arg) throws Throwable { - ItemDefinition.forId(7922).getHandlers().put("option:read", this); - ItemDefinition.forId(11169).getHandlers().put("option:read", this); - return this; - } -} diff --git a/Server/src/main/content/global/handlers/item/NewspaperListener.kt b/Server/src/main/content/global/handlers/item/NewspaperListener.kt new file mode 100644 index 000000000..bb32667c3 --- /dev/null +++ b/Server/src/main/content/global/handlers/item/NewspaperListener.kt @@ -0,0 +1,80 @@ +package content.global.handlers.item + +import core.api.* +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import org.rs09.consts.Items + +/** + * Interaction and interface listener for the Varrock newspaper. + * This handles component(530) globally. + * youtu.be/ePVNOiSzOS4 + */ +class NewspaperListener : InteractionListener { + companion object { + + const val NEWSPAPER_INTERFACE_530 = 530 /* Should be in org.rs09.consts.Components but isn't. */ + + val leftPage = "" + + "Varrock gets " + + "Makeover" + + "

" + + "The city of Varrock " + + "is the latest recipient " + + "of a complete " + + "makeover. When " + + "interviewed, King " + + "Roald said, 'In order " + + "to keep visitors " + + "coming to see the " + + "sights of our " + + "beautiful capital, we " + + "felt that tidying-up " + + "the city would be " + + "more effective than " + + "just issuing a decree " + + "- make sure you visit " + + "the new museum " + + "while you are here.'" + + val rightPage = "" + + "Obituaries " + + "

" + + "Goblin-Died
" + + "Giant Rat-Died
" + + "Unicorn-Died
" + + "Varrock Guard-Died
" + + "Varrock Guard-Died
" + + "Varrock Guard-Died
" + + "Bear-Died." + + "

" + + "Classifieds" + + "

" + + "Lowe's Archery " + + "Emporium for the " + + "finest ranging " + + "weapons in town!" + + "

" + + "Time to party! Visit " + + "the Fancy Dress " + + "Shop for all your " + + "party outfits." + + "

" + + "The Dancing " + + "Donkey - cold beer " + + "always in stock." + } + override fun defineListeners() { + on(Items.NEWSPAPER_11169, IntType.ITEM, "read") { player, _ -> + openInterface(player, NEWSPAPER_INTERFACE_530) + setInterfaceText(player, leftPage ,NEWSPAPER_INTERFACE_530, 7) + setInterfaceText(player, rightPage ,NEWSPAPER_INTERFACE_530, 8) + return@on true + } + + on(Items.AL_KHARID_FLYER_7922, IntType.ITEM, "read") { player, _ -> + sendDialogueLines(player, "Come to the Al Kharid Market place! High quality", "produce at low, low prices! Show this flyer to a", "merchant for money off your next purchase,", "courtesy of Ali Morrisane!") + return@on true + } + } +}