60public class ClanChannelHandler {
71 this.channel = channel;
79 if (player.clanChannel !=
null) {
80 String owner = player.clanChannel.getOwner();
81 player.clanChannel =
null;
90 player.send(
new SendMessage(
"Attempting to connect to clan..."));
92 if (channel ==
null) {
93 boolean loaded =
true;
94 Path path = Paths.get(
"./data/content/clan/");
95 File[] files = path.toFile().listFiles();
98 System.out.println(
"No clan files were found!");
99 player.message(
"Clan does not exist!");
101 if (owner.equalsIgnoreCase(player.
getName())) {
107 for (File file : files) {
108 if (file.getName().toLowerCase().contains(player.getUsername().toLowerCase().trim()) && file.length() > 0) {
114 if (owner.equalsIgnoreCase(player.
getName())) {
116 player.send(
new SendMessage(
"Your clan didn't load into the server properly!"));
117 player.send(
new SendMessage(
"If you see this message, your clan was not reset."));
118 player.message(
"Try to join your clan again. If you still see this message, contact a staff member.");
119 ClanChannel.load(player.getUsername().toLowerCase().trim());
125 player.send(
new SendMessage(
"This clan didn't load into the server properly!"));
126 player.message(
"Try to join your clan again. If you still see this message, contact a staff member.");
127 ClanChannel.load(player.getUsername().toLowerCase().trim());
130 player.send(
new SendMessage(
"Connection was refused: No channel exists!"));
134 if (!channel.getOwner().equals(
"Osroyale") && channel.activeSize() >= 80) {
135 player.send(
new SendMessage(
"Connection was refused: Channel currently full!"));
138 if (channel.isBanned(player.
getName())) {
139 player.send(
new SendMessage(
"Connection was refused: Currently banned from channel!"));
143 player.message(
"Only Iron-man accounts can join this clan!");
146 channel.connect(player);
153 if (player ==
null || player.clanChannel ==
null)
156 channel.disconnect(player.
getName(), logout);
160 public static void manage(
Player player) {
162 Optional<ClanMember> member = channel.getMember(player.
getName());
163 member.ifPresent(m -> {
164 if (!channel.canManage(m)) {
165 player.send(
new SendMessage(
"You do not have sufficient privileges to manage this clan!"));
168 player.send(
new SendString(channel.getName(), 42102));
169 player.send(
new SendString(channel.getTag(), 42104));
170 player.send(
new SendString(channel.getSlogan(), 42106));
171 player.send(
new SendString(channel.getPassword(), 42108));
172 player.send(
new SendString(channel.getDetails().type.getIcon() +
"" + channel.getDetails().type.getName(), 42110));
173 player.send(
new SendString(channel.getManagement().getRank(ENTER_RANK_INDEX) +
" " + channel.getManagement().getEnter(), 42112));
174 player.send(
new SendString(channel.getManagement().getRank(TALK_RANK_INDEX) +
" " + channel.getManagement().getTalk(), 42114));
175 player.send(
new SendString(channel.getManagement().getRank(MANAGE_RANK_INDEX) +
" " + channel.getManagement().getManage(), 42116));
176 player.send(
new SendConfig(326, channel.getManagement().locked ? 1 : 0));
178 player.interfaceManager.setSidebar(
Config.CLAN_TAB, 42000);
193 if (!channel.canEnter(member)) {
194 player.send(
new SendMessage(
"Connection was refused: No required permission!"));
198 if (channel.isLocked() && !channel.canManage(member)) {
199 player.send(
new SendMessage(
"Connection was refused: Clan is currently locked!"));
209 boolean testPassword(Player player, ClanMember member) {
210 if (!channel.hasPassword() || channel.canManage(member)) {
214 player.dialogueFactory.
sendStatement(
"This clan requires a password in order to join.").
onAction(() -> {
215 player.send(
new SendInputMessage(
"Enter the password:", 6, input -> {
216 if (!channel.isPassword(input)) {
217 player.send(
new SendMessage(
"You have entered an invalid clan password."));
218 player.dialogueFactory.
clear();
222 channel.establish(player, member);
231 void connected(ClanMember member) {
233 member.
player.ifPresent(player -> {
234 player.send(
new SendMessage(
"Now talking in clan chat <col=FFFF64><shad=0>" + Utility.formatName(channel.getName()) +
"</shad></col>."));
235 player.send(
new SendMessage(
"To talk, start each line of chat with the / symbol."));
242 void sendConnectionWarning(Player player, ClanMember member) {
244 "-<col=FF0000>WARNING</col>-",
245 "Contributing to this clan or gaining a rank will remove",
246 "all of your progress from your current clan <col=FF4444>" + player.lastClan +
"</col>.",
247 "Are you sure you want to join?")
250 () -> channel.add(player, member),
251 "No, I don't want to risk it.",
252 () -> player.clanChannel =
null).
execute();
255 public static void manageMember(Player player,
int button) {
256 ClanChannel channel = player.clanChannel;
259 channel.getMember(player.
getName()).ifPresent(member -> {
260 if (!channel.canManage(member))
263 List<ClanMember> sorted =
new ArrayList<>(channel.getActiveMembers());
266 int ordinal = ClanUtility.getRankOrdinal(button);
267 if (ordinal >= sorted.size())
270 ClanMember other = sorted.get(ordinal);
271 if (other !=
null && !other.
name.equalsIgnoreCase(player.
getName()) && other.
rank.lessThan(ClanRank.LEADER)) {
272 player.attributes.set(
"CLAN_RANK_MEMBER", other);
273 player.send(
new SendString(other.
name, 43606));
274 player.interfaceManager.
open(43600);
286 int size = channel.size() < 10 ? 10 : channel.size();
287 player.send(
new SendString(
"Talking in: <col=F7DC6F>" +
Utility.formatName(channel.getName()), 33502));
288 player.send(
new SendConfig(393, channel.lootshareEnabled() ? 1 : 0));
292 List<ClanMember> members =
new LinkedList<>();
293 members.addAll(channel.getMembers());
296 Iterator<ClanMember> iterator = members.iterator();
297 boolean tooltip = channel.canManage(member);
300 for (
int index = 0; index < size * 3; index++) {
302 if (iterator.hasNext()) {
303 nextMember = iterator.next();
305 if (nextMember ==
null || (!nextMember.
player.isPresent() && index / 3 >= members.size())) {
311 }
else if (nextMember.
player.isPresent()) {
312 player.send(
new SendString(nextMember.
rank.getString(),
string++));
314 player.send(
new SendTooltip(tooltip ? (nextMember.
name.equals(player.
getName()) ?
"" :
"Manage " + nextMember.
name) :
"",
string++));
325 player.send(
new SendString(
"Talking in: <col=F7DC6F>None", 33502));
326 for (
int i = 0; i < 99; i += 4) {
327 player.send(
new SendString(
"", 33531 + (i + 1)));
328 player.send(
new SendString(
"", 33531 + (i + 2)));
329 player.send(
new SendString(
"", 33531 + (i + 3)));
static ClanChannel getChannel(String channel)
static boolean disconnect(Player player, boolean logout)
static void connect(Player player, String owner)
final DialogueFactory sendStatement(String... lines)
final DialogueFactory sendOption(String option1, Runnable action1, String option2, Runnable action2)
final DialogueFactory onAction(Runnable action)