58 private static Map<String, ClanChannel> CHANNELS =
new HashMap<>();
70 public static Set<ClanChannel>
ALLTIME =
new TreeSet<>();
73 private static Set<ClanChannel> TOP_PVP =
new TreeSet<>();
76 private static Set<ClanChannel> TOP_PVM =
new TreeSet<>();
79 private static Set<ClanChannel> TOP_SKILLING =
new TreeSet<>();
82 private static Set<ClanChannel> TOP_IRON_MAN =
new TreeSet<>();
86 return CHANNELS.get(channel.toLowerCase().trim());
91 CHANNELS.put(channel.getOwner().toLowerCase().trim(), channel);
96 CHANNELS.remove(channel.getOwner().toLowerCase().trim());
101 public static void setActive(
ClanChannel channel) {
105 public static void setInactive(ClanChannel channel) {
111 public static boolean nameExist(String name) {
112 return ACTIVE_TAGS.contains(name.toLowerCase().trim());
115 public static boolean tagExist(String tag) {
116 for (ClanChannel channel : CHANNELS.values()) {
117 if (channel.getTag().equalsIgnoreCase(tag))
123 public static void saveAllActiveClans() {
124 for (ClanChannel channel : ClanRepository.ACTIVE_CHANNELS) {
125 if (channel.activeSize() <= 0) {
132 private static void saveClan(ClanChannel channel) {
133 Thread.startVirtualThread(() -> {
134 final File dir = Paths.get(
"data",
"content",
"clan").toFile();
140 try (FileWriter fw =
new FileWriter(dir.toPath().resolve(channel.getOwner() +
".json").toFile())) {
141 fw.write(GsonUtils.JSON_PRETTY_NO_NULLS.get().toJson(channel.toJson()));
142 }
catch (
final Exception e) {
150 Path path = Paths.get(
"./data/content/clan/");
151 File[] files = path.toFile().listFiles();
154 System.out.println(
"No clan files were found.");
158 for (File file : files) {
159 String fileName = file.getName();
160 if (!fileName.toLowerCase().endsWith(
".json"))
continue;
171 ClanChannel.load(file.getName().replace(
".json",
""));
175 public static Optional<Set<ClanChannel>> getTopChanels(
ClanType type) {
177 return Optional.of(TOP_PVP);
179 if (type.equals(ClanType.PVM)) {
180 return Optional.of(TOP_PVM);
182 if (type.equals(ClanType.SKILLING)) {
183 return Optional.of(TOP_SKILLING);
185 if (type.equals(ClanType.IRON_MAN)) {
186 return Optional.of(TOP_IRON_MAN);
188 return Optional.empty();
191 public static Optional<Set<ClanChannel>> getTopChanels(ClanViewer.Filter filter) {
192 if (filter.equals(ClanViewer.Filter.ALL_TIME)) {
195 if (filter.equals(ClanViewer.Filter.TOP_PVM)) {
196 return Optional.of(TOP_PVM);
198 if (filter.equals(ClanViewer.Filter.TOP_PVP)) {
199 return Optional.of(TOP_PVP);
201 if (filter.equals(ClanViewer.Filter.TOP_SKILLING)) {
202 return Optional.of(TOP_SKILLING);
204 if (filter.equals(ClanViewer.Filter.TOP_IRON_MAN)) {
205 return Optional.of(TOP_IRON_MAN);
207 return Optional.empty();
static void removeChannel(ClanChannel channel)
static Set< String > ACTIVE_TAGS
static ClanChannel getChannel(String channel)
static Set< ClanChannel > ACTIVE_CHANNELS
static Set< ClanChannel > ALLTIME
static Set< String > ACTIVE_NAMES
static void addChannel(ClanChannel channel)