Implemented a generic book interface

Converted all books to new book interface
Converted stats command to use the new book interface
This commit is contained in:
Oven Bread
2023-04-24 14:32:52 +00:00
committed by Ryan
parent 4b20cdd001
commit 323c653275
35 changed files with 2177 additions and 2385 deletions
@@ -1,197 +0,0 @@
package core.game.dialogue.book;
import core.game.component.Component;
import core.game.dialogue.DialoguePlugin;
import core.game.dialogue.DialoguePlugin;
import core.game.node.entity.player.Player;
import core.plugin.PluginManifest;
import core.plugin.PluginType;
/**
* Represents a dialogue book.
* @author 'Vexia
* @date 1/1/14
*/
@PluginManifest(type = PluginType.DIALOGUE)
public abstract class Book extends DialoguePlugin {
/**
* Represents the component interface of the book.
*/
private static final Component INTERFACE = new Component(49);
/**
* Represents the red string.
*/
protected static final String RED = "<col=8A0808>";
/**
* Represents the blue string.
*/
protected static final String BLUE = "<col=08088A>";
/**
* Represents the name of the book.
*/
protected String name;
/**
* Represents the id of this book.
*/
protected int id;
/**
* Represents the pages of this book.
*/
protected PageSet[] sets;
/**
* Represents the index of the page set we're at.
*/
protected int index = -1;
/**
* Constructs a new {@code Book} {@code Object}.
* @param name the name.
* @param id the id.
*/
public Book(final Player player, final String name, final int id, final PageSet... sets) {
this.player = player;
this.name = name;
this.id = id;
this.sets = sets;
}
/**
* Constructs a new {@code Book} {@code Object}.
*/
public Book() {
/**
* empty.
*/
}
@Override
public boolean open(Object... args) {
return open(player);
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (buttonId) {
case 112:
player.getInterfaceManager().close();
break;
case 66:
case 52:
next();
break;
case 64:
case 50:
previous();
break;
}
return true;
}
@Override
public Object fireEvent(String identifier, Object... args) {
return this;
}
/**
* Method used to open a book.
* @return <code>True</code> if succesfully opened.
*/
public boolean open(final Player player) {
next();
return true;
}
/**
* Method used to write the next dialogue.
*/
public void next() {
player.lock();
index++;
if (index > sets.length - 1) {
player.unlock();
player.getInterfaceManager().close();
return;
}
final Page[] set = sets[index].getPages();
display(set);
player.unlock();
}
/**
* Method used to write the previous dialogue.
*/
public void previous() {
player.lock();
index--;
if (index < 0) {
index = 0;
}
final Page[] set = sets[index].getPages();
display(set);
player.unlock();
}
/**
* Method used to display a set of pages.
* @param set the set.
*/
public void display(Page[] set) {
// TODO: It seems like different subclasses instantiate this by
// copy-paste, this should probably be made final, and should switch between a few
// implementations by component id
}
/**
* Method used when the book is finished.
*/
public void finish() {
}
/**
* Gets the name.
* @return The name.
*/
public String getName() {
return name;
}
/**
* Gets the id.
* @return The id.
*/
public int getId() {
return id;
}
/**
* Gets the index.
* @return The index.
*/
public int getIndex() {
return index;
}
/**
* Sets the index.
* @param index The index to set.
*/
public void setIndex(int index) {
this.index = index;
}
/**
* Gets the interface component.
* @return the component.
*/
public Component getInterface() {
return INTERFACE;
}
}
@@ -1,46 +0,0 @@
package core.game.dialogue.book;
/**
* Represents a book line.
* @author 'Vexia
* @date 31/12/2013
*/
public class BookLine {
/**
* Represents the message to display.
*/
private final String message;
/**
* Represents the child if of the line.
*/
private final int child;
/**
* Constructs a new {@code Page} {@code Object}.
* @param message the message.
* @param child the child.
*/
public BookLine(final String message, final int child) {
this.message = message;
this.child = child;
}
/**
* Gets the message.
* @return The message.
*/
public String getMessage() {
return message;
}
/**
* Gets the child.
* @return The child.
*/
public int getChild() {
return child;
}
}
@@ -1,31 +0,0 @@
package core.game.dialogue.book;
/**
* Represents a page on a book.
* @author 'Vexia
* @date 1/1/14
*/
public class Page {
/**
* Represents the lines on a page.
*/
private final BookLine[] lines;
/**
* Constructs a new {@code Page} {@code Object}.
* @param lines the lines.
*/
public Page(BookLine... lines) {
this.lines = lines;
}
/**
* Gets the lines.
* @return The lines.
*/
public BookLine[] getLines() {
return lines;
}
}
@@ -1,29 +0,0 @@
package core.game.dialogue.book;
/**
* Represents a set of pages on a book.
* @author 'Vexia
*/
public class PageSet {
/**
* Represents the set of pages.
*/
private final Page[] pages;
/**
* Constructs a new {@code PageSet} {@code Object}.
* @param pages the pages.
*/
public PageSet(final Page... pages) {
this.pages = pages;
}
/**
* Gets the pages.
* @return The pages.
*/
public Page[] getPages() {
return pages;
}
}
@@ -1,17 +1,20 @@
package core.game.system.command.sets
import core.game.component.Component
import content.data.BossKillCounter
import content.global.activity.ttrail.TreasureTrailManager
import content.global.handlers.iface.BookInterface
import content.global.handlers.iface.Page
import content.global.handlers.iface.PageSet
import content.global.skill.slayer.SlayerManager
import core.api.setAttribute
import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.Items;
import org.rs09.consts.NPCs;
import core.api.utils.GlobalKillCounter;
import core.game.interaction.InterfaceListener
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import core.api.utils.GlobalKillCounter
import core.game.system.command.Privilege
import core.game.world.repository.Repository
import java.util.*
val TUROTH_IDS = intArrayOf(NPCs.TUROTH_1622, NPCs.TUROTH_1623, NPCs.TUROTH_1626, NPCs.TUROTH_1627, NPCs.TUROTH_1628, NPCs.TUROTH_1629, NPCs.TUROTH_1630)
val KURASK_IDS = intArrayOf(NPCs.KURASK_1608, NPCs.KURASK_1609, NPCs.KURASK_4229, NPCs.KURASK_7811)
@@ -27,193 +30,169 @@ val STEEL_DRAGON_IDS = intArrayOf(NPCs.STEEL_DRAGON_1592, NPCs.STEEL_DRAGON_3590
val MITHRIL_DRAGON_IDS = intArrayOf(NPCs.MITHRIL_DRAGON_5363, NPCs.MITHRIL_DRAGON_8424)
val SKELETAL_WYVERN_IDS = intArrayOf(NPCs.SKELETAL_WYVERN_3068, NPCs.SKELETAL_WYVERN_3069, NPCs.SKELETAL_WYVERN_3070, NPCs.SKELETAL_WYVERN_3071)
val SPACER = "<str> </str>";
val NUM_PAGES = 3
fun sendStats(player: Player, other: Player, page: Int){
prepareInterface(player, other, page)
val globalData = other.savedData.globalData
for(i in (68..97)) {
when(page) {
0 -> {
when(i) {
//Various stats
97 -> sendLine(player,"Easy Clues: ${TreasureTrailManager.getInstance(other).completedClues[0]}",i)
68 -> sendLine(player,"Medium Clues: ${TreasureTrailManager.getInstance(other).completedClues[1]}",i)
69 -> sendLine(player,"Hard Clues: ${TreasureTrailManager.getInstance(other).completedClues[2]}",i)
70 -> sendLine(player, SPACER,i)
71 -> sendLine(player,"Slayer Tasks: ${SlayerManager.getInstance(other).flags.completedTasks}",i)
72 -> sendLine(player,"Quest Points: ${other.questRepository.points}",i)
73 -> sendLine(player,"Ironman Mode: ${other.ironmanManager.mode.name.toLowerCase()}",i)
74 -> sendLine(player,"Deaths: ${other.getAttribute("$STATS_BASE:$STATS_DEATHS",0)}",i)
75 -> sendLine(player, SPACER,i)
76 -> sendLine(player,"Logs Chopped: ${other.getAttribute("$STATS_BASE:$STATS_LOGS",0)}",i)
77 -> sendLine(player,"Rocks Mined: ${other.getAttribute("$STATS_BASE:$STATS_ROCKS",0)}",i)
78 -> sendLine(player,"Fish Caught: ${other.getAttribute("$STATS_BASE:$STATS_FISH",0)}",i)
79 -> sendLine(player, "Essence Crafted: ${other.getAttribute("$STATS_BASE:$STATS_RC",0)}", i)
//Boss KC
82 -> sendLine(player, "KBD KC: ${globalData.bossCounters.get(BossKillCounter.KING_BLACK_DRAGON.ordinal)}",i)
83 -> sendLine(player, "TDs KC: ${globalData.bossCounters.get(BossKillCounter.TORMENTED_DEMONS.ordinal)}",i)
84 -> sendLine(player, "Supreme KC: ${globalData.bossCounters.get(BossKillCounter.DAGANNOTH_SUPREME.ordinal)}",i)
85 -> sendLine(player, "Rex KC: ${globalData.bossCounters.get(BossKillCounter.DAGANNOTH_REX.ordinal)}",i)
86 -> sendLine(player, "Prime KC: ${globalData.bossCounters.get(BossKillCounter.DAGANNOTH_PRIME.ordinal)}",i)
87 -> sendLine(player, "Barrows KC: ${globalData.barrowsLoots}",i)
88 -> sendLine(player, "Chaos Ele: ${globalData.bossCounters.get(BossKillCounter.CHAOS_ELEMENTAL.ordinal)}",i)
89 -> sendLine(player, "Mole KC: ${globalData.bossCounters.get(BossKillCounter.GIANT_MOLE.ordinal)}",i)
90 -> sendLine(player, "Sara KC: ${globalData.bossCounters.get(BossKillCounter.SARADOMIN.ordinal)}",i)
91 -> sendLine(player, "Zammy KC: ${globalData.bossCounters.get(BossKillCounter.ZAMORAK.ordinal)}",i)
92 -> sendLine(player, "Bandos KC: ${globalData.bossCounters.get(BossKillCounter.BANDOS.ordinal)}",i)
93 -> sendLine(player, "Arma KC: ${globalData.bossCounters.get(BossKillCounter.ARMADYL.ordinal)}",i)
94 -> sendLine(player, "Jad KC: ${globalData.bossCounters.get(BossKillCounter.JAD.ordinal)}",i)
95 -> sendLine(player, "KQ KC: ${globalData.bossCounters.get(BossKillCounter.KALPHITE_QUEEN.ordinal)}",i)
96 -> sendLine(player, "Corp KC: ${globalData.bossCounters.get(BossKillCounter.CORPOREAL_BEAST.ordinal)}",i)
else -> sendLine(player,"",i)
}
}
1 -> {
when(i) {
97 -> sendLine(player, "Turoths: ${GlobalKillCounter.getKills(other, TUROTH_IDS)}", i)
68 -> sendLine(player, "Kurasks: ${GlobalKillCounter.getKills(other, KURASK_IDS)}", i)
69 -> sendLine(player, "Leaf-bladed swords: ${GlobalKillCounter.getRareDrops(other, Items.LEAF_BLADED_SWORD_13290)}", i)
70 -> sendLine(player, SPACER,i)
71 -> sendLine(player, "Gargoyles: ${GlobalKillCounter.getKills(other, GARGOYLE_IDS)}", i)
72 -> sendLine(player, "Granite mauls: ${GlobalKillCounter.getRareDrops(other, Items.GRANITE_MAUL_4153)}", i)
73 -> sendLine(player, SPACER,i)
74 -> sendLine(player, "Spiritual mages: ${GlobalKillCounter.getKills(other, SPIRITUAL_MAGE_IDS)}", i)
75 -> sendLine(player, "Dragon boots: ${GlobalKillCounter.getRareDrops(other, Items.DRAGON_BOOTS_11732)}", i)
76 -> sendLine(player, SPACER,i)
77 -> sendLine(player, "Abyssal demons: ${GlobalKillCounter.getKills(other, NPCs.ABYSSAL_DEMON_1615)}", i)
78 -> sendLine(player, "Abyssal whips: ${GlobalKillCounter.getRareDrops(other, Items.ABYSSAL_WHIP_4151)}", i)
79 -> sendLine(player, SPACER,i)
80 -> sendLine(player, "Dark beasts: ${GlobalKillCounter.getKills(other, NPCs.DARK_BEAST_2783)}", i)
81 -> sendLine(player, "Dark bows: ${GlobalKillCounter.getRareDrops(other, Items.DARK_BOW_11235)}", i)
82 -> sendLine(player, "Green Dragons: ${GlobalKillCounter.getKills(other, GREEN_DRAGON_IDS)}", i)
83 -> sendLine(player, "Blue Dragons: ${GlobalKillCounter.getKills(other, BLUE_DRAGON_IDS)}", i)
84 -> sendLine(player, "Red Dragons: ${GlobalKillCounter.getKills(other, RED_DRAGON_IDS)}", i)
85 -> sendLine(player, "Black Dragons: ${GlobalKillCounter.getKills(other, BLACK_DRAGON_IDS)}", i)
86 -> sendLine(player, SPACER,i)
87 -> sendLine(player, "Bronze Dragons: ${GlobalKillCounter.getKills(other, BRONZE_DRAGON_IDS)}", i)
88 -> sendLine(player, "Iron Dragons: ${GlobalKillCounter.getKills(other, IRON_DRAGON_IDS)}", i)
89 -> sendLine(player, "Steel Dragons: ${GlobalKillCounter.getKills(other, STEEL_DRAGON_IDS)}", i)
90 -> sendLine(player, "Mithril Dragons: ${GlobalKillCounter.getKills(other, MITHRIL_DRAGON_IDS)}", i)
91 -> sendLine(player, "Skeletal Wyverns: ${GlobalKillCounter.getKills(other, SKELETAL_WYVERN_IDS)}", i)
92 -> sendLine(player, SPACER,i)
93 -> sendLine(player, "Draconic visages: ${GlobalKillCounter.getRareDrops(other, Items.DRACONIC_VISAGE_11286)}", i)
else -> sendLine(player,"",i)
}
}
2 -> {
when(i) {
97 -> sendLine(player, "Ahrim's hood: ${GlobalKillCounter.getRareDrops(other, Items.AHRIMS_HOOD_4708)}", i)
68 -> sendLine(player, "Ahrim's staff: ${GlobalKillCounter.getRareDrops(other, Items.AHRIMS_STAFF_4710)}", i)
69 -> sendLine(player, "Ahrim's robetop: ${GlobalKillCounter.getRareDrops(other, Items.AHRIMS_ROBETOP_4712)}", i)
70 -> sendLine(player, "Ahrim's robeskirt: ${GlobalKillCounter.getRareDrops(other, Items.AHRIMS_ROBESKIRT_4714)}", i)
71 -> sendLine(player, SPACER,i)
72 -> sendLine(player, "Dharok's helm: ${GlobalKillCounter.getRareDrops(other, Items.DHAROKS_HELM_4716)}", i)
73 -> sendLine(player, "Dharok's greataxe: ${GlobalKillCounter.getRareDrops(other, Items.DHAROKS_GREATAXE_4718)}", i)
74 -> sendLine(player, "Dharok's platebody: ${GlobalKillCounter.getRareDrops(other, Items.DHAROKS_PLATEBODY_4720)}", i)
75 -> sendLine(player, "Dharok's platelegs: ${GlobalKillCounter.getRareDrops(other, Items.DHAROKS_PLATELEGS_4722)}", i)
76 -> sendLine(player, SPACER,i)
77 -> sendLine(player, "Guthan's helm: ${GlobalKillCounter.getRareDrops(other, Items.GUTHANS_HELM_4724)}", i)
78 -> sendLine(player, "Guthan's warspear: ${GlobalKillCounter.getRareDrops(other, Items.GUTHANS_WARSPEAR_4726)}", i)
79 -> sendLine(player, "Guthan's platebody: ${GlobalKillCounter.getRareDrops(other, Items.GUTHANS_PLATEBODY_4728)}", i)
80 -> sendLine(player, "Guthan's chainskirt: ${GlobalKillCounter.getRareDrops(other, Items.GUTHANS_CHAINSKIRT_4730)}", i)
82 -> sendLine(player, "Karil's coif: ${GlobalKillCounter.getRareDrops(other, Items.KARILS_COIF_4732)}", i)
83 -> sendLine(player, "Karil's crossbow: ${GlobalKillCounter.getRareDrops(other, Items.KARILS_CROSSBOW_4734)}", i)
84 -> sendLine(player, "Karil's leathertop: ${GlobalKillCounter.getRareDrops(other, Items.KARILS_LEATHERTOP_4736)}", i)
85 -> sendLine(player, "Karil's leatherskirt: ${GlobalKillCounter.getRareDrops(other, Items.KARILS_LEATHERSKIRT_4738)}", i)
86 -> sendLine(player, SPACER,i)
87 -> sendLine(player, "Torag's helm: ${GlobalKillCounter.getRareDrops(other, Items.TORAGS_HELM_4745)}", i)
88 -> sendLine(player, "Torag's hammers: ${GlobalKillCounter.getRareDrops(other, Items.TORAGS_HAMMERS_4747)}", i)
89 -> sendLine(player, "Torag's platebody: ${GlobalKillCounter.getRareDrops(other, Items.TORAGS_PLATEBODY_4749)}", i)
90 -> sendLine(player, "Torag's platelegs: ${GlobalKillCounter.getRareDrops(other, Items.TORAGS_PLATELEGS_4751)}", i)
91 -> sendLine(player, SPACER,i)
92 -> sendLine(player, "Verac's helm: ${GlobalKillCounter.getRareDrops(other, Items.VERACS_HELM_4753)}", i)
93 -> sendLine(player, "Verac's flail: ${GlobalKillCounter.getRareDrops(other, Items.VERACS_FLAIL_4755)}", i)
94 -> sendLine(player, "Verac's brassard: ${GlobalKillCounter.getRareDrops(other, Items.VERACS_BRASSARD_4757)}", i)
95 -> sendLine(player, "Verac's plateskirt: ${GlobalKillCounter.getRareDrops(other, Items.VERACS_PLATESKIRT_4759)}", i)
else -> sendLine(player,"",i)
}
}
}
}
player.interfaceManager.open(Component(26))
}
fun sendLine(player: Player, line: String, child: Int) {
player.packetDispatch.sendString(line,26,child)
}
fun prepareInterface(player: Player,other: Player, page: Int){
player.setAttribute("stats-page-info", StatsPageInfo(other, page))
if(page == 0) {
player.packetDispatch.sendInterfaceConfig(26,62,true)
player.packetDispatch.sendInterfaceConfig(26,65,true)
} else {
sendLine(player, "Previous", 65)
}
if(page == NUM_PAGES - 1) {
player.packetDispatch.sendInterfaceConfig(26,64,true)
player.packetDispatch.sendInterfaceConfig(26,66,true)
} else {
sendLine(player, "Next", 66)
}
player.packetDispatch.sendString(other.username + "'s Stats - Page ${page + 1}",26,101)
}
data class StatsPageInfo(val other: Player, val page: Int) {}
val SPACER = "<str> </str>"
val FAKE_CONTENT = arrayOf(
PageSet(Page(), Page()),
PageSet(Page(), Page()),
PageSet(Page(), Page()),
)
@Initializable
class StatsCommandSet : CommandSet(Privilege.STANDARD) {
override fun defineCommands() {
define("stats"){player,args ->
if(args.size == 1){
sendStats(player)
return@define
companion object {
private fun display(player: Player, pageNum: Int, buttonId: Int) : Boolean {
val queryPlayer: Player? = player.getAttribute("stats-command-query-player", null)
if (queryPlayer == null) {
return false
}
val globalData = queryPlayer.globalData
BookInterface.pageSetup(player, BookInterface.FANCY_BOOK_26,queryPlayer.username + "'s Stats", FAKE_CONTENT)
for(i in (68..97)) {
when(pageNum) {
0 -> {
when(i) {
//Various stats
97 -> sendLine(player,"Easy Clues: ${TreasureTrailManager.getInstance(queryPlayer).completedClues[0]}",i)
68 -> sendLine(player,"Medium Clues: ${TreasureTrailManager.getInstance(queryPlayer).completedClues[1]}",i)
69 -> sendLine(player,"Hard Clues: ${TreasureTrailManager.getInstance(queryPlayer).completedClues[2]}",i)
70 -> sendLine(player, SPACER,i)
71 -> sendLine(player,"Slayer Tasks: ${SlayerManager.getInstance(queryPlayer).flags.completedTasks}",i)
72 -> sendLine(player,"Quest Points: ${queryPlayer.questRepository.points}",i)
73 -> sendLine(player,"Ironman Mode: ${queryPlayer.ironmanManager.mode.name.lowercase(Locale.getDefault())}",i)
74 -> sendLine(player,"Deaths: ${queryPlayer.getAttribute("$STATS_BASE:$STATS_DEATHS",0)}",i)
75 -> sendLine(player, SPACER,i)
76 -> sendLine(player,"Logs Chopped: ${queryPlayer.getAttribute("$STATS_BASE:$STATS_LOGS",0)}",i)
77 -> sendLine(player,"Rocks Mined: ${queryPlayer.getAttribute("$STATS_BASE:$STATS_ROCKS",0)}",i)
78 -> sendLine(player,"Fish Caught: ${queryPlayer.getAttribute("$STATS_BASE:$STATS_FISH",0)}",i)
79 -> sendLine(player, "Essence Crafted: ${queryPlayer.getAttribute("$STATS_BASE:$STATS_RC",0)}", i)
//Boss KC
82 -> sendLine(player, "KBD KC: ${globalData.bossCounters.get(BossKillCounter.KING_BLACK_DRAGON.ordinal)}",i)
83 -> sendLine(player, "TDs KC: ${globalData.bossCounters.get(BossKillCounter.TORMENTED_DEMONS.ordinal)}",i)
84 -> sendLine(player, "Supreme KC: ${globalData.bossCounters.get(BossKillCounter.DAGANNOTH_SUPREME.ordinal)}",i)
85 -> sendLine(player, "Rex KC: ${globalData.bossCounters.get(BossKillCounter.DAGANNOTH_REX.ordinal)}",i)
86 -> sendLine(player, "Prime KC: ${globalData.bossCounters.get(BossKillCounter.DAGANNOTH_PRIME.ordinal)}",i)
87 -> sendLine(player, "Barrows KC: ${globalData.barrowsLoots}",i)
88 -> sendLine(player, "Chaos Ele: ${globalData.bossCounters.get(BossKillCounter.CHAOS_ELEMENTAL.ordinal)}",i)
89 -> sendLine(player, "Mole KC: ${globalData.bossCounters.get(BossKillCounter.GIANT_MOLE.ordinal)}",i)
90 -> sendLine(player, "Sara KC: ${globalData.bossCounters.get(BossKillCounter.SARADOMIN.ordinal)}",i)
91 -> sendLine(player, "Zammy KC: ${globalData.bossCounters.get(BossKillCounter.ZAMORAK.ordinal)}",i)
92 -> sendLine(player, "Bandos KC: ${globalData.bossCounters.get(BossKillCounter.BANDOS.ordinal)}",i)
93 -> sendLine(player, "Arma KC: ${globalData.bossCounters.get(BossKillCounter.ARMADYL.ordinal)}",i)
94 -> sendLine(player, "Jad KC: ${globalData.bossCounters.get(BossKillCounter.JAD.ordinal)}",i)
95 -> sendLine(player, "KQ KC: ${globalData.bossCounters.get(BossKillCounter.KALPHITE_QUEEN.ordinal)}",i)
96 -> sendLine(player, "Corp KC: ${globalData.bossCounters.get(BossKillCounter.CORPOREAL_BEAST.ordinal)}",i)
else -> sendLine(player,"",i)
}
}
1 -> {
when(i) {
97 -> sendLine(player, "Turoths: ${GlobalKillCounter.getKills(queryPlayer, TUROTH_IDS)}", i)
68 -> sendLine(player, "Kurasks: ${GlobalKillCounter.getKills(queryPlayer, KURASK_IDS)}", i)
69 -> sendLine(player, "Leaf-bladed swords: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.LEAF_BLADED_SWORD_13290)}", i)
70 -> sendLine(player, SPACER,i)
71 -> sendLine(player, "Gargoyles: ${GlobalKillCounter.getKills(queryPlayer, GARGOYLE_IDS)}", i)
72 -> sendLine(player, "Granite mauls: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.GRANITE_MAUL_4153)}", i)
73 -> sendLine(player, SPACER,i)
74 -> sendLine(player, "Spiritual mages: ${GlobalKillCounter.getKills(queryPlayer, SPIRITUAL_MAGE_IDS)}", i)
75 -> sendLine(player, "Dragon boots: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.DRAGON_BOOTS_11732)}", i)
76 -> sendLine(player, SPACER,i)
77 -> sendLine(player, "Abyssal demons: ${GlobalKillCounter.getKills(queryPlayer, NPCs.ABYSSAL_DEMON_1615)}", i)
78 -> sendLine(player, "Abyssal whips: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.ABYSSAL_WHIP_4151)}", i)
79 -> sendLine(player, SPACER,i)
80 -> sendLine(player, "Dark beasts: ${GlobalKillCounter.getKills(queryPlayer, NPCs.DARK_BEAST_2783)}", i)
81 -> sendLine(player, "Dark bows: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.DARK_BOW_11235)}", i)
82 -> sendLine(player, "Green Dragons: ${GlobalKillCounter.getKills(queryPlayer, GREEN_DRAGON_IDS)}", i)
83 -> sendLine(player, "Blue Dragons: ${GlobalKillCounter.getKills(queryPlayer, BLUE_DRAGON_IDS)}", i)
84 -> sendLine(player, "Red Dragons: ${GlobalKillCounter.getKills(queryPlayer, RED_DRAGON_IDS)}", i)
85 -> sendLine(player, "Black Dragons: ${GlobalKillCounter.getKills(queryPlayer, BLACK_DRAGON_IDS)}", i)
86 -> sendLine(player, SPACER,i)
87 -> sendLine(player, "Bronze Dragons: ${GlobalKillCounter.getKills(queryPlayer, BRONZE_DRAGON_IDS)}", i)
88 -> sendLine(player, "Iron Dragons: ${GlobalKillCounter.getKills(queryPlayer, IRON_DRAGON_IDS)}", i)
89 -> sendLine(player, "Steel Dragons: ${GlobalKillCounter.getKills(queryPlayer, STEEL_DRAGON_IDS)}", i)
90 -> sendLine(player, "Mithril Dragons: ${GlobalKillCounter.getKills(queryPlayer, MITHRIL_DRAGON_IDS)}", i)
91 -> sendLine(player, "Skeletal Wyverns: ${GlobalKillCounter.getKills(queryPlayer, SKELETAL_WYVERN_IDS)}", i)
92 -> sendLine(player, SPACER,i)
93 -> sendLine(player, "Draconic visages: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.DRACONIC_VISAGE_11286)}", i)
else -> sendLine(player,"",i)
}
}
2 -> {
when(i) {
97 -> sendLine(player, "Ahrim's hood: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.AHRIMS_HOOD_4708)}", i)
68 -> sendLine(player, "Ahrim's staff: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.AHRIMS_STAFF_4710)}", i)
69 -> sendLine(player, "Ahrim's robetop: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.AHRIMS_ROBETOP_4712)}", i)
70 -> sendLine(player, "Ahrim's robeskirt: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.AHRIMS_ROBESKIRT_4714)}", i)
71 -> sendLine(player, SPACER,i)
72 -> sendLine(player, "Dharok's helm: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.DHAROKS_HELM_4716)}", i)
73 -> sendLine(player, "Dharok's greataxe: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.DHAROKS_GREATAXE_4718)}", i)
74 -> sendLine(player, "Dharok's platebody: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.DHAROKS_PLATEBODY_4720)}", i)
75 -> sendLine(player, "Dharok's platelegs: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.DHAROKS_PLATELEGS_4722)}", i)
76 -> sendLine(player, SPACER,i)
77 -> sendLine(player, "Guthan's helm: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.GUTHANS_HELM_4724)}", i)
78 -> sendLine(player, "Guthan's warspear: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.GUTHANS_WARSPEAR_4726)}", i)
79 -> sendLine(player, "Guthan's platebody: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.GUTHANS_PLATEBODY_4728)}", i)
80 -> sendLine(player, "Guthan's chainskirt: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.GUTHANS_CHAINSKIRT_4730)}", i)
82 -> sendLine(player, "Karil's coif: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.KARILS_COIF_4732)}", i)
83 -> sendLine(player, "Karil's crossbow: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.KARILS_CROSSBOW_4734)}", i)
84 -> sendLine(player, "Karil's leathertop: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.KARILS_LEATHERTOP_4736)}", i)
85 -> sendLine(player, "Karil's leatherskirt: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.KARILS_LEATHERSKIRT_4738)}", i)
86 -> sendLine(player, SPACER,i)
87 -> sendLine(player, "Torag's helm: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.TORAGS_HELM_4745)}", i)
88 -> sendLine(player, "Torag's hammers: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.TORAGS_HAMMERS_4747)}", i)
89 -> sendLine(player, "Torag's platebody: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.TORAGS_PLATEBODY_4749)}", i)
90 -> sendLine(player, "Torag's platelegs: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.TORAGS_PLATELEGS_4751)}", i)
91 -> sendLine(player, SPACER,i)
92 -> sendLine(player, "Verac's helm: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.VERACS_HELM_4753)}", i)
93 -> sendLine(player, "Verac's flail: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.VERACS_FLAIL_4755)}", i)
94 -> sendLine(player, "Verac's brassard: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.VERACS_BRASSARD_4757)}", i)
95 -> sendLine(player, "Verac's plateskirt: ${GlobalKillCounter.getRareDrops(queryPlayer, Items.VERACS_PLATESKIRT_4759)}", i)
else -> sendLine(player,"",i)
}
}
}
}
return true
}
fun sendLine(player: Player, line: String, child: Int) {
player.packetDispatch.sendString(line ,BookInterface.FANCY_BOOK_26, child)
}
}
override fun defineCommands() {
define("stats"){ player, args ->
// Bad number of args
if(args.size > 2){
reject(player,"Usage: ::stats playername")
return@define
}
val other = Repository.getPlayerByName(args[1])
if(other == null){
// If stats is called without a username, return self.
var queryPlayer: Player? = null
if(args.size == 1){
queryPlayer = player
}
// If stats is called with a username, find the player or set to null.
if(args.size == 2) {
queryPlayer = Repository.getPlayerByName(args[1])
}
// If main player is not found, return error.
if(queryPlayer == null){
reject(player,"Invalid player or player not online.")
return@define
}
sendStats(player,other, 0)
}
}
fun sendStats(player: Player){
sendStats(player,player, 0)
}
}
class StatsInterface : InterfaceListener {
val COMPONENT_ID = 26
override fun defineInterfaceListeners() {
on(COMPONENT_ID, 61) { player, _, _, _, _, _ ->
val info: StatsPageInfo? = player.getAttribute("stats-page-info", null)
if(info != null) {
sendStats(player, info.other, info.page-1)
}
return@on true
}
on(COMPONENT_ID, 63) { player, _, _, _, _, _ ->
val info: StatsPageInfo? = player.getAttribute("stats-page-info", null)
if(info != null) {
sendStats(player, info.other, info.page+1)
}
return@on true
setAttribute(player, "bookInterfaceCallback", ::display)
setAttribute(player, "bookInterfaceCurrentPage", 0)
setAttribute(player, "stats-command-query-player", queryPlayer)
display(player, 0, 0)
return@define
}
}
}