mirror of
https://github.com/moparisthebest/MoparClassic
synced 2024-12-21 23:18:52 -05:00
Re-wrote the 'CacheHandler' and made it generic, and made it actually work... (added the Apache Collections library)
Replaced non-time-critical currentTimeMillis with a call to GameEngine.getTime which is updated multiple times per server tick.
This commit is contained in:
parent
b84908fd0c
commit
be94d13fbe
@ -12,14 +12,14 @@
|
|||||||
<delete file="${jar}" />
|
<delete file="${jar}" />
|
||||||
<delete dir="${build}" />
|
<delete dir="${build}" />
|
||||||
<mkdir dir="${build}" />
|
<mkdir dir="${build}" />
|
||||||
<javac srcdir="${src}" destdir="${build}" debug="on" target="1.5">
|
<javac srcdir="${src}" destdir="${build}" debug="on" target="1.6">
|
||||||
<classpath>
|
<classpath>
|
||||||
<pathelement location="${lib}/mina.jar" />
|
<pathelement location="${lib}/mina.jar" />
|
||||||
<pathelement location="${lib}/xpp3.jar" />
|
<pathelement location="${lib}/xpp3.jar" />
|
||||||
<pathelement location="${lib}/slf4j.jar" />
|
<pathelement location="${lib}/slf4j.jar" />
|
||||||
<pathelement location="${lib}/pircbot.jar" />
|
<pathelement location="${lib}/pircbot.jar" />
|
||||||
<pathelement location="${lib}/bsh.jar" />
|
<pathelement location="${lib}/bsh.jar" />
|
||||||
|
<pathelement location="${lib}/commons-collections-3.2.1.jar" />
|
||||||
<pathelement location="${lib}/xstream.jar" />
|
<pathelement location="${lib}/xstream.jar" />
|
||||||
<pathelement location="${lib}/mysql-connector.jar" />
|
<pathelement location="${lib}/mysql-connector.jar" />
|
||||||
<pathelement location="${lib}/hex-string.jar" />
|
<pathelement location="${lib}/hex-string.jar" />
|
||||||
@ -47,6 +47,7 @@
|
|||||||
<pathelement location="${lib}/mina.jar" />
|
<pathelement location="${lib}/mina.jar" />
|
||||||
<pathelement location="${lib}/xpp3.jar" />
|
<pathelement location="${lib}/xpp3.jar" />
|
||||||
<pathelement location="${lib}/bsh.jar" />
|
<pathelement location="${lib}/bsh.jar" />
|
||||||
|
<pathelement location="${lib}/commons-collections-3.2.1.jar" />
|
||||||
<pathelement location="${lib}/pircbot.jar" />
|
<pathelement location="${lib}/pircbot.jar" />
|
||||||
<pathelement location="${lib}/slf4j.jar" />
|
<pathelement location="${lib}/slf4j.jar" />
|
||||||
<pathelement location="${lib}/xstream.jar" />
|
<pathelement location="${lib}/xstream.jar" />
|
||||||
|
Binary file not shown.
27
GameServer/src/org/moparscape/msc/gs/Cache.java
Normal file
27
GameServer/src/org/moparscape/msc/gs/Cache.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package org.moparscape.msc.gs;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.map.LRUMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A basic cache backed by a {@link LRUMap}.
|
||||||
|
*
|
||||||
|
* @author CodeForFame
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Cache<K, V> {
|
||||||
|
|
||||||
|
// Shitty commons and their failure to support generics...
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Map<K, V> cache = new LRUMap();
|
||||||
|
|
||||||
|
public V get(K key) {
|
||||||
|
return cache.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(K key, V value) {
|
||||||
|
cache.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,46 +0,0 @@
|
|||||||
package org.moparscape.msc.gs;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.moparscape.msc.gs.model.mini.Cache;
|
|
||||||
import org.moparscape.msc.gs.tools.DataConversions;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created to hold variables server-side to a player even when they log out.
|
|
||||||
* Needed for certain minor things that don't need SQL.
|
|
||||||
*
|
|
||||||
* @author xEnt
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CacheHandler {
|
|
||||||
|
|
||||||
public HashMap<Long, Cache> playerNames = new HashMap<Long, Cache>();
|
|
||||||
public static CacheHandler cache = null;
|
|
||||||
|
|
||||||
protected CacheHandler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CacheHandler getCache() {
|
|
||||||
if (cache == null)
|
|
||||||
cache = new CacheHandler();
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasData(String name) {
|
|
||||||
if (playerNames.get(DataConversions.usernameToHash(name)) != null)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cache getCache(String name) {
|
|
||||||
return playerNames.get(DataConversions.usernameToHash(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addCache(String name, Cache c) {
|
|
||||||
if (hasData(name))
|
|
||||||
playerNames.remove(DataConversions.usernameToHash(name));
|
|
||||||
playerNames.put(DataConversions.usernameToHash(name), c);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -31,10 +31,6 @@ public class Instance {
|
|||||||
return getWorld().getDelayedEventHandler();
|
return getWorld().getDelayedEventHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CacheHandler getCacheHandler() {
|
|
||||||
return CacheHandler.getCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PluginHandler getPluginHandler() {
|
public static PluginHandler getPluginHandler() {
|
||||||
return PluginHandler.getPluginHandler();
|
return PluginHandler.getPluginHandler();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.moparscape.msc.gs.Instance;
|
|||||||
import org.moparscape.msc.gs.builders.LSPacketBuilder;
|
import org.moparscape.msc.gs.builders.LSPacketBuilder;
|
||||||
import org.moparscape.msc.gs.connection.LSPacket;
|
import org.moparscape.msc.gs.connection.LSPacket;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.core.LoginConnector;
|
import org.moparscape.msc.gs.core.LoginConnector;
|
||||||
import org.moparscape.msc.gs.model.Player;
|
import org.moparscape.msc.gs.model.Player;
|
||||||
import org.moparscape.msc.gs.model.Point;
|
import org.moparscape.msc.gs.model.Point;
|
||||||
@ -186,7 +187,7 @@ public class MiscPacketBuilder {
|
|||||||
Point location = Point.location(p.readShort(), p
|
Point location = Point.location(p.readShort(), p
|
||||||
.readShort());
|
.readShort());
|
||||||
long loginDate = p.readLong();
|
long loginDate = p.readLong();
|
||||||
int lastMoved = (int) ((System.currentTimeMillis() - p
|
int lastMoved = (int) ((GameEngine.getTime() - p
|
||||||
.readLong()) / 1000);
|
.readLong()) / 1000);
|
||||||
boolean chatBlock = p.readByte() == 1;
|
boolean chatBlock = p.readByte() == 1;
|
||||||
int fatigue = p.readShort();
|
int fatigue = p.readShort();
|
||||||
@ -253,7 +254,7 @@ public class MiscPacketBuilder {
|
|||||||
s.addInt(x);
|
s.addInt(x);
|
||||||
s.addInt(y);
|
s.addInt(y);
|
||||||
s.addInt(type);
|
s.addInt(type);
|
||||||
s.addLong((System.currentTimeMillis() / 1000));
|
s.addLong((GameEngine.getTime() / 1000));
|
||||||
packets.add(s.toPacket());
|
packets.add(s.toPacket());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package org.moparscape.msc.gs.connection;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
import org.apache.mina.common.IoSession;
|
import org.apache.mina.common.IoSession;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.util.Logger;
|
import org.moparscape.msc.gs.util.Logger;
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ public class Packet {
|
|||||||
this.pData = pData;
|
this.pData = pData;
|
||||||
this.pLength = pData.length;
|
this.pLength = pData.length;
|
||||||
this.bare = bare;
|
this.bare = bare;
|
||||||
time = System.currentTimeMillis();
|
time = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -384,7 +384,7 @@ public final class ClientUpdater implements Processor {
|
|||||||
if (p.destroyed()) {
|
if (p.destroyed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = GameEngine.getTime();
|
||||||
if (curTime - p.getLastPing() >= 30000) {
|
if (curTime - p.getLastPing() >= 30000) {
|
||||||
p.destroy(false);
|
p.destroy(false);
|
||||||
} else if (p.warnedToMove()) {
|
} else if (p.warnedToMove()) {
|
||||||
|
@ -15,7 +15,6 @@ import java.util.Calendar;
|
|||||||
import java.util.GregorianCalendar;
|
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.Constants;
|
import org.moparscape.msc.config.Constants;
|
||||||
import org.moparscape.msc.config.Formulae;
|
import org.moparscape.msc.config.Formulae;
|
||||||
@ -40,7 +39,6 @@ import org.moparscape.msc.gs.tools.DataConversions;
|
|||||||
import org.moparscape.msc.gs.util.Logger;
|
import org.moparscape.msc.gs.util.Logger;
|
||||||
import org.moparscape.msc.gs.util.PersistenceManager;
|
import org.moparscape.msc.gs.util.PersistenceManager;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The central motor of the game. This class is responsible for the primary
|
* The central motor of the game. This class is responsible for the primary
|
||||||
* operation of the entire game.
|
* operation of the entire game.
|
||||||
@ -56,6 +54,7 @@ public final class GameEngine extends Thread {
|
|||||||
public static Captcha getCaptcha() {
|
public static Captcha getCaptcha() {
|
||||||
return captcha;
|
return captcha;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for updating all connected clients
|
* Responsible for updating all connected clients
|
||||||
*/
|
*/
|
||||||
@ -67,8 +66,8 @@ public final class GameEngine extends Thread {
|
|||||||
/**
|
/**
|
||||||
* When the update loop was last ran, required for throttle
|
* When the update loop was last ran, required for throttle
|
||||||
*/
|
*/
|
||||||
private long lastSentClientUpdate = System.currentTimeMillis();
|
private long lastSentClientUpdate = GameEngine.getTime();
|
||||||
private long lastSentClientUpdateFast = System.currentTimeMillis();
|
private long lastSentClientUpdateFast = GameEngine.getTime();
|
||||||
private long lastCleanedChatlogs = 0;
|
private long lastCleanedChatlogs = 0;
|
||||||
private int lastCleanedChatlogsOutput = 0;
|
private int lastCleanedChatlogsOutput = 0;
|
||||||
/**
|
/**
|
||||||
@ -83,11 +82,25 @@ public final class GameEngine extends Thread {
|
|||||||
* Whether the engine's thread is running
|
* Whether the engine's thread is running
|
||||||
*/
|
*/
|
||||||
private boolean running = true;
|
private boolean running = true;
|
||||||
long time = 0;
|
private static volatile long time = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this instead of System.currentTimeIllis, as each call does a system
|
||||||
|
* call, and potentially a hardware poll...<br>
|
||||||
|
* Also, you don't generally need the time to be updated more often than
|
||||||
|
* each part in the main loop.
|
||||||
|
*
|
||||||
|
* @return The current time.
|
||||||
|
*/
|
||||||
|
public static long getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes incoming packets.
|
* Processes incoming packets.
|
||||||
*/
|
*/
|
||||||
private Map<String, Integer> written = Collections.synchronizedMap(new HashMap<String, Integer>());
|
private Map<String, Integer> written = Collections
|
||||||
|
.synchronizedMap(new HashMap<String, Integer>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new game engine with an empty packet queue.
|
* Constructs a new game engine with an empty packet queue.
|
||||||
@ -108,7 +121,8 @@ public final class GameEngine extends Thread {
|
|||||||
p.save();
|
p.save();
|
||||||
p.getActionSender().sendLogout();
|
p.getActionSender().sendLogout();
|
||||||
}
|
}
|
||||||
Instance.getServer().getLoginConnector().getActionSender().saveProfiles();
|
Instance.getServer().getLoginConnector().getActionSender()
|
||||||
|
.saveProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,14 +144,13 @@ public final class GameEngine extends Thread {
|
|||||||
* counts.put(addr, 0); } else c = counts.get(addr) + 1; counts.put(addr,
|
* counts.put(addr, 0); } else c = counts.get(addr) + 1; counts.put(addr,
|
||||||
* c); } else { clients.put(addr, now); } } else { clients.put(addr, now); }
|
* c); } else { clients.put(addr, now); } } else { clients.put(addr, now); }
|
||||||
* }
|
* }
|
||||||
|
*
|
||||||
private InetAddress getAddress(IoSession io) {
|
* private InetAddress getAddress(IoSession io) { return
|
||||||
return ((InetSocketAddress) io.getRemoteAddress()).getAddress();
|
* ((InetSocketAddress) io.getRemoteAddress()).getAddress(); }
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Returns the current packet queue.
|
* Returns the current packet queue.
|
||||||
*
|
*
|
||||||
* @return A <code>PacketQueue</code>
|
* @return A <code>PacketQueue</code>
|
||||||
*/
|
*/
|
||||||
public PacketQueue<RSCPacket> getPacketQueue() {
|
public PacketQueue<RSCPacket> getPacketQueue() {
|
||||||
@ -153,7 +166,8 @@ public final class GameEngine extends Thread {
|
|||||||
* Loads the packet handling classes from the persistence manager.
|
* Loads the packet handling classes from the persistence manager.
|
||||||
*/
|
*/
|
||||||
protected void loadPacketHandlers() {
|
protected void loadPacketHandlers() {
|
||||||
PacketHandlerDef[] handlerDefs = (PacketHandlerDef[]) PersistenceManager.load("PacketHandlers.xml");
|
PacketHandlerDef[] handlerDefs = (PacketHandlerDef[]) PersistenceManager
|
||||||
|
.load("PacketHandlers.xml");
|
||||||
for (PacketHandlerDef handlerDef : handlerDefs) {
|
for (PacketHandlerDef handlerDef : handlerDefs) {
|
||||||
try {
|
try {
|
||||||
String className = handlerDef.getClassName();
|
String className = handlerDef.getClassName();
|
||||||
@ -169,19 +183,22 @@ public final class GameEngine extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processClients() {
|
private void processClients() {
|
||||||
clientUpdater.sendQueuedPackets();
|
clientUpdater.sendQueuedPackets();
|
||||||
long now = System.currentTimeMillis();
|
long now = GameEngine.getTime();
|
||||||
if (now - lastSentClientUpdate >= 600) {
|
if (now - lastSentClientUpdate >= 600) {
|
||||||
if (now - lastSentClientUpdate >= 1000) {
|
if (now - lastSentClientUpdate >= 1000) {
|
||||||
//Logger.println("MAJOR UPDATE DELAYED: " + (now - lastSentClientUpdate));
|
// Logger.println("MAJOR UPDATE DELAYED: " + (now -
|
||||||
|
// lastSentClientUpdate));
|
||||||
}
|
}
|
||||||
lastSentClientUpdate = now;
|
lastSentClientUpdate = now;
|
||||||
clientUpdater.doMajor();
|
clientUpdater.doMajor();
|
||||||
}
|
}
|
||||||
if (now - lastSentClientUpdateFast >= 104) {
|
if (now - lastSentClientUpdateFast >= 104) {
|
||||||
if (now - lastSentClientUpdateFast >= 6000) {
|
if (now - lastSentClientUpdateFast >= 6000) {
|
||||||
//Logger.println("MINOR UPDATE DELAYED: " + (now - lastSentClientUpdateFast));
|
// Logger.println("MINOR UPDATE DELAYED: " + (now -
|
||||||
|
// lastSentClientUpdateFast));
|
||||||
}
|
}
|
||||||
lastSentClientUpdateFast = now;
|
lastSentClientUpdateFast = now;
|
||||||
clientUpdater.doMinor();
|
clientUpdater.doMinor();
|
||||||
@ -191,34 +208,38 @@ public final class GameEngine extends Thread {
|
|||||||
private void processEvents() {
|
private void processEvents() {
|
||||||
eventHandler.doEvents();
|
eventHandler.doEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirects system err
|
* Redirects system err
|
||||||
*/
|
*/
|
||||||
public static void redirectSystemStreams() {
|
public static void redirectSystemStreams() {
|
||||||
OutputStream out = new OutputStream() {
|
OutputStream out = new OutputStream() {
|
||||||
@Override
|
@Override
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
String line = String.valueOf((char) b);
|
String line = String.valueOf((char) b);
|
||||||
Logger.systemerr(line);
|
Logger.systemerr(line);
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
@Override
|
||||||
String line = new String(b, off, len);
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
Logger.systemerr(line);
|
String line = new String(b, off, len);
|
||||||
}
|
Logger.systemerr(line);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void write(byte[] b) throws IOException {
|
@Override
|
||||||
write(b, 0, b.length);
|
public void write(byte[] b) throws IOException {
|
||||||
}
|
write(b, 0, b.length);
|
||||||
};
|
}
|
||||||
System.setErr(new PrintStream(out, true));
|
};
|
||||||
}
|
System.setErr(new PrintStream(out, true));
|
||||||
|
}
|
||||||
|
|
||||||
private void processIncomingPackets() {
|
private void processIncomingPackets() {
|
||||||
for (RSCPacket p : packetQueue.getPackets()) {
|
for (RSCPacket p : packetQueue.getPackets()) {
|
||||||
IoSession session = p.getSession();
|
IoSession session = p.getSession();
|
||||||
Player player = (Player) session.getAttachment();
|
Player player = (Player) session.getAttachment();
|
||||||
if (player.getUsername() == null && p.getID() != 32 && p.getID() != 77 && p.getID() != 0) {
|
if (player.getUsername() == null && p.getID() != 32
|
||||||
|
&& p.getID() != 77 && p.getID() != 0) {
|
||||||
final String ip = player.getCurrentIP();
|
final String ip = player.getCurrentIP();
|
||||||
// flagSession(session);
|
// flagSession(session);
|
||||||
if (!written.containsKey(ip)) {
|
if (!written.containsKey(ip)) {
|
||||||
@ -227,7 +248,8 @@ public final class GameEngine extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
written.remove(ip);
|
written.remove(ip);
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec("sudo /sbin/route delete " + ip);
|
Runtime.getRuntime().exec(
|
||||||
|
"sudo /sbin/route delete " + ip);
|
||||||
} catch (Exception err) {
|
} catch (Exception err) {
|
||||||
System.out.println(err);
|
System.out.println(err);
|
||||||
}
|
}
|
||||||
@ -239,7 +261,8 @@ public final class GameEngine extends Thread {
|
|||||||
} catch (Exception err) {
|
} catch (Exception err) {
|
||||||
System.out.println(err);
|
System.out.println(err);
|
||||||
}
|
}
|
||||||
Logger.println("Dummy packet from " + player.getCurrentIP() + ": " + p.getID());
|
Logger.println("Dummy packet from " + player.getCurrentIP()
|
||||||
|
+ ": " + p.getID());
|
||||||
written.put(ip, 1);
|
written.put(ip, 1);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -250,31 +273,37 @@ public final class GameEngine extends Thread {
|
|||||||
try {
|
try {
|
||||||
handler.handlePacket(p, session);
|
handler.handlePacket(p, session);
|
||||||
try {
|
try {
|
||||||
if(p.getID() != 5) {
|
if (p.getID() != 5) {
|
||||||
//String s = "[PACKET] " + session.getRemoteAddress().toString().replace("/", "") + " : " + p.getID()+ " ["+handler.getClass().toString()+"]" + " : "+ player.getUsername() + " : ";
|
// String s = "[PACKET] " +
|
||||||
//for(Byte b : p.getData())
|
// session.getRemoteAddress().toString().replace("/",
|
||||||
// s += b;
|
// "") + " : " + p.getID()+
|
||||||
//Logger.println(s);
|
// " ["+handler.getClass().toString()+"]" + " : "+
|
||||||
}
|
// player.getUsername() + " : ";
|
||||||
|
// for(Byte b : p.getData())
|
||||||
|
// s += b;
|
||||||
|
// Logger.println(s);
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String s;
|
String s;
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw, true);
|
PrintWriter pw = new PrintWriter(sw, true);
|
||||||
e.printStackTrace(pw);
|
e.printStackTrace(pw);
|
||||||
pw.flush();
|
pw.flush();
|
||||||
sw.flush();
|
sw.flush();
|
||||||
s = sw.toString();
|
s = sw.toString();
|
||||||
Logger.error("Exception with p[" + p.getID() + "] from " + player.getUsername() + " [" + player.getCurrentIP() + "]: " + s);
|
Logger.error("Exception with p[" + p.getID() + "] from "
|
||||||
|
+ player.getUsername() + " ["
|
||||||
|
+ player.getCurrentIP() + "]: " + s);
|
||||||
player.getActionSender().sendLogout();
|
player.getActionSender().sendLogout();
|
||||||
player.destroy(false);
|
player.destroy(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.error("Unhandled packet from " + player.getCurrentIP() + ": " + p.getID() + "len: " + p.getLength());
|
Logger.error("Unhandled packet from " + player.getCurrentIP()
|
||||||
|
+ ": " + p.getID() + "len: " + p.getLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,68 +330,81 @@ public final class GameEngine extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
|
|
||||||
eventHandler.add(new DelayedEvent(null, 300000*10*2) { // Ran every 50*2 minutes
|
eventHandler.add(new DelayedEvent(null, 300000 * 10 * 2) { // Ran every
|
||||||
@Override
|
// 50*2
|
||||||
public void run() {
|
// minutes
|
||||||
new Thread(new Runnable() {
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
garbageCollect();
|
new Thread(new Runnable() {
|
||||||
}
|
public void run() {
|
||||||
}).start();
|
garbageCollect();
|
||||||
}}
|
}
|
||||||
);
|
}).start();
|
||||||
eventHandler.add(new DelayedEvent(null, 300000) { // 5 min
|
|
||||||
public void run() {
|
|
||||||
world.dbKeepAlive();
|
|
||||||
Long now = System.currentTimeMillis();
|
|
||||||
for (Player p : world.getPlayers()) {
|
|
||||||
if (now - p.getLastSaveTime() >= 900000) {
|
|
||||||
p.save();
|
|
||||||
p.setLastSaveTime(now);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
Instance.getServer().getLoginConnector().getActionSender().saveProfiles();
|
eventHandler.add(new DelayedEvent(null, 300000) { // 5 min
|
||||||
}
|
public void run() {
|
||||||
});
|
world.dbKeepAlive();
|
||||||
|
long now = GameEngine.getTime();
|
||||||
|
for (Player p : world.getPlayers()) {
|
||||||
|
if (now - p.getLastSaveTime() >= 900000) {
|
||||||
|
p.save();
|
||||||
|
p.setLastSaveTime(now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Instance.getServer().getLoginConnector()
|
||||||
|
.getActionSender().saveProfiles();
|
||||||
|
}
|
||||||
|
});
|
||||||
while (running) {
|
while (running) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50);
|
Thread.sleep(50);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
}
|
}
|
||||||
Long AIDS = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
Long Delay;
|
long Delay;
|
||||||
processLoginServer();
|
processLoginServer();
|
||||||
Delay = System.currentTimeMillis() - AIDS;
|
Delay = System.currentTimeMillis() - time;
|
||||||
if(Delay >= 1000) Logger.println("processLoginServer is taking longer than it should, exactly " + Delay + "ms");
|
if (Delay >= 1000)
|
||||||
AIDS = System.currentTimeMillis();
|
Logger.println("processLoginServer is taking longer than it should, exactly "
|
||||||
|
+ Delay + "ms");
|
||||||
|
time = System.currentTimeMillis();
|
||||||
processIncomingPackets();
|
processIncomingPackets();
|
||||||
Delay = System.currentTimeMillis() - AIDS;
|
Delay = System.currentTimeMillis() - time;
|
||||||
if(Delay >= 1000) Logger.println("processIncomingPackets is taking longer than it should, exactly " + Delay + "ms");
|
if (Delay >= 1000)
|
||||||
AIDS = System.currentTimeMillis();
|
Logger.println("processIncomingPackets is taking longer than it should, exactly "
|
||||||
|
+ Delay + "ms");
|
||||||
|
time = System.currentTimeMillis();
|
||||||
processEvents();
|
processEvents();
|
||||||
Delay = System.currentTimeMillis() - AIDS;
|
Delay = System.currentTimeMillis() - time;
|
||||||
if(Delay >= 1000) Logger.println("processEvents is taking longer than it should, exactly " + Delay + "ms");
|
if (Delay >= 1000)
|
||||||
AIDS = System.currentTimeMillis();
|
Logger.println("processEvents is taking longer than it should, exactly "
|
||||||
|
+ Delay + "ms");
|
||||||
|
time = System.currentTimeMillis();
|
||||||
processClients();
|
processClients();
|
||||||
Delay = System.currentTimeMillis() - AIDS;
|
Delay = System.currentTimeMillis() - time;
|
||||||
if(Delay >= 1000) Logger.println("processClients is taking longer than it should, exactly " + Delay + "ms");
|
if (Delay >= 1000)
|
||||||
AIDS = System.currentTimeMillis();
|
Logger.println("processClients is taking longer than it should, exactly "
|
||||||
|
+ Delay + "ms");
|
||||||
|
time = System.currentTimeMillis();
|
||||||
cleanSnapshotDeque();
|
cleanSnapshotDeque();
|
||||||
Delay = System.currentTimeMillis() - AIDS;
|
Delay = System.currentTimeMillis() - time;
|
||||||
if(Delay >= 1000) Logger.println("processSnapshotDeque is taking longer than it should, exactly " + Delay + "ms");
|
if (Delay >= 1000)
|
||||||
|
Logger.println("processSnapshotDeque is taking longer than it should, exactly "
|
||||||
|
+ Delay + "ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans snapshots of entries over 60 seconds old (executed every second)
|
* Cleans snapshots of entries over 60 seconds old (executed every second)
|
||||||
*/
|
*/
|
||||||
public void cleanSnapshotDeque() {
|
public void cleanSnapshotDeque() {
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = GameEngine.getTime();
|
||||||
if (curTime - lastCleanedChatlogs > 1000) {
|
if (curTime - lastCleanedChatlogs > 1000) {
|
||||||
lastCleanedChatlogs = curTime;
|
lastCleanedChatlogs = curTime;
|
||||||
lastCleanedChatlogsOutput++;
|
lastCleanedChatlogsOutput++;
|
||||||
if(lastCleanedChatlogsOutput > 60*5) {
|
if (lastCleanedChatlogsOutput > 60 * 5) {
|
||||||
Logger.println("----------------------------------------------");
|
Logger.println("----------------------------------------------");
|
||||||
Logger.println(world.getSnapshots().size() + " items on deque");
|
Logger.println(world.getSnapshots().size() + " items on deque");
|
||||||
}
|
}
|
||||||
@ -373,25 +415,27 @@ public final class GameEngine extends Thread {
|
|||||||
if (curTime - s.getTimestamp() > 60000) {
|
if (curTime - s.getTimestamp() > 60000) {
|
||||||
i.remove();
|
i.remove();
|
||||||
s = null;
|
s = null;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
s = null;
|
s = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = null;
|
i = null;
|
||||||
if(lastCleanedChatlogsOutput > 60*5) {
|
if (lastCleanedChatlogsOutput > 60 * 5) {
|
||||||
Logger.println(world.getSnapshots().size() + " items on deque AFTER CLEANUP");
|
Logger.println(world.getSnapshots().size()
|
||||||
|
+ " items on deque AFTER CLEANUP");
|
||||||
Logger.println("----------------------------------------------");
|
Logger.println("----------------------------------------------");
|
||||||
lastCleanedChatlogsOutput = 0;
|
lastCleanedChatlogsOutput = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans garbage (Tilecleanup)
|
* Cleans garbage (Tilecleanup)
|
||||||
*/
|
*/
|
||||||
public synchronized void garbageCollect() {
|
public synchronized void garbageCollect() {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
int curMemory = (int) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000;
|
int curMemory = (int) (Runtime.getRuntime().totalMemory() - Runtime
|
||||||
|
.getRuntime().freeMemory()) / 1000;
|
||||||
int tileObjs = 0;
|
int tileObjs = 0;
|
||||||
int cleaned = 0;
|
int cleaned = 0;
|
||||||
for (int i = 0; i < Instance.getWorld().tiles.length; i++) {
|
for (int i = 0; i < Instance.getWorld().tiles.length; i++) {
|
||||||
@ -399,7 +443,8 @@ public final class GameEngine extends Thread {
|
|||||||
ActiveTile tile = Instance.getWorld().tiles[i][in];
|
ActiveTile tile = Instance.getWorld().tiles[i][in];
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
tileObjs++;
|
tileObjs++;
|
||||||
if (!tile.hasGameObject() && !tile.hasItems() && !tile.hasNpcs() && !tile.hasPlayers()) {
|
if (!tile.hasGameObject() && !tile.hasItems()
|
||||||
|
&& !tile.hasNpcs() && !tile.hasPlayers()) {
|
||||||
Instance.getWorld().tiles[i][in] = null;
|
Instance.getWorld().tiles[i][in] = null;
|
||||||
cleaned++;
|
cleaned++;
|
||||||
}
|
}
|
||||||
@ -407,9 +452,13 @@ public final class GameEngine extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Runtime.getRuntime().gc();
|
Runtime.getRuntime().gc();
|
||||||
int newMemory = (int) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000;
|
int newMemory = (int) (Runtime.getRuntime().totalMemory() - Runtime
|
||||||
|
.getRuntime().freeMemory()) / 1000;
|
||||||
Logger.println("GARBAGE COLLECT | Executing Memory Cleanup");
|
Logger.println("GARBAGE COLLECT | Executing Memory Cleanup");
|
||||||
Logger.println("GARBAGE COLLECT | Memory before: " + curMemory + "kb" + " Memory after: " + newMemory + " (Freed: " + (curMemory - newMemory) + "kb)");
|
Logger.println("GARBAGE COLLECT | Memory before: " + curMemory + "kb"
|
||||||
Logger.println("GARBAGE COLLECT | Cleanup took " + (System.currentTimeMillis() - startTime) + "ms");
|
+ " Memory after: " + newMemory + " (Freed: "
|
||||||
|
+ (curMemory - newMemory) + "kb)");
|
||||||
|
Logger.println("GARBAGE COLLECT | Cleanup took "
|
||||||
|
+ (System.currentTimeMillis() - startTime) + "ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.model.Player;
|
import org.moparscape.msc.gs.model.Player;
|
||||||
import org.moparscape.msc.gs.model.World;
|
import org.moparscape.msc.gs.model.World;
|
||||||
import org.moparscape.msc.gs.model.snapshot.Activity;
|
import org.moparscape.msc.gs.model.snapshot.Activity;
|
||||||
@ -44,7 +45,7 @@ public class ReportHandlerQueries {
|
|||||||
*/
|
*/
|
||||||
public synchronized void submitRepot(long from, long about, byte reason, Player from2) {
|
public synchronized void submitRepot(long from, long about, byte reason, Player from2) {
|
||||||
|
|
||||||
long time = System.currentTimeMillis()/1000;
|
long time = GameEngine.getTime()/1000;
|
||||||
String f = org.moparscape.msc.gs.tools.DataConversions.hashToUsername(from);
|
String f = org.moparscape.msc.gs.tools.DataConversions.hashToUsername(from);
|
||||||
String a = org.moparscape.msc.gs.tools.DataConversions.hashToUsername(about);
|
String a = org.moparscape.msc.gs.tools.DataConversions.hashToUsername(about);
|
||||||
|
|
||||||
@ -123,7 +124,7 @@ public class ReportHandlerQueries {
|
|||||||
insertNewDupeDataRow.setString(1, username);
|
insertNewDupeDataRow.setString(1, username);
|
||||||
insertNewDupeDataRow.setLong(2, hash);
|
insertNewDupeDataRow.setLong(2, hash);
|
||||||
insertNewDupeDataRow.setString(3, data.toString());
|
insertNewDupeDataRow.setString(3, data.toString());
|
||||||
insertNewDupeDataRow.setLong(4,System.currentTimeMillis());
|
insertNewDupeDataRow.setLong(4,GameEngine.getTime());
|
||||||
insertNewDupeDataRow.executeUpdate();
|
insertNewDupeDataRow.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -2,6 +2,7 @@ package org.moparscape.msc.gs.event;
|
|||||||
|
|
||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.core.DelayedEventHandler;
|
import org.moparscape.msc.gs.core.DelayedEventHandler;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.model.Player;
|
import org.moparscape.msc.gs.model.Player;
|
||||||
import org.moparscape.msc.gs.model.World;
|
import org.moparscape.msc.gs.model.World;
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ public abstract class DelayedEvent {
|
|||||||
public static final World world = Instance.getWorld();
|
public static final World world = Instance.getWorld();
|
||||||
protected int delay = 500;
|
protected int delay = 500;
|
||||||
protected final DelayedEventHandler handler = Instance.getWorld().getDelayedEventHandler();
|
protected final DelayedEventHandler handler = Instance.getWorld().getDelayedEventHandler();
|
||||||
private long lastRun = System.currentTimeMillis();
|
private long lastRun = GameEngine.getTime();
|
||||||
protected Player owner;
|
protected Player owner;
|
||||||
protected boolean matchRunning = true;
|
protected boolean matchRunning = true;
|
||||||
public Object[] args = null;
|
public Object[] args = null;
|
||||||
@ -65,7 +66,7 @@ public abstract class DelayedEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean shouldRun() {
|
public final boolean shouldRun() {
|
||||||
return matchRunning && System.currentTimeMillis() - lastRun >= delay;
|
return matchRunning && GameEngine.getTime() - lastRun >= delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void stop() {
|
public final void stop() {
|
||||||
@ -73,11 +74,11 @@ public abstract class DelayedEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int timeTillNextRun() {
|
public int timeTillNextRun() {
|
||||||
int time = (int) (delay - (System.currentTimeMillis() - lastRun));
|
int time = (int) (delay - (GameEngine.getTime() - lastRun));
|
||||||
return time < 0 ? 0 : time;
|
return time < 0 ? 0 : time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void updateLastRun() {
|
public final void updateLastRun() {
|
||||||
lastRun = System.currentTimeMillis();
|
lastRun = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
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;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.model.InvItem;
|
import org.moparscape.msc.gs.model.InvItem;
|
||||||
import org.moparscape.msc.gs.model.Item;
|
import org.moparscape.msc.gs.model.Item;
|
||||||
import org.moparscape.msc.gs.model.Mob;
|
import org.moparscape.msc.gs.model.Mob;
|
||||||
@ -184,8 +185,8 @@ public class RangeEvent extends DelayedEvent {
|
|||||||
p.informOfProjectile(projectile);
|
p.informOfProjectile(projectile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.currentTimeMillis() - affectedMob.lastTimeShot > 500) {
|
if (GameEngine.getTime() - affectedMob.lastTimeShot > 500) {
|
||||||
affectedMob.lastTimeShot = System.currentTimeMillis();
|
affectedMob.lastTimeShot = GameEngine.getTime();
|
||||||
affectedMob.setLastDamage(damage);
|
affectedMob.setLastDamage(damage);
|
||||||
int newHp = affectedMob.getHits() - damage;
|
int newHp = affectedMob.getHits() - damage;
|
||||||
affectedMob.setHits(newHp);
|
affectedMob.setHits(newHp);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.moparscape.msc.gs.event;
|
package org.moparscape.msc.gs.event;
|
||||||
|
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.external.NPCLoc;
|
import org.moparscape.msc.gs.external.NPCLoc;
|
||||||
import org.moparscape.msc.gs.model.Mob;
|
import org.moparscape.msc.gs.model.Mob;
|
||||||
import org.moparscape.msc.gs.model.Npc;
|
import org.moparscape.msc.gs.model.Npc;
|
||||||
@ -42,7 +43,7 @@ public abstract class WalkMobToMobEvent extends DelayedEvent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void arrived();
|
public abstract void arrived();
|
||||||
@ -65,7 +66,7 @@ public abstract class WalkMobToMobEvent extends DelayedEvent {
|
|||||||
else if (owner.hasMoved())
|
else if (owner.hasMoved())
|
||||||
return; // We're still moving
|
return; // We're still moving
|
||||||
else {
|
else {
|
||||||
if (System.currentTimeMillis() - startTime <= 10000) // Make NPCs
|
if (GameEngine.getTime() - startTime <= 10000) // Make NPCs
|
||||||
// give a 10
|
// give a 10
|
||||||
// second
|
// second
|
||||||
// chase
|
// chase
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.moparscape.msc.gs.model;
|
package org.moparscape.msc.gs.model;
|
||||||
|
|
||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.db.DBConnection;
|
import org.moparscape.msc.gs.db.DBConnection;
|
||||||
import org.moparscape.msc.gs.event.DelayedEvent;
|
import org.moparscape.msc.gs.event.DelayedEvent;
|
||||||
import org.moparscape.msc.gs.external.EntityHandler;
|
import org.moparscape.msc.gs.external.EntityHandler;
|
||||||
@ -48,7 +49,7 @@ public class Item extends Entity {
|
|||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
if (owner != null)
|
if (owner != null)
|
||||||
droppedby = owner.getUsernameHash();
|
droppedby = owner.getUsernameHash();
|
||||||
spawnedTime = System.currentTimeMillis();
|
spawnedTime = GameEngine.getTime();
|
||||||
setLocation(Point.location(x, y));
|
setLocation(Point.location(x, y));
|
||||||
if(amount > 10000000) {
|
if(amount > 10000000) {
|
||||||
String username;
|
String username;
|
||||||
@ -91,7 +92,7 @@ public class Item extends Entity {
|
|||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
setID(loc.id);
|
setID(loc.id);
|
||||||
setAmount(loc.amount);
|
setAmount(loc.amount);
|
||||||
spawnedTime = System.currentTimeMillis();
|
spawnedTime = GameEngine.getTime();
|
||||||
setLocation(Point.location(loc.x, loc.y));
|
setLocation(Point.location(loc.x, loc.y));
|
||||||
if(loc.amount > 10000000) {
|
if(loc.amount > 10000000) {
|
||||||
String username;
|
String username;
|
||||||
@ -178,6 +179,6 @@ public class Item extends Entity {
|
|||||||
}
|
}
|
||||||
if (!getDef().canTrade())
|
if (!getDef().canTrade())
|
||||||
return false;
|
return false;
|
||||||
return System.currentTimeMillis() - spawnedTime > 60000;
|
return GameEngine.getTime() - spawnedTime > 60000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.moparscape.msc.gs.model;
|
package org.moparscape.msc.gs.model;
|
||||||
|
|
||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.DelayedEvent;
|
import org.moparscape.msc.gs.event.DelayedEvent;
|
||||||
import org.moparscape.msc.gs.event.DuelEvent;
|
import org.moparscape.msc.gs.event.DuelEvent;
|
||||||
import org.moparscape.msc.gs.event.FightEvent;
|
import org.moparscape.msc.gs.event.FightEvent;
|
||||||
@ -53,8 +54,8 @@ public abstract class Mob extends Entity {
|
|||||||
/**
|
/**
|
||||||
* Time of last movement, used for timeout
|
* Time of last movement, used for timeout
|
||||||
*/
|
*/
|
||||||
protected long lastMovement = System.currentTimeMillis();
|
protected long lastMovement = GameEngine.getTime();
|
||||||
public long lastTimeShot = System.currentTimeMillis();
|
public long lastTimeShot = GameEngine.getTime();
|
||||||
protected int mobSprite = 1;
|
protected int mobSprite = 1;
|
||||||
private int[][] mobSprites = new int[][] { { 3, 2, 1 }, { 4, -1, 0 }, { 5, 6, 7 } };
|
private int[][] mobSprites = new int[][] { { 3, 2, 1 }, { 4, -1, 0 }, { 5, 6, 7 } };
|
||||||
/**
|
/**
|
||||||
@ -251,7 +252,7 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCombatTimer() {
|
public void setCombatTimer() {
|
||||||
combatTimer = System.currentTimeMillis();
|
combatTimer = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void setHits(int lvl);
|
public abstract void setHits(int lvl);
|
||||||
@ -261,7 +262,7 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLastMoved() {
|
public void setLastMoved() {
|
||||||
lastMovement = System.currentTimeMillis();
|
lastMovement = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(Point p) {
|
public void setLocation(Point p) {
|
||||||
|
@ -6,6 +6,7 @@ import java.util.ConcurrentModificationException;
|
|||||||
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;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.DelayedEvent;
|
import org.moparscape.msc.gs.event.DelayedEvent;
|
||||||
import org.moparscape.msc.gs.event.FightEvent;
|
import org.moparscape.msc.gs.event.FightEvent;
|
||||||
import org.moparscape.msc.gs.external.EntityHandler;
|
import org.moparscape.msc.gs.external.EntityHandler;
|
||||||
@ -315,7 +316,7 @@ public class Npc extends Mob {
|
|||||||
if (hasRan()) {
|
if (hasRan()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
long now = System.currentTimeMillis();
|
long now = GameEngine.getTime();
|
||||||
if (getChasing() != null) {
|
if (getChasing() != null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -534,7 +535,7 @@ public class Npc extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updatePosition() {
|
public void updatePosition() {
|
||||||
long now = System.currentTimeMillis();
|
long now = GameEngine.getTime();
|
||||||
Player victim = null;
|
Player victim = null;
|
||||||
if (!isBusy() && def.isAggressive() && now - getCombatTimer() > 3000 && (victim = findVictim()) != null) {
|
if (!isBusy() && def.isAggressive() && now - getCombatTimer() > 3000 && (victim = findVictim()) != null) {
|
||||||
resetPath();
|
resetPath();
|
||||||
|
@ -21,6 +21,7 @@ import org.moparscape.msc.gs.builders.MiscPacketBuilder;
|
|||||||
import org.moparscape.msc.gs.builders.ls.SavePacketBuilder;
|
import org.moparscape.msc.gs.builders.ls.SavePacketBuilder;
|
||||||
import org.moparscape.msc.gs.connection.LSPacket;
|
import org.moparscape.msc.gs.connection.LSPacket;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.db.DBConnection;
|
import org.moparscape.msc.gs.db.DBConnection;
|
||||||
import org.moparscape.msc.gs.event.DelayedEvent;
|
import org.moparscape.msc.gs.event.DelayedEvent;
|
||||||
import org.moparscape.msc.gs.event.MiniEvent;
|
import org.moparscape.msc.gs.event.MiniEvent;
|
||||||
@ -64,24 +65,24 @@ public final class Player extends Mob {
|
|||||||
private int lastwithdrawamount = 0;
|
private int lastwithdrawamount = 0;
|
||||||
|
|
||||||
public void setLastWithdrawTime(int itemid, int amount) {
|
public void setLastWithdrawTime(int itemid, int amount) {
|
||||||
this.lastwithdrawtime = System.currentTimeMillis();
|
this.lastwithdrawtime = GameEngine.getTime();
|
||||||
|
|
||||||
lastwithdrawitem = itemid;
|
lastwithdrawitem = itemid;
|
||||||
lastwithdrawamount = amount;
|
lastwithdrawamount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastDepositTime(int itemid, int amount) {
|
public void setLastDepositTime(int itemid, int amount) {
|
||||||
this.lastbanktime = System.currentTimeMillis();
|
this.lastbanktime = GameEngine.getTime();
|
||||||
|
|
||||||
lastdepositeditem = itemid;
|
lastdepositeditem = itemid;
|
||||||
lastdepositedamount = amount;
|
lastdepositedamount = amount;
|
||||||
}
|
}
|
||||||
public void setLastInvTime(int itemposition) {
|
public void setLastInvTime(int itemposition) {
|
||||||
this.lastinvtime = System.currentTimeMillis();
|
this.lastinvtime = GameEngine.getTime();
|
||||||
lastitemposition = itemposition;
|
lastitemposition = itemposition;
|
||||||
}
|
}
|
||||||
public boolean shouldThrowDepositError(int itemid, int amount) {
|
public boolean shouldThrowDepositError(int itemid, int amount) {
|
||||||
if(System.currentTimeMillis() - lastbanktime < 100 && lastdepositeditem == itemid && lastdepositedamount == amount)
|
if(GameEngine.getTime() - lastbanktime < 100 && lastdepositeditem == itemid && lastdepositedamount == amount)
|
||||||
return false;
|
return false;
|
||||||
if(amount == 0)
|
if(amount == 0)
|
||||||
return false;
|
return false;
|
||||||
@ -89,7 +90,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldThrowWithdrawError(int itemid, int amount) {
|
public boolean shouldThrowWithdrawError(int itemid, int amount) {
|
||||||
if(System.currentTimeMillis() - lastwithdrawtime < 100 && lastwithdrawitem == itemid && lastwithdrawamount == amount)
|
if(GameEngine.getTime() - lastwithdrawtime < 100 && lastwithdrawitem == itemid && lastwithdrawamount == amount)
|
||||||
return false;
|
return false;
|
||||||
if(amount == 0)
|
if(amount == 0)
|
||||||
return false;
|
return false;
|
||||||
@ -99,7 +100,7 @@ public final class Player extends Mob {
|
|||||||
private int lastitemposition = 0;
|
private int lastitemposition = 0;
|
||||||
|
|
||||||
public boolean shouldThrowInvError(int itemposition) {
|
public boolean shouldThrowInvError(int itemposition) {
|
||||||
if(System.currentTimeMillis() - lastinvtime < 100 && lastitemposition == itemposition)
|
if(GameEngine.getTime() - lastinvtime < 100 && lastitemposition == itemposition)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -113,7 +114,7 @@ public final class Player extends Mob {
|
|||||||
public boolean hasAdminPriv = false;
|
public boolean hasAdminPriv = false;
|
||||||
public boolean hasModPriv = false;
|
public boolean hasModPriv = false;
|
||||||
public boolean hasPmodPriv = false;
|
public boolean hasPmodPriv = false;
|
||||||
public long lastCommandUsed = System.currentTimeMillis();
|
public long lastCommandUsed = GameEngine.getTime();
|
||||||
/**
|
/**
|
||||||
* Has the first major update for this player been sent? If not, we can't
|
* Has the first major update for this player been sent? If not, we can't
|
||||||
* send them any minor updates.
|
* send them any minor updates.
|
||||||
@ -234,7 +235,7 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
public int tempy = -1;
|
public int tempy = -1;
|
||||||
public Npc lastNpcChasingYou = null;
|
public Npc lastNpcChasingYou = null;
|
||||||
public long lastNPCChat = System.currentTimeMillis();
|
public long lastNPCChat = GameEngine.getTime();
|
||||||
public boolean doricDependency = false;
|
public boolean doricDependency = false;
|
||||||
|
|
||||||
public boolean flagCarrier = false;
|
public boolean flagCarrier = false;
|
||||||
@ -249,13 +250,13 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
public void addInterval() {
|
public void addInterval() {
|
||||||
if (lastInterval == 0) {
|
if (lastInterval == 0) {
|
||||||
lastInterval = System.currentTimeMillis();
|
lastInterval = GameEngine.getTime();
|
||||||
} else {
|
} else {
|
||||||
intervals.addFirst(System.currentTimeMillis() - lastInterval);
|
intervals.addFirst(GameEngine.getTime() - lastInterval);
|
||||||
if (intervals.size() > 75) {
|
if (intervals.size() > 75) {
|
||||||
intervals.removeLast();
|
intervals.removeLast();
|
||||||
}
|
}
|
||||||
lastInterval = System.currentTimeMillis();
|
lastInterval = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +287,7 @@ public final class Player extends Mob {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isMuted() {
|
public boolean isMuted() {
|
||||||
return (muted - System.currentTimeMillis() > 0);
|
return (muted - GameEngine.getTime() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -295,7 +296,7 @@ public final class Player extends Mob {
|
|||||||
* @return day
|
* @return day
|
||||||
*/
|
*/
|
||||||
public int getDaysMuted() {
|
public int getDaysMuted() {
|
||||||
return (int) ((muted - System.currentTimeMillis()) / 1000 / 3600 / 24);
|
return (int) ((muted - GameEngine.getTime()) / 1000 / 3600 / 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -483,7 +484,7 @@ public final class Player extends Mob {
|
|||||||
* The last menu reply this player gave in a quest
|
* The last menu reply this player gave in a quest
|
||||||
*/
|
*/
|
||||||
//
|
//
|
||||||
public long lastCast = System.currentTimeMillis();
|
public long lastCast = GameEngine.getTime();
|
||||||
/**
|
/**
|
||||||
* Time of last charge spell
|
* Time of last charge spell
|
||||||
*/
|
*/
|
||||||
@ -492,7 +493,7 @@ public final class Player extends Mob {
|
|||||||
* Last packet count time
|
* Last packet count time
|
||||||
*/
|
*/
|
||||||
private long lastCount = 0;
|
private long lastCount = 0;
|
||||||
public long lastDeath = System.currentTimeMillis();
|
public long lastDeath = GameEngine.getTime();
|
||||||
/**
|
/**
|
||||||
* Stores the last IP address used
|
* Stores the last IP address used
|
||||||
*/
|
*/
|
||||||
@ -503,7 +504,7 @@ public final class Player extends Mob {
|
|||||||
private long lastLogin = 0;
|
private long lastLogin = 0;
|
||||||
// Player(IoSession
|
// Player(IoSession
|
||||||
public long lastMineTimer = 0;
|
public long lastMineTimer = 0;
|
||||||
public long lastPacketRecTime = System.currentTimeMillis() / 1000;
|
public long lastPacketRecTime = GameEngine.getTime() / 1000;
|
||||||
/**
|
/**
|
||||||
* Queue of last 100 packets, used for auto detection purposes
|
* Queue of last 100 packets, used for auto detection purposes
|
||||||
*/
|
*/
|
||||||
@ -512,20 +513,20 @@ public final class Player extends Mob {
|
|||||||
/**
|
/**
|
||||||
* Last time a 'ping' was received
|
* Last time a 'ping' was received
|
||||||
*/
|
*/
|
||||||
private long lastPing = System.currentTimeMillis();
|
private long lastPing = GameEngine.getTime();
|
||||||
public String lastPlayerInfo2 = null;
|
public String lastPlayerInfo2 = null;
|
||||||
private int lastQuestMenuReply = -1;
|
private int lastQuestMenuReply = -1;
|
||||||
// don't remove this. -xEnt
|
// don't remove this. -xEnt
|
||||||
public int lastRandom = 0;
|
public int lastRandom = 0;
|
||||||
public long lastRange = System.currentTimeMillis();
|
public long lastRange = GameEngine.getTime();
|
||||||
/**
|
/**
|
||||||
* Time last report was sent, used to throttle reports
|
* Time last report was sent, used to throttle reports
|
||||||
*/
|
*/
|
||||||
private long lastReport = 0;
|
private long lastReport = 0;
|
||||||
public long lastRun = System.currentTimeMillis(); // Leave this here
|
public long lastRun = GameEngine.getTime(); // Leave this here
|
||||||
private long lastSaveTime = System.currentTimeMillis()
|
private long lastSaveTime = GameEngine.getTime()
|
||||||
+ DataConversions.random(600000, 1800000);
|
+ DataConversions.random(600000, 1800000);
|
||||||
private long lastSleepTime = System.currentTimeMillis();
|
private long lastSleepTime = GameEngine.getTime();
|
||||||
/**
|
/**
|
||||||
* The time of the last spell cast, used as a throttle
|
* The time of the last spell cast, used as a throttle
|
||||||
*/
|
*/
|
||||||
@ -708,14 +709,14 @@ public final class Player extends Mob {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean infected = false;
|
public boolean infected = false;
|
||||||
public long lastInfected = System.currentTimeMillis();
|
public long lastInfected = GameEngine.getTime();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Informs the server that the player has just used Infected Blood and activate the cooldown.
|
* Informs the server that the player has just used Infected Blood and activate the cooldown.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setLastInfected() {
|
public void setLastInfected() {
|
||||||
lastInfected = System.currentTimeMillis();
|
lastInfected = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -750,7 +751,7 @@ public final class Player extends Mob {
|
|||||||
ioSession = ios;
|
ioSession = ios;
|
||||||
currentIP = ((InetSocketAddress) ios.getRemoteAddress()).getAddress()
|
currentIP = ((InetSocketAddress) ios.getRemoteAddress()).getAddress()
|
||||||
.getHostAddress();
|
.getHostAddress();
|
||||||
currentLogin = System.currentTimeMillis();
|
currentLogin = GameEngine.getTime();
|
||||||
actionSender = new MiscPacketBuilder(this);
|
actionSender = new MiscPacketBuilder(this);
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
Instance.getWorld();
|
Instance.getWorld();
|
||||||
@ -768,7 +769,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addAttackedBy(Player p) {
|
public void addAttackedBy(Player p) {
|
||||||
attackedBy.put(p.getUsernameHash(), System.currentTimeMillis());
|
attackedBy.put(p.getUsernameHash(), GameEngine.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFriend(long id, int world) {
|
public void addFriend(long id, int world) {
|
||||||
@ -787,7 +788,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPacket(RSCPacket p) {
|
public void addPacket(RSCPacket p) {
|
||||||
long now = System.currentTimeMillis();
|
long now = GameEngine.getTime();
|
||||||
if (now - lastCount > 3000) {
|
if (now - lastCount > 3000) {
|
||||||
lastCount = now;
|
lastCount = now;
|
||||||
packetCount = 0;
|
packetCount = 0;
|
||||||
@ -838,7 +839,7 @@ public final class Player extends Mob {
|
|||||||
super.setAppearnceChanged(true);
|
super.setAppearnceChanged(true);
|
||||||
}
|
}
|
||||||
skullEvent
|
skullEvent
|
||||||
.setLastRun(System.currentTimeMillis() - (1200000 - timeLeft));
|
.setLastRun(GameEngine.getTime() - (1200000 - timeLeft));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToDuelOffer(InvItem item) {
|
public void addToDuelOffer(InvItem item) {
|
||||||
@ -851,20 +852,20 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
public boolean canLogout() {
|
public boolean canLogout() {
|
||||||
if(this.location.inWilderness()) {
|
if(this.location.inWilderness()) {
|
||||||
if(System.currentTimeMillis() - this.getLastMoved() < 10000) {
|
if(GameEngine.getTime() - this.getLastMoved() < 10000) {
|
||||||
getActionSender().sendMessage("You must stand peacefully in one place for 10 seconds!");
|
getActionSender().sendMessage("You must stand peacefully in one place for 10 seconds!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !isBusy() && System.currentTimeMillis() - getCombatTimer() > 10000;
|
return !isBusy() && GameEngine.getTime() - getCombatTimer() > 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canReport() {
|
public boolean canReport() {
|
||||||
return System.currentTimeMillis() - lastReport > 60000;
|
return GameEngine.getTime() - lastReport > 60000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean castTimer() {
|
public boolean castTimer() {
|
||||||
return System.currentTimeMillis() - lastSpellCast > 1200;
|
return GameEngine.getTime() - lastSpellCast > 1200;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkAttack(Mob mob, boolean missile) {
|
public boolean checkAttack(Mob mob, boolean missile) {
|
||||||
@ -894,7 +895,7 @@ public final class Player extends Mob {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - mob.getCombatTimer() < (mob
|
if (GameEngine.getTime() - mob.getCombatTimer() < (mob
|
||||||
.getCombatState() == CombatState.RUNNING
|
.getCombatState() == CombatState.RUNNING
|
||||||
|| mob.getCombatState() == CombatState.WAITING ? 3000 : 500)
|
|| mob.getCombatState() == CombatState.WAITING ? 3000 : 500)
|
||||||
&& !mob.inCombat()) {
|
&& !mob.inCombat()) {
|
||||||
@ -978,11 +979,11 @@ public final class Player extends Mob {
|
|||||||
destroy = true;
|
destroy = true;
|
||||||
actionSender.sendLogout();
|
actionSender.sendLogout();
|
||||||
} else {
|
} else {
|
||||||
final long startDestroy = System.currentTimeMillis();
|
final long startDestroy = GameEngine.getTime();
|
||||||
Instance.getDelayedEventHandler().add(new DelayedEvent(this, 3000) {
|
Instance.getDelayedEventHandler().add(new DelayedEvent(this, 3000) {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (owner.canLogout() || (!(owner.inCombat() && owner.isDueling()) && System.currentTimeMillis() - startDestroy > 600000*2)) {
|
if (owner.canLogout() || (!(owner.inCombat() && owner.isDueling()) && GameEngine.getTime() - startDestroy > 600000*2)) {
|
||||||
owner.destroy(true);
|
owner.destroy(true);
|
||||||
matchRunning = false;
|
matchRunning = false;
|
||||||
}
|
}
|
||||||
@ -999,11 +1000,11 @@ public final class Player extends Mob {
|
|||||||
destroy = true;
|
destroy = true;
|
||||||
actionSender.sendLogout();
|
actionSender.sendLogout();
|
||||||
} else {
|
} else {
|
||||||
final long startDestroy = System.currentTimeMillis();
|
final long startDestroy = GameEngine.getTime();
|
||||||
Instance.getDelayedEventHandler().add(new DelayedEvent(this, 3000) {
|
Instance.getDelayedEventHandler().add(new DelayedEvent(this, 3000) {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (owner.canLogout() || (!(owner.inCombat() && owner.isDueling()) && System.currentTimeMillis() - startDestroy > 60000)) {
|
if (owner.canLogout() || (!(owner.inCombat() && owner.isDueling()) && GameEngine.getTime() - startDestroy > 60000)) {
|
||||||
owner.destroy(true);
|
owner.destroy(true);
|
||||||
matchRunning = false;
|
matchRunning = false;
|
||||||
}
|
}
|
||||||
@ -1115,7 +1116,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getDaysSubscriptionLeft() {
|
public int getDaysSubscriptionLeft() {
|
||||||
long now = (System.currentTimeMillis() / 1000);
|
long now = (GameEngine.getTime() / 1000);
|
||||||
if (subscriptionExpires == 0 || now >= subscriptionExpires) {
|
if (subscriptionExpires == 0 || now >= subscriptionExpires) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1379,8 +1380,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSpellWait() {
|
public int getSpellWait() {
|
||||||
return DataConversions.roundUp((double) (1200 - (System
|
return DataConversions.roundUp((double) (1200 - (GameEngine.getTime() - lastSpellCast)) / 1000D);
|
||||||
.currentTimeMillis() - lastSpellCast)) / 1000D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action getStatus() {
|
public Action getStatus() {
|
||||||
@ -1638,7 +1638,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCharged() {
|
public boolean isCharged() {
|
||||||
return System.currentTimeMillis() - lastCharge < 600000;
|
return GameEngine.getTime() - lastCharge < 600000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDuelConfirmAccepted() {
|
public boolean isDuelConfirmAccepted() {
|
||||||
@ -1806,7 +1806,7 @@ public final class Player extends Mob {
|
|||||||
opponent.resetCombat(CombatState.WON);
|
opponent.resetCombat(CombatState.WON);
|
||||||
}
|
}
|
||||||
actionSender.sendSound("death");
|
actionSender.sendSound("death");
|
||||||
lastDeath = System.currentTimeMillis();
|
lastDeath = GameEngine.getTime();
|
||||||
actionSender.sendDied();
|
actionSender.sendDied();
|
||||||
for (int i = 0; i < 18; i++) {
|
for (int i = 0; i < 18; i++) {
|
||||||
curStat[i] = maxStat[i];
|
curStat[i] = maxStat[i];
|
||||||
@ -1979,7 +1979,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ping() {
|
public void ping() {
|
||||||
lastPing = System.currentTimeMillis();
|
lastPing = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
@ -2215,7 +2215,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setArrowFired() {
|
public void setArrowFired() {
|
||||||
lastArrow = System.currentTimeMillis();
|
lastArrow = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBank(Bank b) {
|
public void setBank(Bank b) {
|
||||||
@ -2223,7 +2223,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCastTimer() {
|
public void setCastTimer() {
|
||||||
lastSpellCast = System.currentTimeMillis();
|
lastSpellCast = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChangingAppearance(boolean b) {
|
public void setChangingAppearance(boolean b) {
|
||||||
@ -2231,7 +2231,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCharged() {
|
public void setCharged() {
|
||||||
lastCharge = System.currentTimeMillis();
|
lastCharge = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClassName(String className) {
|
public void setClassName(String className) {
|
||||||
@ -2373,7 +2373,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLastReport() {
|
public void setLastReport() {
|
||||||
lastReport = System.currentTimeMillis();
|
lastReport = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastSaveTime(long save) {
|
public void setLastSaveTime(long save) {
|
||||||
@ -2386,7 +2386,7 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
public void setLoggedIn(boolean loggedIn) {
|
public void setLoggedIn(boolean loggedIn) {
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
currentLogin = System.currentTimeMillis();
|
currentLogin = GameEngine.getTime();
|
||||||
}
|
}
|
||||||
this.loggedIn = loggedIn;
|
this.loggedIn = loggedIn;
|
||||||
}
|
}
|
||||||
@ -2446,7 +2446,7 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
if (save) {
|
if (save) {
|
||||||
// save();
|
// save();
|
||||||
setLastSaveTime(System.currentTimeMillis());
|
setLastSaveTime(GameEngine.getTime());
|
||||||
getActionSender().sendQuestInfo();
|
getActionSender().sendQuestInfo();
|
||||||
getActionSender().sendMessage(
|
getActionSender().sendMessage(
|
||||||
"@gre@You just gained " + gained + " quest point"
|
"@gre@You just gained " + gained + " quest point"
|
||||||
@ -2530,7 +2530,7 @@ public final class Player extends Mob {
|
|||||||
|
|
||||||
public void setSkulledOn(Player player) {
|
public void setSkulledOn(Player player) {
|
||||||
player.addAttackedBy(this);
|
player.addAttackedBy(this);
|
||||||
if (System.currentTimeMillis() - lastAttackedBy(player) > 1200000) {
|
if (GameEngine.getTime() - lastAttackedBy(player) > 1200000) {
|
||||||
addSkull(1200000);
|
addSkull(1200000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2552,7 +2552,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSpellFail() {
|
public void setSpellFail() {
|
||||||
lastSpellCast = System.currentTimeMillis() + 20000;
|
lastSpellCast = GameEngine.getTime() + 20000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(Action a) {
|
public void setStatus(Action a) {
|
||||||
@ -2643,7 +2643,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean tradeDuelThrottling() {
|
public boolean tradeDuelThrottling() {
|
||||||
long now = System.currentTimeMillis();
|
long now = GameEngine.getTime();
|
||||||
if (now - lastTradeDuelRequest > 1000) {
|
if (now - lastTradeDuelRequest > 1000) {
|
||||||
lastTradeDuelRequest = now;
|
lastTradeDuelRequest = now;
|
||||||
return false;
|
return false;
|
||||||
|
@ -4,6 +4,7 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ConcurrentModificationException;
|
import java.util.ConcurrentModificationException;
|
||||||
|
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.external.EntityHandler;
|
import org.moparscape.msc.gs.external.EntityHandler;
|
||||||
import org.moparscape.msc.gs.util.Logger;
|
import org.moparscape.msc.gs.util.Logger;
|
||||||
|
|
||||||
@ -193,7 +194,7 @@ public class Script {
|
|||||||
*/
|
*/
|
||||||
public int PickOption(String[] strs) {
|
public int PickOption(String[] strs) {
|
||||||
try {
|
try {
|
||||||
long time = System.currentTimeMillis();
|
long time = GameEngine.getTime();
|
||||||
player.setBusy(false);
|
player.setBusy(false);
|
||||||
player.lastOption = -2;
|
player.lastOption = -2;
|
||||||
player.setMenuHandler(new MenuHandler(strs) {
|
player.setMenuHandler(new MenuHandler(strs) {
|
||||||
@ -208,7 +209,7 @@ public class Script {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
player.getActionSender().sendMenu(strs);
|
player.getActionSender().sendMenu(strs);
|
||||||
while (player.lastOption == -2 && System.currentTimeMillis() - time < 20000) { // timeout
|
while (player.lastOption == -2 && GameEngine.getTime() - time < 20000) { // timeout
|
||||||
Wait(25);
|
Wait(25);
|
||||||
}
|
}
|
||||||
if (player.lastOption == -1 || player.lastOption == -2) {
|
if (player.lastOption == -1 || player.lastOption == -2) {
|
||||||
|
@ -6,7 +6,7 @@ package org.moparscape.msc.gs.model.mini;
|
|||||||
* @author xEnt
|
* @author xEnt
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Cache {
|
public class CacheObject {
|
||||||
|
|
||||||
public boolean muted = false;
|
public boolean muted = false;
|
||||||
public boolean inRed = false;
|
public boolean inRed = false;
|
@ -1,5 +1,7 @@
|
|||||||
package org.moparscape.msc.gs.model.snapshot;
|
package org.moparscape.msc.gs.model.snapshot;
|
||||||
|
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Snapshot abstract class
|
* Snapshot abstract class
|
||||||
@ -13,7 +15,7 @@ public abstract class Snapshot {
|
|||||||
|
|
||||||
public Snapshot(String owner) {
|
public Snapshot(String owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.eventTime = System.currentTimeMillis();
|
this.eventTime = GameEngine.getTime();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import org.moparscape.msc.config.Formulae;
|
|||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.FightEvent;
|
import org.moparscape.msc.gs.event.FightEvent;
|
||||||
import org.moparscape.msc.gs.event.RangeEvent;
|
import org.moparscape.msc.gs.event.RangeEvent;
|
||||||
import org.moparscape.msc.gs.event.WalkToMobEvent;
|
import org.moparscape.msc.gs.event.WalkToMobEvent;
|
||||||
@ -76,7 +77,7 @@ public class AttackHandler implements PacketHandler {
|
|||||||
if (affectedMob instanceof Player) {
|
if (affectedMob instanceof Player) {
|
||||||
Player opp = (Player) affectedMob;
|
Player opp = (Player) affectedMob;
|
||||||
|
|
||||||
if (System.currentTimeMillis() - opp.lastMineTimer < 2000 && opp.isBusy())
|
if (GameEngine.getTime() - opp.lastMineTimer < 2000 && opp.isBusy())
|
||||||
cont = true;
|
cont = true;
|
||||||
}
|
}
|
||||||
if(affectedMob instanceof Player) {
|
if(affectedMob instanceof Player) {
|
||||||
|
@ -13,6 +13,7 @@ import org.moparscape.msc.gs.Instance;
|
|||||||
import org.moparscape.msc.gs.builders.ls.MiscPacketBuilder;
|
import org.moparscape.msc.gs.builders.ls.MiscPacketBuilder;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.core.ClientUpdater;
|
import org.moparscape.msc.gs.core.ClientUpdater;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.db.DBConnection;
|
import org.moparscape.msc.gs.db.DBConnection;
|
||||||
import org.moparscape.msc.gs.event.MiniEvent;
|
import org.moparscape.msc.gs.event.MiniEvent;
|
||||||
import org.moparscape.msc.gs.event.SingleEvent;
|
import org.moparscape.msc.gs.event.SingleEvent;
|
||||||
@ -45,14 +46,14 @@ public class CommandHandler implements PacketHandler {
|
|||||||
public void handleCommand(String cmd, String[] args, Player player) throws Exception {
|
public void handleCommand(String cmd, String[] args, Player player) throws Exception {
|
||||||
MiscPacketBuilder loginServer = Instance.getServer().getLoginConnector().getActionSender();
|
MiscPacketBuilder loginServer = Instance.getServer().getLoginConnector().getActionSender();
|
||||||
|
|
||||||
if(System.currentTimeMillis() - player.lastCommandUsed < 2000 && !player.isMod()) {
|
if(GameEngine.getTime() - player.lastCommandUsed < 2000 && !player.isMod()) {
|
||||||
if(System.currentTimeMillis() - player.lastCommandUsed < 100) { // incase spammers
|
if(GameEngine.getTime() - player.lastCommandUsed < 100) { // incase spammers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.getActionSender().sendMessage("2 second delay on using a new command");
|
player.getActionSender().sendMessage("2 second delay on using a new command");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.lastCommandUsed = System.currentTimeMillis();
|
player.lastCommandUsed = GameEngine.getTime();
|
||||||
if (cmd.equals("help")) {
|
if (cmd.equals("help")) {
|
||||||
player.getActionSender().sendAlert("List of commands are shown on forums!", true);
|
player.getActionSender().sendAlert("List of commands are shown on forums!", true);
|
||||||
return;
|
return;
|
||||||
@ -89,20 +90,20 @@ public class CommandHandler implements PacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.equals("stuck")) {
|
if (cmd.equals("stuck")) {
|
||||||
if (System.currentTimeMillis() - player.getCurrentLogin() < 30000) {
|
if (GameEngine.getTime() - player.getCurrentLogin() < 30000) {
|
||||||
player.getActionSender().sendMessage("You cannot do this after you have recently logged in");
|
player.getActionSender().sendMessage("You cannot do this after you have recently logged in");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!player.canLogout() || System.currentTimeMillis() - player.getLastMoved() < 10000) {
|
if(!player.canLogout() || GameEngine.getTime() - player.getLastMoved() < 10000) {
|
||||||
player.getActionSender().sendMessage("You must stand peacefully in one place for 10 seconds!");
|
player.getActionSender().sendMessage("You must stand peacefully in one place for 10 seconds!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.getLocation().inModRoom() && !player.isMod()) {
|
if (player.getLocation().inModRoom() && !player.isMod()) {
|
||||||
player.getActionSender().sendMessage("You cannot use ::stuck here");
|
player.getActionSender().sendMessage("You cannot use ::stuck here");
|
||||||
} else if (!player.isMod() && System.currentTimeMillis() - player.getLastMoved() < 300000 && System.currentTimeMillis() - player.getCastTimer() < 300000) {
|
} else if (!player.isMod() && GameEngine.getTime() - player.getLastMoved() < 300000 && GameEngine.getTime() - player.getCastTimer() < 300000) {
|
||||||
player.getActionSender().sendMessage("There is a 5 minute delay on using ::stuck, please stand still for 5 minutes.");
|
player.getActionSender().sendMessage("There is a 5 minute delay on using ::stuck, please stand still for 5 minutes.");
|
||||||
player.getActionSender().sendMessage("This command is logged ONLY use it when you are REALLY stuck.");
|
player.getActionSender().sendMessage("This command is logged ONLY use it when you are REALLY stuck.");
|
||||||
} else if (!player.inCombat() && System.currentTimeMillis() - player.getCombatTimer() > 300000 || player.isMod()) {
|
} else if (!player.inCombat() && GameEngine.getTime() - player.getCombatTimer() > 300000 || player.isMod()) {
|
||||||
Logger.mod(player.getUsername() + " used stuck at " + player.getX() + ":" + player.getY());
|
Logger.mod(player.getUsername() + " used stuck at " + player.getX() + ":" + player.getY());
|
||||||
player.setCastTimer();
|
player.setCastTimer();
|
||||||
player.teleport(122, 647, true);
|
player.teleport(122, 647, true);
|
||||||
|
@ -5,6 +5,7 @@ import org.moparscape.msc.config.Formulae;
|
|||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.DuelEvent;
|
import org.moparscape.msc.gs.event.DuelEvent;
|
||||||
import org.moparscape.msc.gs.event.SingleEvent;
|
import org.moparscape.msc.gs.event.SingleEvent;
|
||||||
import org.moparscape.msc.gs.event.WalkToMobEvent;
|
import org.moparscape.msc.gs.event.WalkToMobEvent;
|
||||||
@ -246,7 +247,7 @@ public class DuelHandler implements PacketHandler {
|
|||||||
affectedPlayer.setBusy(false);
|
affectedPlayer.setBusy(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
walking.setLastRun(System.currentTimeMillis() + 500);
|
walking.setLastRun(GameEngine.getTime() + 500);
|
||||||
Instance.getDelayedEventHandler().add(walking);
|
Instance.getDelayedEventHandler().add(walking);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3,6 +3,7 @@ package org.moparscape.msc.gs.phandler.client;
|
|||||||
import org.apache.mina.common.IoSession;
|
import org.apache.mina.common.IoSession;
|
||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.model.Player;
|
import org.moparscape.msc.gs.model.Player;
|
||||||
import org.moparscape.msc.gs.model.World;
|
import org.moparscape.msc.gs.model.World;
|
||||||
import org.moparscape.msc.gs.model.snapshot.Activity;
|
import org.moparscape.msc.gs.model.snapshot.Activity;
|
||||||
@ -26,7 +27,7 @@ public class FollowRequest implements PacketHandler {
|
|||||||
player.resetPath();
|
player.resetPath();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - player.lastRun < 3000)
|
if (GameEngine.getTime() - player.lastRun < 3000)
|
||||||
return;
|
return;
|
||||||
player.resetAll();
|
player.resetAll();
|
||||||
player.setFollowing(affectedPlayer, 1);
|
player.setFollowing(affectedPlayer, 1);
|
||||||
|
@ -5,6 +5,7 @@ import org.moparscape.msc.config.Constants;
|
|||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.Server;
|
import org.moparscape.msc.gs.Server;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.DelayedEvent;
|
import org.moparscape.msc.gs.event.DelayedEvent;
|
||||||
import org.moparscape.msc.gs.event.MiniEvent;
|
import org.moparscape.msc.gs.event.MiniEvent;
|
||||||
import org.moparscape.msc.gs.event.SingleEvent;
|
import org.moparscape.msc.gs.event.SingleEvent;
|
||||||
@ -174,7 +175,7 @@ public class InvActionHandler implements PacketHandler {
|
|||||||
} else if (item.getDef().getCommand().equalsIgnoreCase("open")) {
|
} else if (item.getDef().getCommand().equalsIgnoreCase("open")) {
|
||||||
if(item.getID() == INFECTED_BLOOD) {
|
if(item.getID() == INFECTED_BLOOD) {
|
||||||
if(!player.isInfected()) { player.setInfected(); return; }
|
if(!player.isInfected()) { player.setInfected(); return; }
|
||||||
long lastUsed = System.currentTimeMillis() - player.lastInfected();
|
long lastUsed = GameEngine.getTime() - player.lastInfected();
|
||||||
long remaining = 5 - lastUsed / 1000;
|
long remaining = 5 - lastUsed / 1000;
|
||||||
InvItem INFECTED_BLOOD_I = new InvItem(1322, 1);
|
InvItem INFECTED_BLOOD_I = new InvItem(1322, 1);
|
||||||
if(lastUsed / 1000 <= 5) { player.getActionSender().sendMessage("You have to wait " + remaining + " seconds before using that again."); return; }
|
if(lastUsed / 1000 <= 5) { player.getActionSender().sendMessage("You have to wait " + remaining + " seconds before using that again."); return; }
|
||||||
|
@ -8,6 +8,7 @@ import org.moparscape.msc.gs.Instance;
|
|||||||
import org.moparscape.msc.gs.Server;
|
import org.moparscape.msc.gs.Server;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.MiniEvent;
|
import org.moparscape.msc.gs.event.MiniEvent;
|
||||||
import org.moparscape.msc.gs.event.ShortEvent;
|
import org.moparscape.msc.gs.event.ShortEvent;
|
||||||
import org.moparscape.msc.gs.event.WalkToObjectEvent;
|
import org.moparscape.msc.gs.event.WalkToObjectEvent;
|
||||||
@ -466,9 +467,9 @@ public class InvUseOnObject implements PacketHandler {
|
|||||||
if (i.getID() == 517 && i.getAmount() > 20) {
|
if (i.getID() == 517 && i.getAmount() > 20) {
|
||||||
i = new InvItem(517, DataConversions.random(0, 20) + 1);
|
i = new InvItem(517, DataConversions.random(0, 20) + 1);
|
||||||
}
|
}
|
||||||
Logger.println("Player: " + owner.getUsername() + " Got item: " + i.getID() + " From CHEST (" + i.getAmount() + ") sys time (" + System.currentTimeMillis() + ")");
|
Logger.println("Player: " + owner.getUsername() + " Got item: " + i.getID() + " From CHEST (" + i.getAmount() + ") sys time (" + GameEngine.getTime() + ")");
|
||||||
if (i.getAmount() > 4000) {
|
if (i.getAmount() > 4000) {
|
||||||
Logger.println("WARNING!!!! Player: " + owner.getUsername() + " was about to get " + i.getAmount() + " of " + i.getID() + " from the CHEST sys time (" + System.currentTimeMillis() + ")");
|
Logger.println("WARNING!!!! Player: " + owner.getUsername() + " was about to get " + i.getAmount() + " of " + i.getID() + " from the CHEST sys time (" + GameEngine.getTime() + ")");
|
||||||
owner.setBusy(false);
|
owner.setBusy(false);
|
||||||
owner.getActionSender().sendInventory();
|
owner.getActionSender().sendInventory();
|
||||||
return;
|
return;
|
||||||
|
@ -3,6 +3,7 @@ package org.moparscape.msc.gs.phandler.client;
|
|||||||
import org.apache.mina.common.IoSession;
|
import org.apache.mina.common.IoSession;
|
||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.ShortEvent;
|
import org.moparscape.msc.gs.event.ShortEvent;
|
||||||
import org.moparscape.msc.gs.event.WalkToMobEvent;
|
import org.moparscape.msc.gs.event.WalkToMobEvent;
|
||||||
import org.moparscape.msc.gs.model.Bubble;
|
import org.moparscape.msc.gs.model.Bubble;
|
||||||
@ -33,7 +34,7 @@ public class InvUseOnPlayer implements PacketHandler {
|
|||||||
if (affectedPlayer == null || item == null) { // This shouldn't happen
|
if (affectedPlayer == null || item == null) { // This shouldn't happen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - affectedPlayer.lastRun < 2000) {
|
if (GameEngine.getTime() - affectedPlayer.lastRun < 2000) {
|
||||||
player.resetPath();
|
player.resetPath();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.moparscape.msc.gs.Instance;
|
|||||||
import org.moparscape.msc.gs.Server;
|
import org.moparscape.msc.gs.Server;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.DelayedEvent;
|
import org.moparscape.msc.gs.event.DelayedEvent;
|
||||||
import org.moparscape.msc.gs.event.MiniEvent;
|
import org.moparscape.msc.gs.event.MiniEvent;
|
||||||
import org.moparscape.msc.gs.event.ShortEvent;
|
import org.moparscape.msc.gs.event.ShortEvent;
|
||||||
@ -132,7 +133,7 @@ public class ObjectAction implements PacketHandler {
|
|||||||
String command = (click == 0 ? def.getCommand1() : def.getCommand2()).toLowerCase();
|
String command = (click == 0 ? def.getCommand1() : def.getCommand2()).toLowerCase();
|
||||||
// System.out.println(object.getID() + " " +
|
// System.out.println(object.getID() + " " +
|
||||||
// command);
|
// command);
|
||||||
if(object.getID() == 487 && System.currentTimeMillis() - owner.getLastMoved() < 10000) { owner.getActionSender().sendMessage("You must stand still for 10 seconds before using this"); return; }
|
if(object.getID() == 487 && GameEngine.getTime() - owner.getLastMoved() < 10000) { owner.getActionSender().sendMessage("You must stand still for 10 seconds before using this"); return; }
|
||||||
Point telePoint = EntityHandler.getObjectTelePoint(object.getLocation(), command);
|
Point telePoint = EntityHandler.getObjectTelePoint(object.getLocation(), command);
|
||||||
if (telePoint != null) {
|
if (telePoint != null) {
|
||||||
owner.teleport(telePoint.getX(), telePoint.getY(), false);
|
owner.teleport(telePoint.getX(), telePoint.getY(), false);
|
||||||
|
@ -9,6 +9,7 @@ import org.apache.mina.common.IoSession;
|
|||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.model.Player;
|
import org.moparscape.msc.gs.model.Player;
|
||||||
import org.moparscape.msc.gs.model.World;
|
import org.moparscape.msc.gs.model.World;
|
||||||
import org.moparscape.msc.gs.model.snapshot.Activity;
|
import org.moparscape.msc.gs.model.snapshot.Activity;
|
||||||
@ -25,11 +26,11 @@ public class Sleepword implements PacketHandler {
|
|||||||
public void handlePacket(Packet p, IoSession session) throws Exception {
|
public void handlePacket(Packet p, IoSession session) throws Exception {
|
||||||
Player player = (Player) session.getAttachment();
|
Player player = (Player) session.getAttachment();
|
||||||
int pID = ((RSCPacket) p).getID();
|
int pID = ((RSCPacket) p).getID();
|
||||||
long now = System.currentTimeMillis();
|
long now = GameEngine.getTime();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String sleepword_result = ((RSCPacket) p).readString().trim();
|
String sleepword_result = ((RSCPacket) p).readString().trim();
|
||||||
if (System.currentTimeMillis() - player.getLastSleepTime() < 1000)
|
if (GameEngine.getTime() - player.getLastSleepTime() < 1000)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (player.getWrongWords() >= 10) {
|
if (player.getWrongWords() >= 10) {
|
||||||
|
@ -13,6 +13,7 @@ import org.moparscape.msc.config.Formulae;
|
|||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.FightEvent;
|
import org.moparscape.msc.gs.event.FightEvent;
|
||||||
import org.moparscape.msc.gs.event.ObjectRemover;
|
import org.moparscape.msc.gs.event.ObjectRemover;
|
||||||
import org.moparscape.msc.gs.event.WalkMobToMobEvent;
|
import org.moparscape.msc.gs.event.WalkMobToMobEvent;
|
||||||
@ -121,7 +122,7 @@ public class SpellHandler implements PacketHandler {
|
|||||||
private Random r = new Random();
|
private Random r = new Random();
|
||||||
|
|
||||||
private void finalizeSpell(Player player, SpellDef spell) {
|
private void finalizeSpell(Player player, SpellDef spell) {
|
||||||
player.lastCast = System.currentTimeMillis();
|
player.lastCast = GameEngine.getTime();
|
||||||
player.getActionSender().sendSound("spellok");
|
player.getActionSender().sendSound("spellok");
|
||||||
player.getActionSender().sendMessage("Cast spell successfully");
|
player.getActionSender().sendMessage("Cast spell successfully");
|
||||||
player.setCastTimer();
|
player.setCastTimer();
|
||||||
@ -398,12 +399,12 @@ public class SpellHandler implements PacketHandler {
|
|||||||
}
|
}
|
||||||
if (affectedMob instanceof Player) {
|
if (affectedMob instanceof Player) {
|
||||||
Player other = (Player) affectedMob;
|
Player other = (Player) affectedMob;
|
||||||
if (player.getLocation().inWilderness() && System.currentTimeMillis() - other.lastRun < 1000) {
|
if (player.getLocation().inWilderness() && GameEngine.getTime() - other.lastRun < 1000) {
|
||||||
player.resetPath();
|
player.resetPath();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (player.getLocation().inWilderness() && System.currentTimeMillis() - player.lastRun < 3000) {
|
if (player.getLocation().inWilderness() && GameEngine.getTime() - player.lastRun < 3000) {
|
||||||
player.resetPath();
|
player.resetPath();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import org.apache.mina.common.IoSession;
|
|||||||
import org.moparscape.msc.config.Formulae;
|
import org.moparscape.msc.config.Formulae;
|
||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.WalkToMobEvent;
|
import org.moparscape.msc.gs.event.WalkToMobEvent;
|
||||||
import org.moparscape.msc.gs.model.ChatMessage;
|
import org.moparscape.msc.gs.model.ChatMessage;
|
||||||
import org.moparscape.msc.gs.model.Npc;
|
import org.moparscape.msc.gs.model.Npc;
|
||||||
@ -32,10 +33,10 @@ public class TalkToNpcHandler implements PacketHandler {
|
|||||||
player.resetPath();
|
player.resetPath();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - player.lastNPCChat < 1500)
|
if (GameEngine.getTime() - player.lastNPCChat < 1500)
|
||||||
return;
|
return;
|
||||||
player.setLastQuestMenuReply(-2);
|
player.setLastQuestMenuReply(-2);
|
||||||
player.lastNPCChat = System.currentTimeMillis();
|
player.lastNPCChat = GameEngine.getTime();
|
||||||
player.resetAll();
|
player.resetAll();
|
||||||
final Npc affectedNpc = world.getNpc(p.readShort());
|
final Npc affectedNpc = world.getNpc(p.readShort());
|
||||||
if (affectedNpc == null || !world.getQuestManager().isNpcVisible(affectedNpc, player)) {
|
if (affectedNpc == null || !world.getQuestManager().isNpcVisible(affectedNpc, player)) {
|
||||||
|
@ -8,6 +8,7 @@ import org.moparscape.msc.gs.Instance;
|
|||||||
import org.moparscape.msc.gs.builders.ls.MiscPacketBuilder;
|
import org.moparscape.msc.gs.builders.ls.MiscPacketBuilder;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.db.DBConnection;
|
import org.moparscape.msc.gs.db.DBConnection;
|
||||||
import org.moparscape.msc.gs.external.ItemDef;
|
import org.moparscape.msc.gs.external.ItemDef;
|
||||||
import org.moparscape.msc.gs.model.InvItem;
|
import org.moparscape.msc.gs.model.InvItem;
|
||||||
@ -225,7 +226,7 @@ public class TradeHandler implements PacketHandler {
|
|||||||
|
|
||||||
player.getActionSender().sendInventory();
|
player.getActionSender().sendInventory();
|
||||||
player.getActionSender().sendEquipmentStats();
|
player.getActionSender().sendEquipmentStats();
|
||||||
Long now = System.currentTimeMillis();
|
long now = GameEngine.getTime();
|
||||||
player.save();
|
player.save();
|
||||||
player.setLastSaveTime(now);
|
player.setLastSaveTime(now);
|
||||||
affectedPlayer.save();
|
affectedPlayer.save();
|
||||||
|
@ -4,6 +4,7 @@ import org.apache.mina.common.IoSession;
|
|||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.FightEvent;
|
import org.moparscape.msc.gs.event.FightEvent;
|
||||||
import org.moparscape.msc.gs.event.MiniEvent;
|
import org.moparscape.msc.gs.event.MiniEvent;
|
||||||
import org.moparscape.msc.gs.event.WalkMobToMobEvent;
|
import org.moparscape.msc.gs.event.WalkMobToMobEvent;
|
||||||
@ -38,10 +39,10 @@ public class WalkRequest implements PacketHandler {
|
|||||||
player.getActionSender().sendMessage("Running has been disabled in this duel.");
|
player.getActionSender().sendMessage("Running has been disabled in this duel.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.lastRun = System.currentTimeMillis();
|
player.lastRun = GameEngine.getTime();
|
||||||
player.resetCombat(CombatState.RUNNING);
|
player.resetCombat(CombatState.RUNNING);
|
||||||
|
|
||||||
if(player.isInfected() && System.currentTimeMillis() - player.getLastMoved() < 1900) {
|
if(player.isInfected() && GameEngine.getTime() - player.getLastMoved() < 1900) {
|
||||||
final Packet newpacket = p;
|
final Packet newpacket = p;
|
||||||
final IoSession newsession = session;
|
final IoSession newsession = session;
|
||||||
Instance.getDelayedEventHandler().add(new MiniEvent(player, 2000) {
|
Instance.getDelayedEventHandler().add(new MiniEvent(player, 2000) {
|
||||||
@ -127,11 +128,11 @@ public class WalkRequest implements PacketHandler {
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (player.isBusy() && System.currentTimeMillis() - player.lastMineTimer > 2000) {
|
} else if (player.isBusy() && GameEngine.getTime() - player.lastMineTimer > 2000) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.currentTimeMillis() - player.lastCast < 600)
|
if (GameEngine.getTime() - player.lastCast < 600)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.isMining(false);
|
player.isMining(false);
|
||||||
|
@ -5,6 +5,7 @@ import org.moparscape.msc.gs.Instance;
|
|||||||
import org.moparscape.msc.gs.Server;
|
import org.moparscape.msc.gs.Server;
|
||||||
import org.moparscape.msc.gs.connection.Packet;
|
import org.moparscape.msc.gs.connection.Packet;
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.ShortEvent;
|
import org.moparscape.msc.gs.event.ShortEvent;
|
||||||
import org.moparscape.msc.gs.event.WalkToPointEvent;
|
import org.moparscape.msc.gs.event.WalkToPointEvent;
|
||||||
import org.moparscape.msc.gs.external.DoorDef;
|
import org.moparscape.msc.gs.external.DoorDef;
|
||||||
@ -111,7 +112,7 @@ public class WallObjectAction implements PacketHandler {
|
|||||||
if (object.getX() != 282 || object.getY() != 3020) {
|
if (object.getX() != 282 || object.getY() != 3020) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(System.currentTimeMillis() - owner.getLastMoved() < 10000) {
|
if(GameEngine.getTime() - owner.getLastMoved() < 10000) {
|
||||||
owner.getActionSender().sendMessage("You must stand still for 10 seconds before using this");
|
owner.getActionSender().sendMessage("You must stand still for 10 seconds before using this");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package org.moparscape.msc.gs.plugins.plugs.skills;
|
|||||||
|
|
||||||
import org.moparscape.msc.config.Formulae;
|
import org.moparscape.msc.config.Formulae;
|
||||||
import org.moparscape.msc.gs.Instance;
|
import org.moparscape.msc.gs.Instance;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.ShortEvent;
|
import org.moparscape.msc.gs.event.ShortEvent;
|
||||||
import org.moparscape.msc.gs.event.SingleEvent;
|
import org.moparscape.msc.gs.event.SingleEvent;
|
||||||
import org.moparscape.msc.gs.external.EntityHandler;
|
import org.moparscape.msc.gs.external.EntityHandler;
|
||||||
@ -112,7 +113,7 @@ public class Mining implements ObjectListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int retrytime = retrytimes;
|
final int retrytime = retrytimes;
|
||||||
owner.lastMineTimer = System.currentTimeMillis();
|
owner.lastMineTimer = GameEngine.getTime();
|
||||||
owner.getActionSender().sendMessage("You swing your pick at the rock...");
|
owner.getActionSender().sendMessage("You swing your pick at the rock...");
|
||||||
Instance.getDelayedEventHandler().add(new ShortEvent(owner) {
|
Instance.getDelayedEventHandler().add(new ShortEvent(owner) {
|
||||||
public void action() {
|
public void action() {
|
||||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.event.SingleEvent;
|
import org.moparscape.msc.gs.event.SingleEvent;
|
||||||
import org.moparscape.msc.gs.model.ActiveTile;
|
import org.moparscape.msc.gs.model.ActiveTile;
|
||||||
import org.moparscape.msc.gs.model.ChatMessage;
|
import org.moparscape.msc.gs.model.ChatMessage;
|
||||||
@ -277,8 +278,8 @@ public abstract class Quest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = GameEngine.getTime();
|
||||||
while (player.getLastQuestMenuReply() == -1 && (System.currentTimeMillis() - start) <= timeout) {
|
while (player.getLastQuestMenuReply() == -1 && (GameEngine.getTime() - start) <= timeout) {
|
||||||
if (player.getLastQuestMenuReply() == -2)
|
if (player.getLastQuestMenuReply() == -2)
|
||||||
return -1;
|
return -1;
|
||||||
sleep(10);
|
sleep(10);
|
||||||
|
@ -10,6 +10,7 @@ import java.util.jar.JarEntry;
|
|||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
import org.moparscape.msc.config.Config;
|
import org.moparscape.msc.config.Config;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.model.GameObject;
|
import org.moparscape.msc.gs.model.GameObject;
|
||||||
import org.moparscape.msc.gs.model.InvItem;
|
import org.moparscape.msc.gs.model.InvItem;
|
||||||
import org.moparscape.msc.gs.model.Item;
|
import org.moparscape.msc.gs.model.Item;
|
||||||
@ -105,7 +106,7 @@ public class QuestManager {
|
|||||||
*/
|
*/
|
||||||
public final boolean loadQuests() {
|
public final boolean loadQuests() {
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = GameEngine.getTime();
|
||||||
|
|
||||||
if (quests != null)
|
if (quests != null)
|
||||||
quests.clear();
|
quests.clear();
|
||||||
@ -151,7 +152,7 @@ public class QuestManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.println("Loaded " + questCount + " quests successfully (" + (System.currentTimeMillis() - start) + "ms)");
|
Logger.println("Loaded " + questCount + " quests successfully (" + (GameEngine.getTime() - start) + "ms)");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
@ -10,6 +10,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||||
|
import org.moparscape.msc.gs.core.GameEngine;
|
||||||
import org.moparscape.msc.gs.model.Point;
|
import org.moparscape.msc.gs.model.Point;
|
||||||
import org.moparscape.msc.gs.util.Logger;
|
import org.moparscape.msc.gs.util.Logger;
|
||||||
|
|
||||||
@ -363,7 +364,7 @@ public final class DataConversions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String timeSince(long time) {
|
public static String timeSince(long time) {
|
||||||
int seconds = (int) ((System.currentTimeMillis() - time) / 1000);
|
int seconds = (int) ((GameEngine.getTime() - time) / 1000);
|
||||||
int minutes = (int) (seconds / 60);
|
int minutes = (int) (seconds / 60);
|
||||||
int hours = (int) (minutes / 60);
|
int hours = (int) (minutes / 60);
|
||||||
int days = (int) (hours / 24);
|
int days = (int) (hours / 24);
|
||||||
|
@ -10,13 +10,11 @@
|
|||||||
<delete file="${jar}" />
|
<delete file="${jar}" />
|
||||||
<delete dir="${build}" />
|
<delete dir="${build}" />
|
||||||
<mkdir dir="${build}" />
|
<mkdir dir="${build}" />
|
||||||
<javac srcdir="${src}" destdir="${build}" debug="on" target="1.5">
|
<javac srcdir="${src}" destdir="${build}" debug="on" target="1.6">
|
||||||
<classpath>
|
<classpath>
|
||||||
<pathelement location="${lib}/mina.jar" />
|
<pathelement location="${lib}/mina.jar" />
|
||||||
<pathelement location="${lib}/xpp3.jar" />
|
<pathelement location="${lib}/xpp3.jar" />
|
||||||
<pathelement location="${lib}/slf4j.jar" />
|
<pathelement location="${lib}/slf4j.jar" />
|
||||||
|
|
||||||
|
|
||||||
<pathelement location="${lib}/xstream.jar" />
|
<pathelement location="${lib}/xstream.jar" />
|
||||||
<pathelement location="${lib}/mysql-connector.jar" />
|
<pathelement location="${lib}/mysql-connector.jar" />
|
||||||
<pathelement location="${lib}/hex-string.jar" />
|
<pathelement location="${lib}/hex-string.jar" />
|
||||||
|
Loading…
Reference in New Issue
Block a user