RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ClanmasterDialogue.java
1package com.osroyale.content.dialogue.impl;
2
3import com.osroyale.content.clanchannel.ClanMember;
4import com.osroyale.content.clanchannel.channel.ClanChannel;
5import com.osroyale.content.clanchannel.content.ClanLevel;
6import com.osroyale.content.clanchannel.content.ClanTask;
7import com.osroyale.content.clanchannel.content.ClanViewer;
8import com.osroyale.content.dialogue.Dialogue;
9import com.osroyale.content.dialogue.DialogueFactory;
10import com.osroyale.content.store.Store;
11import com.osroyale.game.world.entity.mob.player.Player;
12import com.osroyale.net.packet.out.SendItemOnInterface;
13import com.osroyale.net.packet.out.SendScrollbar;
14import com.osroyale.net.packet.out.SendString;
15import com.osroyale.util.Difficulty;
16import com.osroyale.util.Utility;
17
18import java.util.Optional;
19
61
62public class ClanmasterDialogue extends Dialogue {
63
64 @Override
65 public void sendDialogues(DialogueFactory factory) {
66 Player player = factory.getPlayer();
67 factory.sendNpcChat(3841, "Ello mate!", "What can I do you for today?");
68 factory.sendOption("Information on Clans", () -> clanInformation(factory),
69 "World Clan List", () -> player.clanViewer.open(ClanViewer.ClanTab.OVERVIEW),
70 "Clan Management", () -> clanManagement(factory),
71 "Clan Levels", () -> clanLevel(factory.getPlayer()),
72 "Nevermind", factory::clear);
73 factory.execute();
74 }
75
76 private void mainOptions(DialogueFactory factory) {
77 }
78
80 private void clanInformation(DialogueFactory factory) {
81 factory.sendOption("What is a clan?", () -> clanDefinition(factory),
82 "What are clan perks?", () -> clanPerks(factory),
83 "Nevermind", factory::clear);
84 }
85
86 private void clanDefinition(DialogueFactory factory) {
87 factory.sendNpcChat(3841, "A clan is a united group or syndicate of players",
88 "who work together to complete various tasks depending on the", "clan type. Clans members can identify one another",
89 "by the purple dot on the minimap or their clan tag.");
90 }
91
92 private void clanPerks(DialogueFactory factory) {
93 factory.sendNpcChat(3841,
94 "I offer many perks and items to be used for clans.",
95 "Clan perks affect all online clan members when used.",
96 "These perks vary from rewarding everyone with",
97 "random experience in a random skill to having a drop modifier");
98 factory.sendNpcChat(3841, "for a certain amount of time.");
99 }
100
102 private void clanManagement(DialogueFactory factory) {
103 Player player = factory.getPlayer();
104 ClanChannel channel = player.clanChannel;
105
106 if (channel == null) {
107 factory.sendNpcChat(3841, "You must be in a clan in order to do this!");
108 return;
109 }
110
111 Optional<ClanMember> member = channel.getMember(player.getName());
112
113 if (!member.isPresent() || !channel.canManage(member.get())) {
114 factory.sendNpcChat(3841, "You do not have the proper authorization to manage", "the clan " + channel.getName() + "! If you want to manage your own clan", "please join your own clan and then speak to me again.");
115 return;
116 }
117
118 factory.sendOption("View store", () -> Store.STORES.get("The Clanmaster's Store").open(player), "Manage tasks", () -> clanTask(channel, factory), "Nevermind", factory::clear);
119 }
120
122 private void clanTask(ClanChannel channel, DialogueFactory factory) {
123 ClanTask task = channel.getDetails().clanTask;
124 factory.sendOption("Task Information", () -> {
125 if (task == null) {
126 factory.sendStatement("Your clan currently does not have a task assigned!");
127 return;
128 }
129
130 factory.sendStatement("Your current task is to:", task.getName(channel));
131 }, "Obtain Clan Task", () -> {
132 if (task != null) {
133 factory.sendNpcChat(3841, "Your clan currently has a task assigned!", "Cancel or complete it to obtain another one.");
134 return;
135 }
136 factory.sendOption("Easy Task - <col=255>2 CP</col> Reward", () -> channel.receiveTask(Difficulty.EASY), "Medium Task - <col=255>3 CP</col> Reward", () -> channel.receiveTask(Difficulty.MEDIUM), "Hard Task - <col=255>5 CP</col> Reward", () -> channel.receiveTask(Difficulty.HARD));
137 }, "Cancel Clan Task (<col=FF2929>5 CP</col>)", () -> {
138 if (task == null) {
139 factory.sendStatement("Your clan currently does not have a task assigned!");
140 return;
141 }
142 if (channel.getDetails().points < 5) {
143 factory.sendStatement("You do not have enough points to cancel your task.", "Current CP: " + channel.getDetails().points);
144 return;
145 }
146 channel.getDetails().points -= 5;
147 channel.getDetails().taskAmount = -1;
148 channel.getDetails().clanTask = null;
149 channel.message("Our clan task was cancelled for 25 CP. We have <col=255>" + Utility.formatDigits(channel.getDetails().points) + "</col> remaining.");
150 }, "Nevermind", factory::clear);
151 }
152
154 private void clanLevel(Player player) {
155 int size = ClanLevel.values().length;
156 for (int index = 0, string = 37111; index < size; index++) {
157 ClanLevel level = ClanLevel.values()[index];
158 String color = "<col=" + level.getColor() + ">";
159 String experience = "Experience: <col=7A6856>" + Utility.formatDigits(level.getExperience()) + "</col>";
160 String points = "Points: <col=7A6856>" + Utility.formatDigits(level.getPoints()) + "</col>";
161 player.send(new SendString(color + Utility.formatEnum(level.name()), string));
162 string++;
163 player.send(new SendString(experience + " <col=000000>|</col> " + points, string));
164 string++;
165 player.send(new SendString("", string));
166 string++;
167 }
168 player.send(new SendString("", 37107));
169 player.send(new SendString("Clan Levels Information", 37103));
170 player.send(new SendScrollbar(37110, 750));
171 player.send(new SendItemOnInterface(37199));
172 player.interfaceManager.open(37100);
173 }
174}
final DialogueFactory sendOption(String option1, Runnable action1, String option2, Runnable action2)
final DialogueFactory sendNpcChat(int id, String... lines)