Added configs for save interval, and garbage collection interval.

This commit is contained in:
CodeForFame 2011-06-21 18:43:31 -05:00
parent a0aa5d6cdd
commit 3ca4aa75f0
3 changed files with 14 additions and 3 deletions

View File

@ -32,6 +32,8 @@ public class Config {
public static String[] pmods, mods, admins; public static String[] pmods, mods, admins;
public static String UNUSED_IP; public static String UNUSED_IP;
public static int IP_BAN_REMOVAL_DELAY; public static int IP_BAN_REMOVAL_DELAY;
public static int GARBAGE_COLLECT_INTERVAL;
public static int SAVE_INTERVAL;
static { static {
loadEnv(); loadEnv();
@ -82,6 +84,9 @@ public class Config {
UNUSED_IP = props.getProperty("unused-ip"); UNUSED_IP = props.getProperty("unused-ip");
IP_BAN_REMOVAL_DELAY = Integer.parseInt(props.getProperty("ip-ban-removal-delay")); 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(); 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") + ")"; 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") + ")";

View File

@ -16,6 +16,7 @@ import java.util.GregorianCalendar;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.mina.common.IoSession; import org.apache.mina.common.IoSession;
import org.moparscape.msc.config.Config;
import org.moparscape.msc.config.Constants; import org.moparscape.msc.config.Constants;
import org.moparscape.msc.config.Formulae; import org.moparscape.msc.config.Formulae;
import org.moparscape.msc.gs.Instance; import org.moparscape.msc.gs.Instance;
@ -308,7 +309,7 @@ public final class GameEngine extends Thread {
} }
time = System.currentTimeMillis(); 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 // 50*2
// minutes // minutes
@Override @Override
@ -320,12 +321,12 @@ public final class GameEngine extends Thread {
}).start(); }).start();
} }
}); });
eventHandler.add(new DelayedEvent(null, 300000) { // 5 min eventHandler.add(new DelayedEvent(null, Config.SAVE_INTERVAL) { // 5 min
public void run() { public void run() {
world.dbKeepAlive(); world.dbKeepAlive();
long now = GameEngine.getTime(); long now = GameEngine.getTime();
for (Player p : world.getPlayers()) { for (Player p : world.getPlayers()) {
if (now - p.getLastSaveTime() >= 900000) { if (now - p.getLastSaveTime() >= Config.SAVE_INTERVAL) {
p.save(); p.save();
p.setLastSaveTime(now); p.setLastSaveTime(now);
} }

View File

@ -29,4 +29,9 @@
<!-- This only needs to be specified if you're using a Windows machine --> <!-- This only needs to be specified if you're using a Windows machine -->
<entry key="unused-ip">192.168.0.255</entry> <entry key="unused-ip">192.168.0.255</entry>
<entry key="ip-ban-removal-delay">1800000</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> </properties>