Swapped from list to set to prevent duplicates

Use a set instead, clone instead of adding directly to the list.
This commit is contained in:
James McDowell
2021-05-20 19:16:22 +10:00
parent 0345ce844e
commit 9128329d37
3 changed files with 6 additions and 4 deletions

View File

@@ -408,14 +408,16 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
}
if (YamlConfig.config.server.USE_NPCS_SCRIPTABLE) {
List<Integer> npcsIds = YamlConfig.config.server.NPCS_SCRIPTABLE;
// Create a set to remove duplicate entries if they exist.
Set<Integer> 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());