RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.dialogue.DialogueFactory Class Reference

Represents a factory class that contains important functions for building dialogues. More...

Collaboration diagram for com.runehive.content.dialogue.DialogueFactory:

Public Member Functions

void clear ()
 Clears the current dialogue chain.
 DialogueFactory (Player player)
 Creates a new DialogueFactory.
final DialogueFactory execute ()
 Retrieves the next dialogue in the chain and executes it.
final DialogueFactory executeOption (int type, Optional< OptionDialogue > result)
 Executes an result for a player.
final Queue< ChainablegetChain ()
 Gets the current chain.
Optional< Runnable > getNextAction ()
 Gets the Optional describing the next action in the dialogue chain.
Player getPlayer ()
 The player that owns this factory.
boolean isActive ()
boolean isOption ()
 Gets if the dialogue is option.
void lock (boolean lock)
final DialogueFactory onAction (Runnable action)
 Sets an action so this action can be executed after dialogues are done.
DialogueFactory onNext ()
 Accepts the next dialogue in the chain.
final DialogueFactory sendDialogue (Dialogue dialogue)
 Sends a player a dialogue.
final DialogueFactory sendInformationBox (String title, String...lines)
final DialogueFactory sendItem (String title, String text, int item)
final DialogueFactory sendItem (String title, String text, Item item)
final DialogueFactory sendNpcChat (int id, Expression expression, String... lines)
 Appends an NpcDialogue to the current dialogue chain.
final DialogueFactory sendNpcChat (int id, String... lines)
 Appends an NpcDialogue to the current dialogue chain.
final DialogueFactory sendOption (String option1, Runnable action1, String option2, Runnable action2)
 Appends the OptionDialogue onto the current dialogue chain.
final DialogueFactory sendOption (String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3)
 Appends the OptionDialogue onto the current dialogue chain.
final DialogueFactory sendOption (String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3, String option4, Runnable action4)
 Appends the OptionDialogue onto the current dialogue chain.
final DialogueFactory sendOption (String option1, Runnable action1, String option2, Runnable action2, String option3, Runnable action3, String option4, Runnable action4, String option5, Runnable action5)
 Appends the OptionDialogue onto the current dialogue chain.
final DialogueFactory sendPlayerChat (Expression expression, String... lines)
 Appends a PlayerDialogue to the current dialogue chain.
final DialogueFactory sendPlayerChat (String... lines)
 Appends a PlayerDialogue to the current dialogue chain.
final DialogueFactory sendStatement (String... lines)
 Appends a StatementDialogue to the current dialogue chain.
void setActive (boolean active)
void setNextAction (Optional< Runnable > nextAction)
 Sets the next action in the dialogue chain.

Package Functions

final DialogueFactory sendInformationBox (InformationDialogue dialogue)
final DialogueFactory sendItem (ItemDialogue dialogue)
final DialogueFactory sendNpcChat (NpcDialogue dialogue)
 Sends a dialogue with a npc talking.
final DialogueFactory sendOption (OptionDialogue dialogue)
 Sends a dialogue with options.
final DialogueFactory sendPlayerChat (PlayerDialogue dialogue)
 Sends a dialogue with a player talking.
final DialogueFactory sendStatement (StatementDialogue dialogue)
 Sends a player a statement dialogue.

Private Member Functions

final DialogueFactory append (Chainable chain)
 Appends a chain to this factory.
final String appendKeywords (String line)
 Appends keywords to an existing dialogue text.
final void validateLength (String... text)
 The method that validates the length of text.

Private Attributes

boolean active
 The flag that denotes dialogue is active.
final Queue< ChainableCHAIN = new ArrayDeque<>()
 The queue of dialogues in this factory.
boolean locked
Optional< Runnable > nextAction = Optional.empty()
 The next action in the dialogue chain.
final Player player
 The player who owns this factory.

Static Private Attributes

static final Logger logger = LogManager.getLogger(DialogueFactory.class)
static final int MAXIMUM_LENGTH = 500
 The maximum length of a single line of dialogue.

Detailed Description

Represents a factory class that contains important functions for building dialogues.

Author
nshusa

Definition at line 19 of file DialogueFactory.java.

Constructor & Destructor Documentation

◆ DialogueFactory()

com.runehive.content.dialogue.DialogueFactory.DialogueFactory ( Player player)

Creates a new DialogueFactory.

Parameters
playerThe player who owns this factory.

Definition at line 44 of file DialogueFactory.java.

44 {
45 this.player = player;
46 }

References player.

Referenced by append(), execute(), executeOption(), onAction(), onNext(), sendDialogue(), sendInformationBox(), sendInformationBox(), sendItem(), sendItem(), sendItem(), sendNpcChat(), sendNpcChat(), sendNpcChat(), sendOption(), sendOption(), sendOption(), sendOption(), sendOption(), sendPlayerChat(), sendPlayerChat(), sendPlayerChat(), sendStatement(), and sendStatement().

Here is the caller graph for this function:

Member Function Documentation

◆ append()

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.append ( Chainable chain)
private

Appends a chain to this factory.

Returns
The instance of this factory.

Definition at line 132 of file DialogueFactory.java.

132 {
133 this.CHAIN.add(chain);
134 return this;
135 }

References DialogueFactory().

Referenced by sendInformationBox(), sendItem(), sendItem(), sendNpcChat(), sendNpcChat(), sendOption(), sendOption(), sendOption(), sendOption(), sendPlayerChat(), sendPlayerChat(), and sendStatement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendKeywords()

final String com.runehive.content.dialogue.DialogueFactory.appendKeywords ( String line)
private

Appends keywords to an existing dialogue text.

Parameters
lineThe line to check for a keyword.

Definition at line 208 of file DialogueFactory.java.

