RuneHive-Game
Loading...
Searching...
No Matches
RoyalKingDialogue.java
Go to the documentation of this file.
1package com.runehive.content.dialogue.impl;
2
3import com.runehive.content.dialogue.Dialogue;
4import com.runehive.content.dialogue.DialogueFactory;
5import com.runehive.content.dialogue.Expression;
6import com.runehive.content.store.Store;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.net.packet.out.SendMessage;
9import com.runehive.net.packet.out.SendURL;
10
11/**
12 * The royal king dialogue.
13 *
14 * @author Daniel
15 */
16public class RoyalKingDialogue extends Dialogue {
17
18 private int index;
19
21 this.index = index;
22 }
23
24 @Override
25 public void sendDialogues(DialogueFactory factory) {
26 if (index == 1) {
27 claim(factory);
28 factory.execute();
29 return;
30 }
31 if (index == 2) {
32 store(factory);
33 factory.execute();
34 return;
35 }
36 Player player = factory.getPlayer();
37 factory.sendNpcChat(5523, Expression.HAPPY, "Hello adventurer, how may I help you?");
38 factory.sendOption("Claim Purchase", () -> claim(factory), "Donator Information", () -> player.send(new SendURL("https://runehive.com")), "My donation statistics", () -> myStats(factory), "Open Store", () -> store(factory), "Nevermind", factory::clear);
39 factory.execute();
40 }
41
42 private void myStats(DialogueFactory factory) {
43 factory.sendStatement("Money spent: $" + factory.getPlayer().donation.getSpent(), "Current credits: " + factory.getPlayer().donation.getCredits());
44 }
45
46
47 private void claim(DialogueFactory factory) {
48 Player player = factory.getPlayer();
49 player.send(new SendMessage("Claiming is temporarily disabled until EverythingRS is replaced."));
50 /*new Thread(() -> {
51 try {
52 Donation[] donations = Donation.donations(
53 "V48tgd7OxwrvPMmZZbjkVt6qTYB2MrZ5sw6PD4DBJnM83zepnUlIT8DiFoND3BYEQjqxPamH", player.getName());
54 if (donations.length == 0) {
55 player.send(new SendMessage("You currently don't have any items waiting. You must donate first!"));
56 return;
57 }
58 if (donations[0].message != null) {
59 player.send(new SendMessage(donations[0].message));
60 return;
61 }
62 for (Donation donate : donations) {
63 player.inventory.add(new Item(donate.product_id, donate.product_amount));
64 }
65 player.send(new SendMessage("Thank you for donating!"));
66 } catch (Exception e) {
67 player.send(new SendMessage("Api Services are currently offline. Please check back shortly"));
68 e.printStackTrace();
69 }
70 }).start();*/
71 }
72
73
74 private void store(DialogueFactory factory) {
75 factory.sendOption("Open Donator Store", () -> Store.STORES.get("Donator Store").open(factory.getPlayer()), "Ironman Donator Store", () -> Store.STORES.get("Ironman Donator Store").open(factory.getPlayer()),"Nevermind", factory::clear);
76 }
77}
Represents a factory class that contains important functions for building dialogues.
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
Player getPlayer()
The player that owns this factory.
final DialogueFactory sendNpcChat(int id, String... lines)
Appends an NpcDialogue to the current dialogue chain.
final DialogueFactory sendStatement(String... lines)
Appends a StatementDialogue to the current dialogue chain.
final DialogueFactory sendOption(String option1, Runnable action1, String option2, Runnable action2)
Appends the OptionDialogue onto the current dialogue chain.
Represents an abstract dialogue, in which extending classes will be able to construct and send dialog...
Definition Dialogue.java:11
void sendDialogues(DialogueFactory factory)
Sends a player a dialogue.
The class which holds support for further abstraction for shops.
Definition Store.java:20
static Map< String, Store > STORES
A mapping of each shop by it's name.
Definition Store.java:23
This class represents a character controlled by a player.
Definition Player.java:125
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that opens a URL from client.
Definition SendURL.java:12
Represents the expressions of entities for dialogue.