diff --git a/src/main/java/config/ServerConfig.java b/src/main/java/config/ServerConfig.java index da05372eba..7095bce226 100644 --- a/src/main/java/config/ServerConfig.java +++ b/src/main/java/config/ServerConfig.java @@ -307,6 +307,6 @@ public class ServerConfig { //Event End Timestamp public long EVENT_END_TIMESTAMP; - //Custom NPC overrides. NPC ID to Name pair. + //Custom NPC overrides. List of NPC IDs. public List NPCS_SCRIPTABLE = new ArrayList<>(); } diff --git a/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java b/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java index d0d18c88e7..f5ec11e317 100644 --- a/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java +++ b/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java @@ -408,14 +408,16 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler { } if (YamlConfig.config.server.USE_NPCS_SCRIPTABLE) { - List npcsIds = YamlConfig.config.server.NPCS_SCRIPTABLE; + + // Create a set to remove duplicate entries if they exist. + Set npcsIds = new HashSet<>(YamlConfig.config.server.NPCS_SCRIPTABLE); // Any npc be specified as the rebirth npc. Allow the npc to use custom scripts explicitly. if (YamlConfig.config.server.USE_REBIRTH_SYSTEM) { npcsIds.add(YamlConfig.config.server.REBIRTH_NPC_ID); } - c.announce(MaplePacketCreator.setNPCScriptable(YamlConfig.config.server.NPCS_SCRIPTABLE)); + c.announce(MaplePacketCreator.setNPCScriptable(npcsIds)); } if(newcomer) player.setLoginTime(System.currentTimeMillis()); diff --git a/src/main/java/tools/MaplePacketCreator.java b/src/main/java/tools/MaplePacketCreator.java index 1bb4ccf090..d7f259eda7 100644 --- a/src/main/java/tools/MaplePacketCreator.java +++ b/src/main/java/tools/MaplePacketCreator.java @@ -8326,7 +8326,7 @@ public class MaplePacketCreator { * @param scriptableNpcIds Ids of npcs to enable scripts for. * @return a packet which makes the npc's provided scriptable. */ - public static byte[] setNPCScriptable(List scriptableNpcIds) { // thanks to GabrielSin + public static byte[] setNPCScriptable(Set scriptableNpcIds) { // thanks to GabrielSin MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.writeShort(SendOpcode.SET_NPC_SCRIPTABLE.getValue()); mplew.write(scriptableNpcIds.size());