208 {
209 if (line.contains("#username")) {
210 line = line.replace("#username", Utility.formatName((player.getName())));
211 }
212 if (line.contains("#name")) {
213 line = line.replace("#name", Utility.formatName((player.getName())));
214 }
215 return line;
216 }

References com.runehive.util.Utility.formatName(), and player.

Referenced by sendNpcChat(), and sendPlayerChat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void com.runehive.content.dialogue.DialogueFactory.clear ( )

Clears the current dialogue chain.

Returns
The instance of this factory.

Definition at line 115 of file DialogueFactory.java.

115 {
116 CHAIN.clear();
117 nextAction = Optional.empty();
118 player.dialogue = Optional.empty();
119 player.optionDialogue = Optional.empty();
120 setActive(false);
121 player.interfaceManager.setDialogue(-1);
122 player.send(new SendRemoveInterface(false));
123 // Clear cached interface strings so dialogue can be replayed
124 player.playerAssistant.clearSendStrings();
125 }

References CHAIN, nextAction, player, and setActive().

Referenced by com.runehive.content.skill.impl.crafting.impl.Spinning.click(), com.runehive.content.skill.impl.slayer.SlayerOfferings.confirm(), com.runehive.content.skill.impl.crafting.impl.Stringing.craft(), com.runehive.net.packet.in.DropItemPacketListener.handlePacket(), com.runehive.content.store.impl.PersonalStore.modify(), com.runehive.content.skill.impl.slayer.SlayerOfferings.offer(), com.runehive.content.dialogue.impl.VoteDialogue.sendDialogues(), and com.runehive.content.clanchannel.channel.ClanChannelHandler.testPassword().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute()

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.execute ( )

Retrieves the next dialogue in the chain and executes it.

Returns
The instance of this factory.

Definition at line 161 of file DialogueFactory.java.

161 {
162 if (locked)
163 return this;
164 if (player.movement.isMoving()) {
165 player.movement.reset();
166 }
167 // check to see if there are anymore dialogues.
168 if (getChain().peek() != null) {
169
170 // there is so, grab the next dialogue.
171 Chainable entry = getChain().poll();
172
173 // is this an option dialogue?
174 if (entry instanceof OptionDialogue) {
175 OptionDialogue option = (OptionDialogue) entry;
176 player.optionDialogue = Optional.of(option);
177 } else {
178 player.optionDialogue = Optional.empty();
179 }
180
181 player.interfaceManager.setDialogue(1);
182 setActive(true);
183 // whatever dialogue it is, accept it.
184 entry.accept(this);
185 } else {
186 // there are no dialogues in this chain.
187 // is there an action?
188 if (getNextAction().isPresent()) {
189 // there is so, execute it.
190 getNextAction().ifPresent($it -> $it.run());
191 // we just used this action so empty it so it can't be used
192 // again.
193 setNextAction(Optional.empty());
194 player.optionDialogue = Optional.empty();
195 return this;
196 }
197 // there are no more dialogues, so clear the screen.
198 player.dialogueFactory.clear();
199 }
200 return this;
201 }

References DialogueFactory(), getChain(), getNextAction(), locked, player, setActive(), and setNextAction().

Referenced by com.runehive.content.pet.Pets.buyInsurance(), com.runehive.content.skill.impl.agility.obstacle.impl.WildernessDoorInteraction.canExecute(), com.runehive.content.skill.impl.agility.obstacle.ObstacleInteraction.canExecute(), com.runehive.content.dailyeffect.DailyEffect.canUse(), com.runehive.game.service.DonationService.claimDonation(), com.runehive.game.service.VoteService.claimReward(), com.runehive.content.skill.impl.crafting.impl.Spinning.click(), com.runehive.content.skill.impl.herblore.Herblore.clickItem(), com.runehive.content.activity.impl.barrows.Barrows.clickNpc(), com.runehive.content.skill.impl.firemaking.Firemaking.clickObject(), com.runehive.content.staff.PlayerManagement.confirm(), com.runehive.content.skill.impl.crafting.impl.Stringing.craft(), com.runehive.content.CrystalChest.createKey(), com.runehive.content.dialogue.impl.VoteDialogue.exchange(), com.runehive.content.skill.impl.thieving.Thieving.exchange(), executeOption(), com.runehive.content.skill.impl.fishing.FishingAction.fish(), com.runehive.net.packet.in.DropItemPacketListener.handlePacket(), com.runehive.content.shootingstar.ShootingStar.mine(), com.runehive.content.store.impl.PersonalStore.modify(), com.runehive.content.skill.impl.slayer.SlayerOfferings.offer(), com.runehive.content.bloodmoney.BloodMoneyChest.open(), com.runehive.content.Obelisks.open(), com.runehive.content.RoyaltyProgram.open(), com.runehive.game.world.items.containers.bank.BankPin.open(), com.runehive.content.preset.PresetManager.openSettings(), com.runehive.content.shootingstar.ShootingStar.prospect(), com.runehive.content.Waypoints.removeWaypoint(), com.runehive.content.DropDisplay.search(), com.runehive.content.clanchannel.channel.ClanChannelHandler.sendConnectionWarning(), com.runehive.content.dialogue.impl.ClanmasterDialogue.sendDialogues(), com.runehive.content.dialogue.impl.KamfreenaDialogue.sendDialogues(), com.runehive.content.dialogue.impl.LootshareDialogue.sendDialogues(), com.runehive.content.dialogue.impl.NieveDialogue.sendDialogues(), com.runehive.content.dialogue.impl.PrestigeDialogue.sendDialogues(), com.runehive.content.dialogue.impl.RoyalKingDialogue.sendDialogues(), com.runehive.content.dialogue.impl.VoteDialogue.sendDialogues(), com.runehive.content.dialogue.impl.WellOfGoodwillDialogue.sendDialogues(), com.runehive.content.dialogue.impl.ClanRankDialogue.setRank(), com.runehive.content.Waypoints.setWaypoint(), com.runehive.content.skill.impl.crafting.Crafting.start(), com.runehive.content.skill.impl.fletching.Fletching.start(), com.runehive.content.ai.AIDialogueHandler.streamGandalfResponse(), com.runehive.content.clanchannel.channel.ClanChannelHandler.testPassword(), com.runehive.content.skill.impl.thieving.WallSafe.thieve(), com.runehive.content.skill.impl.cooking.Cooking.useItem(), and com.runehive.content.skill.impl.herblore.Herblore.useItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ executeOption()

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.executeOption ( int type,
Optional< OptionDialogue > result )

