RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.task.impl.PlayerSaveEvent Class Reference
Inheritance diagram for com.runehive.game.task.impl.PlayerSaveEvent:
Collaboration diagram for com.runehive.game.task.impl.PlayerSaveEvent:

Public Member Functions

void execute ()
 A function representing the unit of work that will be carried out.
 PlayerSaveEvent ()
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.

Static Private Attributes

static final Logger logger = LogManager.getLogger(PlayerSaveEvent.class)

Additional Inherited Members

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.
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

Definition at line 11 of file PlayerSaveEvent.java.

Constructor & Destructor Documentation

◆ PlayerSaveEvent()

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

Definition at line 14 of file PlayerSaveEvent.java.

14 {
15 super(1000);
16 }

Member Function Documentation

◆ execute()

void com.runehive.game.task.impl.PlayerSaveEvent.execute ( )

A function representing the unit of work that will be carried out.

Reimplemented from com.runehive.game.task.Task.

Definition at line 19 of file PlayerSaveEvent.java.

19 {
20 if (World.update.get()) {
21 return;
22 }
23
24 int count = 0;
25 for (Player player : World.getPlayers()) {
26 if (player != null && !player.isBot) {
27 PlayerSerializer.save(player);
28 count++;
29 }
30 }
31
32 if (count != 0) {
33
34 if (count > 10) {
35 // DiscordPlugin.sendSimpleMessage("There are currently " + count + " players online!");
36 }
37
38 logger.info(count + " players were saved.");
39 ClanRepository.saveAllActiveClans();
40 }
41 }

References com.runehive.game.world.World.getPlayers(), logger, com.runehive.game.world.entity.mob.player.persist.PlayerSerializer.save(), com.runehive.content.clanchannel.ClanRepository.saveAllActiveClans(), and com.runehive.game.world.World.update.

Here is the call graph for this function:

Member Data Documentation

◆ logger

final Logger com.runehive.game.task.impl.PlayerSaveEvent.logger = LogManager.getLogger(PlayerSaveEvent.class)
staticprivate

Definition at line 12 of file PlayerSaveEvent.java.

Referenced by execute().


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