diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index c876f04050..ab3476e769 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 117cb35c1f..7b1668f7b6 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_8.2_Homunculus/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_8.2_Homunculus/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 117cb35c1f..7b1668f7b6 100644 --- a/L2J_Mobius_8.2_Homunculus/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_8.2_Homunculus/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_9.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_9.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 117cb35c1f..7b1668f7b6 100644 --- a/L2J_Mobius_9.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_9.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/instancezone/InstanceWorld.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/instancezone/InstanceWorld.java index ab60a25f4c..70475b40c6 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/instancezone/InstanceWorld.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/instancezone/InstanceWorld.java @@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.instance.DoorInstance; @@ -36,7 +37,7 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; public class InstanceWorld { private Instance _instance; - private final Set _players = ConcurrentHashMap.newKeySet(); + private final Set _allowed = ConcurrentHashMap.newKeySet(); private final StatSet _parameters = new StatSet(); /** @@ -66,27 +67,38 @@ public class InstanceWorld return _instance.getTemplateId(); } - public Set getAllowed() + public List getAllowed() { - return _players; + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } public void removeAllowed(PlayerInstance player) { - _players.remove(player); + final Integer playerId = player.getId(); + _allowed.remove(playerId); } public void addAllowed(PlayerInstance player) { - if (!_players.contains(player)) + final Integer playerId = player.getId(); + if (!_allowed.contains(playerId)) { - _players.add(player); + _allowed.add(playerId); } } public boolean isAllowed(PlayerInstance player) { - return _players.contains(player); + return _allowed.contains(player.getId()); } /** diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/instancezone/InstanceWorld.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/instancezone/InstanceWorld.java index ab60a25f4c..70475b40c6 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/instancezone/InstanceWorld.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/instancezone/InstanceWorld.java @@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.commons.util.CommonUtil; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.instance.DoorInstance; @@ -36,7 +37,7 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; public class InstanceWorld { private Instance _instance; - private final Set _players = ConcurrentHashMap.newKeySet(); + private final Set _allowed = ConcurrentHashMap.newKeySet(); private final StatSet _parameters = new StatSet(); /** @@ -66,27 +67,38 @@ public class InstanceWorld return _instance.getTemplateId(); } - public Set getAllowed() + public List getAllowed() { - return _players; + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } public void removeAllowed(PlayerInstance player) { - _players.remove(player); + final Integer playerId = player.getId(); + _allowed.remove(playerId); } public void addAllowed(PlayerInstance player) { - if (!_players.contains(player)) + final Integer playerId = player.getId(); + if (!_allowed.contains(playerId)) { - _players.add(player); + _allowed.add(playerId); } } public boolean isAllowed(PlayerInstance player) { - return _players.contains(player); + return _allowed.contains(player.getId()); } /** diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 117cb35c1f..7b1668f7b6 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 117cb35c1f..7b1668f7b6 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 117cb35c1f..7b1668f7b6 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 62649739ea..5f8b09aa95 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 0f9a7ec1f7..c5e2db8633 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/instancezone/Instance.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/instancezone/Instance.java index 0f9a7ec1f7..c5e2db8633 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/instancezone/Instance.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/instancezone/Instance.java @@ -48,6 +48,7 @@ import org.l2jmobius.gameserver.enums.TeleportWhereType; import org.l2jmobius.gameserver.instancemanager.InstanceManager; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; @@ -84,7 +85,7 @@ public class Instance implements IIdentifiable, INamable private final long _startTime; private long _endTime; // Advanced instance parameters - private final Set _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance + private final Set _allowed = ConcurrentHashMap.newKeySet(); // Player ids which can enter to instance private final Set _players = ConcurrentHashMap.newKeySet(); // Players inside instance private final Set _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance private final Map _doors = new HashMap<>(); // Spawned doors inside instance @@ -239,9 +240,9 @@ public class Instance implements IIdentifiable, INamable */ public void addAllowed(PlayerInstance player) { - if (!_allowed.contains(player)) + if (!_allowed.contains(player.getObjectId())) { - _allowed.add(player); + _allowed.add(player.getObjectId()); } } @@ -252,25 +253,25 @@ public class Instance implements IIdentifiable, INamable */ public boolean isAllowed(PlayerInstance player) { - return _allowed.contains(player); + return _allowed.contains(player.getObjectId()); } /** * Returns all players who can enter to instance. * @return allowed players list */ - public Set getAllowed() + public List getAllowed() { - return _allowed; - } - - /** - * Remove player from allowed so he can't enter anymore. - * @param player to remove - */ - public void removeAllowed(PlayerInstance player) - { - _allowed.remove(player); + final List allowed = new ArrayList<>(_allowed.size()); + for (int playerId : _allowed) + { + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if (player != null) + { + allowed.add(player); + } + } + return allowed; } /** @@ -905,15 +906,12 @@ public class Instance implements IIdentifiable, INamable PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) { // Save to database - for (PlayerInstance player : _allowed) + for (Integer playerId : _allowed) { - if (player != null) - { - ps.setInt(1, player.getObjectId()); - ps.setInt(2, _template.getId()); - ps.setLong(3, time); - ps.addBatch(); - } + ps.setInt(1, playerId); + ps.setInt(2, _template.getId()); + ps.setLong(3, time); + ps.addBatch(); } ps.executeBatch(); @@ -927,15 +925,13 @@ public class Instance implements IIdentifiable, INamable { msg.addString(_template.getName()); } - _allowed.forEach(player -> + _allowed.forEach(playerId -> { - if (player != null) + InstanceManager.getInstance().setReenterPenalty(playerId, getTemplateId(), time); + final PlayerInstance player = World.getInstance().getPlayer(playerId); + if ((player != null) && player.isOnline()) { - InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time); - if (player.isOnline()) - { - player.sendPacket(msg); - } + player.sendPacket(msg); } }); } @@ -1046,6 +1042,7 @@ public class Instance implements IIdentifiable, INamable else { removePlayer(player); + // Notify DP scripts if (!isDynamic()) {