Clean up MapleMap

This commit is contained in:
P0nk
2021-09-09 22:24:29 +02:00
parent 3fce4eb7ce
commit f8f524bfe7

View File

@@ -82,29 +82,30 @@ public class MapleMap {
private static final List<MapleMapObjectType> rangedMapobjectTypes = Arrays.asList(MapleMapObjectType.SHOP, MapleMapObjectType.ITEM, MapleMapObjectType.NPC, MapleMapObjectType.MONSTER, MapleMapObjectType.DOOR, MapleMapObjectType.SUMMON, MapleMapObjectType.REACTOR);
private static final Map<Integer, Pair<Integer, Integer>> dropBoundsCache = new HashMap<>(100);
private Map<Integer, MapleMapObject> mapobjects = new LinkedHashMap<>();
private Set<Integer> selfDestructives = new LinkedHashSet<>();
private Collection<SpawnPoint> monsterSpawn = Collections.synchronizedList(new LinkedList<>());
private Collection<SpawnPoint> allMonsterSpawn = Collections.synchronizedList(new LinkedList<>());
private AtomicInteger spawnedMonstersOnMap = new AtomicInteger(0);
private AtomicInteger droppedItemCount = new AtomicInteger(0);
private Collection<Character> characters = new LinkedHashSet<>();
private Map<Integer, Set<Integer>> mapParty = new LinkedHashMap<>();
private Map<Integer, MaplePortal> portals = new HashMap<>();
private Map<Integer, Integer> backgroundTypes = new HashMap<>();
private Map<String, Integer> environment = new LinkedHashMap<>();
private Map<MapleMapItem, Long> droppedItems = new LinkedHashMap<>();
private LinkedList<WeakReference<MapleMapObject>> registeredDrops = new LinkedList<>();
private Map<MobLootEntry, Long> mobLootEntries = new HashMap(20);
private List<Runnable> statUpdateRunnables = new ArrayList(50);
private List<Rectangle> areas = new ArrayList<>();
private final Map<Integer, MapleMapObject> mapobjects = new LinkedHashMap<>();
private final Set<Integer> selfDestructives = new LinkedHashSet<>();
private final Collection<SpawnPoint> monsterSpawn = Collections.synchronizedList(new LinkedList<>());
private final Collection<SpawnPoint> allMonsterSpawn = Collections.synchronizedList(new LinkedList<>());
private final AtomicInteger spawnedMonstersOnMap = new AtomicInteger(0);
private final AtomicInteger droppedItemCount = new AtomicInteger(0);
private final Collection<Character> characters = new LinkedHashSet<>();
private final Map<Integer, Set<Integer>> mapParty = new LinkedHashMap<>();
private final Map<Integer, MaplePortal> portals = new HashMap<>();
private final Map<Integer, Integer> backgroundTypes = new HashMap<>();
private final Map<String, Integer> environment = new LinkedHashMap<>();
private final Map<MapleMapItem, Long> droppedItems = new LinkedHashMap<>();
private final LinkedList<WeakReference<MapleMapObject>> registeredDrops = new LinkedList<>();
private final Map<MobLootEntry, Long> mobLootEntries = new HashMap(20);
private final List<Runnable> statUpdateRunnables = new ArrayList(50);
private final List<Rectangle> areas = new ArrayList<>();
private FootholdTree footholds = null;
private Pair<Integer, Integer> xLimits; // caches the min and max x's with available footholds
private Rectangle mapArea = new Rectangle();
private int mapid;
private AtomicInteger runningOid = new AtomicInteger(1000000001);
private int returnMapId;
private int channel, world;
private final Rectangle mapArea = new Rectangle();
private final int mapid;
private final AtomicInteger runningOid = new AtomicInteger(1000000001);
private final int returnMapId;
private final int channel;
private final int world;
private int seats;
private byte monsterRate;
private boolean clock;
@@ -156,12 +157,12 @@ public class MapleMap {
private int timeExpand;
//locks
private MonitoredReadLock chrRLock;
private MonitoredWriteLock chrWLock;
private MonitoredReadLock objectRLock;
private MonitoredWriteLock objectWLock;
private final MonitoredReadLock chrRLock;
private final MonitoredWriteLock chrWLock;
private final MonitoredReadLock objectRLock;
private final MonitoredWriteLock objectWLock;
private Lock lootLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MAP_LOOT, true);
private final Lock lootLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MAP_LOOT, true);
// due to the nature of loadMapFromWz (synchronized), sole function that calls 'generateMapDropRangeCache', this lock remains optional.
private static final Lock bndLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.MAP_BOUNDS, true);
@@ -493,7 +494,7 @@ public class MapleMap {
try {
Pair<Integer, Integer> bounds = dropBoundsCache.get(mapid);
if(bounds != null) {
if (bounds != null) {
xLimits = bounds;
} else {
// assuming MINIMAP always have an equal-greater picture representation of the map area (players won't walk beyond the area known by the minimap).
@@ -523,13 +524,13 @@ public class MapleMap {
int dx = distx / 2;
int searchx = homex + dx;
if((res = calcPointBelow(new Point(searchx, y))) != null) {
if ((res = calcPointBelow(new Point(searchx, y))) != null) {
awayx = searchx;
dropPos = res;
} else {
homex = searchx;
}
} while(Math.abs(homex - awayx) > 5);
} while (Math.abs(homex - awayx) > 5);
return (dropPos != null) ? dropPos : fallback;
}
@@ -537,7 +538,7 @@ public class MapleMap {
public Point calcDropPos(Point initial, Point fallback) {
if (initial.x < xLimits.left) {
initial.x = xLimits.left;
} else if(initial.x > xLimits.right) {
} else if (initial.x > xLimits.right) {
initial.x = xLimits.right;
}
@@ -546,7 +547,7 @@ public class MapleMap {
ret = bsearchDropPos(initial, fallback);
}
if(!mapArea.contains(ret)) { // found drop pos outside the map :O
if (!mapArea.contains(ret)) { // found drop pos outside the map :O
return fallback;
}
@@ -591,7 +592,7 @@ public class MapleMap {
*/
public static String getRoundedCoordinate(double angle) {
String[] directions = {"E", "SE", "S", "SW", "W", "NW", "N", "NE", "E"};
return directions[ (int)Math.round(( (angle % 360) / 45)) ];
return directions[(int) Math.round(((angle % 360) / 45))];
}
public Pair<String, Integer> getDoorPositionStatus(Point pos) {
@@ -600,7 +601,7 @@ public class MapleMap {
double angle = getAngle(portal.getPosition(), pos);
double distn = pos.distanceSq(portal.getPosition());
if(distn <= 777777.7) {
if (distn <= 777777.7) {
return null;
}
@@ -611,11 +612,11 @@ public class MapleMap {
private static void sortDropEntries(List<MonsterDropEntry> from, List<MonsterDropEntry> item, List<MonsterDropEntry> visibleQuest, List<MonsterDropEntry> otherQuest, Character chr) {
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
for(MonsterDropEntry mde : from) {
if(!ii.isQuestItem(mde.itemId)) {
for (MonsterDropEntry mde : from) {
if (!ii.isQuestItem(mde.itemId)) {
item.add(mde);
} else {
if(chr.needQuestItem(mde.questid, mde.itemId)) {
if (chr.needQuestItem(mde.questid, mde.itemId)) {
visibleQuest.add(mde);
} else {
otherQuest.add(mde);
@@ -625,7 +626,7 @@ public class MapleMap {
}
private byte dropItemsFromMonsterOnMap(List<MonsterDropEntry> dropEntry, Point pos, byte d, int chRate, byte droptype, int mobpos, Character chr, Monster mob) {
if(dropEntry.isEmpty()) {
if (dropEntry.isEmpty()) {
return d;
}
@@ -724,7 +725,7 @@ public class MapleMap {
final MonsterInformationProvider mi = MonsterInformationProvider.getInstance();
final List<MonsterGlobalDropEntry> globalEntry = mi.getRelevantGlobalDrops(this.getId());
final List<MonsterDropEntry> dropEntry = new ArrayList<>();
final List<MonsterDropEntry> dropEntry = new ArrayList<>();
final List<MonsterDropEntry> visibleQuestEntry = new ArrayList<>();
final List<MonsterDropEntry> otherQuestEntry = new ArrayList<>();
@@ -757,7 +758,7 @@ public class MapleMap {
}
public void dropFromReactor(final Character chr, final MapleReactor reactor, Item drop, Point dropPos, short questid) {
spawnDrop(drop, this.calcDropPos(dropPos, reactor.getPosition()), reactor, chr, (byte)(chr.getParty() != null ? 1 : 0), questid);
spawnDrop(drop, this.calcDropPos(dropPos, reactor.getPosition()), reactor, chr, (byte) (chr.getParty() != null ? 1 : 0), questid);
}
private void stopItemMonitor() {
@@ -767,7 +768,7 @@ public class MapleMap {
expireItemsTask.cancel(false);
expireItemsTask = null;
if(YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) {
if (YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) {
mobSpawnLootTask.cancel(false);
mobSpawnLootTask = null;
}
@@ -796,8 +797,8 @@ public class MapleMap {
chrWLock.lock();
try {
if (characters.isEmpty()) {
if(itemMonitorTimeout == 0) {
if(itemMonitor != null) {
if (itemMonitorTimeout == 0) {
if (itemMonitor != null) {
stopItemMonitor();
aggroMonitor.stopAggroCoordinator();
}
@@ -828,7 +829,7 @@ public class MapleMap {
expireItemsTask = TimerManager.getInstance().register(() -> makeDisappearExpiredItemDrops(), YamlConfig.config.server.ITEM_EXPIRE_CHECK, YamlConfig.config.server.ITEM_EXPIRE_CHECK);
if(YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) {
if (YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) {
lootLock.lock();
try {
mobLootEntries.clear();
@@ -861,7 +862,7 @@ public class MapleMap {
}
private void instantiateItemDrop(MapleMapItem mdrop) {
if(droppedItemCount.get() >= YamlConfig.config.server.ITEM_LIMIT_ON_MAP) {
if (droppedItemCount.get() >= YamlConfig.config.server.ITEM_LIMIT_ON_MAP) {
MapleMapObject mapobj;
do {
@@ -912,8 +913,8 @@ public class MapleMap {
try {
long timeNow = Server.getInstance().getCurrentTime();
for(Entry<MapleMapItem, Long> it : droppedItems.entrySet()) {
if(it.getValue() < timeNow) {
for (Entry<MapleMapItem, Long> it : droppedItems.entrySet()) {
if (it.getValue() < timeNow) {
toDisappear.add(it.getKey());
}
}
@@ -921,13 +922,13 @@ public class MapleMap {
objectRLock.unlock();
}
for(MapleMapItem mmi : toDisappear) {
for (MapleMapItem mmi : toDisappear) {
makeDisappearItemFromMap(mmi);
}
objectWLock.lock();
try {
for(MapleMapItem mmi : toDisappear) {
for (MapleMapItem mmi : toDisappear) {
droppedItems.remove(mmi);
}
} finally {
@@ -938,13 +939,13 @@ public class MapleMap {
private void registerMobItemDrops(byte droptype, int mobpos, int chRate, Point pos, List<MonsterDropEntry> dropEntry, List<MonsterDropEntry> visibleQuestEntry, List<MonsterDropEntry> otherQuestEntry, List<MonsterGlobalDropEntry> globalEntry, Character chr, Monster mob) {
MobLootEntry mle = new MobLootEntry(droptype, mobpos, chRate, pos, dropEntry, visibleQuestEntry, otherQuestEntry, globalEntry, chr, mob);
if(YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) {
if (YamlConfig.config.server.USE_SPAWN_LOOT_ON_ANIMATION) {
int animationTime = mob.getAnimationTime("die1");
lootLock.lock();
try {
long timeNow = Server.getInstance().getCurrentTime();
mobLootEntries.put(mle, timeNow + ((long)(0.42 * animationTime)));
mobLootEntries.put(mle, timeNow + ((long) (0.42 * animationTime)));
} finally {
lootLock.unlock();
}
@@ -965,20 +966,20 @@ public class MapleMap {
long timeNow = Server.getInstance().getCurrentTime();
List<MobLootEntry> toRemove = new LinkedList<>();
for(Entry<MobLootEntry, Long> mlee : mleList) {
if(mlee.getValue() < timeNow) {
for (Entry<MobLootEntry, Long> mlee : mleList) {
if (mlee.getValue() < timeNow) {
toRemove.add(mlee.getKey());
}
}
if(!toRemove.isEmpty()) {
if (!toRemove.isEmpty()) {
List<MobLootEntry> toSpawnLoot = new LinkedList<>();
lootLock.lock();
try {
for(MobLootEntry mle : toRemove) {
for (MobLootEntry mle : toRemove) {
Long mler = mobLootEntries.remove(mle);
if(mler != null) {
if (mler != null) {
toSpawnLoot.add(mle);
}
}
@@ -986,7 +987,7 @@ public class MapleMap {
lootLock.unlock();
}
for(MobLootEntry mle : toSpawnLoot) {
for (MobLootEntry mle : toSpawnLoot) {
mle.run();
}
}
@@ -1275,7 +1276,7 @@ public class MapleMap {
public int countAlivePlayers() {
int count = 0;
for(Character mc: getAllPlayers()) {
for (Character mc : getAllPlayers()) {
if (mc.isAlive()) {
count++;
}
@@ -1287,7 +1288,7 @@ public class MapleMap {
public int countBosses() {
int count = 0;
for(Monster mob: getAllMonsters()) {
for (Monster mob : getAllMonsters()) {
if (mob.isBoss()) {
count++;
}
@@ -1344,7 +1345,7 @@ public class MapleMap {
private boolean removeKilledMonsterObject(Monster monster) {
monster.lockMonster();
try {
if(monster.getHp() < 0) {
if (monster.getHp() < 0) {
return false;
}
@@ -1444,8 +1445,8 @@ public class MapleMap {
}
if (monster.hasBossHPBar()) {
for(Character mc : this.getAllPlayers()) {
if(mc.getTargetHpBarHash() == monster.hashCode()) {
for (Character mc : this.getAllPlayers()) {
if (mc.getTargetHpBarHash() == monster.hashCode()) {
mc.resetPlayerAggro();
}
}
@@ -1478,7 +1479,7 @@ public class MapleMap {
public void killMonsterWithDrops(int mobId) {
Map<Integer, Character> mapChars = this.getMapPlayers();
if(!mapChars.isEmpty()) {
if (!mapChars.isEmpty()) {
Character defaultChr = mapChars.entrySet().iterator().next().getValue();
List<Monster> mobList = getAllMonsters();
@@ -1504,7 +1505,7 @@ public class MapleMap {
continue;
}
if(removeKilledMonsterObject(monster)) {
if (removeKilledMonsterObject(monster)) {
monster.dispatchMonsterKilled(false);
}
}
@@ -1641,10 +1642,10 @@ public class MapleMap {
objectRLock.lock();
try {
for (Object ob : list) {
if(ob instanceof MapleMapObject) {
if (ob instanceof MapleMapObject) {
MapleMapObject mmo = (MapleMapObject) ob;
if(mapobjects.containsValue(mmo) && mmo.getType() == MapleMapObjectType.REACTOR) {
if (mapobjects.containsValue(mmo) && mmo.getType() == MapleMapObjectType.REACTOR) {
listObjects.add(mmo);
}
}
@@ -1915,8 +1916,8 @@ public class MapleMap {
}
public void spawnAllMonsterIdFromMapSpawnList(int id, int difficulty, boolean isPq) {
for(SpawnPoint sp: getAllMonsterSpawn()) {
if(sp.getMonsterId() == id && sp.shouldForceSpawn()) {
for (SpawnPoint sp : getAllMonsterSpawn()) {
if (sp.getMonsterId() == id && sp.shouldForceSpawn()) {
spawnMonster(sp.getMonster(), difficulty, isPq);
}
}
@@ -1927,7 +1928,7 @@ public class MapleMap {
}
public void spawnAllMonstersFromMapSpawnList(int difficulty, boolean isPq) {
for(SpawnPoint sp: getAllMonsterSpawn()) {
for (SpawnPoint sp : getAllMonsterSpawn()) {
spawnMonster(sp.getMonster(), difficulty, isPq);
}
}
@@ -2052,7 +2053,7 @@ public class MapleMap {
public MaplePortal getDoorPortal(int doorid) {
MaplePortal doorPortal = portals.get(0x80 + doorid);
if(doorPortal == null) {
if (doorPortal == null) {
FilePrinter.printError(FilePrinter.EXCEPTION, "[Door] " + mapName + "(" + mapid + ") does not contain door portalid " + doorid);
return portals.get(0x80);
}
@@ -2126,7 +2127,7 @@ public class MapleMap {
}
public final void spawnItemDrop(final MapleMapObject dropper, final Character owner, final Item item, Point pos, final boolean ffaDrop, final boolean playerDrop) {
spawnItemDrop(dropper, owner, item, pos, (byte)(ffaDrop ? 2 : 0), playerDrop);
spawnItemDrop(dropper, owner, item, pos, (byte) (ffaDrop ? 2 : 0), playerDrop);
}
public final void spawnItemDrop(final MapleMapObject dropper, final Character owner, final Item item, Point pos, final byte dropType, final boolean playerDrop) {
@@ -2170,7 +2171,7 @@ public class MapleMap {
// spawns item instances of all defined item ids on a list
public final void spawnItemDropList(List<Integer> list, int minCopies, int maxCopies, final MapleMapObject dropper, final Character owner, Point pos, final boolean ffaDrop, final boolean playerDrop) {
int copies = (maxCopies - minCopies) + 1;
if(copies < 1) {
if (copies < 1) {
return;
}
@@ -2239,16 +2240,16 @@ public class MapleMap {
objectRLock.unlock();
}
for(final MapleMapItem drop : list) {
for (final MapleMapItem drop : list) {
drop.lockItem();
try {
if(!drop.isPickedUp()) {
if (!drop.isPickedUp()) {
final Item item = drop.getItem();
if (item != null && reactItem == item.getItemId() && reactQty == item.getQuantity()) {
if (reactArea.contains(drop.getPosition())) {
Client owner = drop.getOwnerClient();
if(owner != null) {
if (owner != null) {
registerMapSchedule(new ActivateItemReactor(drop, react, owner), 5000);
}
}
@@ -2300,7 +2301,7 @@ public class MapleMap {
}
Set<Integer> partyEntry = mapParty.get(partyid);
if(partyEntry == null) {
if (partyEntry == null) {
partyEntry = new LinkedHashSet<>();
partyEntry.add(chr.getId());
@@ -2316,7 +2317,7 @@ public class MapleMap {
}
Set<Integer> partyEntry = mapParty.get(partyid);
if(partyEntry != null) {
if (partyEntry != null) {
if (partyEntry.size() > 1) {
partyEntry.remove(chr.getId());
} else {
@@ -2373,7 +2374,7 @@ public class MapleMap {
MapScriptManager msm = MapScriptManager.getInstance();
if (chrSize == 1) {
if(!hasItemMonitor()) {
if (!hasItemMonitor()) {
startItemMonitor();
aggroMonitor.startAggroCoordinator();
}
@@ -2636,7 +2637,7 @@ public class MapleMap {
public MaplePortal findMarketPortal() {
for (MaplePortal portal : portals.values()) {
String ptScript = portal.getScriptName();
if(ptScript != null && ptScript.contains("market")) {
if (ptScript != null && ptScript.contains("market")) {
return portal;
}
}
@@ -2682,8 +2683,8 @@ public class MapleMap {
if (MapleMiniDungeonInfo.isDungeonMap(mapid)) {
MapleMiniDungeon mmd = cserv.getMiniDungeon(mapid);
if(mmd != null) {
if(!mmd.unregisterPlayer(chr)) {
if (mmd != null) {
if (!mmd.unregisterPlayer(chr)) {
cserv.removeMiniDungeon(mapid);
}
}
@@ -3086,7 +3087,7 @@ public class MapleMap {
checkpos.y -= 1;
List<SpawnPoint> toRemove = new LinkedList<>();
for(SpawnPoint sp: getMonsterSpawn()) {
for (SpawnPoint sp : getMonsterSpawn()) {
Point pos = sp.getPosition();
if (sp.getMonsterId() == mobId && checkpos.equals(pos)) {
toRemove.add(sp);
@@ -3109,7 +3110,7 @@ public class MapleMap {
checkpos.y -= 1;
List<SpawnPoint> toRemove = new LinkedList<>();
for(SpawnPoint sp: getAllMonsterSpawn()) {
for (SpawnPoint sp : getAllMonsterSpawn()) {
Point pos = sp.getPosition();
if (sp.getMonsterId() == mobId && checkpos.equals(pos)) {
toRemove.add(sp);
@@ -3127,7 +3128,7 @@ public class MapleMap {
public void reportMonsterSpawnPoints(Character chr) {
chr.dropMessage(6, "Mob spawnpoints on map " + getId() + ", with available Mob SPs " + monsterSpawn.size() + ", used " + spawnedMonstersOnMap.get() + ":");
for(SpawnPoint sp: getAllMonsterSpawn()) {
for (SpawnPoint sp : getAllMonsterSpawn()) {
chr.dropMessage(6, " id: " + sp.getMonsterId() + " canSpawn: " + !sp.getDenySpawn() + " numSpawned: " + sp.getSpawned() + " x: " + sp.getPosition().getX() + " y: " + sp.getPosition().getY() + " time: " + sp.getMobTime() + " team: " + sp.getTeam());
}
}
@@ -3137,7 +3138,7 @@ public class MapleMap {
try {
Map<Integer, Character> mapChars = new HashMap<>(characters.size());
for(Character chr : characters) {
for (Character chr : characters) {
mapChars.put(chr.getId(), chr);
}
@@ -3331,7 +3332,7 @@ public class MapleMap {
chrRLock.lock();
try {
for (Character chr : this.characters) {
if (chr.getName().toLowerCase().equals(name.toLowerCase())) {
if (chr.getName().equalsIgnoreCase(name)) {
return chr;
}
}
@@ -3342,7 +3343,7 @@ public class MapleMap {
}
public boolean makeDisappearItemFromMap(MapleMapObject mapobj) {
if(mapobj instanceof MapleMapItem) {
if (mapobj instanceof MapleMapItem) {
return makeDisappearItemFromMap((MapleMapItem) mapobj);
} else {
return mapobj == null; // no drop to make disappear...
@@ -3369,16 +3370,16 @@ public class MapleMap {
private class MobLootEntry implements Runnable {
private byte droptype;
private int mobpos;
private int chRate;
private Point pos;
private List<MonsterDropEntry> dropEntry;
private List<MonsterDropEntry> visibleQuestEntry;
private List<MonsterDropEntry> otherQuestEntry;
private List<MonsterGlobalDropEntry> globalEntry;
private Character chr;
private Monster mob;
private final byte droptype;
private final int mobpos;
private final int chRate;
private final Point pos;
private final List<MonsterDropEntry> dropEntry;
private final List<MonsterDropEntry> visibleQuestEntry;
private final List<MonsterDropEntry> otherQuestEntry;
private final List<MonsterGlobalDropEntry> globalEntry;
private final Character chr;
private final Monster mob;
protected MobLootEntry(byte droptype, int mobpos, int chRate, Point pos, List<MonsterDropEntry> dropEntry, List<MonsterDropEntry> visibleQuestEntry, List<MonsterDropEntry> otherQuestEntry, List<MonsterGlobalDropEntry> globalEntry, Character chr, Monster mob) {
this.droptype = droptype;
@@ -3411,9 +3412,9 @@ public class MapleMap {
private class ActivateItemReactor implements Runnable {
private MapleMapItem mapitem;
private MapleReactor reactor;
private Client c;
private final MapleMapItem mapitem;
private final MapleReactor reactor;
private final Client c;
public ActivateItemReactor(MapleMapItem mapitem, MapleReactor reactor, Client c) {
this.mapitem = mapitem;
@@ -3425,7 +3426,7 @@ public class MapleMap {
public void run() {
reactor.hitLockReactor();
try {
if(reactor.getReactorType() == 100) {
if (reactor.getReactorType() == 100) {
if (reactor.getShouldCollect() == true && mapitem != null && mapitem == getMapObject(mapitem.getObjectId())) {
mapitem.lockItem();
try {
@@ -3470,8 +3471,8 @@ public class MapleMap {
}
public void instanceMapFirstSpawn(int difficulty, boolean isPq) {
for(SpawnPoint spawnPoint: getAllMonsterSpawn()) {
if(spawnPoint.getMobTime() == -1) { //just those allowed to be spawned only once
for (SpawnPoint spawnPoint : getAllMonsterSpawn()) {
if (spawnPoint.getMobTime() == -1) { //just those allowed to be spawned only once
spawnMonster(spawnPoint.getMonster());
}
}
@@ -3488,7 +3489,7 @@ public class MapleMap {
Collections.shuffle(randomSpawn);
int spawned = 0;
for (SpawnPoint spawnPoint : randomSpawn) {
if(spawnPoint.shouldSpawn()) {
if (spawnPoint.shouldSpawn()) {
spawnMonster(spawnPoint.getMonster());
spawned++;
if (spawned >= numShouldSpawn) {
@@ -3510,7 +3511,7 @@ public class MapleMap {
Collections.shuffle(randomSpawn);
int spawned = 0;
for (SpawnPoint spawnPoint : randomSpawn) {
if(spawnPoint.shouldForceSpawn()) {
if (spawnPoint.shouldForceSpawn()) {
spawnMonster(spawnPoint.getMonster());
spawned++;
if (spawned >= numShouldSpawn) {
@@ -3534,16 +3535,16 @@ public class MapleMap {
}
public void setAllowSpawnPointInBox(boolean allow, Rectangle box) {
for(SpawnPoint sp: getMonsterSpawn()) {
if(box.contains(sp.getPosition())) {
for (SpawnPoint sp : getMonsterSpawn()) {
if (box.contains(sp.getPosition())) {
sp.setDenySpawn(!allow);
}
}
}
public void setAllowSpawnPointInRange(boolean allow, Point from, double rangeSq) {
for(SpawnPoint sp: getMonsterSpawn()) {
if(from.distanceSq(sp.getPosition()) <= rangeSq) {
for (SpawnPoint sp : getMonsterSpawn()) {
if (from.distanceSq(sp.getPosition()) <= rangeSq) {
sp.setDenySpawn(!allow);
}
}
@@ -3576,7 +3577,7 @@ public class MapleMap {
System.out.println("----------------------------------");
*/
if(YamlConfig.config.server.USE_ENABLE_FULL_RESPAWN) {
if (YamlConfig.config.server.USE_ENABLE_FULL_RESPAWN) {
return (monsterSpawn.size() - spawnedMonstersOnMap.get());
}
@@ -3594,7 +3595,7 @@ public class MapleMap {
try {
numPlayers = characters.size();
if(numPlayers == 0) {
if (numPlayers == 0) {
return;
}
} finally {
@@ -3602,16 +3603,16 @@ public class MapleMap {
}
int numShouldSpawn = getNumShouldSpawn(numPlayers);
if(numShouldSpawn > 0) {
if (numShouldSpawn > 0) {
List<SpawnPoint> randomSpawn = new ArrayList<>(getMonsterSpawn());
Collections.shuffle(randomSpawn);
short spawned = 0;
for(SpawnPoint spawnPoint : randomSpawn) {
if(spawnPoint.shouldSpawn()) {
for (SpawnPoint spawnPoint : randomSpawn) {
if (spawnPoint.shouldSpawn()) {
spawnMonster(spawnPoint.getMonster());
spawned++;
if(spawned >= numShouldSpawn) {
if (spawned >= numShouldSpawn) {
break;
}
}
@@ -4029,7 +4030,7 @@ public class MapleMap {
}
public boolean isHorntailDefeated() { // all parts of dead horntail can be found here?
for(int i = 8810010; i <= 8810017; i++) {
for (int i = 8810010; i <= 8810017; i++) {
if (getMonsterById(i) == null) {
return false;
}
@@ -4149,8 +4150,8 @@ public class MapleMap {
private final List<GuardianSpawnPoint> guardianSpawns = new LinkedList<>();
private final List<MCSkill> blueTeamBuffs = new ArrayList();
private final List<MCSkill> redTeamBuffs = new ArrayList();
private List<Integer> skillIds = new ArrayList();
private List<Pair<Integer, Integer>> mobsToSpawn = new ArrayList();
private final List<Integer> skillIds = new ArrayList();
private final List<Pair<Integer, Integer>> mobsToSpawn = new ArrayList();
public List<MCSkill> getBlueTeamBuffs() {
return blueTeamBuffs;
@@ -4314,7 +4315,9 @@ public class MapleMap {
}
public void buffMonsters(int team, MCSkill skill) {
if (skill == null) return;
if (skill == null) {
return;
}
if (team == 0) {
redTeamBuffs.add(skill);
@@ -4395,7 +4398,7 @@ public class MapleMap {
}
public void dispose() {
for(Monster mm : this.getAllMonsters()) {
for (Monster mm : this.getAllMonsters()) {
mm.dispose();
}
@@ -4411,22 +4414,22 @@ public class MapleMap {
aggroMonitor.dispose();
aggroMonitor = null;
if(itemMonitor != null) {
if (itemMonitor != null) {
itemMonitor.cancel(false);
itemMonitor = null;
}
if(expireItemsTask != null) {
if (expireItemsTask != null) {
expireItemsTask.cancel(false);
expireItemsTask = null;
}
if(mobSpawnLootTask != null) {
if (mobSpawnLootTask != null) {
mobSpawnLootTask.cancel(false);
mobSpawnLootTask = null;
}
if(characterStatUpdateTask != null) {
if (characterStatUpdateTask != null) {
characterStatUpdateTask.cancel(false);
characterStatUpdateTask = null;
}