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,104 +0,0 @@
package content.global.skill.construction;
import core.game.dialogue.DialogueInterpreter;
import core.game.dialogue.DialoguePlugin;
import core.game.dialogue.book.Book;
import core.game.dialogue.book.Page;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.game.world.GameWorld;
import core.plugin.Initializable;
/**
* Handles the construction guide book.
* @author Emperor
*
*/
@Initializable
public class ConstructionGuideBook extends Book {
/**
* The resources used in beta.
*/
private static final Item[] RESOURCES = {
new Item(8794),
new Item(2347),
new Item(4819, 500000),
new Item(4820, 500000),
new Item(1539, 500000),
new Item(4821, 500000),
new Item(4822, 500000),
new Item(4823, 500000),
new Item(4824, 500000),
new Item(961, 500000),
new Item(8779, 500000),
new Item(8781, 500000),
new Item(8783, 500000),
new Item(8791, 500000),
new Item(8785, 500000),
new Item(8787, 500000),
new Item(8789, 500000), //16
new Item(8418, 500000),
new Item(8420, 500000),
new Item(8422, 500000),
new Item(8424, 500000),
new Item(8426, 500000),
new Item(8428, 500000),
new Item(8430, 500000),
new Item(8432, 500000),
new Item(8434, 500000),
new Item(8436, 500000),
};
/**
* Constructs a new {@code ConstructionGuideBook} {@code Object}.
*/
public ConstructionGuideBook() {
/*
* empty.
*/
}
/**
* Constructs a new {@code ConstructionGuideBook} {@code Object}.
* @param player
*/
public ConstructionGuideBook(Player player) {
super(player, "Construction guide book", DialogueInterpreter.getDialogueKey("book:conguide"));
}
@Override
public boolean open(final Player player) {
if (GameWorld.getSettings().isDevMode() && GameWorld.getSettings().isBeta()) {
for (Item item : RESOURCES) {
if (!player.getInventory().contains(item.getId(), item.getAmount())) {
player.getInventory().add(item, player);
}
}
}
interpreter.sendPlainMessage(false, "Upon reading the book you discover you're supposed to", "use these resources to test out construction.", "Report all bugs on the forums.");
return true;
}
@Override
public void finish() {
}
@Override
public void display(Page[] set) {
}
@Override
public DialoguePlugin newInstance(Player player) {
return new ConstructionGuideBook(player);
}
@Override
public int[] getIds() {
return new int[] { DialogueInterpreter.getDialogueKey("book:conguide") };
}
}
@@ -0,0 +1,70 @@
package content.global.skill.construction
import core.api.sendMessage
import core.game.dialogue.DialogueInterpreter
import core.game.interaction.IntType
import core.game.interaction.InteractionListener
import core.game.node.item.Item
import core.game.world.GameWorld.settings
import org.rs09.consts.Items
/**
* Construction Guide Book
* Used to be book:conguide?
* @author ovenbreado
* @author Emperor
*/
class ConstructionGuideBook : InteractionListener {
companion object {
private val TITLE = "Construction guide book"
/** The resources used in beta. */
private val RESOURCES = arrayOf(
Item(8794),
Item(2347),
Item(4819, 500000),
Item(4820, 500000),
Item(1539, 500000),
Item(4821, 500000),
Item(4822, 500000),
Item(4823, 500000),
Item(4824, 500000),
Item(961, 500000),
Item(8779, 500000),
Item(8781, 500000),
Item(8783, 500000),
Item(8791, 500000),
Item(8785, 500000),
Item(8787, 500000),
Item(8789, 500000), // 16
Item(8418, 500000),
Item(8420, 500000),
Item(8422, 500000),
Item(8424, 500000),
Item(8426, 500000),
Item(8428, 500000),
Item(8430, 500000),
Item(8432, 500000),
Item(8434, 500000),
Item(8436, 500000)
)
}
override fun defineListeners() {
println(intArrayOf(DialogueInterpreter.getDialogueKey("book:conguide")))
// There is supposedly a book here.
on(Items.CONSTRUCTION_GUIDE_8463, IntType.ITEM, "read") { player, _ ->
if (settings!!.isDevMode && settings!!.isBeta) {
for (item in RESOURCES) {
if (!player.inventory.contains(item.id, item.amount)) {
player.inventory.add(item, player)
}
}
}
sendMessage(player, "Upon reading the book you discover you're supposed to use these resources to test out construction. Report all bugs on the forums.")
return@on true
}
}
}