RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.task.impl.ClanUpdateEvent Class Reference

An randomevent which handles updating clan chats. More...

Inheritance diagram for com.runehive.game.task.impl.ClanUpdateEvent:
Collaboration diagram for com.runehive.game.task.impl.ClanUpdateEvent:

Public Member Functions

 ClanUpdateEvent ()
Public Member Functions inherited from com.runehive.game.task.TickableTask
void execute ()
 A function representing the unit of work that will be carried out.
 TickableTask (boolean instant, int delay)
Public Member Functions inherited from com.runehive.game.task.Task
Task attach (Object newKey)
 Attaches a new key.
synchronized final void cancel ()
 Cancels all subsequent executions.
synchronized final void cancel (boolean logout)
 Cancels all subsequent executions.
boolean canRun ()
 Determines if the task can be ran.
Optional< Object > getAttachment ()
String getCreationStackTraceStr ()
int getDelay ()
Long getElapsedTimeFromRunStartTime ()
Optional< Long > getRunStartTime ()
long getTaskCreationTime ()
String getTaskId ()
boolean isInstant ()
boolean isRunning ()
void setDelay (int delay)
 Sets the cyclic delay.
void setExecutionTime ()
 Task (boolean instant, int delay)
 Creates a new Task.
 Task (int delay)
 Creates a new Task that doesn't execute instantly.

Protected Member Functions

void tick ()
Protected Member Functions inherited from com.runehive.game.task.Task
void baseExecute ()
boolean canSchedule ()
 A function executed on registration.
void onCancel (boolean logout)
 A function executed on cancellation.
void onSchedule ()
 A function executed on registration.

Additional Inherited Members

Package Functions inherited from com.runehive.game.task.Task
void onException (Exception e)
 A function executed on thrown exceptions.
void onLoop ()
 A function executed when iterated over.
final synchronized void process ()
synchronized void setRunning (boolean running)

Detailed Description

An randomevent which handles updating clan chats.

Author
Daniel | Obey

Definition at line 17 of file ClanUpdateEvent.java.

Constructor & Destructor Documentation

◆ ClanUpdateEvent()

com.runehive.game.task.impl.ClanUpdateEvent.ClanUpdateEvent ( )

Definition at line 19 of file ClanUpdateEvent.java.

19 {
20 super(false, 60);
21 }

Member Function Documentation

◆ tick()

void com.runehive.game.task.impl.ClanUpdateEvent.tick ( )
protected

Reimplemented from com.runehive.game.task.TickableTask.

Definition at line 24 of file ClanUpdateEvent.java.

24 {
25 if (ClanRepository.ACTIVE_CHANNELS.isEmpty()) {
26 return;
27 }
28
29 for (ClanChannel channel : ClanRepository.ACTIVE_CHANNELS) {
30 if (channel.activeSize() <= 0) {
31 continue;
32 }
33
34 channel.forEach(clanMember -> channel.getHandler().updateMemberList(clanMember));
35
36 Thread.startVirtualThread(() -> {
37 final File dir = Paths.get("data", "content", "clan").toFile();
38
39 if (!dir.exists()) {
40 dir.mkdirs();
41 }
42
43 try (FileWriter fw = new FileWriter(dir.toPath().resolve(channel.getOwner() + ".json").toFile())) {
44 fw.write(GsonUtils.JSON_PRETTY_NO_NULLS.get().toJson(channel.toJson()));
45 } catch (final Exception e) {
46 e.printStackTrace();
47 }
48 });
49
50 }
51 }

References com.runehive.content.clanchannel.ClanRepository.ACTIVE_CHANNELS, com.runehive.content.clanchannel.channel.ClanChannel.activeSize(), com.runehive.content.clanchannel.channel.ClanChannel.forEach(), com.runehive.content.clanchannel.channel.ClanChannel.getHandler(), com.runehive.content.clanchannel.channel.ClanChannel.getOwner(), com.runehive.util.GsonUtils.JSON_PRETTY_NO_NULLS, com.runehive.content.clanchannel.channel.ClanChannel.toJson(), and com.runehive.content.clanchannel.channel.ClanChannelHandler.updateMemberList().

Here is the call graph for this function:

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