Rename and clean up MapleNPC

This commit is contained in:
P0nk
2021-09-09 22:09:31 +02:00
parent 3aa455a757
commit e48c25a200
11 changed files with 29 additions and 29 deletions

View File

@@ -26,9 +26,9 @@ package client.command.commands.gm2;
import client.Character; import client.Character;
import client.Client; import client.Client;
import client.command.Command; import client.command.Command;
import server.life.MapleNPC;
import server.life.MaplePlayerNPC; import server.life.MaplePlayerNPC;
import server.life.Monster; import server.life.Monster;
import server.life.NPC;
import server.maps.MapleMapObject; import server.maps.MapleMapObject;
import java.util.HashSet; import java.util.HashSet;
@@ -43,13 +43,13 @@ public class WhereaMiCommand extends Command {
Character player = c.getPlayer(); Character player = c.getPlayer();
HashSet<Character> chars = new HashSet<>(); HashSet<Character> chars = new HashSet<>();
HashSet<MapleNPC> npcs = new HashSet<>(); HashSet<NPC> npcs = new HashSet<>();
HashSet<MaplePlayerNPC> playernpcs = new HashSet<>(); HashSet<MaplePlayerNPC> playernpcs = new HashSet<>();
HashSet<Monster> mobs = new HashSet<>(); HashSet<Monster> mobs = new HashSet<>();
for (MapleMapObject mmo : player.getMap().getMapObjects()) { for (MapleMapObject mmo : player.getMap().getMapObjects()) {
if (mmo instanceof MapleNPC) { if (mmo instanceof NPC) {
MapleNPC npc = (MapleNPC) mmo; NPC npc = (NPC) mmo;
npcs.add(npc); npcs.add(npc);
} else if (mmo instanceof Character) { } else if (mmo instanceof Character) {
Character mc = (Character) mmo; Character mc = (Character) mmo;
@@ -81,7 +81,7 @@ public class WhereaMiCommand extends Command {
if (!npcs.isEmpty()) { if (!npcs.isEmpty()) {
player.yellowMessage("NPCs on this map:"); player.yellowMessage("NPCs on this map:");
for (MapleNPC npc : npcs) { for (NPC npc : npcs) {
player.dropMessage(5, ">> " + npc.getName() + " - " + npc.getId() + " - Oid: " + npc.getObjectId()); player.dropMessage(5, ">> " + npc.getName() + " - " + npc.getId() + " - Oid: " + npc.getObjectId());
} }
} }

View File

@@ -27,7 +27,7 @@ import client.Character;
import client.Client; import client.Client;
import client.command.Command; import client.command.Command;
import server.life.LifeFactory; import server.life.LifeFactory;
import server.life.MapleNPC; import server.life.NPC;
import tools.PacketCreator; import tools.PacketCreator;
public class NpcCommand extends Command { public class NpcCommand extends Command {
@@ -42,7 +42,7 @@ public class NpcCommand extends Command {
player.yellowMessage("Syntax: !npc <npcid>"); player.yellowMessage("Syntax: !npc <npcid>");
return; return;
} }
MapleNPC npc = LifeFactory.getNPC(Integer.parseInt(params[0])); NPC npc = LifeFactory.getNPC(Integer.parseInt(params[0]));
if (npc != null) { if (npc != null) {
npc.setPosition(player.getPosition()); npc.setPosition(player.getPosition());
npc.setCy(player.getPosition().y); npc.setCy(player.getPosition().y);

View File

@@ -28,7 +28,7 @@ import client.Client;
import client.command.Command; import client.command.Command;
import net.server.channel.Channel; import net.server.channel.Channel;
import server.life.LifeFactory; import server.life.LifeFactory;
import server.life.MapleNPC; import server.life.NPC;
import server.maps.MapleMap; import server.maps.MapleMap;
import tools.DatabaseConnection; import tools.DatabaseConnection;
import tools.PacketCreator; import tools.PacketCreator;
@@ -59,7 +59,7 @@ public class PnpcCommand extends Command {
return; return;
} }
MapleNPC npc = LifeFactory.getNPC(npcId); NPC npc = LifeFactory.getNPC(npcId);
Point checkpos = player.getMap().getGroundBelow(player.getPosition()); Point checkpos = player.getMap().getGroundBelow(player.getPosition());
int xpos = checkpos.x; int xpos = checkpos.x;

View File

@@ -27,8 +27,8 @@ import config.YamlConfig;
import net.AbstractPacketHandler; import net.AbstractPacketHandler;
import net.packet.InPacket; import net.packet.InPacket;
import scripting.npc.NPCScriptManager; import scripting.npc.NPCScriptManager;
import server.life.MapleNPC;
import server.life.MaplePlayerNPC; import server.life.MaplePlayerNPC;
import server.life.NPC;
import server.maps.MapleMapObject; import server.maps.MapleMapObject;
import tools.FilePrinter; import tools.FilePrinter;
import tools.PacketCreator; import tools.PacketCreator;
@@ -48,8 +48,8 @@ public final class NPCTalkHandler extends AbstractPacketHandler {
int oid = p.readInt(); int oid = p.readInt();
MapleMapObject obj = c.getPlayer().getMap().getMapObject(oid); MapleMapObject obj = c.getPlayer().getMap().getMapObject(oid);
if (obj instanceof MapleNPC) { if (obj instanceof NPC) {
MapleNPC npc = (MapleNPC) obj; NPC npc = (NPC) obj;
if(YamlConfig.config.server.USE_DEBUG == true) c.getPlayer().dropMessage(5, "Talking to NPC " + npc.getId()); if(YamlConfig.config.server.USE_DEBUG == true) c.getPlayer().dropMessage(5, "Talking to NPC " + npc.getId());
if (npc.getId() == 9010009) { //is duey if (npc.getId() == 9010009) { //is duey

View File

@@ -26,7 +26,7 @@ import client.Client;
import net.AbstractPacketHandler; import net.AbstractPacketHandler;
import net.packet.InPacket; import net.packet.InPacket;
import scripting.quest.QuestScriptManager; import scripting.quest.QuestScriptManager;
import server.life.MapleNPC; import server.life.NPC;
import server.quest.MapleQuest; import server.quest.MapleQuest;
import java.awt.*; import java.awt.*;
@@ -52,7 +52,7 @@ public final class QuestActionHandler extends AbstractPacketHandler {
} }
if (!quest.isAutoStart() && !quest.isAutoComplete()) { if (!quest.isAutoStart() && !quest.isAutoComplete()) {
MapleNPC npc = player.getMap().getNPCById(npcId); NPC npc = player.getMap().getNPCById(npcId);
if(npc == null) { if(npc == null) {
return false; return false;
} }

View File

@@ -948,7 +948,7 @@ public class AbstractPlayerInteraction {
} }
public void spawnNpc(int npcId, Point pos, MapleMap map) { public void spawnNpc(int npcId, Point pos, MapleMap map) {
MapleNPC npc = LifeFactory.getNPC(npcId); NPC npc = LifeFactory.getNPC(npcId);
if (npc != null) { if (npc != null) {
npc.setPosition(pos); npc.setPosition(pos);
npc.setCy(pos.y); npc.setCy(pos.y);

View File

@@ -42,8 +42,8 @@ import server.ThreadManager;
import server.TimerManager; import server.TimerManager;
import server.expeditions.Expedition; import server.expeditions.Expedition;
import server.life.LifeFactory; import server.life.LifeFactory;
import server.life.MapleNPC;
import server.life.Monster; import server.life.Monster;
import server.life.NPC;
import server.maps.MapleMap; import server.maps.MapleMap;
import server.maps.MapleMapManager; import server.maps.MapleMapManager;
import server.maps.MaplePortal; import server.maps.MaplePortal;
@@ -849,7 +849,7 @@ public class EventInstanceManager {
} }
public void spawnNpc(int npcId, Point pos, MapleMap map) { public void spawnNpc(int npcId, Point pos, MapleMap map) {
MapleNPC npc = LifeFactory.getNPC(npcId); NPC npc = LifeFactory.getNPC(npcId);
if (npc != null) { if (npc != null) {
npc.setPosition(pos); npc.setPosition(pos);
npc.setCy(pos.y); npc.setCy(pos.y);

View File

@@ -284,8 +284,8 @@ public class LifeFactory {
} }
} }
public static MapleNPC getNPC(int nid) { public static NPC getNPC(int nid) {
return new MapleNPC(nid, new MapleNPCStats(DataTool.getString(nid + "/name", npcStringData, "MISSINGNO"))); return new NPC(nid, new MapleNPCStats(DataTool.getString(nid + "/name", npcStringData, "MISSINGNO")));
} }
public static String getNPCDefaultTalk(int nid) { public static String getNPCDefaultTalk(int nid) {

View File

@@ -26,10 +26,10 @@ import server.MapleShopFactory;
import server.maps.MapleMapObjectType; import server.maps.MapleMapObjectType;
import tools.PacketCreator; import tools.PacketCreator;
public class MapleNPC extends AbstractLoadedLife { public class NPC extends AbstractLoadedLife {
private final MapleNPCStats stats; private final MapleNPCStats stats;
public MapleNPC(int id, MapleNPCStats stats) { public NPC(int id, MapleNPCStats stats) {
super(id); super(id);
this.stats = stats; this.stats = stats;
} }

View File

@@ -1684,10 +1684,10 @@ public class MapleMap {
} }
} }
public MapleNPC getNPCById(int id) { public NPC getNPCById(int id) {
for (MapleMapObject obj : getMapObjects()) { for (MapleMapObject obj : getMapObjects()) {
if (obj.getType() == MapleMapObjectType.NPC) { if (obj.getType() == MapleMapObjectType.NPC) {
MapleNPC npc = (MapleNPC) obj; NPC npc = (NPC) obj;
if (npc.getId() == id) { if (npc.getId() == id) {
return npc; return npc;
} }
@@ -1702,7 +1702,7 @@ public class MapleMap {
try { try {
for (MapleMapObject obj : mapobjects.values()) { for (MapleMapObject obj : mapobjects.values()) {
if (obj.getType() == MapleMapObjectType.NPC) { if (obj.getType() == MapleMapObjectType.NPC) {
if (((MapleNPC) obj).getId() == npcid) { if (((NPC) obj).getId() == npcid) {
return true; return true;
} }
} }
@@ -1720,7 +1720,7 @@ public class MapleMap {
objectWLock.lock(); objectWLock.lock();
try { try {
for (MapleMapObject obj : npcs) { for (MapleMapObject obj : npcs) {
if (((MapleNPC) obj).getId() == npcid) { if (((NPC) obj).getId() == npcid) {
broadcastMessage(PacketCreator.removeNPCController(obj.getObjectId())); broadcastMessage(PacketCreator.removeNPCController(obj.getObjectId()));
broadcastMessage(PacketCreator.removeNPC(obj.getObjectId())); broadcastMessage(PacketCreator.removeNPC(obj.getObjectId()));
@@ -3965,7 +3965,7 @@ public class MapleMap {
try { try {
for (MapleMapObject obj : mapobjects.values()) { for (MapleMapObject obj : mapobjects.values()) {
if (obj.getType() == MapleMapObjectType.NPC) { if (obj.getType() == MapleMapObjectType.NPC) {
MapleNPC npc = (MapleNPC) obj; NPC npc = (NPC) obj;
if (npc.getId() == id) { if (npc.getId() == id) {
npc.setHide(!npc.isHidden()); npc.setHide(!npc.isHidden());
if (!npc.isHidden()) //Should only be hidden upon changing maps if (!npc.isHidden()) //Should only be hidden upon changing maps

View File

@@ -61,10 +61,10 @@ import server.CashShop.CashItemFactory;
import server.CashShop.SpecialCashItem; import server.CashShop.SpecialCashItem;
import server.*; import server.*;
import server.events.gm.Snowball; import server.events.gm.Snowball;
import server.life.MapleNPC;
import server.life.MaplePlayerNPC; import server.life.MaplePlayerNPC;
import server.life.MobSkill; import server.life.MobSkill;
import server.life.Monster; import server.life.Monster;
import server.life.NPC;
import server.maps.*; import server.maps.*;
import server.maps.MapleMiniGame.MiniGameResult; import server.maps.MapleMiniGame.MiniGameResult;
import server.movement.LifeMovementFragment; import server.movement.LifeMovementFragment;
@@ -1291,7 +1291,7 @@ public class PacketCreator {
return p; return p;
} }
public static Packet spawnNPC(MapleNPC life) { public static Packet spawnNPC(NPC life) {
OutPacket p = OutPacket.create(SendOpcode.SPAWN_NPC); OutPacket p = OutPacket.create(SendOpcode.SPAWN_NPC);
p.writeInt(life.getObjectId()); p.writeInt(life.getObjectId());
p.writeInt(life.getId()); p.writeInt(life.getId());
@@ -1305,7 +1305,7 @@ public class PacketCreator {
return p; return p;
} }
public static Packet spawnNPCRequestController(MapleNPC life, boolean miniMap) { public static Packet spawnNPCRequestController(NPC life, boolean miniMap) {
OutPacket p = OutPacket.create(SendOpcode.SPAWN_NPC_REQUEST_CONTROLLER); OutPacket p = OutPacket.create(SendOpcode.SPAWN_NPC_REQUEST_CONTROLLER);
p.writeByte(1); p.writeByte(1);
p.writeInt(life.getObjectId()); p.writeInt(life.getObjectId());