Quest Item Restore + Packets w/ Timezone + Item/Exp-dec Field Limits
Fixed leaders being able to create expeditions even though the already passed the day limit. Fixed overflow case in calculated max value of skills. Implemented item expiration from DB after the due date. Refactored item flags using byte-length instead of short. Added FieldLimit checks for disappearing item drops and no EXP deduction in limited areas. Added "Quest Item Restore" functionality. Implemented item flag auto-instantiation when generating items. Added gate state update in Papulatus lobby area. Fixed a recent issue regarding bounding box calculation of AoE player skills. Implemented minidungeon close, to occur as soon as the party leader leaves the area. Refactored HenesysPQ attributed out of the MapleMap object, now they should be available from the respective event script. Fixed friendly mobs not dropping item periodically, a recent issue after tweaking the loot system. Fixed Papulatus expedition closing after the exped leader leaves or a minimum of player required to start is no longer there. Fixed several expeditions closing after performing party operations, such as "change party leader". Reviewed expected max damage calculation for summons, which would not work properly in several occasions. Normalized timezone from packets sent to client, now using the same timezone defined from the server flags. Fixed certain scenarios in CPQ that would happen within the stage between the "challenge accepted" and ingress in the battlefield. Revised credits script. Added GM checks in the autoban method.
This commit is contained in:
+27
-11
@@ -23,15 +23,14 @@ package server;
|
||||
|
||||
import client.inventory.Item;
|
||||
import java.util.Calendar;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class DueyPackage {
|
||||
private String sender = null;
|
||||
private Item item = null;
|
||||
private int mesos = 0;
|
||||
private String message = "";
|
||||
private int day;
|
||||
private int month;
|
||||
private int year;
|
||||
private Calendar timestamp;
|
||||
private int packageId = 0;
|
||||
|
||||
public DueyPackage(int pId, Item item) {
|
||||
@@ -76,18 +75,35 @@ public class DueyPackage {
|
||||
}
|
||||
|
||||
public long sentTimeInMilliseconds() {
|
||||
Calendar ts = timestamp;
|
||||
if (ts != null) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(ts.getTime());
|
||||
cal.add(Calendar.MONTH, 1); // duey representation is in an array of months.
|
||||
|
||||
return cal.getTimeInMillis();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDeliveringTime() {
|
||||
Calendar ts = timestamp;
|
||||
if (ts != null) {
|
||||
return ts.getTimeInMillis() >= System.currentTimeMillis();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSentTime(Timestamp ts) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(year, month, day);
|
||||
cal.setTimeInMillis(ts.getTime());
|
||||
cal.set(Calendar.HOUR, 0);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
return cal.getTimeInMillis();
|
||||
}
|
||||
|
||||
public void setSentTime(String sentTime) {
|
||||
day = Integer.parseInt(sentTime.substring(0, 2));
|
||||
month = Integer.parseInt(sentTime.substring(3, 5));
|
||||
year = Integer.parseInt(sentTime.substring(6, 10));
|
||||
|
||||
this.timestamp = cal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ public class MapleItemInformationProvider {
|
||||
protected Map<Integer, String> nameCache = new HashMap<>();
|
||||
protected Map<Integer, String> descCache = new HashMap<>();
|
||||
protected Map<Integer, String> msgCache = new HashMap<>();
|
||||
protected Map<Integer, Boolean> accountItemRestrictionCache = new HashMap<>();
|
||||
protected Map<Integer, Boolean> dropRestrictionCache = new HashMap<>();
|
||||
protected Map<Integer, Boolean> pickupRestrictionCache = new HashMap<>();
|
||||
protected Map<Integer, Integer> getMesoCache = new HashMap<>();
|
||||
@@ -1046,7 +1047,7 @@ public class MapleItemInformationProvider {
|
||||
return getEquipById(equipId, -1);
|
||||
}
|
||||
|
||||
Item getEquipById(int equipId, int ringId) {
|
||||
private Item getEquipById(int equipId, int ringId) {
|
||||
Equip nEquip;
|
||||
nEquip = new Equip(equipId, (byte) 0, ringId);
|
||||
nEquip.setQuantity((short) 1);
|
||||
@@ -1084,11 +1085,11 @@ public class MapleItemInformationProvider {
|
||||
} else if (stat.getKey().equals("tuc")) {
|
||||
nEquip.setUpgradeSlots((byte) stat.getValue().intValue());
|
||||
} else if (isUntradeableRestricted(equipId)) { // thanks Hyun & Thora for showing an issue with more than only "Untradeable" items being flagged as such here
|
||||
byte flag = nEquip.getFlag();
|
||||
short flag = nEquip.getFlag();
|
||||
flag |= ItemConstants.UNTRADEABLE;
|
||||
nEquip.setFlag(flag);
|
||||
} else if (stats.get("fs") > 0) {
|
||||
byte flag = nEquip.getFlag();
|
||||
short flag = nEquip.getFlag();
|
||||
flag |= ItemConstants.SPIKES;
|
||||
nEquip.setFlag(flag);
|
||||
equipCache.put(equipId, nEquip);
|
||||
@@ -1230,6 +1231,23 @@ public class MapleItemInformationProvider {
|
||||
untradeableCache.put(itemId, bRestricted);
|
||||
return bRestricted;
|
||||
}
|
||||
|
||||
public boolean isAccountRestricted(int itemId) {
|
||||
if (accountItemRestrictionCache.containsKey(itemId)) {
|
||||
return accountItemRestrictionCache.get(itemId);
|
||||
}
|
||||
|
||||
boolean bRestricted = false;
|
||||
if(itemId != 0) {
|
||||
MapleData data = getItemData(itemId);
|
||||
if (data != null) {
|
||||
bRestricted = MapleDataTool.getIntConvert("info/accountSharable", data, 0) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
accountItemRestrictionCache.put(itemId, bRestricted);
|
||||
return bRestricted;
|
||||
}
|
||||
|
||||
public boolean isLootRestricted(int itemId) {
|
||||
if (dropRestrictionCache.containsKey(itemId)) {
|
||||
@@ -1242,7 +1260,7 @@ public class MapleItemInformationProvider {
|
||||
if (data != null) {
|
||||
bRestricted = MapleDataTool.getIntConvert("info/tradeBlock", data, 0) == 1;
|
||||
if (!bRestricted) {
|
||||
bRestricted = MapleDataTool.getIntConvert("info/accountSharable", data, 0) == 1;
|
||||
bRestricted = isAccountRestricted(itemId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +245,8 @@ public class MapleSkillbookInformationProvider {
|
||||
} catch(IOException ioe) {
|
||||
System.out.println("Failed to read Quest.wz file. Line " + lineNumber + ": " + line);
|
||||
ioe.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Failed to parse Quest.wz XML file."); // catch this exception, thanks to YonhNi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1207,9 +1207,15 @@ public class MapleStatEffect {
|
||||
}
|
||||
|
||||
private Rectangle calculateBoundingBox(Point posFrom, boolean facingLeft) {
|
||||
int multiplier = facingLeft ? 1 : -1;
|
||||
Point mylt = new Point(lt.x * multiplier + posFrom.x, lt.y + posFrom.y);
|
||||
Point myrb = new Point(rb.x * multiplier + posFrom.x, rb.y + posFrom.y);
|
||||
Point mylt;
|
||||
Point myrb;
|
||||
if (facingLeft) {
|
||||
mylt = new Point(lt.x + posFrom.x, lt.y + posFrom.y);
|
||||
myrb = new Point(rb.x + posFrom.x, rb.y + posFrom.y);
|
||||
} else {
|
||||
myrb = new Point(-lt.x + posFrom.x, rb.y + posFrom.y); // thanks Conrad, April for noticing a disturbance in AoE skill behavior after a hitched refactor here
|
||||
mylt = new Point(-rb.x + posFrom.x, lt.y + posFrom.y);
|
||||
}
|
||||
Rectangle bounds = new Rectangle(mylt.x, mylt.y, myrb.x - mylt.x, myrb.y - mylt.y);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import constants.ServerConstants;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -184,6 +185,10 @@ public class MapleExpeditionBossLog {
|
||||
}
|
||||
|
||||
public static boolean attemptBoss(int cid, int channel, MapleExpedition exped, boolean log) {
|
||||
if (!ServerConstants.USE_ENABLE_DAILY_EXPEDITIONS) {
|
||||
return true;
|
||||
}
|
||||
|
||||
BossLogEntry boss = BossLogEntry.getBossEntryByName(exped.getType().name());
|
||||
if (boss == null) {
|
||||
return true;
|
||||
|
||||
@@ -52,6 +52,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import net.server.audit.locks.MonitoredReentrantLock;
|
||||
@@ -100,6 +101,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
private int team;
|
||||
private int parentMobOid = 0;
|
||||
private final HashMap<Integer, AtomicLong> takenDamage = new HashMap<>();
|
||||
private ScheduledFuture<?> monsterItemDrop = null;
|
||||
private Runnable removeAfterAction = null;
|
||||
private boolean availablePuppetUpdate = true;
|
||||
|
||||
@@ -512,14 +514,14 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
return avgExpReward + Math.sqrt(varExpReward);
|
||||
}
|
||||
|
||||
private void distributePlayerExperience(MapleCharacter chr, float exp, float partyBonusMod, int totalPartyLevel, boolean highestPartyDamager, boolean whiteExpGain) {
|
||||
private void distributePlayerExperience(MapleCharacter chr, float exp, float partyBonusMod, int totalPartyLevel, boolean highestPartyDamager, boolean whiteExpGain, boolean hasPartySharers) {
|
||||
float playerExp = (ServerConstants.EXP_SPLIT_COMMON_MOD * chr.getLevel()) / totalPartyLevel;
|
||||
if (highestPartyDamager) playerExp += ServerConstants.EXP_SPLIT_MVP_MOD;
|
||||
|
||||
playerExp *= exp;
|
||||
float bonusExp = partyBonusMod * playerExp;
|
||||
|
||||
this.giveExpToCharacter(chr, playerExp, bonusExp, whiteExpGain);
|
||||
this.giveExpToCharacter(chr, playerExp, bonusExp, whiteExpGain, hasPartySharers);
|
||||
}
|
||||
|
||||
private void distributePartyExperience(Map<MapleCharacter, Long> partyParticipation, float expPerDmg, Set<MapleCharacter> underleveled, Map<Integer, Float> personalRatio, double sdevRatio) {
|
||||
@@ -560,10 +562,11 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
float participationExp = partyDamage * expPerDmg;
|
||||
|
||||
// thanks Crypter for reporting an insufficiency on party exp bonuses
|
||||
float partyBonusMod = (membersSize > 1) ? 0.05f * membersSize : 0.0f;
|
||||
boolean hasPartySharers = membersSize > 1;
|
||||
float partyBonusMod = hasPartySharers ? 0.05f * membersSize : 0.0f;
|
||||
|
||||
for (MapleCharacter mc : expMembers) {
|
||||
distributePlayerExperience(mc, participationExp, partyBonusMod, totalPartyLevel, mc == participationMvp, isWhiteExpGain(mc, personalRatio, sdevRatio));
|
||||
distributePlayerExperience(mc, participationExp, partyBonusMod, totalPartyLevel, mc == participationMvp, isWhiteExpGain(mc, personalRatio, sdevRatio), hasPartySharers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,7 +639,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
float exp = chrParticipation.getValue() * expPerDmg;
|
||||
MapleCharacter chr = chrParticipation.getKey();
|
||||
|
||||
distributePlayerExperience(chr, exp, 0.0f, chr.getLevel(), true, isWhiteExpGain(chr, personalRatio, sdevRatio));
|
||||
distributePlayerExperience(chr, exp, 0.0f, chr.getLevel(), true, isWhiteExpGain(chr, personalRatio, sdevRatio), false);
|
||||
}
|
||||
|
||||
for (Map<MapleCharacter, Long> partyParticipation : partyExpDist.values()) {
|
||||
@@ -657,13 +660,17 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
|
||||
}
|
||||
|
||||
private float getStatusExpMultiplier(MapleCharacter attacker) {
|
||||
private float getStatusExpMultiplier(MapleCharacter attacker, boolean hasPartySharers) {
|
||||
float multiplier = 1.0f;
|
||||
|
||||
// thanks Prophecy & Aika for finding out Holy Symbol not being applied on party bonuses
|
||||
Integer holySymbol = attacker.getBuffedValue(MapleBuffStat.HOLY_SYMBOL);
|
||||
if (holySymbol != null) {
|
||||
multiplier *= (1.0 + (holySymbol.doubleValue() / 100.0));
|
||||
if (ServerConstants.USE_FULL_HOLY_SYMBOL) { // thanks Mordred, xinyifly, AyumiLove, andy33 for noticing HS hands out 20% of its potential on less than 3 players
|
||||
multiplier *= (1.0 + (holySymbol.doubleValue() / 100.0));
|
||||
} else {
|
||||
multiplier *= (1.0 + (holySymbol.doubleValue() / (hasPartySharers ? 100.0 : 500.0)));
|
||||
}
|
||||
}
|
||||
|
||||
statiLock.lock();
|
||||
@@ -689,10 +696,10 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
return (int) exp;
|
||||
}
|
||||
|
||||
private void giveExpToCharacter(MapleCharacter attacker, Float personalExp, Float partyExp, boolean white) {
|
||||
private void giveExpToCharacter(MapleCharacter attacker, Float personalExp, Float partyExp, boolean white, boolean hasPartySharers) {
|
||||
if (attacker.isAlive()) {
|
||||
if (personalExp != null) {
|
||||
personalExp *= getStatusExpMultiplier(attacker);
|
||||
personalExp *= getStatusExpMultiplier(attacker, hasPartySharers);
|
||||
personalExp *= attacker.getExpRate();
|
||||
} else {
|
||||
personalExp = 0.0f;
|
||||
@@ -706,7 +713,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
int _personalExp = expValueToInteger(personalExp); // assuming no negative xp here
|
||||
|
||||
if (partyExp != null) {
|
||||
partyExp *= getStatusExpMultiplier(attacker);
|
||||
partyExp *= getStatusExpMultiplier(attacker, hasPartySharers);
|
||||
partyExp *= attacker.getExpRate();
|
||||
partyExp *= ServerConstants.PARTY_BONUS_EXP_RATE;
|
||||
} else {
|
||||
@@ -722,6 +729,10 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
|
||||
public List<MonsterDropEntry> retrieveRelevantDrops() {
|
||||
if (this.getStats().isFriendly()) { // thanks Conrad for noticing friendly mobs not spawning loots after a recent update
|
||||
return MapleMonsterInformationProvider.getInstance().retrieveEffectiveDrop(this.getId());
|
||||
}
|
||||
|
||||
Map<Integer, MapleCharacter> pchars = map.getMapAllPlayers();
|
||||
|
||||
List<MapleCharacter> lootChars = new LinkedList<>();
|
||||
@@ -814,6 +825,35 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
return looter != null ? looter : killer;
|
||||
}
|
||||
|
||||
public void dropFromFriendlyMonster(long delay) {
|
||||
final MapleMonster m = this;
|
||||
monsterItemDrop = TimerManager.getInstance().register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!m.isAlive()) {
|
||||
if (monsterItemDrop != null) {
|
||||
monsterItemDrop.cancel(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MapleMap map = m.getMap();
|
||||
List<MapleCharacter> chrList = map.getAllPlayers();
|
||||
if (!chrList.isEmpty()) {
|
||||
MapleCharacter chr = (MapleCharacter) chrList.get(0);
|
||||
|
||||
EventInstanceManager eim = map.getEventInstance();
|
||||
if (eim != null) {
|
||||
eim.friendlyItemDrop(m);
|
||||
}
|
||||
|
||||
map.dropFromFriendlyMonster(chr, m);
|
||||
}
|
||||
}
|
||||
}, delay, delay);
|
||||
}
|
||||
|
||||
private void dispatchUpdateQuestMobCount() {
|
||||
Set<Integer> attackerChrids = takenDamage.keySet();
|
||||
if(!attackerChrids.isEmpty()) {
|
||||
@@ -2176,6 +2216,10 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (monsterItemDrop != null) {
|
||||
monsterItemDrop.cancel(false);
|
||||
}
|
||||
|
||||
this.getMap().dismissRemoveAfter(this);
|
||||
disposeLocks();
|
||||
}
|
||||
|
||||
@@ -42,15 +42,15 @@ public enum FieldLimit {
|
||||
//CASH_WEATHER_CONSUME_LIMIT(0x4000),
|
||||
//NO_PET(0x8000), // Ariant colosseum-related?
|
||||
//ANTI_MACRO_LIMIT(0x10000), // No notes
|
||||
CANNOTJUMPDOWN(0x20000);
|
||||
CANNOTJUMPDOWN(0x20000),
|
||||
//SUMMON_NPC_LIMIT(0x40000); // Seems to .. disable Rush if 0x2 is set
|
||||
|
||||
//......... EVEN MORE LIMITS ............
|
||||
//SUMMON_NPC_LIMIT(0x40000),
|
||||
//NO_EXP_DECREASE(0x80000),
|
||||
NO_EXP_DECREASE(0x80000),
|
||||
//NO_DAMAGE_ON_FALLING(0x100000),
|
||||
//PARCEL_OPEN_LIMIT(0x200000),
|
||||
//DROP_LIMIT(0x400000),
|
||||
DROP_LIMIT(0x400000);
|
||||
//ROCKETBOOSTER_LIMIT(0x800000) //lol we don't even have mechanics <3
|
||||
|
||||
private long i;
|
||||
|
||||
@@ -159,9 +159,6 @@ public class MapleMap {
|
||||
private MapleCharacter mapOwner = null;
|
||||
private long mapOwnerLastActivityTime = Long.MAX_VALUE;
|
||||
|
||||
// HPQ
|
||||
private int riceCakes = 0;
|
||||
private int bunnyDamage = 0;
|
||||
// events
|
||||
private boolean eventstarted = false, isMuted = false;
|
||||
private MapleSnowball snowball0 = null;
|
||||
@@ -1864,35 +1861,8 @@ public class MapleMap {
|
||||
spawnMonster(mob);
|
||||
}
|
||||
|
||||
public void addBunnyHit() {
|
||||
bunnyDamage++;
|
||||
if (bunnyDamage > 5) {
|
||||
broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny is feeling sick. Please protect it so it can make delicious rice cakes."));
|
||||
bunnyDamage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void monsterItemDrop(final MapleMonster m, long delay) {
|
||||
final ScheduledFuture<?> monsterItemDrop = TimerManager.getInstance().register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<MapleMapObject> chrList = MapleMap.this.getPlayers();
|
||||
|
||||
if (m.isAlive() && !chrList.isEmpty()) {
|
||||
MapleCharacter chr = (MapleCharacter) chrList.get(0);
|
||||
|
||||
if (m.getId() == 9300061) {
|
||||
MapleMap.this.riceCakes++;
|
||||
MapleMap.this.broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny made rice cake number " + (MapleMap.this.riceCakes) + "."));
|
||||
}
|
||||
|
||||
dropFromFriendlyMonster(chr, m);
|
||||
}
|
||||
}
|
||||
}, delay, delay);
|
||||
if (!m.isAlive()) {
|
||||
monsterItemDrop.cancel(true);
|
||||
}
|
||||
m.dropFromFriendlyMonster(delay);
|
||||
}
|
||||
|
||||
public void spawnFakeMonsterOnGroundBelow(MapleMonster mob, Point pos) {
|
||||
@@ -2259,6 +2229,11 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
public final void spawnItemDrop(final MapleMapObject dropper, final MapleCharacter owner, final Item item, Point pos, final byte dropType, final boolean playerDrop) {
|
||||
if (FieldLimit.DROP_LIMIT.check(this.getFieldLimit())) { // thanks Conrad for noticing some maps shouldn't have loots available
|
||||
this.disappearingItemDrop(dropper, owner, item, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
final Point droppos = calcDropPos(pos, pos);
|
||||
final MapleMapItem mdrop = new MapleMapItem(item, droppos, dropper, owner, owner.getClient(), dropType, playerDrop);
|
||||
mdrop.setDropTime(Server.getInstance().getCurrentTime());
|
||||
@@ -3938,10 +3913,6 @@ public class MapleMap {
|
||||
return fieldLimit;
|
||||
}
|
||||
|
||||
public void resetRiceCakes() {
|
||||
this.riceCakes = 0;
|
||||
}
|
||||
|
||||
public void allowSummonState(boolean b) {
|
||||
MapleMap.this.allowSummons = b;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,14 @@
|
||||
*/
|
||||
package server.maps;
|
||||
|
||||
import constants.ServerConstants;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.TimerManager;
|
||||
|
||||
public class MapleMapManager {
|
||||
|
||||
@@ -38,8 +35,6 @@ public class MapleMapManager {
|
||||
|
||||
private Map<Integer, MapleMap> maps = new HashMap<>();
|
||||
|
||||
private ScheduledFuture<?> updateTask;
|
||||
|
||||
private ReadLock mapsRLock;
|
||||
private WriteLock mapsWLock;
|
||||
|
||||
@@ -51,13 +46,6 @@ public class MapleMapManager {
|
||||
ReentrantReadWriteLock rrwl = new MonitoredReentrantReadWriteLock(MonitoredLockType.MAP_MANAGER);
|
||||
this.mapsRLock = rrwl.readLock();
|
||||
this.mapsWLock = rrwl.writeLock();
|
||||
|
||||
updateTask = TimerManager.getInstance().register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateMaps();
|
||||
}
|
||||
}, ServerConstants.RESPAWN_INTERVAL);
|
||||
}
|
||||
|
||||
public MapleMap resetMap(int mapid) {
|
||||
@@ -136,7 +124,7 @@ public class MapleMapManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMaps() {
|
||||
public void updateMaps() {
|
||||
for (MapleMap map : getMaps().values()) {
|
||||
map.respawn();
|
||||
map.mobMpRecovery();
|
||||
@@ -144,11 +132,6 @@ public class MapleMapManager {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (updateTask != null) {
|
||||
updateTask.cancel(false);
|
||||
updateTask = null;
|
||||
}
|
||||
|
||||
for (MapleMap map : getMaps().values()) {
|
||||
map.dispose();
|
||||
}
|
||||
|
||||
@@ -49,19 +49,7 @@ public class MapleMiniDungeon {
|
||||
timeoutTask = TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lock.lock();
|
||||
try {
|
||||
List<MapleCharacter> lchr = new ArrayList<>(players);
|
||||
|
||||
for(MapleCharacter chr : lchr) {
|
||||
chr.changeMap(baseMap);
|
||||
}
|
||||
|
||||
dispose();
|
||||
timeoutTask = null;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
close();
|
||||
}
|
||||
}, expireTime);
|
||||
|
||||
@@ -95,8 +83,28 @@ public class MapleMiniDungeon {
|
||||
dispose();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
if (chr.isPartyLeader()) { // thanks Conrad for noticing party is not sent out of the MD as soon as leader leaves it
|
||||
close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
lock.lock();
|
||||
try {
|
||||
List<MapleCharacter> lchr = new ArrayList<>(players);
|
||||
|
||||
for(MapleCharacter chr : lchr) {
|
||||
chr.changeMap(baseMap);
|
||||
}
|
||||
|
||||
dispose();
|
||||
timeoutTask = null;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class MapleQuest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isAutoComplete() {
|
||||
return autoPreComplete || autoComplete;
|
||||
}
|
||||
@@ -544,8 +544,13 @@ public class MapleQuest {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean isExploitableQuest(short questid) {
|
||||
return exploitableQuests.contains(questid);
|
||||
public boolean restoreLostItem(MapleCharacter chr, int itemid) {
|
||||
ItemAction itemAct = (ItemAction) startActs.get(MapleQuestActionType.ITEM);
|
||||
if (itemAct != null) {
|
||||
return itemAct.restoreLostItem(chr, itemid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getMedalRequirement() {
|
||||
@@ -572,6 +577,10 @@ public class MapleQuest {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public static boolean isExploitableQuest(short questid) {
|
||||
return exploitableQuests.contains(questid);
|
||||
}
|
||||
|
||||
public static List<MapleQuest> getMatchedQuests(String search) {
|
||||
List<MapleQuest> ret = new LinkedList<>();
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@ import java.util.List;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
import tools.FilePrinter;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
import tools.Randomizer;
|
||||
@@ -250,8 +252,34 @@ public class ItemAction extends MapleQuestAction {
|
||||
}
|
||||
return jobFound;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean restoreLostItem(MapleCharacter chr, int itemid) {
|
||||
if (!MapleItemInformationProvider.getInstance().isQuestItem(itemid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// thanks danielktran (MapleHeroesD)
|
||||
for (ItemData item : items) {
|
||||
if (item.getId() == itemid) {
|
||||
int missingQty = item.getCount() - chr.countItem(itemid);
|
||||
if (missingQty > 0) {
|
||||
if (!chr.canHold(itemid, missingQty)) {
|
||||
chr.dropMessage(1, "Please check if you have enough space in your inventory.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MapleInventoryManipulator.addById(chr.getClient(), item.getId(), (short) missingQty);
|
||||
FilePrinter.print(FilePrinter.QUEST_RESTORE_ITEM, chr + " obtained " + itemid + " qty. " + missingQty + " from quest " + questID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private class ItemData {
|
||||
private final int map, id, count, job, gender;
|
||||
|
||||
Reference in New Issue
Block a user