Rename and clean up MapleEventRecallCoordinator
This commit is contained in:
@@ -35,7 +35,7 @@ import net.server.channel.Channel;
|
||||
import net.server.channel.CharacterIdChannelPair;
|
||||
import net.server.coordinator.session.Hwid;
|
||||
import net.server.coordinator.session.SessionCoordinator;
|
||||
import net.server.coordinator.world.MapleEventRecallCoordinator;
|
||||
import net.server.coordinator.world.EventRecallCoordinator;
|
||||
import net.server.guild.GuildPackets;
|
||||
import net.server.guild.MapleAlliance;
|
||||
import net.server.guild.MapleGuild;
|
||||
@@ -408,7 +408,7 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
|
||||
}
|
||||
|
||||
if (newcomer) {
|
||||
EventInstanceManager eim = MapleEventRecallCoordinator.getInstance().recallEventInstance(cid);
|
||||
EventInstanceManager eim = EventRecallCoordinator.getInstance().recallEventInstance(cid);
|
||||
if (eim != null) {
|
||||
eim.registerPlayer(player);
|
||||
}
|
||||
|
||||
@@ -21,44 +21,44 @@ package net.server.coordinator.world;
|
||||
|
||||
import config.YamlConfig;
|
||||
import scripting.event.EventInstanceManager;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MapleEventRecallCoordinator {
|
||||
|
||||
private final static MapleEventRecallCoordinator instance = new MapleEventRecallCoordinator();
|
||||
|
||||
public static MapleEventRecallCoordinator getInstance() {
|
||||
public class EventRecallCoordinator {
|
||||
|
||||
private final static EventRecallCoordinator instance = new EventRecallCoordinator();
|
||||
|
||||
public static EventRecallCoordinator getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ConcurrentHashMap<Integer, EventInstanceManager> eventHistory = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
private final ConcurrentHashMap<Integer, EventInstanceManager> eventHistory = new ConcurrentHashMap<>();
|
||||
|
||||
private static boolean isRecallableEvent(EventInstanceManager eim) {
|
||||
return eim != null && !eim.isEventDisposed() && !eim.isEventCleared();
|
||||
}
|
||||
|
||||
|
||||
public EventInstanceManager recallEventInstance(int characterId) {
|
||||
EventInstanceManager eim = eventHistory.remove(characterId);
|
||||
return isRecallableEvent(eim) ? eim : null;
|
||||
}
|
||||
|
||||
|
||||
public void storeEventInstance(int characterId, EventInstanceManager eim) {
|
||||
if (YamlConfig.config.server.USE_ENABLE_RECALL_EVENT && isRecallableEvent(eim)) {
|
||||
eventHistory.put(characterId, eim);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void manageEventInstances() {
|
||||
if (!eventHistory.isEmpty()) {
|
||||
List<Integer> toRemove = new LinkedList<>();
|
||||
|
||||
|
||||
for (Entry<Integer, EventInstanceManager> eh : eventHistory.entrySet()) {
|
||||
if (!isRecallableEvent(eh.getValue())) {
|
||||
toRemove.add(eh.getKey());
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
package net.server.task;
|
||||
|
||||
import net.server.coordinator.world.MapleEventRecallCoordinator;
|
||||
import net.server.coordinator.world.EventRecallCoordinator;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,6 +29,6 @@ public class EventRecallCoordinatorTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
MapleEventRecallCoordinator.getInstance().manageEventInstances();
|
||||
EventRecallCoordinator.getInstance().manageEventInstances();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.server.audit.locks.*;
|
||||
import net.server.audit.locks.factory.MonitoredReadLockFactory;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import net.server.audit.locks.factory.MonitoredWriteLockFactory;
|
||||
import net.server.coordinator.world.MapleEventRecallCoordinator;
|
||||
import net.server.coordinator.world.EventRecallCoordinator;
|
||||
import net.server.world.MapleParty;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
@@ -552,7 +552,7 @@ public class EventInstanceManager {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
MapleEventRecallCoordinator.getInstance().storeEventInstance(chr.getId(), this);
|
||||
EventRecallCoordinator.getInstance().storeEventInstance(chr.getId(), this);
|
||||
}
|
||||
|
||||
public void monsterKilled(Character chr, final MapleMonster mob) {
|
||||
|
||||
Reference in New Issue
Block a user