Corrected contents of Varrock newspaper and refactored related code

This commit is contained in:
Oven Bread 2024-03-16 12:10:19 +00:00 committed by Ryan
parent 8729f93d01
commit 6856d75d88
2 changed files with 80 additions and 45 deletions

View file

@ -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<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.forId(7922).getHandlers().put("option:read", this);
ItemDefinition.forId(11169).getHandlers().put("option:read", this);
return this;
}
}

View file

@ -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" +
"<br><br>" +
"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 " +
"<br><br>" +
"Goblin-Died<br>" +
"Giant Rat-Died<br>" +
"Unicorn-Died<br>" +
"Varrock Guard-Died<br>" +
"Varrock Guard-Died<br>" +
"Varrock Guard-Died<br>" +
"Bear-Died." +
"<br><br>" +
"Classifieds" +
"<br><br>" +
"Lowe's Archery " +
"Emporium for the " +
"finest ranging " +
"weapons in town!" +
"<br><br>" +
"Time to party! Visit " +
"the Fancy Dress " +
"Shop for all your " +
"party outfits." +
"<br><br>" +
"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
}
}
}