Executes an result for a player.

Parameters
typeThe type of option.
resultThe option to execute.

Definition at line 96 of file DialogueFactory.java.

96 {
97 if (result.isPresent()) {
98 OptionDialogue optionDialogue = result.get();
99
100 if (type < 0 || type >= optionDialogue.getActions().size()) {
101 return this;
102 }
103
104 optionDialogue.getActions().get(type).run();
105 }
106 execute();
107 return this;
108 }

References DialogueFactory(), execute(), and com.runehive.content.dialogue.OptionDialogue.getActions().

Here is the call graph for this function:

◆ getChain()

final Queue< Chainable > com.runehive.content.dialogue.DialogueFactory.getChain ( )

Gets the current chain.

Returns
The queue of dialogues.

Definition at line 142 of file DialogueFactory.java.

142 {
143 return CHAIN;
144 }

References CHAIN.

Referenced by execute(), isOption(), and onNext().

Here is the caller graph for this function:

◆ getNextAction()

Optional< Runnable > com.runehive.content.dialogue.DialogueFactory.getNextAction ( )

Gets the Optional describing the next action in the dialogue chain.

Returns
The optional describing the next action.

Definition at line 649 of file DialogueFactory.java.

649 {
650 return nextAction;
651 }

References nextAction.

Referenced by execute().

Here is the caller graph for this function:

◆ getPlayer()

◆ isActive()

boolean com.runehive.content.dialogue.DialogueFactory.isActive ( )

Definition at line 662 of file DialogueFactory.java.

662 {
663 return active;
664 }

References active.

◆ isOption()

boolean com.runehive.content.dialogue.DialogueFactory.isOption ( )

Gets if the dialogue is option.

Returns
The option dialogue.

Definition at line 151 of file DialogueFactory.java.

151 {
152 Chainable next = getChain().peek();
153 return next instanceof OptionDialogue;
154 }

References getChain().

Here is the call graph for this function:

◆ lock()

void com.runehive.content.dialogue.DialogueFactory.lock ( boolean lock)

Definition at line 71 of file DialogueFactory.java.

71 {
72 this.locked = lock;
73 }

References lock().

Referenced by lock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onAction()

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.onAction ( Runnable action)

Sets an action so this action can be executed after dialogues are done.

Parameters
actionThe action to set.
Returns
The instance of this factory.

Definition at line 66 of file DialogueFactory.java.

66 {
67 setNextAction(Optional.of(action));
68 return this;
69 }

References DialogueFactory(), and setNextAction().

Referenced by com.runehive.content.store.impl.PersonalStore.edit(), com.runehive.content.store.impl.PersonalStore.modify(), com.runehive.game.plugin.PluginContext.onClick(), com.runehive.content.skill.impl.crafting.impl.Spinning.open(), com.runehive.content.preset.PresetManager.openSettings(), com.runehive.content.dialogue.impl.NieveDialogue.sell(), com.runehive.content.ai.AIDialogueHandler.sendDialogues(), com.runehive.content.dialogue.impl.ClanRankDialogue.sendDialogues(), com.runehive.content.dialogue.impl.ConstructionDialogue.sendDialogues(), com.runehive.content.dialogue.impl.NieveDialogue.sendDialogues(), com.runehive.content.dialogue.impl.WellOfGoodwillDialogue.sendDialogues(), com.runehive.content.ai.AIDialogueHandler.streamGandalfResponse(), and com.runehive.content.clanchannel.channel.ClanChannelHandler.testPassword().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onNext()

DialogueFactory com.runehive.content.dialogue.DialogueFactory.onNext ( )

Accepts the next dialogue in the chain.

Returns
The instance of this factory.

Definition at line 80 of file DialogueFactory.java.

80 {
81 if (getChain().peek() != null) {
82 Chainable chain = getChain().poll();
83 chain.accept(this);
84 } else {
85 player.interfaceManager.close();
86 }
87 return this;
88 }

References DialogueFactory(), getChain(), and player.

Here is the call graph for this function:

◆ sendDialogue()

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendDialogue ( Dialogue dialogue)

Sends a player a dialogue.

Parameters
dialogueThe dialogue to sent.

Definition at line 53 of file DialogueFactory.java.

53 {
54 player.dialogue = Optional.of(dialogue);
55 dialogue.sendDialogues(this);
56 return this;
57 }

References DialogueFactory().

Referenced by com.runehive.content.ai.AIDialogueHandler.streamGandalfResponse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendInformationBox() [1/2]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendInformationBox ( InformationDialogue dialogue)
package

Definition at line 580 of file DialogueFactory.java.

