Rename MaplePortal

This commit is contained in:
P0nk
2021-09-09 22:36:45 +02:00
parent 667bc69eb1
commit 7f4760ba1a
19 changed files with 69 additions and 69 deletions

View File

@@ -802,7 +802,7 @@ public class Character extends AbstractCharacterObject {
c.setAccountName(this.client.getAccountName());//No null's for accountName
this.setClient(c);
this.map = c.getChannelServer().getMapFactory().getMap(getMapId());
MaplePortal portal = map.findClosestPlayerSpawnpoint(getPosition());
Portal portal = map.findClosestPlayerSpawnpoint(getPosition());
if (portal == null) {
portal = map.getPortal(0);
}
@@ -1292,7 +1292,7 @@ public class Character extends AbstractCharacterObject {
}
MapleMap map_ = getWarpMap(mapid);
MaplePortal portal_ = map_.getPortal(portal);
Portal portal_ = map_.getPortal(portal);
changeMap(map_, portal_ != null ? portal_ : map_.getRandomPlayerSpawnpoint());
setBanishPlayerData(banMap, banSp, banTime);
@@ -1337,7 +1337,7 @@ public class Character extends AbstractCharacterObject {
changeMap(warpMap, warpMap.getPortal(portal));
}
public void changeMap(int map, MaplePortal portal) {
public void changeMap(int map, Portal portal) {
MapleMap warpMap;
EventInstanceManager eim = getEventInstance();
@@ -1358,7 +1358,7 @@ public class Character extends AbstractCharacterObject {
changeMap(to, to.getPortal(portal));
}
public void changeMap(final MapleMap target, MaplePortal pto) {
public void changeMap(final MapleMap target, Portal pto) {
canWarpCounter++;
eventChangedMap(target.getId()); // player can be dropped from an event here, hence the new warping target.
@@ -1393,7 +1393,7 @@ public class Character extends AbstractCharacterObject {
eventAfterChangedMap(this.getMapId());
}
public void forceChangeMap(final MapleMap target, MaplePortal pto) {
public void forceChangeMap(final MapleMap target, Portal pto) {
// will actually enter the map given as parameter, regardless of being an eventmap or whatnot
canWarpCounter++;
@@ -7120,7 +7120,7 @@ public class Character extends AbstractCharacterObject {
if (ret.map == null) {
ret.map = mapManager.getMap(100000000);
}
MaplePortal portal = ret.map.getPortal(ret.initialSpawnPoint);
Portal portal = ret.map.getPortal(ret.initialSpawnPoint);
if (portal == null) {
portal = ret.map.getPortal(0);
ret.initialSpawnPoint = 0;
@@ -8145,7 +8145,7 @@ public class Character extends AbstractCharacterObject {
}
public void saveLocationOnWarp() { // suggestion to remember the map before warp command thanks to Lei
MaplePortal closest = map.findClosestPortal(getPosition());
Portal closest = map.findClosestPortal(getPosition());
int curMapid = getMapId();
for (int i = 0; i < savedLocations.length; i++) {
@@ -8156,7 +8156,7 @@ public class Character extends AbstractCharacterObject {
}
public void saveLocation(String type) {
MaplePortal closest = map.findClosestPortal(getPosition());
Portal closest = map.findClosestPortal(getPosition());
savedLocations[SavedLocationType.fromString(type).ordinal()] = new SavedLocation(getMapId(), closest != null ? closest.getId() : 0);
}
@@ -8412,7 +8412,7 @@ public class Character extends AbstractCharacterObject {
if (map == null || map.getId() == 610020000 || map.getId() == 610020001) { // reset to first spawnpoint on those maps
ps.setInt(24, 0);
} else {
MaplePortal closest = map.findClosestPlayerSpawnpoint(getPosition());
Portal closest = map.findClosestPlayerSpawnpoint(getPosition());
if (closest != null) {
ps.setInt(24, closest.getId());
} else {

View File

@@ -108,7 +108,7 @@ public class GotoCommand extends Command {
MapleMap target = c.getChannelServer().getMapFactory().getMap(gotomaps.get(params[0]));
// expedition issue with this command detected thanks to Masterrulax
MaplePortal targetPortal = target.getRandomPlayerSpawnpoint();
Portal targetPortal = target.getRandomPlayerSpawnpoint();
player.saveLocationOnWarp();
player.changeMap(target, targetPortal);
} else {

View File

@@ -27,7 +27,7 @@ import client.Character;
import client.Client;
import client.command.Command;
import server.maps.MapleMap;
import server.maps.MaplePortal;
import server.maps.Portal;
public class JailCommand extends Command {
{
@@ -59,7 +59,7 @@ public class JailCommand extends Command {
if (victim.getMapId() != mapid) { // those gone to jail won't be changing map anyway
MapleMap target = c.getChannelServer().getMapFactory().getMap(mapid);
MaplePortal targetPortal = target.getPortal(0);
Portal targetPortal = target.getPortal(0);
victim.saveLocationOnWarp();
victim.changeMap(target, targetPortal);
player.message(victim.getName() + " was jailed for " + minutesJailed + " minutes.");

View File

@@ -32,8 +32,8 @@ import server.life.Monster;
import server.life.SpawnPoint;
import server.maps.MapObject;
import server.maps.MapObjectType;
import server.maps.MaplePortal;
import server.maps.MapleReactor;
import server.maps.Portal;
import java.awt.*;
import java.util.Arrays;
@@ -80,7 +80,7 @@ public class DebugCommand extends Command {
break;
case "portal":
MaplePortal portal = player.getMap().findClosestPortal(player.getPosition());
Portal portal = player.getMap().findClosestPortal(player.getPosition());
if (portal != null)
player.dropMessage(6, "Closest portal: " + portal.getId() + " '" + portal.getName() + "' Type: " + portal.getType() + " --> toMap: " + portal.getTargetMapId() + " scriptname: '" + portal.getScriptName() + "' state: " + (portal.getPortalState() ? 1 : 0) + ".");
else player.dropMessage(6, "There is no portal on this map.");

View File

@@ -29,7 +29,7 @@ import net.AbstractPacketHandler;
import net.packet.InPacket;
import server.MapleTrade;
import server.maps.MapleMap;
import server.maps.MaplePortal;
import server.maps.Portal;
import tools.FilePrinter;
import tools.PacketCreator;
@@ -78,7 +78,7 @@ public final class ChangeMapHandler extends AbstractPacketHandler {
p.readByte(); // 1 = from dying 0 = regular portals
int targetid = p.readInt();
String startwp = p.readString();
MaplePortal portal = chr.getMap().getPortal(startwp);
Portal portal = chr.getMap().getPortal(startwp);
p.readByte();
boolean wheel = p.readByte() > 0;

View File

@@ -26,7 +26,7 @@ import net.AbstractPacketHandler;
import net.packet.InPacket;
import server.MapleTrade;
import server.MapleTrade.TradeResult;
import server.maps.MaplePortal;
import server.maps.Portal;
import tools.PacketCreator;
public final class ChangeMapSpecialHandler extends AbstractPacketHandler {
@@ -35,7 +35,7 @@ public final class ChangeMapSpecialHandler extends AbstractPacketHandler {
p.readByte();
String startwp = p.readString();
p.readShort();
MaplePortal portal = c.getPlayer().getMap().getPortal(startwp);
Portal portal = c.getPlayer().getMap().getPortal(startwp);
if (portal == null || c.getPlayer().portalDelay() > currentServerTime() || c.getPlayer().getBlockedPortals().contains(portal.getScriptName())) {
c.sendPacket(PacketCreator.enableActions());
return;

View File

@@ -29,8 +29,8 @@ import net.AbstractPacketHandler;
import net.packet.InPacket;
import server.maps.MapObject;
import server.maps.MapObjectType;
import server.maps.MaplePortal;
import server.maps.PlayerShop;
import server.maps.Portal;
import tools.PacketCreator;
import java.awt.*;
@@ -63,7 +63,7 @@ public final class HiredMerchantRequest extends AbstractPacketHandler {
}
Point cpos = chr.getPosition();
MaplePortal portal = chr.getMap().findClosestTeleportPortal(cpos);
Portal portal = chr.getMap().findClosestTeleportPortal(cpos);
if (portal != null && portal.getPosition().distance(cpos) < 120.0) {
chr.sendPacket(PacketCreator.getMiniRoomError(10));
return;

View File

@@ -814,7 +814,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
}
Point cpos = chr.getPosition();
MaplePortal portal = chr.getMap().findClosestTeleportPortal(cpos);
Portal portal = chr.getMap().findClosestTeleportPortal(cpos);
if (portal != null && portal.getPosition().distance(cpos) < 120.0) {
chr.sendPacket(PacketCreator.getMiniRoomError(10));
return false;

View File

@@ -46,8 +46,8 @@ import server.life.Monster;
import server.life.NPC;
import server.maps.MapManager;
import server.maps.MapleMap;
import server.maps.MaplePortal;
import server.maps.MapleReactor;
import server.maps.Portal;
import tools.PacketCreator;
import tools.Pair;
@@ -1277,7 +1277,7 @@ public class EventInstanceManager {
thisStage--; //stages counts from ONE, scripts from ZERO
MapleMap nextStage = getMapInstance(thisMapId);
MaplePortal portal = nextStage.getPortal("next00");
Portal portal = nextStage.getPortal("next00");
if (portal != null) {
portal.setScriptName(eventFamily + thisStage);
}
@@ -1288,7 +1288,7 @@ public class EventInstanceManager {
thisStage--; //stages counts from ONE, scripts from ZERO
MapleMap nextStage = getMapInstance(thisMapId);
MaplePortal portal = nextStage.getPortal(portalName);
Portal portal = nextStage.getPortal(portalName);
if (portal != null) {
portal.setScriptName(scriptName);
}

View File

@@ -24,7 +24,7 @@ package scripting.portal;
import client.Client;
import scripting.AbstractPlayerInteraction;
import scripting.map.MapScriptManager;
import server.maps.MaplePortal;
import server.maps.Portal;
import tools.DatabaseConnection;
import tools.PacketCreator;
@@ -34,14 +34,14 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class PortalPlayerInteraction extends AbstractPlayerInteraction {
private final MaplePortal portal;
private final Portal portal;
public PortalPlayerInteraction(Client c, MaplePortal portal) {
public PortalPlayerInteraction(Client c, Portal portal) {
super(c);
this.portal = portal;
}
public MaplePortal getPortal() {
public Portal getPortal() {
return portal;
}

View File

@@ -25,7 +25,7 @@ import client.Client;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scripting.AbstractScriptManager;
import server.maps.MaplePortal;
import server.maps.Portal;
import javax.script.Invocable;
import javax.script.ScriptEngine;
@@ -64,7 +64,7 @@ public class PortalScriptManager extends AbstractScriptManager {
return script;
}
public boolean executePortalScript(MaplePortal portal, Client c) {
public boolean executePortalScript(Portal portal, Client c) {
try {
PortalScript script = getPortalScript(portal.getScriptName());
if (script != null) {

View File

@@ -908,7 +908,7 @@ public class MapleStatEffect {
if (moveTo != -1) {
if (moveTo != applyto.getMapId()) {
MapleMap target;
MaplePortal pt;
Portal pt;
if (moveTo == 999999999) {
if (sourceid != 2030100) {

View File

@@ -37,7 +37,7 @@ import java.util.Collection;
public class Door {
private int ownerId;
private MapleMap town;
private MaplePortal townPortal;
private Portal townPortal;
private final MapleMap target;
private Pair<String, Integer> posStatus = null;
private long deployTime;
@@ -81,7 +81,7 @@ public class Door {
public void updateDoorPortal(Character owner) {
int slot = owner.fetchDoorSlot();
MaplePortal nextTownPortal = getTownDoorPortal(slot);
Portal nextTownPortal = getTownDoorPortal(slot);
if (nextTownPortal != null) {
townPortal = nextTownPortal;
areaDoor.update(nextTownPortal.getId(), nextTownPortal.getPosition());
@@ -141,7 +141,7 @@ public class Door {
}
}
private MaplePortal getTownDoorPortal(int doorid) {
private Portal getTownDoorPortal(int doorid) {
return town.getDoorPortal(doorid);
}
@@ -161,7 +161,7 @@ public class Door {
return town;
}
public MaplePortal getTownPortal() {
public Portal getTownPortal() {
return townPortal;
}

View File

@@ -32,7 +32,7 @@ import tools.PacketCreator;
import java.awt.*;
public class GenericPortal implements MaplePortal {
public class GenericPortal implements Portal {
private String name;
private String target;
private Point position;
@@ -144,7 +144,7 @@ public class GenericPortal implements MaplePortal {
Character chr = c.getPlayer();
if (!(chr.getChalkboard() != null && GameConstants.isFreeMarketRoom(getTargetMapId()))) {
MapleMap to = chr.getEventInstance() == null ? c.getChannelServer().getMapFactory().getMap(getTargetMapId()) : chr.getEventInstance().getMapInstance(getTargetMapId());
MaplePortal pto = to.getPortal(getTarget());
Portal pto = to.getPortal(getTarget());
if (pto == null) {// fallback for missing portals - no real life case anymore - interesting for not implemented areas
pto = to.getPortal(0);
}

View File

@@ -28,7 +28,7 @@ import java.util.concurrent.ScheduledFuture;
public class MapMonitor {
private ScheduledFuture<?> monitorSchedule;
private MapleMap map;
private MaplePortal portal;
private Portal portal;
public MapMonitor(final MapleMap map, String portal) {
this.map = map;
@@ -49,7 +49,7 @@ public class MapMonitor {
map.killAllMonsters();
map.clearDrops();
if (portal != null) {
portal.setPortalStatus(MaplePortal.OPEN);
portal.setPortalStatus(Portal.OPEN);
}
map.resetReactors();

View File

@@ -23,6 +23,6 @@ package server.maps;
public class MapPortal extends GenericPortal {
public MapPortal() {
super(MaplePortal.MAP_PORTAL);
super(Portal.MAP_PORTAL);
}
}

View File

@@ -90,7 +90,7 @@ public class MapleMap {
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, Portal> portals = new HashMap<>();
private final Map<Integer, Integer> backgroundTypes = new HashMap<>();
private final Map<String, Integer> environment = new LinkedHashMap<>();
private final Map<MapItem, Long> droppedItems = new LinkedHashMap<>();
@@ -596,7 +596,7 @@ public class MapleMap {
}
public Pair<String, Integer> getDoorPositionStatus(Point pos) {
MaplePortal portal = findClosestPlayerSpawnpoint(pos);
Portal portal = findClosestPlayerSpawnpoint(pos);
double angle = getAngle(portal.getPosition(), pos);
double distn = pos.distanceSq(portal.getPosition());
@@ -2051,8 +2051,8 @@ public class MapleMap {
}, chr -> chr.getMapId() == door.getFrom().getId());
}
public MaplePortal getDoorPortal(int doorid) {
MaplePortal doorPortal = portals.get(0x80 + doorid);
public Portal getDoorPortal(int doorid) {
Portal doorPortal = portals.get(0x80 + doorid);
if (doorPortal == null) {
FilePrinter.printError(FilePrinter.EXCEPTION, "[Door] " + mapName + "(" + mapid + ") does not contain door portalid " + doorid);
return portals.get(0x80);
@@ -2584,23 +2584,23 @@ public class MapleMap {
Server.getInstance().registerAnnouncePlayerDiseases(c);
}
public MaplePortal getRandomPlayerSpawnpoint() {
List<MaplePortal> spawnPoints = new ArrayList<>();
for (MaplePortal portal : portals.values()) {
public Portal getRandomPlayerSpawnpoint() {
List<Portal> spawnPoints = new ArrayList<>();
for (Portal portal : portals.values()) {
if (portal.getType() >= 0 && portal.getType() <= 1 && portal.getTargetMapId() == 999999999) {
spawnPoints.add(portal);
}
}
MaplePortal portal = spawnPoints.get(new Random().nextInt(spawnPoints.size()));
Portal portal = spawnPoints.get(new Random().nextInt(spawnPoints.size()));
return portal != null ? portal : getPortal(0);
}
public MaplePortal findClosestTeleportPortal(Point from) {
MaplePortal closest = null;
public Portal findClosestTeleportPortal(Point from) {
Portal closest = null;
double shortestDistance = Double.POSITIVE_INFINITY;
for (MaplePortal portal : portals.values()) {
for (Portal portal : portals.values()) {
double distance = portal.getPosition().distanceSq(from);
if (portal.getType() == MaplePortal.TELEPORT_PORTAL && distance < shortestDistance && portal.getTargetMapId() != 999999999) {
if (portal.getType() == Portal.TELEPORT_PORTAL && distance < shortestDistance && portal.getTargetMapId() != 999999999) {
closest = portal;
shortestDistance = distance;
}
@@ -2608,10 +2608,10 @@ public class MapleMap {
return closest;
}
public MaplePortal findClosestPlayerSpawnpoint(Point from) {
MaplePortal closest = null;
public Portal findClosestPlayerSpawnpoint(Point from) {
Portal closest = null;
double shortestDistance = Double.POSITIVE_INFINITY;
for (MaplePortal portal : portals.values()) {
for (Portal portal : portals.values()) {
double distance = portal.getPosition().distanceSq(from);
if (portal.getType() >= 0 && portal.getType() <= 1 && distance < shortestDistance && portal.getTargetMapId() == 999999999) {
closest = portal;
@@ -2621,10 +2621,10 @@ public class MapleMap {
return closest;
}
public MaplePortal findClosestPortal(Point from) {
MaplePortal closest = null;
public Portal findClosestPortal(Point from) {
Portal closest = null;
double shortestDistance = Double.POSITIVE_INFINITY;
for (MaplePortal portal : portals.values()) {
for (Portal portal : portals.values()) {
double distance = portal.getPosition().distanceSq(from);
if (distance < shortestDistance) {
closest = portal;
@@ -2634,8 +2634,8 @@ public class MapleMap {
return closest;
}
public MaplePortal findMarketPortal() {
for (MaplePortal portal : portals.values()) {
public Portal findMarketPortal() {
for (Portal portal : portals.values()) {
String ptScript = portal.getScriptName();
if (ptScript != null && ptScript.contains("market")) {
return portal;
@@ -2645,7 +2645,7 @@ public class MapleMap {
}
/*
public Collection<MaplePortal> getPortals() {
public Collection<Portal> getPortals() {
return Collections.unmodifiableCollection(portals.values());
}
*/
@@ -3008,12 +3008,12 @@ public class MapleMap {
}
}
public void addPortal(MaplePortal myPortal) {
public void addPortal(Portal myPortal) {
portals.put(myPortal.getId(), myPortal);
}
public MaplePortal getPortal(String portalname) {
for (MaplePortal port : portals.values()) {
public Portal getPortal(String portalname) {
for (Portal port : portals.values()) {
if (port.getName().equals(portalname)) {
return port;
}
@@ -3021,7 +3021,7 @@ public class MapleMap {
return null;
}
public MaplePortal getPortal(int portalid) {
public Portal getPortal(int portalid) {
return portals.get(portalid);
}

View File

@@ -33,9 +33,9 @@ public class MaplePortalFactory {
nextDoorPortal = 0x80;
}
public MaplePortal makePortal(int type, Data portal) {
public Portal makePortal(int type, Data portal) {
GenericPortal ret = null;
if (type == MaplePortal.MAP_PORTAL) {
if (type == Portal.MAP_PORTAL) {
ret = new MapPortal();
} else {
ret = new GenericPortal(type);
@@ -56,7 +56,7 @@ public class MaplePortalFactory {
script = null;
}
myPortal.setScriptName(script);
if (myPortal.getType() == MaplePortal.DOOR_PORTAL) {
if (myPortal.getType() == Portal.DOOR_PORTAL) {
myPortal.setId(nextDoorPortal);
nextDoorPortal++;
} else {

View File

@@ -25,7 +25,7 @@ import client.Client;
import java.awt.*;
public interface MaplePortal {
public interface Portal {
int TELEPORT_PORTAL = 1;
int MAP_PORTAL = 2;
int DOOR_PORTAL = 6;