RuneHive-Game
Loading...
Searching...
No Matches
ClanRankDialogue.java
Go to the documentation of this file.
1package com.runehive.content.dialogue.impl;
2
3import com.runehive.content.clanchannel.ClanMember;
4import com.runehive.content.clanchannel.ClanRank;
5import com.runehive.content.clanchannel.channel.ClanChannel;
6import com.runehive.content.dialogue.Dialogue;
7import com.runehive.content.dialogue.DialogueFactory;
8import com.runehive.game.world.entity.mob.player.Player;
9import com.runehive.net.packet.out.SendMessage;
10
11public class ClanRankDialogue extends Dialogue {
12
13 @Override
14 public void sendDialogues(DialogueFactory factory) {
15 Player player = factory.getPlayer();
16 ClanChannel channel = player.clanChannel;
17 if (channel == null)
18 return;
19 ClanMember playerMember = channel.getMember(player.getName()).orElse(null);
20 if (playerMember == null || !channel.canManage(playerMember)) {
21 player.send(new SendMessage("You do not have the required rank to do this."));
22 return;
23 }
24 ClanMember member = player.attributes.get("CLAN_RANK_MEMBER", ClanMember.class);
25 if (member == null)
26 return;
27 factory.sendOption("Recruit", () -> factory.onAction(() -> {
28 setRank(player, channel, member, ClanRank.RECRUIT);
29 }), "Corporal", () -> factory.onAction(() -> {
30 setRank(player, channel, member, ClanRank.CORPORAL);
31 }), "Sergeant", () -> factory.onAction(() -> {
32 setRank(player, channel, member, ClanRank.SERGEANT);
33 }), "Lieutenant", () -> factory.onAction(() -> {
34 setRank(player, channel, member, ClanRank.LIEUTENANT);
35 }), "Next", () -> {
36 factory.onAction(() -> {
37 factory.sendOption("Captain", () -> factory.onAction(() -> {
38 setRank(player, player.clanChannel, member, ClanRank.CAPTAIN);
39 }), "General", () -> factory.onAction(() -> {
40 setRank(player, player.clanChannel, member, ClanRank.GENERAL);
41 }), "Nevermind", () -> factory.onAction(factory::clear));
42 });
43 }).execute();
44 }
45
46 private void setRank(Player player, ClanChannel channel, ClanMember member, ClanRank rank) {
47 channel.setRank(member, rank);
48 player.dialogueFactory.sendStatement("You have promoted " + member.name + " to " + rank.getString() + " " + rank.name).execute();
49 player.interfaceManager.close();
50 }
51
52}
Handles the clan channel member.
final String name
The name of the clan member.
Optional< ClanMember > getMember(String name)
void setRank(ClanMember member, ClanRank rank)
Represents a factory class that contains important functions for building dialogues.
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
final DialogueFactory onAction(Runnable action)
Sets an action so this action can be executed after dialogues are done.
Player getPlayer()
The player that owns this factory.
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.
void setRank(Player player, ClanChannel channel, ClanMember member, ClanRank rank)
final GenericAttributes attributes
Definition Mob.java:95
This class represents a character controlled by a player.
Definition Player.java:125
String getName()
Gets the name of this entity.
Definition Player.java:774
The OutgoingPacket that sends a message to a Players chatbox in the client.
public< K, E > E get(K key)
Gets a generic attribute.
The enum containing all the rank's data within a clan channel.
Definition ClanRank.java:8
final String name
The name of the clan rank.
Definition ClanRank.java:21