580 {
581 validateLength(dialogue.getLines());
582 switch (dialogue.getLines().length) {
583 case 1:
584 player.send(new SendString(dialogue.getTitle(), 6180));
585 player.send(new SendString("", 6181));
586 player.send(new SendString(dialogue.getLines()[0], 6182));
587 player.send(new SendString("", 6183));
588 player.send(new SendString("", 6184));
589 player.send(new SendChatBoxInterface(6179));
590 break;
591 case 2:
592 player.send(new SendString(dialogue.getTitle(), 6180));
593 player.send(new SendString("", 6181));
594 player.send(new SendString(dialogue.getLines()[0], 6182));
595 player.send(new SendString(dialogue.getLines()[1], 6183));
596 player.send(new SendString("", 6184));
597 player.send(new SendChatBoxInterface(6179));
598 break;
599 case 3:
600 player.send(new SendString(dialogue.getTitle(), 6180));
601 player.send(new SendString("", 6181));
602 player.send(new SendString(dialogue.getLines()[0], 6182));
603 player.send(new SendString(dialogue.getLines()[1], 6183));
604 player.send(new SendString(dialogue.getLines()[2], 6184));
605 player.send(new SendChatBoxInterface(6179));
606 break;
607 case 4:
608 player.send(new SendString(dialogue.getTitle(), 6180));
609 player.send(new SendString(dialogue.getLines()[0], 6181));
610 player.send(new SendString(dialogue.getLines()[1], 6182));
611 player.send(new SendString(dialogue.getLines()[2], 6183));
612 player.send(new SendString(dialogue.getLines()[3], 6184));
613 player.send(new SendChatBoxInterface(6179));
614 break;
615 default:
616 logger.error(String.format("Invalid information dialogue line length: %s", dialogue.getLines().length));
617 break;
618 }
619 return this;
620 }

References DialogueFactory(), logger, player, and validateLength().

Here is the call graph for this function:

◆ sendInformationBox() [2/2]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendInformationBox ( String title,
String... lines )

Definition at line 574 of file DialogueFactory.java.

574 {
575 validateLength(lines);
576 append(new InformationDialogue(title, lines));
577 return this;
578 }

References append(), DialogueFactory(), and validateLength().

