RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.clanchannel.channel.ClanChannelHandler Class Reference

The handler for the clan channel. More...

Collaboration diagram for com.runehive.content.clanchannel.channel.ClanChannelHandler:

Public Member Functions

void updateMemberList (ClanMember member)
 Handles updating the clan channel member list.

Static Public Member Functions

static void clean (Player player)
 Handles cleaning the clan tab itemcontainer.
static void connect (Player player, String owner)
 Handles player joining a clan channel.
static boolean disconnect (Player player, boolean logout)
 Handles player joining a clan channel.
static void manage (Player player)
static void manageMember (Player player, int button)
static void onLogin (Player player)
 Handles logging into the server.

Package Functions

boolean attemptConnection (Player player, ClanMember member)
 Attempts a connection to the clan channel.
 ClanChannelHandler (ClanChannel channel)
 Constructs a new ClanChannelHandler.
void connected (ClanMember member)
 Handles connecting to the clan channel.
void sendConnectionWarning (Player player, ClanMember member)
 The sends the connection warning for hopping clans.
boolean testPassword (Player player, ClanMember member)
 Handles entering a clan channel password.

Private Attributes

final ClanChannel channel
 The clan channel instance.

Detailed Description

The handler for the clan channel.

Author
Michael
Daniel

Definition at line 24 of file ClanChannelHandler.java.

Constructor & Destructor Documentation

◆ ClanChannelHandler()

com.runehive.content.clanchannel.channel.ClanChannelHandler.ClanChannelHandler ( ClanChannel channel)
package

Constructs a new ClanChannelHandler.

Definition at line 34 of file ClanChannelHandler.java.

34 {
35 this.channel = channel;
36 }

References channel.

Member Function Documentation

◆ attemptConnection()

boolean com.runehive.content.clanchannel.channel.ClanChannelHandler.attemptConnection ( Player player,
ClanMember member )
package

Attempts a connection to the clan channel.

Definition at line 149 of file ClanChannelHandler.java.

149 {
150 if (member.rank.equals(ClanRank.MEMBER)) {
151 if (ProfileRepository.isFriend(player, channel.getOwner()))
152 member.rank = ClanRank.FRIEND;
153 if (PlayerRight.isDeveloper(player))
154 member.rank = ClanRank.SYSTEM;
155 }
156
157 if (!channel.canEnter(member)) {
158 player.send(new SendMessage("Connection was refused: No required permission!"));
159 return false;
160 }
161
162 if (channel.isLocked() && !channel.canManage(member)) {
163 player.send(new SendMessage("Connection was refused: Clan is currently locked!"));
164 return false;
165 }
166
167 return true;
168 }
ClanRank rank
The rank of the clan member.

References channel, com.runehive.content.clanchannel.ClanRank.FRIEND, com.runehive.game.world.entity.mob.player.PlayerRight.isDeveloper(), com.runehive.game.world.entity.mob.player.profile.ProfileRepository.isFriend(), com.runehive.content.clanchannel.ClanRank.MEMBER, com.runehive.content.clanchannel.ClanMember.rank, com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.content.clanchannel.ClanRank.SYSTEM.

Here is the call graph for this function:

◆ clean()

void com.runehive.content.clanchannel.channel.ClanChannelHandler.clean ( Player player)
static

Handles cleaning the clan tab itemcontainer.

Definition at line 288 of file ClanChannelHandler.java.

288 {
289 player.send(new SendString("Talking in: <col=F7DC6F>None", 33502));
290 for (int i = 0; i < 99; i += 4) {
291 player.send(new SendString("", 33531 + (i + 1)));
292 player.send(new SendString("", 33531 + (i + 2)));
293 player.send(new SendString("", 33531 + (i + 3)));
294 }
295 player.send(new SendScrollbar(33530, 11 * 22));
296 }

References com.runehive.game.world.entity.mob.player.Player.send().

Referenced by com.runehive.content.clanchannel.channel.ClanChannel.ban(), com.runehive.content.clanchannel.channel.ClanChannel.disconnect(), and onLogin().

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

◆ connect()

void com.runehive.content.clanchannel.channel.ClanChannelHandler.connect ( Player player,
String owner )
static

Handles player joining a clan channel.

Definition at line 53 of file ClanChannelHandler.java.

