mirror of
https://github.com/moparisthebest/MoparClassic
synced 2025-02-28 08:21:52 -05:00
Added configs for save interval, and garbage collection interval.
This commit is contained in:
parent
a0aa5d6cdd
commit
3ca4aa75f0
@ -32,6 +32,8 @@ public class Config {
|
||||
public static String[] pmods, mods, admins;
|
||||
public static String UNUSED_IP;
|
||||
public static int IP_BAN_REMOVAL_DELAY;
|
||||
public static int GARBAGE_COLLECT_INTERVAL;
|
||||
public static int SAVE_INTERVAL;
|
||||
|
||||
static {
|
||||
loadEnv();
|
||||
@ -82,6 +84,9 @@ public class Config {
|
||||
UNUSED_IP = props.getProperty("unused-ip");
|
||||
IP_BAN_REMOVAL_DELAY = Integer.parseInt(props.getProperty("ip-ban-removal-delay"));
|
||||
|
||||
GARBAGE_COLLECT_INTERVAL = Integer.parseInt(props.getProperty("garbage-collect-interval"));
|
||||
SAVE_INTERVAL = Integer.parseInt(props.getProperty("save-interval"));
|
||||
|
||||
props.clear();
|
||||
|
||||
Constants.GameServer.MOTD = "@yel@Welcome to @whi@" + Config.SERVER_NAME + "@yel@ - World @whi@" + (Config.SERVER_NUM == 0 ? 2 : Config.SERVER_NUM) + " (" + (Config.members ? "P2P" : "F2P") + ")";
|
||||
|
@ -16,6 +16,7 @@ import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.mina.common.IoSession;
|
||||
import org.moparscape.msc.config.Config;
|
||||
import org.moparscape.msc.config.Constants;
|
||||
import org.moparscape.msc.config.Formulae;
|
||||
import org.moparscape.msc.gs.Instance;
|
||||
@ -308,7 +309,7 @@ public final class GameEngine extends Thread {
|
||||
}
|
||||
time = System.currentTimeMillis();
|
||||
|
||||
eventHandler.add(new DelayedEvent(null, 300000 * 10 * 2) { // Ran every
|
||||
eventHandler.add(new DelayedEvent(null, Config.GARBAGE_COLLECT_INTERVAL) { // Ran every
|
||||
// 50*2
|
||||
// minutes
|
||||
@Override
|
||||
@ -320,12 +321,12 @@ public final class GameEngine extends Thread {
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
eventHandler.add(new DelayedEvent(null, 300000) { // 5 min
|
||||
eventHandler.add(new DelayedEvent(null, Config.SAVE_INTERVAL) { // 5 min
|
||||
public void run() {
|
||||
world.dbKeepAlive();
|
||||
long now = GameEngine.getTime();
|
||||
for (Player p : world.getPlayers()) {
|
||||
if (now - p.getLastSaveTime() >= 900000) {
|
||||
if (now - p.getLastSaveTime() >= Config.SAVE_INTERVAL) {
|
||||
p.save();
|
||||
p.setLastSaveTime(now);
|
||||
}
|
||||
|
@ -29,4 +29,9 @@
|
||||
<!-- This only needs to be specified if you're using a Windows machine -->
|
||||
<entry key="unused-ip">192.168.0.255</entry>
|
||||
<entry key="ip-ban-removal-delay">1800000</entry>
|
||||
|
||||
<!-- Every 100 minutes -->
|
||||
<entry key="garbage-collect-interval">6000000</entry>
|
||||
<!-- Every 5 minutes -->
|
||||
<entry key="save-interval">300000</entry>
|
||||
</properties>
|
||||
|
Loading…
x
Reference in New Issue
Block a user