Referenced by com.runehive.content.dialogue.InformationDialogue.accept(), and com.runehive.content.preset.PresetManager.openSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendItem() [1/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendItem ( ItemDialogue dialogue)
package

Definition at line 563 of file DialogueFactory.java.

563 {
564 validateLength(dialogue.getContext());
565 player.send(new SendInterfaceAnimation(4883, 591));
566 player.send(new SendString(dialogue.getTitle(), 4884));
567 player.send(new SendString(dialogue.getContext(), 4885));
568 player.send(new SendString("Click here to continue.", 4886));
569 player.send(new SendItemModelOnInterface(4883, 250, dialogue.getItem()));
570 player.send(new SendChatBoxInterface(4882));
571 return this;
572 }

References DialogueFactory(), player, and validateLength().

Here is the call graph for this function:

◆ sendItem() [2/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendItem ( String title,
String text,
int item )

Definition at line 557 of file DialogueFactory.java.

557 {
558 validateLength(text);
559 append(new ItemDialogue(title, text, item));
560 return this;
561 }

References append(), DialogueFactory(), and validateLength().

Here is the call graph for this function:

◆ sendItem() [3/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendItem ( String title,
String text,
Item item )

Definition at line 551 of file DialogueFactory.java.

551 {
552 validateLength(text);
553 append(new ItemDialogue(title, text, item.getId()));
554 return this;
555 }
final int getId()
Gets the identification of this item.
Definition Item.java:324

References append(), DialogueFactory(), com.runehive.game.world.items.Item.getId(), and validateLength().

Referenced by com.runehive.content.dialogue.ItemDialogue.accept(), and com.runehive.content.CrystalChest.createKey().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendNpcChat() [1/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendNpcChat ( int id,
Expression expression,
String... lines )

Appends an NpcDialogue to the current dialogue chain.

Parameters
idThe id of this npc.
expressionThe expression of this npc.
linesThe text of this dialogue.
Returns
The instance of this factory.

Definition at line 313 of file DialogueFactory.java.

313 {
314 return append(new NpcDialogue(id, expression, lines));
315 }

References append(), and DialogueFactory().

Here is the call graph for this function:

◆ sendNpcChat() [2/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendNpcChat ( int id,
String... lines )

Appends an NpcDialogue to the current dialogue chain.

Parameters
idThe id of this npc.
linesThe text of this dialogue.
Returns
The instance of this factory.

Definition at line 301 of file DialogueFactory.java.

301 {
302 return append(new NpcDialogue(id, Expression.DEFAULT, lines));
303 }

References append(), com.runehive.content.dialogue.Expression.DEFAULT, and DialogueFactory().

Referenced by com.runehive.content.dialogue.NpcDialogue.accept(), com.runehive.content.pet.Pets.buyInsurance(), com.runehive.game.service.DonationService.claimDonation(), com.runehive.content.pet.Pets.claimLostPets(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanDefinition(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanManagement(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanPerks(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanTask(), com.runehive.content.activity.impl.barrows.Barrows.clickNpc(), com.runehive.content.dialogue.impl.VoteDialogue.exchange(), com.runehive.content.skill.impl.thieving.Thieving.exchange(), com.runehive.content.dialogue.impl.PrestigeDialogue.explainPerks(), com.runehive.content.dialogue.impl.PrestigeDialogue.explainPrestige(), com.runehive.content.skill.impl.slayer.SlayerOfferings.offer(), com.runehive.content.dialogue.impl.NieveDialogue.sell(), com.runehive.content.ai.AIDialogueHandler.sendDialogues(), com.runehive.content.dialogue.impl.ClanmasterDialogue.sendDialogues(), com.runehive.content.dialogue.impl.ConstructionDialogue.sendDialogues(), com.runehive.content.dialogue.impl.KamfreenaDialogue.sendDialogues(), com.runehive.content.dialogue.impl.NieveDialogue.sendDialogues(), com.runehive.content.dialogue.impl.PrestigeDialogue.sendDialogues(), com.runehive.content.dialogue.impl.RoyalKingDialogue.sendDialogues(), com.runehive.content.dialogue.impl.VoteDialogue.sendDialogues(), and com.runehive.content.ai.AIDialogueHandler.streamGandalfResponse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendNpcChat() [3/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendNpcChat ( NpcDialogue dialogue)
package

Sends a dialogue with a npc talking.

Parameters
dialogueThe dialogue.
Returns
The instance of this factory.

Definition at line 323 of file DialogueFactory.java.

323 {
324 Expression expression = dialogue.getExpression();
325 String[] lines = dialogue.getLines();
326 validateLength(lines);
327 // NPC speaking → camera behind NPC, looking at player (+slightly faster turn)
328 player.dialogueCamMode = com.runehive.game.world.entity.mob.player.camera.DialogueCameraDirector.Mode.BEHIND_NPC;
329 com.runehive.game.world.entity.mob.player.camera.DialogueCameraDirector.boostSwap(player, 8);
330 int id = dialogue.getId();
331 final NpcDefinition npcDef = NpcDefinition.get(id);
332
333 if (npcDef == null) return this;
334 switch (lines.length) {
335 case 1:
336 player.send(new SendInterfaceAnimation(4883, expression.getId()));
337 player.send(new SendString(npcDef.getName(), 4884));
338 player.send(new SendString(appendKeywords(lines[0]), 4885));
339 player.send(new SendNpcHead(npcDef.getId(), 4883));
340 player.send(new SendChatBoxInterface(4882));
341 break;
342 case 2:
343 player.send(new SendInterfaceAnimation(4888, expression.getId()));
344 player.send(new SendString(npcDef.getName(), 4889));
345 player.send(new SendString(appendKeywords(lines[0]), 4890));
346 player.send(new SendString(appendKeywords(lines[1]), 4891));
347 player.send(new SendNpcHead(npcDef.getId(), 4888));
348 player.send(new SendChatBoxInterface(4887));
349 break;
350 case 3:
351 player.send(new SendInterfaceAnimation(4894, expression.getId()));
352 player.send(new SendString(npcDef.getName(), 4895));
353 player.send(new SendString(appendKeywords(lines[0]), 4896));
354 player.send(new SendString(appendKeywords(lines[1]), 4897));
355 player.send(new SendString(appendKeywords(lines[2]), 4898));
356 player.send(new SendNpcHead(npcDef.getId(), 4894));
357 player.send(new SendChatBoxInterface(4893));
358 break;
359 case 4:
360 player.send(new SendInterfaceAnimation(4901, expression.getId()));
361 player.send(new SendString(npcDef.getName(), 4902));
362 player.send(new SendString(appendKeywords(lines[0]), 4903));
363 player.send(new SendString(appendKeywords(lines[1]), 4904));
364 player.send(new SendString(appendKeywords(lines[2]), 4905));
365 player.send(new SendString(appendKeywords(lines[3]), 4906));
366 player.send(new SendNpcHead(npcDef.getId(), 4901));
367 player.send(new SendChatBoxInterface(4900));
368 break;
369 default:
370 logger.error(String.format("Invalid npc dialogue line length: %s", lines.length));
371 break;
372 }
373 return this;
374 }

References appendKeywords(), DialogueFactory(), com.runehive.game.world.entity.mob.npc.definition.NpcDefinition.get(), com.runehive.content.dialogue.Expression.getId(), com.runehive.game.world.entity.mob.npc.definition.NpcDefinition.getId(), com.runehive.game.world.entity.mob.npc.definition.NpcDefinition.getName(), logger, player, and validateLength().

Here is the call graph for this function:

◆ sendOption() [1/5]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendOption ( OptionDialogue dialogue)
package

Sends a dialogue with options.

Parameters
dialogueThe dialogue.
Returns
The instance of this factory.

Definition at line 442 of file DialogueFactory.java.

442 {
443 String[] options = dialogue.getLines();
444 validateLength(options);
445 switch (options.length) {
446 case 2:
447 player.send(new SendString("Select an Option", 2460));
448 player.send(new SendString(options[0], 2461));
449 player.send(new SendTooltip("</col>Select <col=A89590>" + options[0], 2461));
450 player.send(new SendString(options[1], 2462));
451 player.send(new SendTooltip("</col>Select <col=A89590>" + options[1], 2461));
452 player.send(new SendChatBoxInterface(2459));
453 return this;
454 case 3:
455 player.send(new SendString("Select an Option", 2470));
456 player.send(new SendString(options[0], 2471));
457 player.send(new SendTooltip("</col>Select <col=A89590>" + options[0], 2471));
458 player.send(new SendString(options[1], 2472));
459 player.send(new SendTooltip("</col>Select <col=A89590>" + options[1], 2472));
460 player.send(new SendString(options[2], 2473));
461 player.send(new SendTooltip("</col>Select <col=A89590>" + options[2], 2473));
462 player.send(new SendChatBoxInterface(2469));
463 return this;
464 case 4:
465 player.send(new SendString("Select an Option", 2481));
466 player.send(new SendString(options[0], 2482));
467 player.send(new SendTooltip("</col>Select <col=A89590>" + options[0], 2482));
468 player.send(new SendString(options[1], 2483));
469 player.send(new SendTooltip("</col>Select <col=A89590>" + options[1], 2483));
470 player.send(new SendString(options[2], 2484));
471 player.send(new SendTooltip("</col>Select <col=A89590>" + options[2], 2484));
472 player.send(new SendString(options[3], 2485));
473 player.send(new SendTooltip("</col>Select <col=A89590>" + options[3], 2485));
474 player.send(new SendChatBoxInterface(2480));
475 return this;
476 case 5:
477 player.send(new SendString("Select an Option", 2493));
478 player.send(new SendString(options[0], 2494));
479 player.send(new SendTooltip("</col>Select <col=A89590>" + options[0], 2494));
480 player.send(new SendString(options[1], 2495));
481 player.send(new SendTooltip("</col>Select <col=A89590>" + options[1], 2495));
482 player.send(new SendString(options[2], 2496));
483 player.send(new SendTooltip("</col>Select <col=A89590>" + options[2], 2496));
484 player.send(new SendString(options[3], 2497));
485 player.send(new SendTooltip("</col>Select <col=A89590>" + options[3], 2497));
486 player.send(new SendString(options[4], 2498));
487 player.send(new SendTooltip("</col>Select <col=A89590>" + options[4], 2498));
488 player.send(new SendChatBoxInterface(2492));
489 return this;
490 }
491 return this;
492 }

References DialogueFactory(), player, and validateLength().

Here is the call graph for this function:

◆ sendOption() [2/5]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendOption ( String option1,
Runnable action1,
String option2,
Runnable action2 )

Appends the OptionDialogue onto the current dialogue chain.

Parameters
option1The text for the first option.
action1The action for the first action.
option2The text for the second option.
action2The action for the second action.

Definition at line 384 of file DialogueFactory.java.

384 {
385 return append(new OptionDialogue(option1, action1, option2, action2));
386 }

References append(), and DialogueFactory().

Referenced by com.runehive.content.dialogue.OptionDialogue.accept(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanInformation(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanManagement(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanTask(), com.runehive.content.activity.impl.barrows.Barrows.clickNpc(), com.runehive.content.staff.PlayerManagement.confirm(), com.runehive.content.store.impl.PersonalStore.edit(), com.runehive.net.packet.in.DropItemPacketListener.handlePacket(), com.runehive.content.store.impl.PersonalStore.modify(), com.runehive.content.skill.impl.slayer.SlayerOfferings.offer(), com.runehive.game.plugin.PluginContext.onClick(), com.runehive.content.skill.impl.crafting.impl.Spinning.open(), com.runehive.game.world.items.containers.bank.BankPin.open(), com.runehive.content.preset.PresetManager.openSettings(), com.runehive.content.dialogue.impl.NieveDialogue.sell(), com.runehive.content.clanchannel.channel.ClanChannelHandler.sendConnectionWarning(), com.runehive.content.dialogue.impl.ClanmasterDialogue.sendDialogues(), com.runehive.content.dialogue.impl.ClanRankDialogue.sendDialogues(), com.runehive.content.dialogue.impl.ConstructionDialogue.sendDialogues(), com.runehive.content.dialogue.impl.NieveDialogue.sendDialogues(), com.runehive.content.dialogue.impl.PrestigeDialogue.sendDialogues(), com.runehive.content.dialogue.impl.RoyalKingDialogue.sendDialogues(), com.runehive.content.dialogue.impl.VoteDialogue.sendDialogues(), com.runehive.content.dialogue.impl.WellOfGoodwillDialogue.sendDialogues(), com.runehive.content.teleport.TeleportHandler.special(), com.runehive.content.dialogue.impl.RoyalKingDialogue.store(), and com.runehive.content.ai.AIDialogueHandler.streamGandalfResponse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendOption() [3/5]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendOption ( String option1,
Runnable action1,
String option2,
Runnable action2,
String option3,
Runnable action3 )

Appends the OptionDialogue onto the current dialogue chain.

Parameters
option1The text for the first option.
action1The action for the first action.
option2The text for the second option.
action2The action for the second action.
option3The text for the third option.
action3The action for the third action.

Definition at line 398 of file DialogueFactory.java.

398 {
399 return append(new OptionDialogue(option1, action1, option2, action2, option3, action3));
400 }

References append(), and DialogueFactory().

Here is the call graph for this function:

◆ sendOption() [4/5]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendOption ( String option1,
Runnable action1,
String option2,
Runnable action2,
String option3,
Runnable action3,
String option4,
Runnable action4 )

Appends the OptionDialogue onto the current dialogue chain.

Parameters
option1The text for the first option.
action1The action for the first action.
option2The text for the second option.
action2The action for the second action.
option3The text for the third option.
action3The action for the third action.
option4The text for the four option.
action4The action for the four action.

Definition at line 414 of file DialogueFactory.java.

414 {
415 return append(new OptionDialogue(option1, action1, option2, action2, option3, action3, option4, action4));
416 }

References append(), and DialogueFactory().

Here is the call graph for this function:

◆ sendOption() [5/5]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendOption ( String option1,
Runnable action1,
String option2,
Runnable action2,
String option3,
Runnable action3,
String option4,
Runnable action4,
String option5,
Runnable action5 )

Appends the OptionDialogue onto the current dialogue chain.

Parameters
option1The text for the first option.
action1The action for the first action.
option2The text for the second option.
action2The action for the second action.
option3The text for the third option.
action3The action for the third action.
option4The text for the four option.
action4The action for the four action.
option5The text for the fifth option.
action5The action for the fifth action.

Definition at line 432 of file DialogueFactory.java.

432 {
433 return append(new OptionDialogue(option1, action1, option2, action2, option3, action3, option4, action4, option5, action5));
434 }

References append(), and DialogueFactory().

Here is the call graph for this function:

◆ sendPlayerChat() [1/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendPlayerChat ( Expression expression,
String... lines )

Appends a PlayerDialogue to the current dialogue chain.

Parameters
linesThe dialogue of the player talking.
expressionThe expression of this dialogue.
Returns
The instance of this factory.

Definition at line 235 of file DialogueFactory.java.

235 {
236 return append(new PlayerDialogue(expression, lines));
237 }

References append(), and DialogueFactory().

Here is the call graph for this function:

◆ sendPlayerChat() [2/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendPlayerChat ( PlayerDialogue dialogue)
package

Sends a dialogue with a player talking.

Parameters
dialogueThe player dialogue.
Returns
The instance of this factory.

Definition at line 245 of file DialogueFactory.java.

245 {
246 Expression expression = dialogue.getExpression();
247 String[] lines = dialogue.getLines();
248 validateLength(lines);
249 // Player speaking → camera behind player, looking at NPC (+slightly faster turn)
250 player.dialogueCamMode = com.runehive.game.world.entity.mob.player.camera.DialogueCameraDirector.Mode.BEHIND_PLAYER;
251 com.runehive.game.world.entity.mob.player.camera.DialogueCameraDirector.boostSwap(player, 8);
252 switch (lines.length) {
253 case 1:
254 player.send(new SendInterfaceAnimation(969, expression.getId()));
255 player.send(new SendString(Utility.formatName(player.getName()), 970));
256 player.send(new SendString(appendKeywords(lines[0]), 971));
257 player.send(new SendPlayerDialogueHead(969));
258 player.send(new SendChatBoxInterface(968));
259 break;
260 case 2:
261 player.send(new SendInterfaceAnimation(974, expression.getId()));
262 player.send(new SendString(Utility.formatName(player.getName()), 975));
263 player.send(new SendString(appendKeywords(lines[0]), 976));
264 player.send(new SendString(appendKeywords(lines[1]), 977));
265 player.send(new SendPlayerDialogueHead(974));
266 player.send(new SendChatBoxInterface(973));
267 break;
268 case 3:
269 player.send(new SendInterfaceAnimation(980, expression.getId()));
270 player.send(new SendString(Utility.formatName(player.getName()), 981));
271 player.send(new SendString(appendKeywords(lines[0]), 982));
272 player.send(new SendString(appendKeywords(lines[1]), 983));
273 player.send(new SendString(appendKeywords(lines[2]), 984));
274 player.send(new SendPlayerDialogueHead(980));
275 player.send(new SendChatBoxInterface(979));
276 break;
277 case 4:
278 player.send(new SendInterfaceAnimation(987, expression.getId()));
279 player.send(new SendString(Utility.formatName(player.getName()), 988));
280 player.send(new SendString(appendKeywords(lines[0]), 989));
281 player.send(new SendString(appendKeywords(lines[1]), 990));
282 player.send(new SendString(appendKeywords(lines[2]), 991));
283 player.send(new SendString(appendKeywords(lines[3]), 992));
284 player.send(new SendPlayerDialogueHead(987));
285 player.send(new SendChatBoxInterface(986));
286 break;
287 default:
288 logger.error(String.format("Invalid player dialogue line length: %s", lines.length));
289 break;
290 }
291 return this;
292 }

References appendKeywords(), DialogueFactory(), com.runehive.util.Utility.formatName(), com.runehive.content.dialogue.Expression.getId(), logger, player, and validateLength().

Here is the call graph for this function:

◆ sendPlayerChat() [3/3]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendPlayerChat ( String... lines)

Appends a PlayerDialogue to the current dialogue chain.

Parameters
linesThe dialogue of the player talking.
Returns
The instance of this factory.

Definition at line 224 of file DialogueFactory.java.

224 {
225 return append(new PlayerDialogue(lines));
226 }

References append(), and DialogueFactory().

Referenced by com.runehive.content.dialogue.PlayerDialogue.accept(), and com.runehive.content.dialogue.impl.VoteDialogue.sendDialogues().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendStatement() [1/2]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendStatement ( StatementDialogue dialogue)
package

Sends a player a statement dialogue.

Parameters
dialogueThe statement dialogue.

Definition at line 511 of file DialogueFactory.java.

511 {
512 validateLength(dialogue.getLines());
513 switch (dialogue.getLines().length) {
514 case 1:
515 player.send(new SendString(dialogue.getLines()[0], 357));
516 player.send(new SendChatBoxInterface(356));
517 break;
518 case 2:
519 player.send(new SendString(dialogue.getLines()[0], 360));
520 player.send(new SendString(dialogue.getLines()[1], 361));
521 player.send(new SendChatBoxInterface(359));
522 break;
523 case 3:
524 player.send(new SendString(dialogue.getLines()[0], 364));
525 player.send(new SendString(dialogue.getLines()[1], 365));
526 player.send(new SendString(dialogue.getLines()[2], 366));
527 player.send(new SendChatBoxInterface(363));
528 break;
529 case 4:
530 player.send(new SendString(dialogue.getLines()[0], 369));
531 player.send(new SendString(dialogue.getLines()[1], 370));
532 player.send(new SendString(dialogue.getLines()[2], 371));
533 player.send(new SendString(dialogue.getLines()[3], 372));
534 player.send(new SendChatBoxInterface(368));
535 break;
536 case 5:
537 player.send(new SendString(dialogue.getLines()[0], 375));
538 player.send(new SendString(dialogue.getLines()[1], 376));
539 player.send(new SendString(dialogue.getLines()[2], 377));
540 player.send(new SendString(dialogue.getLines()[3], 378));
541 player.send(new SendString(dialogue.getLines()[4], 379));
542 player.send(new SendChatBoxInterface(374));
543 break;
544 default:
545 logger.error(String.format("Invalid statement dialogue line length: %s", dialogue.getLines().length));
546 break;
547 }
548 return this;
549 }

References DialogueFactory(), logger, player, and validateLength().

Here is the call graph for this function:

◆ sendStatement() [2/2]

final DialogueFactory com.runehive.content.dialogue.DialogueFactory.sendStatement ( String... lines)

Appends a StatementDialogue to the current dialogue chain.

Parameters
linesThe text for this statement.
Returns
The instance of this factory.

Definition at line 500 of file DialogueFactory.java.

500 {
501 validateLength(lines);
502 append(new StatementDialogue(lines));
503 return this;
504 }

References append(), DialogueFactory(), and validateLength().

Referenced by com.runehive.content.dialogue.StatementDialogue.accept(), com.runehive.content.skill.impl.agility.obstacle.impl.WildernessDoorInteraction.canExecute(), com.runehive.content.skill.impl.agility.obstacle.ObstacleInteraction.canExecute(), com.runehive.content.dailyeffect.DailyEffect.canUse(), com.runehive.game.service.DonationService.claimDonation(), com.runehive.game.service.VoteService.claimReward(), com.runehive.content.dialogue.impl.ClanmasterDialogue.clanTask(), com.runehive.content.skill.impl.crafting.impl.Spinning.click(), com.runehive.content.skill.impl.herblore.Herblore.clickItem(), com.runehive.content.skill.impl.firemaking.Firemaking.clickObject(), com.runehive.content.staff.PlayerManagement.confirm(), com.runehive.content.skill.impl.crafting.impl.Stringing.craft(), com.runehive.content.store.impl.PersonalStore.edit(), com.runehive.content.skill.impl.fishing.FishingAction.fish(), com.runehive.net.packet.in.DropItemPacketListener.handlePacket(), com.runehive.content.shootingstar.ShootingStar.mine(), com.runehive.content.dialogue.impl.RoyalKingDialogue.myStats(), com.runehive.content.bloodmoney.BloodMoneyChest.open(), com.runehive.content.Obelisks.open(), com.runehive.content.RoyaltyProgram.open(), com.runehive.content.preset.PresetManager.openSettings(), com.runehive.content.shootingstar.ShootingStar.prospect(), com.runehive.content.Waypoints.removeWaypoint(), com.runehive.content.DropDisplay.search(), com.runehive.content.dialogue.impl.NieveDialogue.sell(), com.runehive.content.clanchannel.channel.ClanChannelHandler.sendConnectionWarning(), com.runehive.content.dialogue.impl.LootshareDialogue.sendDialogues(), com.runehive.content.dialogue.impl.WellOfGoodwillDialogue.sendDialogues(), com.runehive.content.dialogue.impl.ClanRankDialogue.setRank(), com.runehive.content.Waypoints.setWaypoint(), com.runehive.content.teleport.TeleportHandler.special(), com.runehive.content.skill.impl.crafting.Crafting.start(), com.runehive.content.skill.impl.fletching.Fletching.start(), com.runehive.content.clanchannel.channel.ClanChannelHandler.testPassword(), com.runehive.content.skill.impl.thieving.WallSafe.thieve(), com.runehive.content.skill.impl.cooking.Cooking.useItem(), and com.runehive.content.skill.impl.herblore.Herblore.useItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setActive()

void com.runehive.content.dialogue.DialogueFactory.setActive ( boolean active)

Definition at line 666 of file DialogueFactory.java.

666 {
667 this.active = active;
668 }

References active.

Referenced by clear(), execute(), and com.runehive.game.world.entity.skill.SkillManager.showLevelUpInterface().

Here is the caller graph for this function:

◆ setNextAction()

void com.runehive.content.dialogue.DialogueFactory.setNextAction ( Optional< Runnable > nextAction)

Sets the next action in the dialogue chain.

Parameters
nextActionThe action to set.

Definition at line 658 of file DialogueFactory.java.

658 {
659 this.nextAction = nextAction;
660 }

References nextAction.

Referenced by execute(), and onAction().

Here is the caller graph for this function:

◆ validateLength()

final void com.runehive.content.dialogue.DialogueFactory.validateLength ( String... text)
private

The method that validates the length of text.

Parameters
textthe text that will be validated.
Exceptions
IllegalStateExceptionif any lines of the text exceed a certain length.

Definition at line 628 of file DialogueFactory.java.

628 {
629 if (Arrays.stream(text).filter(Objects::nonNull).anyMatch(s -> s.length() > MAXIMUM_LENGTH)) {
630 throw new IllegalStateException("Dialogue length too long, maximum length is: " + MAXIMUM_LENGTH);
631 }
632 }

References MAXIMUM_LENGTH.

Referenced by sendInformationBox(), sendInformationBox(), sendItem(), sendItem(), sendItem(), sendNpcChat(), sendOption(), sendPlayerChat(), sendStatement(), and sendStatement().

Here is the caller graph for this function:

Member Data Documentation

◆ active

boolean com.runehive.content.dialogue.DialogueFactory.active
private

The flag that denotes dialogue is active.

Definition at line 33 of file DialogueFactory.java.

Referenced by isActive(), and setActive().

◆ CHAIN

final Queue<Chainable> com.runehive.content.dialogue.DialogueFactory.CHAIN = new ArrayDeque<>()
private

The queue of dialogues in this factory.

Definition at line 24 of file DialogueFactory.java.

Referenced by clear(), and getChain().

◆ locked

boolean com.runehive.content.dialogue.DialogueFactory.locked
private

Definition at line 37 of file DialogueFactory.java.

Referenced by execute().

◆ logger

final Logger com.runehive.content.dialogue.DialogueFactory.logger = LogManager.getLogger(DialogueFactory.class)
staticprivate

◆ MAXIMUM_LENGTH

final int com.runehive.content.dialogue.DialogueFactory.MAXIMUM_LENGTH = 500
staticprivate

The maximum length of a single line of dialogue.

Definition at line 27 of file DialogueFactory.java.

Referenced by validateLength().

◆ nextAction

Optional<Runnable> com.runehive.content.dialogue.DialogueFactory.nextAction = Optional.empty()
private

The next action in the dialogue chain.

Definition at line 36 of file DialogueFactory.java.

Referenced by clear(), getNextAction(), and setNextAction().

◆ player

final Player com.runehive.content.dialogue.DialogueFactory.player
private

The documentation for this class was generated from the following file: