RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ClanUpdateEvent.java
1
package
com.osroyale.game.task.impl;
2
3
import
com.osroyale.content.clanchannel.ClanRepository;
4
import
com.osroyale.content.clanchannel.channel.ClanChannel;
5
import
com.osroyale.game.task.TickableTask;
6
import
com.osroyale.util.GsonUtils;
7
8
import
java.io.File;
9
import
java.io.FileWriter;
10
import
java.nio.file.Paths;
11
38
39
public
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
51
for
(
ClanChannel
channel :
ClanRepository
.
ACTIVE_CHANNELS
) {
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
}
com.osroyale.content.clanchannel.ClanRepository
Definition
ClanRepository.java:55
com.osroyale.content.clanchannel.ClanRepository.ACTIVE_CHANNELS
static Set< ClanChannel > ACTIVE_CHANNELS
Definition
ClanRepository.java:61
com.osroyale.content.clanchannel.channel.ClanChannelHandler.updateMemberList
void updateMemberList(ClanMember member)
Definition
ClanChannelHandler.java:282
com.osroyale.content.clanchannel.channel.ClanChannel
Definition
ClanChannel.java:71
com.osroyale.content.clanchannel.channel.ClanChannel.forEach
void forEach(Consumer< ClanMember > member)
Definition
ClanChannel.java:430
com.osroyale.util.GsonUtils
Definition
GsonUtils.java:25