53 {
54 player.send(new SendMessage("Attempting to connect to clan..."));
55 ClanChannel channel = ClanRepository.getChannel(owner);
56 if (channel == null) {
57 boolean loaded = true;
58 Path path = Paths.get("./data/content/clan/");
59 File[] files = path.toFile().listFiles();
60
61 if (files == null) {
62 System.out.println("No clan files were found!");
63 player.message("Clan does not exist!");
64
65 if (owner.equalsIgnoreCase(player.getName())) {
66 ClanChannel.create(player);
67 }
68 return;
69 }
70
71 for (File file : files) {
72 if (file.getName().toLowerCase().contains(player.getUsername().toLowerCase().trim()) && file.length() > 0) {
73 loaded = false;
74 break;
75 }
76 }
77
78 if (owner.equalsIgnoreCase(player.getName())) {
79 if (!loaded) {
80 player.send(new SendMessage("Your clan didn't load into the server properly!"));
81 player.send(new SendMessage("If you see this message, your clan was not reset."));
82 player.message("Try to join your clan again. If you still see this message, contact a staff member.");
83 ClanChannel.load(player.getUsername().toLowerCase().trim());
84 return;
85 }
86 ClanChannel.create(player);
87 } else {
88 if (!loaded) {
89 player.send(new SendMessage("This clan didn't load into the server properly!"));
90 player.message("Try to join your clan again. If you still see this message, contact a staff member.");
91 ClanChannel.load(player.getUsername().toLowerCase().trim());
92 return;
93 }
94 player.send(new SendMessage("Connection was refused: No channel exists!"));
95 }
96 return;
97 }
98 if (!channel.getOwner().equals("osroyale") && channel.activeSize() >= 80) {
99 player.send(new SendMessage("Connection was refused: Channel currently full!"));
100 return;
101 }
102 if (channel.isBanned(player.getName())) {
103 player.send(new SendMessage("Connection was refused: Currently banned from channel!"));
104 return;
105 }
106 if (channel.getDetails().type == ClanType.IRON_MAN && !PlayerRight.isIronman(player)) {
107 player.message("Only Iron-man accounts can join this clan!");
108 return;
109 }
110 channel.connect(player);
111 }
void connect(Player player)
Handles a player connecting to the clan channel.
String getName()
Gets the name of this entity.
Definition Player.java:774
IRON_MAN
Clans that are focused on iron man accounts.
Definition ClanType.java:22

