forked from 2009Scape/Server
Added initial version
This commit is contained in:
commit
b1dccb3fed
14153 changed files with 1285206 additions and 0 deletions
35
Client/src/main/java/org/runite/client/TimeUtils.java
Normal file
35
Client/src/main/java/org/runite/client/TimeUtils.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package org.runite.client;
|
||||
|
||||
public final class TimeUtils {
|
||||
|
||||
private static long correction;
|
||||
private static long previous;
|
||||
|
||||
public static synchronized long time() {
|
||||
long time = System.currentTimeMillis();
|
||||
if (time < previous) {
|
||||
correction += previous + -time;
|
||||
}
|
||||
|
||||
previous = time;
|
||||
return correction + time;
|
||||
}
|
||||
|
||||
public static void sleep(long millis) {
|
||||
if (0L < millis) {
|
||||
if (0L == millis % 10L) {
|
||||
sleepWrapped(millis + -1L);
|
||||
sleepWrapped(1L);
|
||||
} else {
|
||||
sleepWrapped(millis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void sleepWrapped(long millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException var4) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue