RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ClanUpdateEvent.java
1package com.osroyale.game.task.impl;
2
3import com.osroyale.content.clanchannel.ClanRepository;
4import com.osroyale.content.clanchannel.channel.ClanChannel;
5import com.osroyale.game.task.TickableTask;
6import com.osroyale.util.GsonUtils;
7
8import java.io.File;
9import java.io.FileWriter;
10import java.nio.file.Paths;
11
38
39public class ClanUpdateEvent extends TickableTask {
40
41 public ClanUpdateEvent() {
42 super(false, 60);
43 }
44
45 @Override
46 protected void tick() {
47 if (ClanRepository.ACTIVE_CHANNELS.isEmpty()) {
48 return;
49 }
50
52 if (channel.activeSize() <= 0) {
53 continue;
54 }
55
56 channel.forEach(clanMember -> channel.getHandler().updateMemberList(clanMember));
57
58 Thread.startVirtualThread(() -> {
59 final File dir = Paths.get("data", "content", "clan").toFile();
60
61 if (!dir.exists()) {
62 dir.mkdirs();
63 }
64
65 try (FileWriter fw = new FileWriter(dir.toPath().resolve(channel.getOwner() + ".json").toFile())) {
66 fw.write(GsonUtils.JSON_PRETTY_NO_NULLS.get().toJson(channel.toJson()));
67 } catch (final Exception e) {
68 e.printStackTrace();
69 }
70 });
71
72 }
73 }
74
75}
void forEach(Consumer< ClanMember > member)