References channel, com.runehive.content.clanchannel.channel.ClanChannel.create(), com.runehive.content.clanchannel.ClanRepository.getChannel(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.player.Player.getUsername(), com.runehive.content.clanchannel.ClanType.IRON_MAN, com.runehive.game.world.entity.mob.player.PlayerRight.isIronman(), com.runehive.content.clanchannel.channel.ClanChannel.load(), com.runehive.game.world.entity.mob.player.Player.message(), and com.runehive.game.world.entity.mob.player.Player.send().

Referenced by onLogin().

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

◆ connected()

void com.runehive.content.clanchannel.channel.ClanChannelHandler.connected ( ClanMember member)
package

Handles connecting to the clan channel.

Definition at line 195 of file ClanChannelHandler.java.

195 {
196 updateMemberList(member);
197 member.player.ifPresent(player -> {
198 player.send(new SendMessage("Now talking in clan chat <col=FFFF64><shad=0>" + Utility.formatName(channel.getName()) + "</shad></col>."));
199 player.send(new SendMessage("To talk, start each line of chat with the / symbol."));
200 });
201 }
Optional< Player > player
The player instance of the clan member .

References channel, com.runehive.util.Utility.formatName(), com.runehive.content.clanchannel.ClanMember.player, and updateMemberList().

Here is the call graph for this function:

◆ disconnect()

boolean com.runehive.content.clanchannel.channel.ClanChannelHandler.disconnect ( Player player,
boolean logout )
static

Handles player joining a clan channel.

Definition at line 116 of file ClanChannelHandler.java.

116 {
117 if (player == null || player.clanChannel == null)
118 return false;
119 ClanChannel channel = player.clanChannel;
120 channel.disconnect(player.getName(), logout);
121 return true;
122 }
void disconnect(String name, boolean logout)
Handles disconnecting a player from the clan channel.

References channel, com.runehive.game.world.entity.mob.player.Player.clanChannel, and com.runehive.game.world.entity.mob.player.Player.getName().

Referenced by com.runehive.game.world.entity.mob.player.Player.unregister().

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

◆ manage()

void com.runehive.content.clanchannel.channel.ClanChannelHandler.manage ( Player player)
static

Definition at line 124 of file ClanChannelHandler.java.

124 {
125 ClanChannel channel = player.clanChannel;
126 Optional<ClanMember> member = channel.getMember(player.getName());
127 member.ifPresent(m -> {
128 if (!channel.canManage(m)) {
129 player.send(new SendMessage("You do not have sufficient privileges to manage this clan!"));
130 return;
131 }
132 player.send(new SendString(channel.getName(), 42102));
133 player.send(new SendString(channel.getTag(), 42104));
134 player.send(new SendString(channel.getSlogan(), 42106));
135 player.send(new SendString(channel.getPassword(), 42108));
136 player.send(new SendString(channel.getDetails().type.getIcon() + "" + channel.getDetails().type.getName(), 42110));
137 player.send(new SendString(channel.getManagement().getRank(ENTER_RANK_INDEX) + " " + channel.getManagement().getEnter(), 42112));
138 player.send(new SendString(channel.getManagement().getRank(TALK_RANK_INDEX) + " " + channel.getManagement().getTalk(), 42114));
139 player.send(new SendString(channel.getManagement().getRank(MANAGE_RANK_INDEX) + " " + channel.getManagement().getManage(), 42116));
140 player.send(new SendConfig(326, channel.getManagement().locked ? 1 : 0));
141 player.send(new SendItemOnInterface(42126, channel.getShowcaseItems()));
142 player.interfaceManager.setSidebar(Config.CLAN_TAB, 42000);
143 });
144 }
Optional< ClanMember > getMember(String name)

References channel, com.runehive.Config.CLAN_TAB, com.runehive.game.world.entity.mob.player.Player.clanChannel, com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.game.world.entity.mob.player.InterfaceManager.setSidebar().

Referenced by com.runehive.content.clanchannel.content.ClanShowcase.set(), and com.runehive.content.clanchannel.content.ClanViewer.update().

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

◆ manageMember()

void com.runehive.content.clanchannel.channel.ClanChannelHandler.manageMember ( Player player,
int button )
static

Definition at line 219 of file ClanChannelHandler.java.

219 {
220 ClanChannel channel = player.clanChannel;
221 if (channel == null)
222 return;
223 channel.getMember(player.getName()).ifPresent(member -> {
224 if (!channel.canManage(member))
225 return;
226
227 List<ClanMember> sorted = new ArrayList<>(channel.getActiveMembers());
228 sorted.sort(player.settings.clanMemberComporator);
229
230 int ordinal = ClanUtility.getRankOrdinal(button);
231 if (ordinal >= sorted.size())
232 return;
233
234 ClanMember other = sorted.get(ordinal);
235 if (other != null && !other.name.equalsIgnoreCase(player.getName()) && other.rank.lessThan(ClanRank.LEADER)) {
236 player.attributes.set("CLAN_RANK_MEMBER", other);
237 player.send(new SendString(other.name, 43606));
238 player.interfaceManager.open(43600);
239 }
240 });
241 }
final String name
The name of the clan member.
final GenericAttributes attributes
Definition Mob.java:95
void open(int identification)
Opens an interface for the player.
ClanMemberComporator clanMemberComporator
The clan sort type.
Definition Settings.java:56
public< K, E > void set(K key, E attribute)
Sets a generic attribute.

References com.runehive.game.world.entity.mob.Mob.attributes, channel, com.runehive.game.world.entity.mob.player.Player.clanChannel, com.runehive.game.world.entity.mob.player.Settings.clanMemberComporator, com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.content.clanchannel.ClanUtility.getRankOrdinal(), com.runehive.game.world.entity.mob.player.Player.interfaceManager, com.runehive.content.clanchannel.ClanRank.LEADER, com.runehive.content.clanchannel.ClanRank.lessThan(), com.runehive.content.clanchannel.ClanMember.name, com.runehive.game.world.entity.mob.player.InterfaceManager.open(), com.runehive.content.clanchannel.ClanMember.rank, com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.util.generic.GenericAttributes.set(), and com.runehive.game.world.entity.mob.player.Player.settings.

Here is the call graph for this function:

◆ onLogin()

void com.runehive.content.clanchannel.channel.ClanChannelHandler.onLogin ( Player player)
static

Handles logging into the server.

Definition at line 41 of file ClanChannelHandler.java.

41 {
42 clean(player);
43 if (player.clanChannel != null) {
44 String owner = player.clanChannel.getOwner();
45 player.clanChannel = null;
46 connect(player, owner);
47 }
48 }

References com.runehive.game.world.entity.mob.player.Player.clanChannel, clean(), connect(), and com.runehive.content.clanchannel.channel.ClanChannel.getOwner().

Referenced by com.runehive.game.world.entity.mob.player.PlayerAssistant.login().

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

◆ sendConnectionWarning()

void com.runehive.content.clanchannel.channel.ClanChannelHandler.sendConnectionWarning ( Player player,
ClanMember member )
package

The sends the connection warning for hopping clans.

Definition at line 206 of file ClanChannelHandler.java.

206 {
208 "-<col=FF0000>WARNING</col>-",
209 "Contributing to this clan or gaining a rank will remove",
210 "all of your progress from your current clan <col=FF4444>" + player.lastClan + "</col>.",
211 "Are you sure you want to join?")
212 .sendOption(
213 "Yes, I accept.",
214 () -> channel.add(player, member),
215 "No, I don't want to risk it.",
216 () -> player.clanChannel = null).execute();
217 }
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
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.

