Use TimeUnit for time calculations
This commit is contained in:
@@ -42,6 +42,9 @@ import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
import static java.util.concurrent.TimeUnit.HOURS;
|
||||
|
||||
/*
|
||||
* @author Flav
|
||||
*/
|
||||
@@ -101,18 +104,18 @@ public class CashShop {
|
||||
if (ItemConstants.EXPIRING_ITEMS) {
|
||||
if (period == 1) {
|
||||
if (itemId == 5211048 || itemId == 5360042) { // 4 Hour 2X coupons, the period is 1, but we don't want them to last a day.
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + (1000 * 60 * 60 * 4));
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(4));
|
||||
/*
|
||||
} else if(itemId == 5211047 || itemId == 5360014) { // 3 Hour 2X coupons, unused as of now
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + (1000 * 60 * 60 * 3));
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(3));
|
||||
*/
|
||||
} else if (itemId == 5211060) { // 2 Hour 3X coupons.
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + (1000 * 60 * 60 * 2));
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(2));
|
||||
} else {
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + (1000 * 60 * 60 * 24));
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + DAYS.toMillis(1));
|
||||
}
|
||||
} else {
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + (1000 * 60 * 60 * 24 * period));
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + DAYS.toMillis(period));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import client.inventory.Item;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
|
||||
public class DueyPackage {
|
||||
private String sender = null;
|
||||
private Item item = null;
|
||||
@@ -102,7 +104,7 @@ public class DueyPackage {
|
||||
cal.setTimeInMillis(ts.getTime());
|
||||
|
||||
if (quick) {
|
||||
if (System.currentTimeMillis() - ts.getTime() < 24 * 60 * 60 * 1000) { // thanks inhyuk for noticing quick delivery packages unavailable to retrieve from the get-go
|
||||
if (System.currentTimeMillis() - ts.getTime() < DAYS.toMillis(1)) { // thanks inhyuk for noticing quick delivery packages unavailable to retrieve from the get-go
|
||||
cal.add(Calendar.DATE, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ package server.events;
|
||||
import client.Character;
|
||||
import client.SkillFactory;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
|
||||
/**
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
@@ -44,7 +46,7 @@ public class RescueGaga extends Events {
|
||||
skillid = 10001014;
|
||||
}
|
||||
|
||||
long expiration = (System.currentTimeMillis() + 3600 * 24 * 20 * 1000);//20 days
|
||||
long expiration = (System.currentTimeMillis() + DAYS.toMillis(20));
|
||||
if (completed < 20) {
|
||||
chr.changeSkillLevel(SkillFactory.getSkill(skillid), (byte) 1, 1, expiration);
|
||||
chr.changeSkillLevel(SkillFactory.getSkill(skillid + 1), (byte) 1, 1, expiration);
|
||||
|
||||
@@ -43,6 +43,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
/**
|
||||
* @author Alan (SharpAceX)
|
||||
*/
|
||||
@@ -116,7 +118,7 @@ public class Expedition {
|
||||
|
||||
public void beginRegistration() {
|
||||
registering = true;
|
||||
leader.sendPacket(PacketCreator.getClock(type.getRegistrationTime() * 60));
|
||||
leader.sendPacket(PacketCreator.getClock((int) MINUTES.toSeconds(type.getRegistrationMinutes())));
|
||||
if (!silent) {
|
||||
startMap.broadcastMessage(leader, PacketCreator.serverNotice(6, "[Expedition] " + leader.getName() + " has been declared the expedition captain. Please register for the expedition."), false);
|
||||
leader.sendPacket(PacketCreator.serverNotice(6, "[Expedition] You have become the expedition captain. Gather enough people for your team then talk to the NPC to start."));
|
||||
@@ -126,7 +128,7 @@ public class Expedition {
|
||||
|
||||
private void scheduleRegistrationEnd() {
|
||||
final Expedition exped = this;
|
||||
startTime = System.currentTimeMillis() + type.getRegistrationTime() * 60 * 1000;
|
||||
startTime = System.currentTimeMillis() + MINUTES.toMillis(type.getRegistrationMinutes());
|
||||
|
||||
schedule = TimerManager.getInstance().schedule(() -> {
|
||||
if (registering) {
|
||||
@@ -137,7 +139,7 @@ public class Expedition {
|
||||
|
||||
dispose(false);
|
||||
}
|
||||
}, type.getRegistrationTime() * 60 * 1000);
|
||||
}, MINUTES.toMillis(type.getRegistrationMinutes()));
|
||||
}
|
||||
|
||||
public void dispose(boolean log) {
|
||||
|
||||
@@ -28,6 +28,9 @@ import java.util.Calendar;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
import static java.util.concurrent.TimeUnit.HOURS;
|
||||
|
||||
/**
|
||||
* @author Conrad
|
||||
* @author Ronan
|
||||
@@ -97,8 +100,8 @@ public class ExpeditionBossLog {
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
|
||||
long weekLength = 7 * 24 * 60 * 60 * 1000;
|
||||
long halfDayLength = 12 * 60 * 60 * 1000;
|
||||
long weekLength = DAYS.toMillis(7);
|
||||
long halfDayLength = HOURS.toMillis(12);
|
||||
|
||||
long deltaTime = now.getTime().getTime() - thursday.getTime().getTime(); // 2x time: get Date into millis
|
||||
deltaTime += halfDayLength;
|
||||
|
||||
@@ -47,14 +47,14 @@ public enum ExpeditionType {
|
||||
private final int maxSize;
|
||||
private final int minLevel;
|
||||
private final int maxLevel;
|
||||
private final int registrationTime;
|
||||
private final int registrationMinutes;
|
||||
|
||||
ExpeditionType(int minSize, int maxSize, int minLevel, int maxLevel, int minutes) {
|
||||
this.minSize = minSize;
|
||||
this.maxSize = maxSize;
|
||||
this.minLevel = minLevel;
|
||||
this.maxLevel = maxLevel;
|
||||
this.registrationTime = minutes;
|
||||
this.registrationMinutes = minutes;
|
||||
}
|
||||
|
||||
public int getMinSize() {
|
||||
@@ -73,7 +73,7 @@ public enum ExpeditionType {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public int getRegistrationTime() {
|
||||
return registrationTime;
|
||||
public int getRegistrationMinutes() {
|
||||
return registrationMinutes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
/**
|
||||
* @author Danny (Leifde)
|
||||
*/
|
||||
@@ -82,8 +84,8 @@ public class MobSkillFactory {
|
||||
int x = DataTool.getInt("x", skillData, 1);
|
||||
int y = DataTool.getInt("y", skillData, 1);
|
||||
int count = DataTool.getInt("count", skillData, 1);
|
||||
long duration = DataTool.getInt("time", skillData, 0) * 1000;
|
||||
long cooltime = DataTool.getInt("interval", skillData, 0) * 1000;
|
||||
long duration = SECONDS.toMillis(DataTool.getInt("time", skillData, 0));
|
||||
long cooltime = SECONDS.toMillis(DataTool.getInt("interval", skillData, 0));
|
||||
int iprop = DataTool.getInt("prop", skillData, 100);
|
||||
float prop = iprop / 100;
|
||||
int limit = DataTool.getInt("limit", skillData, 0);
|
||||
|
||||
@@ -27,6 +27,8 @@ import net.server.Server;
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class SpawnPoint {
|
||||
private final int monster;
|
||||
private final int mobTime;
|
||||
@@ -87,7 +89,7 @@ public class SpawnPoint {
|
||||
public void monsterKilled(int aniTime) {
|
||||
nextPossibleSpawn = Server.getInstance().getCurrentTime();
|
||||
if (mobTime > 0) {
|
||||
nextPossibleSpawn += mobTime * 1000;
|
||||
nextPossibleSpawn += SECONDS.toMillis(mobTime);
|
||||
} else {
|
||||
nextPossibleSpawn += aniTime;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class MapFactory {
|
||||
private static final Data nameData;
|
||||
private static final DataProvider mapSource;
|
||||
@@ -357,7 +359,7 @@ public class MapFactory {
|
||||
int y = DataTool.getInt(reactor.getChildByPath("y"));
|
||||
myReactor.setFacingDirection(FacingDirection);
|
||||
myReactor.setPosition(new Point(x, y));
|
||||
myReactor.setDelay(DataTool.getInt(reactor.getChildByPath("reactorTime")) * 1000);
|
||||
myReactor.setDelay((int) SECONDS.toMillis(DataTool.getInt(reactor.getChildByPath("reactorTime"))));
|
||||
myReactor.setName(DataTool.getString(reactor.getChildByPath("name"), ""));
|
||||
myReactor.resetReactorActions(0);
|
||||
return myReactor;
|
||||
|
||||
@@ -30,6 +30,8 @@ import tools.PacketCreator;
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class MapItem extends AbstractMapObject {
|
||||
protected Client ownerClient;
|
||||
protected Item item;
|
||||
@@ -128,7 +130,7 @@ public class MapItem extends AbstractMapObject {
|
||||
}
|
||||
|
||||
public final boolean hasExpiredOwnershipTime() {
|
||||
return System.currentTimeMillis() - dropTime >= 15 * 1000;
|
||||
return System.currentTimeMillis() - dropTime >= SECONDS.toMillis(15);
|
||||
}
|
||||
|
||||
public final boolean canBePickedBy(Character chr) {
|
||||
|
||||
@@ -77,6 +77,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class MapleMap {
|
||||
|
||||
private static final List<MapObjectType> rangedMapobjectTypes = Arrays.asList(MapObjectType.SHOP, MapObjectType.ITEM, MapObjectType.NPC, MapObjectType.MONSTER, MapObjectType.DOOR, MapObjectType.SUMMON, MapObjectType.REACTOR);
|
||||
@@ -1880,11 +1883,11 @@ public class MapleMap {
|
||||
if (selfDestruction == null) {
|
||||
removeAfterAction = () -> killMonster(monster, null, false);
|
||||
|
||||
registerMapSchedule(removeAfterAction, monster.getStats().removeAfter() * 1000);
|
||||
registerMapSchedule(removeAfterAction, SECONDS.toMillis(monster.getStats().removeAfter()));
|
||||
} else {
|
||||
removeAfterAction = () -> killMonster(monster, null, false, selfDestruction.getAction());
|
||||
|
||||
registerMapSchedule(removeAfterAction, selfDestruction.removeAfter() * 1000);
|
||||
registerMapSchedule(removeAfterAction, SECONDS.toMillis(selfDestruction.removeAfter()));
|
||||
}
|
||||
|
||||
monster.pushRemoveAfterAction(removeAfterAction);
|
||||
@@ -2396,7 +2399,7 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
if (mapid == 200090060) { // To Rien
|
||||
int travelTime = getWorldServer().getTransportationTime(1 * 60 * 1000);
|
||||
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(1));
|
||||
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
|
||||
TimerManager.getInstance().schedule(() -> {
|
||||
if (chr.getMapId() == 200090060) {
|
||||
@@ -2404,7 +2407,7 @@ public class MapleMap {
|
||||
}
|
||||
}, travelTime);
|
||||
} else if (mapid == 200090070) { // To Lith Harbor
|
||||
int travelTime = getWorldServer().getTransportationTime(1 * 60 * 1000);
|
||||
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(1));
|
||||
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
|
||||
TimerManager.getInstance().schedule(() -> {
|
||||
if (chr.getMapId() == 200090070) {
|
||||
@@ -2412,7 +2415,7 @@ public class MapleMap {
|
||||
}
|
||||
}, travelTime);
|
||||
} else if (mapid == 200090030) { // To Ereve (SkyFerry)
|
||||
int travelTime = getWorldServer().getTransportationTime(2 * 60 * 1000);
|
||||
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(2));
|
||||
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
|
||||
TimerManager.getInstance().schedule(() -> {
|
||||
if (chr.getMapId() == 200090030) {
|
||||
@@ -2420,7 +2423,7 @@ public class MapleMap {
|
||||
}
|
||||
}, travelTime);
|
||||
} else if (mapid == 200090031) { // To Victoria Island (SkyFerry)
|
||||
int travelTime = getWorldServer().getTransportationTime(2 * 60 * 1000);
|
||||
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(2));
|
||||
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
|
||||
TimerManager.getInstance().schedule(() -> {
|
||||
if (chr.getMapId() == 200090031) {
|
||||
@@ -2428,7 +2431,7 @@ public class MapleMap {
|
||||
}
|
||||
}, travelTime);
|
||||
} else if (mapid == 200090021) { // To Orbis (SkyFerry)
|
||||
int travelTime = getWorldServer().getTransportationTime(8 * 60 * 1000);
|
||||
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(8));
|
||||
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
|
||||
TimerManager.getInstance().schedule(() -> {
|
||||
if (chr.getMapId() == 200090021) {
|
||||
@@ -2436,7 +2439,7 @@ public class MapleMap {
|
||||
}
|
||||
}, travelTime);
|
||||
} else if (mapid == 200090020) { // To Ereve From Orbis (SkyFerry)
|
||||
int travelTime = getWorldServer().getTransportationTime(8 * 60 * 1000);
|
||||
int travelTime = getWorldServer().getTransportationTime((int) MINUTES.toMillis(8));
|
||||
chr.sendPacket(PacketCreator.getClock(travelTime / 1000));
|
||||
TimerManager.getInstance().schedule(() -> {
|
||||
if (chr.getMapId() == 200090020) {
|
||||
@@ -2449,7 +2452,7 @@ public class MapleMap {
|
||||
mmd.registerPlayer(chr);
|
||||
}
|
||||
} else if (GameConstants.isAriantColiseumArena(mapid)) {
|
||||
int pqTimer = (10 * 60 * 1000);
|
||||
int pqTimer = (int) MINUTES.toMillis(10);
|
||||
chr.sendPacket(PacketCreator.getClock(pqTimer / 1000));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
*/
|
||||
@@ -43,7 +45,7 @@ public class MiniDungeon {
|
||||
|
||||
public MiniDungeon(int base, long timeLimit) {
|
||||
baseMap = base;
|
||||
expireTime = timeLimit * 1000;
|
||||
expireTime = SECONDS.toMillis(timeLimit);
|
||||
|
||||
timeoutTask = TimerManager.getInstance().schedule(() -> close(), expireTime);
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
/**
|
||||
* @author Matze
|
||||
* @author Ronan (HeavenMS)
|
||||
@@ -284,7 +286,7 @@ public class MiniGame extends AbstractMapObject {
|
||||
visitorscore += 10;
|
||||
ownerscore += 10;
|
||||
|
||||
nextavailabletie = timeNow + 5 * 60 * 1000;
|
||||
nextavailabletie = timeNow + MINUTES.toMillis(5);
|
||||
}
|
||||
|
||||
this.broadcast(PacketCreator.getMiniGameTie(this));
|
||||
|
||||
@@ -33,6 +33,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
@@ -61,8 +64,8 @@ public class AriantColiseum {
|
||||
map = eventMap;
|
||||
map.resetFully();
|
||||
|
||||
int pqTimer = 10 * 60 * 1000;
|
||||
int pqTimerBoard = (9 * 60 * 1000) + 50 * 1000;
|
||||
long pqTimer = MINUTES.toMillis(10);
|
||||
long pqTimerBoard = MINUTES.toMillis(9) + TimeUnit.SECONDS.toMillis(50);
|
||||
|
||||
List<Character> players = exped.getActiveMembers();
|
||||
score = new HashMap<>();
|
||||
@@ -278,7 +281,7 @@ public class AriantColiseum {
|
||||
score.clear();
|
||||
exped = null;
|
||||
map = null;
|
||||
}, 5 * 60 * 1000);
|
||||
}, MINUTES.toMillis(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ import tools.PacketCreator;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
/**
|
||||
* @author Drago (Dragohe4rt)
|
||||
*/
|
||||
@@ -43,7 +46,7 @@ public class MonsterCarnival {
|
||||
p1.setEnemy(p2);
|
||||
p2.setEnemy(p1);
|
||||
map = cs.getMapFactory().getDisposableMap(mapid);
|
||||
startTime = System.currentTimeMillis() + 10 * 60 * 1000;
|
||||
startTime = System.currentTimeMillis() + MINUTES.toMillis(10);
|
||||
int redPortal = 0;
|
||||
int bluePortal = 0;
|
||||
if (map.isPurpleCPQMap()) {
|
||||
@@ -96,8 +99,8 @@ public class MonsterCarnival {
|
||||
|
||||
// thanks Atoot, Vcoc for noting double CPQ functional being sent to players in CPQ start
|
||||
|
||||
timer = TimerManager.getInstance().schedule(() -> timeUp(), map.getTimeDefault() * 1000); // thanks Atoot for noticing an irregular "event extended" issue here
|
||||
effectTimer = TimerManager.getInstance().schedule(() -> complete(), map.getTimeDefault() * 1000 - 10 * 1000);
|
||||
timer = TimerManager.getInstance().schedule(() -> timeUp(), SECONDS.toMillis(map.getTimeDefault())); // thanks Atoot for noticing an irregular "event extended" issue here
|
||||
effectTimer = TimerManager.getInstance().schedule(() -> complete(), SECONDS.toMillis(map.getTimeDefault() - 10));
|
||||
respawnTask = TimerManager.getInstance().register(() -> respawn(), YamlConfig.config.server.RESPAWN_INTERVAL);
|
||||
|
||||
cs.initMonsterCarnival(cpq1, room);
|
||||
@@ -344,12 +347,12 @@ public class MonsterCarnival {
|
||||
for (Character chrMap : map.getAllPlayers()) {
|
||||
chrMap.dropMessage(5, LanguageConstants.getMessage(chrMap, LanguageConstants.CPQExtendTime));
|
||||
}
|
||||
startTime = System.currentTimeMillis() + 3 * 60 * 1000;
|
||||
startTime = System.currentTimeMillis() + MINUTES.toMillis(3);
|
||||
|
||||
map.broadcastMessage(PacketCreator.getClock(3 * 60));
|
||||
map.broadcastMessage(PacketCreator.getClock((int) MINUTES.toSeconds(3)));
|
||||
|
||||
timer = TimerManager.getInstance().schedule(() -> timeUp(), map.getTimeExpand() * 1000);
|
||||
effectTimer = TimerManager.getInstance().schedule(() -> complete(), map.getTimeExpand() * 1000 - 10 * 1000); // thanks Vcoc for noticing a time set issue here
|
||||
timer = TimerManager.getInstance().schedule(() -> timeUp(), SECONDS.toMillis(map.getTimeExpand()));
|
||||
effectTimer = TimerManager.getInstance().schedule(() -> complete(), SECONDS.toMillis(map.getTimeExpand() - 10)); // thanks Vcoc for noticing a time set issue here
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
|
||||
@@ -30,6 +30,8 @@ import tools.PacketCreator;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
/**
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
@@ -136,7 +138,7 @@ public class Pyramid extends PartyQuest {
|
||||
timer = TimerManager.getInstance().schedule(() -> {
|
||||
stage++;
|
||||
warp(map + (stage * 100));//Should work :D
|
||||
}, value * 1000);//, 4000
|
||||
}, SECONDS.toMillis(value));//, 4000
|
||||
broadcastInfo("party", getParticipants().size() > 1 ? 1 : 0);
|
||||
broadcastInfo("hit", kill);
|
||||
broadcastInfo("miss", miss);
|
||||
|
||||
@@ -38,6 +38,9 @@ import tools.StringUtil;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.HOURS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
/**
|
||||
* @author Matze
|
||||
* @author Ronan - support for medal quests
|
||||
@@ -204,7 +207,7 @@ public class Quest {
|
||||
}
|
||||
|
||||
IntervalRequirement ir = (IntervalRequirement) startReqs.get(QuestRequirementType.INTERVAL);
|
||||
return ir.getInterval() < YamlConfig.config.server.QUEST_POINT_REPEATABLE_INTERVAL * 60 * 60 * 1000;
|
||||
return ir.getInterval() < HOURS.toMillis(YamlConfig.config.server.QUEST_POINT_REPEATABLE_INTERVAL);
|
||||
}
|
||||
|
||||
public boolean canStartQuestByStatus(Character chr) {
|
||||
@@ -343,7 +346,7 @@ public class Quest {
|
||||
newStatus.setCompleted(chr.getQuest(this).getCompleted());
|
||||
|
||||
if (timeLimit > 0) {
|
||||
newStatus.setExpirationTime(System.currentTimeMillis() + (timeLimit * 1000));
|
||||
newStatus.setExpirationTime(System.currentTimeMillis() + SECONDS.toMillis(timeLimit));
|
||||
chr.questTimeLimit(this, timeLimit);
|
||||
}
|
||||
if (timeLimit2 > 0) {
|
||||
|
||||
@@ -42,6 +42,8 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
/**
|
||||
* @author Tyler (Twdtwd)
|
||||
* @author Ronan
|
||||
@@ -152,7 +154,7 @@ public class ItemAction extends AbstractQuestAction {
|
||||
for (ItemData iEntry : giveItem) {
|
||||
int itemid = iEntry.getId(), count = iEntry.getCount(), period = iEntry.getPeriod(); // thanks Vcoc for noticing quest milestone item not getting removed from inventory after a while
|
||||
|
||||
InventoryManipulator.addById(chr.getClient(), itemid, (short) count, "", -1, period > 0 ? (System.currentTimeMillis() + period * 60 * 1000) : -1);
|
||||
InventoryManipulator.addById(chr.getClient(), itemid, (short) count, "", -1, period > 0 ? (System.currentTimeMillis() + MINUTES.toMillis(period)) : -1);
|
||||
chr.sendPacket(PacketCreator.getShowItemGain(itemid, (short) count, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,14 @@ import provider.DataTool;
|
||||
import server.quest.Quest;
|
||||
import server.quest.QuestRequirementType;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.HOURS;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
/**
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class IntervalRequirement extends AbstractQuestRequirement {
|
||||
private int interval = -1;
|
||||
private long interval = -1;
|
||||
private final int questID;
|
||||
|
||||
public IntervalRequirement(Quest quest, Data data) {
|
||||
@@ -41,13 +44,13 @@ public class IntervalRequirement extends AbstractQuestRequirement {
|
||||
processData(data);
|
||||
}
|
||||
|
||||
public int getInterval() {
|
||||
public long getInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(Data data) {
|
||||
interval = DataTool.getInt(data) * 60 * 1000;
|
||||
interval = MINUTES.toMillis(DataTool.getInt(data));
|
||||
}
|
||||
|
||||
private static String getIntervalTimeLeft(Character chr, IntervalRequirement r) {
|
||||
@@ -57,21 +60,21 @@ public class IntervalRequirement extends AbstractQuestRequirement {
|
||||
long leftTime = futureTime - System.currentTimeMillis();
|
||||
|
||||
byte mode = 0;
|
||||
if (leftTime / (60 * 1000) > 0) {
|
||||
if (leftTime / MINUTES.toMillis(1) > 0) {
|
||||
mode++; //counts minutes
|
||||
|
||||
if (leftTime / (60 * 60 * 1000) > 0) {
|
||||
if (leftTime / HOURS.toMillis(1) > 0) {
|
||||
mode++; //counts hours
|
||||
}
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case 2:
|
||||
int hours = (int) ((leftTime / (1000 * 60 * 60)));
|
||||
int hours = (int) ((leftTime / HOURS.toMillis(1)));
|
||||
str.append(hours + " hours, ");
|
||||
|
||||
case 1:
|
||||
int minutes = (int) ((leftTime / (1000 * 60)) % 60);
|
||||
int minutes = (int) ((leftTime / MINUTES.toMillis(1)) % 60);
|
||||
str.append(minutes + " minutes, ");
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user