From e917980a39e8b22202d9a7c2f6eb51b6c29c9490 Mon Sep 17 00:00:00 2001 From: P0nk Date: Thu, 9 Sep 2021 22:27:30 +0200 Subject: [PATCH] Rename and clean up MapleMapManager --- src/main/java/client/Character.java | 2 +- src/main/java/net/server/channel/Channel.java | 6 ++--- .../java/net/server/task/RespawnTask.java | 4 ++-- .../scripting/event/EventInstanceManager.java | 8 +++---- .../scripting/npc/NPCConversationManager.java | 4 ++-- .../{MapleMapManager.java => MapManager.java} | 24 +++++++++---------- 6 files changed, 24 insertions(+), 24 deletions(-) rename src/main/java/server/maps/{MapleMapManager.java => MapManager.java} (91%) diff --git a/src/main/java/client/Character.java b/src/main/java/client/Character.java index 80c941f112..a0f8a04cc8 100644 --- a/src/main/java/client/Character.java +++ b/src/main/java/client/Character.java @@ -7114,7 +7114,7 @@ public class Character extends AbstractCharacterObject { if (channelserver) { - MapleMapManager mapManager = client.getChannelServer().getMapFactory(); + MapManager mapManager = client.getChannelServer().getMapFactory(); ret.map = mapManager.getMap(ret.mapid); if (ret.map == null) { diff --git a/src/main/java/net/server/channel/Channel.java b/src/main/java/net/server/channel/Channel.java index 7dc55b97dc..a417b62e2c 100644 --- a/src/main/java/net/server/channel/Channel.java +++ b/src/main/java/net/server/channel/Channel.java @@ -67,7 +67,7 @@ public final class Channel { private PlayerStorage players = new PlayerStorage(); private ChannelServer channelServer; private String serverMessage; - private MapleMapManager mapManager; + private MapManager mapManager; private EventScriptManager eventSM; private ServicesManager services; private Map hiredMerchants = new HashMap<>(); @@ -113,7 +113,7 @@ public final class Channel { this.channel = channel; this.ongoingStartTime = startTime + 10000; // rude approach to a world's last channel boot time, placeholder for the 1st wedding reservation ever - this.mapManager = new MapleMapManager(null, world, channel); + this.mapManager = new MapManager(null, world, channel); this.port = BASE_PORT + (this.channel - 1) + (world * 100); this.ip = YamlConfig.config.server.HOST + ":" + port; @@ -246,7 +246,7 @@ public final class Channel { } } - public MapleMapManager getMapFactory() { + public MapManager getMapFactory() { return mapManager; } diff --git a/src/main/java/net/server/task/RespawnTask.java b/src/main/java/net/server/task/RespawnTask.java index 0a3c74078d..647634ca90 100644 --- a/src/main/java/net/server/task/RespawnTask.java +++ b/src/main/java/net/server/task/RespawnTask.java @@ -3,7 +3,7 @@ package net.server.task; import net.server.PlayerStorage; import net.server.Server; import net.server.channel.Channel; -import server.maps.MapleMapManager; +import server.maps.MapManager; /** * @author Resinate @@ -16,7 +16,7 @@ public class RespawnTask implements Runnable { PlayerStorage ps = ch.getPlayerStorage(); if (ps != null) { if (!ps.getAllCharacters().isEmpty()) { - MapleMapManager mapManager = ch.getMapFactory(); + MapManager mapManager = ch.getMapFactory(); if (mapManager != null) { mapManager.updateMaps(); } diff --git a/src/main/java/scripting/event/EventInstanceManager.java b/src/main/java/scripting/event/EventInstanceManager.java index e81e4e9267..00de090cdd 100644 --- a/src/main/java/scripting/event/EventInstanceManager.java +++ b/src/main/java/scripting/event/EventInstanceManager.java @@ -44,8 +44,8 @@ import server.expeditions.Expedition; import server.life.LifeFactory; import server.life.Monster; import server.life.NPC; +import server.maps.MapManager; import server.maps.MapleMap; -import server.maps.MapleMapManager; import server.maps.MaplePortal; import server.maps.MapleReactor; import tools.PacketCreator; @@ -71,7 +71,7 @@ public class EventInstanceManager { private Map killCount = new HashMap<>(); private EventManager em; private EventScriptScheduler ess; - private MapleMapManager mapManager; + private MapManager mapManager; private String name; private Properties props = new Properties(); private Map objectProps = new HashMap<>(); @@ -114,7 +114,7 @@ public class EventInstanceManager { this.em = em; this.name = name; this.ess = new EventScriptScheduler(); - this.mapManager = new MapleMapManager(this, em.getWorldServer().getId(), em.getChannelServer().getId()); + this.mapManager = new MapManager(this, em.getWorldServer().getId(), em.getChannelServer().getId()); } public void setName(String name) { @@ -656,7 +656,7 @@ public class EventInstanceManager { sL = sL.dispose(); } - public MapleMapManager getMapFactory() { + public MapManager getMapFactory() { return mapManager; } diff --git a/src/main/java/scripting/npc/NPCConversationManager.java b/src/main/java/scripting/npc/NPCConversationManager.java index a684575e58..ac3842a778 100644 --- a/src/main/java/scripting/npc/NPCConversationManager.java +++ b/src/main/java/scripting/npc/NPCConversationManager.java @@ -51,8 +51,8 @@ import server.gachapon.MapleGachapon; import server.gachapon.MapleGachapon.MapleGachaponItem; import server.life.LifeFactory; import server.life.PlayerNPC; +import server.maps.MapManager; import server.maps.MapleMap; -import server.maps.MapleMapManager; import server.maps.MapleMapObject; import server.maps.MapleMapObjectType; import server.partyquest.AriantColiseum; @@ -499,7 +499,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction { PyramidMode mod = PyramidMode.valueOf(mode); Party partyz = getPlayer().getParty(); - MapleMapManager mapManager = c.getChannelServer().getMapFactory(); + MapManager mapManager = c.getChannelServer().getMapFactory(); MapleMap map = null; int mapid = 926010100; diff --git a/src/main/java/server/maps/MapleMapManager.java b/src/main/java/server/maps/MapManager.java similarity index 91% rename from src/main/java/server/maps/MapleMapManager.java rename to src/main/java/server/maps/MapManager.java index 892f821f29..547339a4e5 100644 --- a/src/main/java/server/maps/MapleMapManager.java +++ b/src/main/java/server/maps/MapManager.java @@ -30,17 +30,17 @@ import scripting.event.EventInstanceManager; import java.util.HashMap; import java.util.Map; -public class MapleMapManager { - - private int channel, world; +public class MapManager { + private final int channel; + private final int world; private EventInstanceManager event; - - private Map maps = new HashMap<>(); - - private MonitoredReadLock mapsRLock; - private MonitoredWriteLock mapsWLock; - public MapleMapManager(EventInstanceManager eim, int world, int channel) { + private final Map maps = new HashMap<>(); + + private final MonitoredReadLock mapsRLock; + private final MonitoredWriteLock mapsWLock; + + public MapManager(EventInstanceManager eim, int world, int channel) { this.world = world; this.channel = channel; this.event = eim; @@ -103,7 +103,7 @@ public class MapleMapManager { return (map != null) ? map : loadMapFromWz(mapid, true); } - + public MapleMap getDisposableMap(int mapid) { return loadMapFromWz(mapid, false); } @@ -125,14 +125,14 @@ public class MapleMapManager { mapsRLock.unlock(); } } - + public void updateMaps() { for (MapleMap map : getMaps().values()) { map.respawn(); map.mobMpRecovery(); } } - + public void dispose() { for (MapleMap map : getMaps().values()) { map.dispose();