References channel, com.runehive.game.world.entity.mob.player.Player.clanChannel, com.runehive.game.world.entity.mob.player.Player.dialogueFactory, com.runehive.content.dialogue.DialogueFactory.execute(), com.runehive.game.world.entity.mob.player.Player.lastClan, com.runehive.content.dialogue.DialogueFactory.sendOption(), and com.runehive.content.dialogue.DialogueFactory.sendStatement().

Here is the call graph for this function:

◆ testPassword()

boolean com.runehive.content.clanchannel.channel.ClanChannelHandler.testPassword ( Player player,
ClanMember member )
package

Handles entering a clan channel password.

Definition at line 173 of file ClanChannelHandler.java.

173 {
174 if (!channel.hasPassword() || channel.canManage(member)) {
175 return false;
176 }
177
178 player.dialogueFactory.sendStatement("This clan requires a password in order to join.").onAction(() -> {
179 player.send(new SendInputMessage("Enter the password:", 6, input -> {
180 if (!channel.isPassword(input)) {
181 player.send(new SendMessage("You have entered an invalid clan password."));
182 player.dialogueFactory.clear();
183 return;
184 }
185 player.dialogueFactory.sendStatement("Password was accepted!").execute();
186 channel.establish(player, member);
187 }));
188 }).execute();
189 return true;
190 }
void clear()
Clears the current dialogue chain.
final DialogueFactory onAction(Runnable action)
Sets an action so this action can be executed after dialogues are done.

References channel, com.runehive.content.dialogue.DialogueFactory.clear(), com.runehive.game.world.entity.mob.player.Player.dialogueFactory, com.runehive.content.dialogue.DialogueFactory.execute(), com.runehive.content.dialogue.DialogueFactory.onAction(), com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.content.dialogue.DialogueFactory.sendStatement().

Here is the call graph for this function:

◆ updateMemberList()

void com.runehive.content.clanchannel.channel.ClanChannelHandler.updateMemberList ( ClanMember member)

Handles updating the clan channel member list.

Definition at line 246 of file ClanChannelHandler.java.

246 {
247 Player player = member.player.orElse(null);
248 if (player == null)
249 return;
250 int size = channel.size() < 10 ? 10 : channel.size();
251 player.send(new SendString("Talking in: <col=F7DC6F>" + Utility.formatName(channel.getName()), 33502));
252 player.send(new SendConfig(393, channel.lootshareEnabled() ? 1 : 0));
253 player.send(new SendScrollbar(33530, size * 22));
254
255
256 List<ClanMember> members = new LinkedList<>();
257 members.addAll(channel.getMembers());
258 members.sort(player.settings.clanMemberComporator);
259
260 Iterator<ClanMember> iterator = members.iterator();
261 boolean tooltip = channel.canManage(member);
262 int string = 33532;
263
264 for (int index = 0; index < size * 3; index++) {
265 ClanMember nextMember = null;
266 if (iterator.hasNext()) {
267 nextMember = iterator.next();
268 }
269 if (nextMember == null || (!nextMember.player.isPresent() && index / 3 >= members.size())) {
270 player.send(new SendString("", string++));
271 player.send(new SendString("", string));
272 player.send(new SendTooltip("", string++));
273 player.send(new SendString("", string++));
274 string++;
275 } else if (nextMember.player.isPresent()) {
276 player.send(new SendString(nextMember.rank.getString(), string++));
277 player.send(new SendString(nextMember.name, string));
278 player.send(new SendTooltip(tooltip ? (nextMember.name.equals(player.getName()) ? "" : "Manage " + nextMember.name) : "", string++));
279 player.send(new SendString("", string++));
280 string++;
281 }
282 }
283 }
val index

References channel, com.runehive.game.world.entity.mob.player.Settings.clanMemberComporator, com.runehive.util.Utility.formatName(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.content.clanchannel.ClanRank.getString(), com.runehive.content.clanchannel.ClanMember.name, com.runehive.content.clanchannel.ClanMember.player, com.runehive.content.clanchannel.ClanMember.rank, com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.game.world.entity.mob.player.Player.settings.

Referenced by connected(), and com.runehive.game.task.impl.ClanUpdateEvent.tick().

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

Member Data Documentation

◆ channel

final ClanChannel com.runehive.content.clanchannel.channel.ClanChannelHandler.channel
private

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