Save allowed player instances instead of object ids.

This commit is contained in:
MobiusDev 2018-06-08 16:27:20 +00:00
parent 913dbff9a6
commit 3cd9404a34
71 changed files with 422 additions and 363 deletions

View File

@ -29,7 +29,6 @@ import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -120,10 +119,9 @@ public final class ChamberOfDelusion extends AbstractInstance
}
else
{
for (int objId : instance.getAllowed())
for (L2PcInstance plr : instance.getAllowed())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if ((pl != null) && pl.isOnline() && !pl.isInParty())
if ((plr != null) && plr.isOnline() && !plr.isInParty())
{
instance.finishInstance(0);
break;

View File

@ -27,7 +27,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -841,13 +840,12 @@ public final class Kamaloka extends AbstractInstance
sm.addInstanceName(world.getTemplateId());
// set instance reenter time for all allowed players
for (int oid : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(oid);
if ((obj != null) && obj.isOnline())
if ((plr != null) && plr.isOnline())
{
InstanceManager.getInstance().setReenterPenalty(oid, world.getTemplateId(), reenter.getTimeInMillis());
obj.sendPacket(sm);
InstanceManager.getInstance().setReenterPenalty(plr.getObjectId(), world.getTemplateId(), reenter.getTimeInMillis());
plr.sendPacket(sm);
}
}
world.finishInstance();

View File

@ -3449,6 +3449,15 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
*/
public void playMovie(Instance instance, Movie movie)
{
playMovie(instance.getPlayers(), movie);
if (instance != null)
{
for (L2PcInstance player : instance.getPlayers())
{
if ((player != null) && (player.getInstanceWorld() == instance))
{
playMovie(player, movie);
}
}
}
}
}

View File

@ -45,7 +45,6 @@ import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.enums.InstanceTeleportType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType;
@ -84,7 +83,7 @@ public final class Instance implements IIdentifiable, INamable
private final long _startTime;
private long _endTime;
// Advanced instance parameters
private final Set<Integer> _allowed = ConcurrentHashMap.newKeySet(); // ObjectId of players which can enter to instance
private final Set<L2PcInstance> _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet(); // Players inside instance
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance
private final Map<Integer, L2DoorInstance> _doors = new HashMap<>(); // Spawned doors inside instance
@ -223,7 +222,10 @@ public final class Instance implements IIdentifiable, INamable
*/
public void addAllowed(L2PcInstance player)
{
_allowed.add(player.getObjectId());
if (!_allowed.contains(player))
{
_allowed.add(player);
}
}
/**
@ -233,25 +235,25 @@ public final class Instance implements IIdentifiable, INamable
*/
public boolean isAllowed(L2PcInstance player)
{
return _allowed.contains(player.getObjectId());
return _allowed.contains(player);
}
/**
* Returns all players who can enter to instance.
* @return allowed players list
*/
public Set<Integer> getAllowed()
public Set<L2PcInstance> getAllowed()
{
return _allowed;
}
/**
* Remove player from allowed so he can't enter anymore.
* @param objectId object id of player
* @param player to remove
*/
public void removeAllowed(int objectId)
public void removeAllowed(L2PcInstance player)
{
_allowed.remove(objectId);
_allowed.remove(player);
}
/**
@ -817,12 +819,15 @@ public final class Instance implements IIdentifiable, INamable
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
{
// Save to database
for (Integer objId : _allowed)
for (L2PcInstance player : _allowed)
{
ps.setInt(1, objId);
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
if (player != null)
{
ps.setInt(1, player.getObjectId());
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
}
}
ps.executeBatch();
@ -836,13 +841,15 @@ public final class Instance implements IIdentifiable, INamable
{
msg.addString(getName());
}
_allowed.forEach(objId ->
_allowed.forEach(player ->
{
InstanceManager.getInstance().setReenterPenalty(objId, getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline())
if ((player != null))
{
player.sendPacket(msg);
InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time);
if (player.isOnline())
{
player.sendPacket(msg);
}
}
});
}

View File

@ -29,7 +29,6 @@ import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -120,10 +119,9 @@ public final class ChamberOfDelusion extends AbstractInstance
}
else
{
for (int objId : instance.getAllowed())
for (L2PcInstance plr : instance.getAllowed())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if ((pl != null) && pl.isOnline() && !pl.isInParty())
if ((plr != null) && plr.isOnline() && !plr.isInParty())
{
instance.finishInstance(0);
break;

View File

@ -27,7 +27,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -841,13 +840,12 @@ public final class Kamaloka extends AbstractInstance
sm.addInstanceName(world.getTemplateId());
// set instance reenter time for all allowed players
for (int oid : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(oid);
if ((obj != null) && obj.isOnline())
if ((plr != null) && plr.isOnline())
{
InstanceManager.getInstance().setReenterPenalty(oid, world.getTemplateId(), reenter.getTimeInMillis());
obj.sendPacket(sm);
InstanceManager.getInstance().setReenterPenalty(plr.getObjectId(), world.getTemplateId(), reenter.getTimeInMillis());
plr.sendPacket(sm);
}
}
world.finishInstance();

View File

@ -3449,6 +3449,15 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
*/
public void playMovie(Instance instance, Movie movie)
{
playMovie(instance.getPlayers(), movie);
if (instance != null)
{
for (L2PcInstance player : instance.getPlayers())
{
if ((player != null) && (player.getInstanceWorld() == instance))
{
playMovie(player, movie);
}
}
}
}
}

View File

@ -45,7 +45,6 @@ import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.enums.InstanceTeleportType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType;
@ -84,7 +83,7 @@ public final class Instance implements IIdentifiable, INamable
private final long _startTime;
private long _endTime;
// Advanced instance parameters
private final Set<Integer> _allowed = ConcurrentHashMap.newKeySet(); // ObjectId of players which can enter to instance
private final Set<L2PcInstance> _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet(); // Players inside instance
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance
private final Map<Integer, L2DoorInstance> _doors = new HashMap<>(); // Spawned doors inside instance
@ -223,7 +222,10 @@ public final class Instance implements IIdentifiable, INamable
*/
public void addAllowed(L2PcInstance player)
{
_allowed.add(player.getObjectId());
if (!_allowed.contains(player))
{
_allowed.add(player);
}
}
/**
@ -233,25 +235,25 @@ public final class Instance implements IIdentifiable, INamable
*/
public boolean isAllowed(L2PcInstance player)
{
return _allowed.contains(player.getObjectId());
return _allowed.contains(player);
}
/**
* Returns all players who can enter to instance.
* @return allowed players list
*/
public Set<Integer> getAllowed()
public Set<L2PcInstance> getAllowed()
{
return _allowed;
}
/**
* Remove player from allowed so he can't enter anymore.
* @param objectId object id of player
* @param player to remove
*/
public void removeAllowed(int objectId)
public void removeAllowed(L2PcInstance player)
{
_allowed.remove(objectId);
_allowed.remove(player);
}
/**
@ -817,12 +819,15 @@ public final class Instance implements IIdentifiable, INamable
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
{
// Save to database
for (Integer objId : _allowed)
for (L2PcInstance player : _allowed)
{
ps.setInt(1, objId);
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
if (player != null)
{
ps.setInt(1, player.getObjectId());
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
}
}
ps.executeBatch();
@ -836,13 +841,15 @@ public final class Instance implements IIdentifiable, INamable
{
msg.addString(getName());
}
_allowed.forEach(objId ->
_allowed.forEach(player ->
{
InstanceManager.getInstance().setReenterPenalty(objId, getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline())
if ((player != null))
{
player.sendPacket(msg);
InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time);
if (player.isOnline())
{
player.sendPacket(msg);
}
}
});
}

View File

@ -29,7 +29,6 @@ import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -120,10 +119,9 @@ public final class ChamberOfDelusion extends AbstractInstance
}
else
{
for (int objId : instance.getAllowed())
for (L2PcInstance plr : instance.getAllowed())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if ((pl != null) && pl.isOnline() && !pl.isInParty())
if ((plr != null) && plr.isOnline() && !plr.isInParty())
{
instance.finishInstance(0);
break;

View File

@ -27,7 +27,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -841,13 +840,12 @@ public final class Kamaloka extends AbstractInstance
sm.addInstanceName(world.getTemplateId());
// set instance reenter time for all allowed players
for (int oid : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(oid);
if ((obj != null) && obj.isOnline())
if ((plr != null) && plr.isOnline())
{
InstanceManager.getInstance().setReenterPenalty(oid, world.getTemplateId(), reenter.getTimeInMillis());
obj.sendPacket(sm);
InstanceManager.getInstance().setReenterPenalty(plr.getObjectId(), world.getTemplateId(), reenter.getTimeInMillis());
plr.sendPacket(sm);
}
}
world.finishInstance();

View File

@ -3461,6 +3461,15 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
*/
public void playMovie(Instance instance, Movie movie)
{
playMovie(instance.getPlayers(), movie);
if (instance != null)
{
for (L2PcInstance player : instance.getPlayers())
{
if ((player != null) && (player.getInstanceWorld() == instance))
{
playMovie(player, movie);
}
}
}
}
}

View File

@ -45,7 +45,6 @@ import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.enums.InstanceTeleportType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType;
@ -84,7 +83,7 @@ public final class Instance implements IIdentifiable, INamable
private final long _startTime;
private long _endTime;
// Advanced instance parameters
private final Set<Integer> _allowed = ConcurrentHashMap.newKeySet(); // ObjectId of players which can enter to instance
private final Set<L2PcInstance> _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet(); // Players inside instance
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance
private final Map<Integer, L2DoorInstance> _doors = new HashMap<>(); // Spawned doors inside instance
@ -223,7 +222,10 @@ public final class Instance implements IIdentifiable, INamable
*/
public void addAllowed(L2PcInstance player)
{
_allowed.add(player.getObjectId());
if (!_allowed.contains(player))
{
_allowed.add(player);
}
}
/**
@ -233,25 +235,25 @@ public final class Instance implements IIdentifiable, INamable
*/
public boolean isAllowed(L2PcInstance player)
{
return _allowed.contains(player.getObjectId());
return _allowed.contains(player);
}
/**
* Returns all players who can enter to instance.
* @return allowed players list
*/
public Set<Integer> getAllowed()
public Set<L2PcInstance> getAllowed()
{
return _allowed;
}
/**
* Remove player from allowed so he can't enter anymore.
* @param objectId object id of player
* @param player to remove
*/
public void removeAllowed(int objectId)
public void removeAllowed(L2PcInstance player)
{
_allowed.remove(objectId);
_allowed.remove(player);
}
/**
@ -817,12 +819,15 @@ public final class Instance implements IIdentifiable, INamable
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
{
// Save to database
for (Integer objId : _allowed)
for (L2PcInstance player : _allowed)
{
ps.setInt(1, objId);
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
if (player != null)
{
ps.setInt(1, player.getObjectId());
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
}
}
ps.executeBatch();
@ -836,13 +841,15 @@ public final class Instance implements IIdentifiable, INamable
{
msg.addString(getName());
}
_allowed.forEach(objId ->
_allowed.forEach(player ->
{
InstanceManager.getInstance().setReenterPenalty(objId, getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline())
if ((player != null))
{
player.sendPacket(msg);
InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time);
if (player.isOnline())
{
player.sendPacket(msg);
}
}
});
}

View File

@ -29,7 +29,6 @@ import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -120,10 +119,9 @@ public final class ChamberOfDelusion extends AbstractInstance
}
else
{
for (int objId : instance.getAllowed())
for (L2PcInstance plr : instance.getAllowed())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if ((pl != null) && pl.isOnline() && !pl.isInParty())
if ((plr != null) && plr.isOnline() && !plr.isInParty())
{
instance.finishInstance(0);
break;

View File

@ -27,7 +27,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -841,13 +840,12 @@ public final class Kamaloka extends AbstractInstance
sm.addInstanceName(world.getTemplateId());
// set instance reenter time for all allowed players
for (int oid : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(oid);
if ((obj != null) && obj.isOnline())
if ((plr != null) && plr.isOnline())
{
InstanceManager.getInstance().setReenterPenalty(oid, world.getTemplateId(), reenter.getTimeInMillis());
obj.sendPacket(sm);
InstanceManager.getInstance().setReenterPenalty(plr.getObjectId(), world.getTemplateId(), reenter.getTimeInMillis());
plr.sendPacket(sm);
}
}
world.finishInstance();

View File

@ -3461,6 +3461,15 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
*/
public void playMovie(Instance instance, Movie movie)
{
playMovie(instance.getPlayers(), movie);
if (instance != null)
{
for (L2PcInstance player : instance.getPlayers())
{
if ((player != null) && (player.getInstanceWorld() == instance))
{
playMovie(player, movie);
}
}
}
}
}

View File

@ -45,7 +45,6 @@ import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.enums.InstanceTeleportType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType;
@ -84,7 +83,7 @@ public final class Instance implements IIdentifiable, INamable
private final long _startTime;
private long _endTime;
// Advanced instance parameters
private final Set<Integer> _allowed = ConcurrentHashMap.newKeySet(); // ObjectId of players which can enter to instance
private final Set<L2PcInstance> _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet(); // Players inside instance
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance
private final Map<Integer, L2DoorInstance> _doors = new HashMap<>(); // Spawned doors inside instance
@ -223,7 +222,10 @@ public final class Instance implements IIdentifiable, INamable
*/
public void addAllowed(L2PcInstance player)
{
_allowed.add(player.getObjectId());
if (!_allowed.contains(player))
{
_allowed.add(player);
}
}
/**
@ -233,25 +235,25 @@ public final class Instance implements IIdentifiable, INamable
*/
public boolean isAllowed(L2PcInstance player)
{
return _allowed.contains(player.getObjectId());
return _allowed.contains(player);
}
/**
* Returns all players who can enter to instance.
* @return allowed players list
*/
public Set<Integer> getAllowed()
public Set<L2PcInstance> getAllowed()
{
return _allowed;
}
/**
* Remove player from allowed so he can't enter anymore.
* @param objectId object id of player
* @param player to remove
*/
public void removeAllowed(int objectId)
public void removeAllowed(L2PcInstance player)
{
_allowed.remove(objectId);
_allowed.remove(player);
}
/**
@ -817,12 +819,15 @@ public final class Instance implements IIdentifiable, INamable
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
{
// Save to database
for (Integer objId : _allowed)
for (L2PcInstance player : _allowed)
{
ps.setInt(1, objId);
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
if (player != null)
{
ps.setInt(1, player.getObjectId());
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
}
}
ps.executeBatch();
@ -836,13 +841,15 @@ public final class Instance implements IIdentifiable, INamable
{
msg.addString(getName());
}
_allowed.forEach(objId ->
_allowed.forEach(player ->
{
InstanceManager.getInstance().setReenterPenalty(objId, getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline())
if ((player != null))
{
player.sendPacket(msg);
InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time);
if (player.isOnline())
{
player.sendPacket(msg);
}
}
});
}

View File

@ -29,7 +29,6 @@ import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.instancemanager.SoIManager;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -339,13 +338,13 @@ public class HallOfErosionAttack extends AbstractNpcAI
for (L2PcInstance partyMember : player.getParty().isInCommandChannel() ? player.getParty().getCommandChannel().getMembers() : player.getParty().getMembers())
{
teleportPlayer(partyMember, coords, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
else
{
teleportPlayer(player, coords, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
runTumors((HEAWorld) world);
}
@ -489,12 +488,11 @@ public class HallOfErosionAttack extends AbstractNpcAI
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(INSTANCEID);
for (int objectId : tmpworld.getAllowed())
for (L2PcInstance player : tmpworld.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(player.getObjectId(), INSTANCEID, reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -572,12 +570,11 @@ public class HallOfErosionAttack extends AbstractNpcAI
if (npc.getId() == COHEMENES)
{
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.SHOUT, npc.getId(), NpcStringId.KEU_I_WILL_LEAVE_FOR_NOW_BUT_DON_T_THINK_THIS_IS_OVER_THE_SEED_OF_INFINITY_CAN_NEVER_DIE));
for (int objId : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if (pl != null)
if (plr != null)
{
final QuestState st = pl.getQuestState(Q00696_ConquerTheHallOfErosion.class.getSimpleName());
final QuestState st = plr.getQuestState(Q00696_ConquerTheHallOfErosion.class.getSimpleName());
if ((st != null) && (st.getInt("cond") == 1))
{
st.set("cohemenes", "1");
@ -616,13 +613,12 @@ public class HallOfErosionAttack extends AbstractNpcAI
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(INSTANCEID);
for (int objectId : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
if ((plr != null) && plr.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
obj.sendPacket(sm);
InstanceManager.getInstance().setInstanceTime(plr.getObjectId(), INSTANCEID, reenter.getTimeInMillis());
plr.sendPacket(sm);
}
}
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
@ -686,9 +682,8 @@ public class HallOfErosionAttack extends AbstractNpcAI
protected void broadCastPacket(HEAWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == world.getInstanceId()))
{
player.sendPacket(packet);

View File

@ -28,7 +28,6 @@ import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -340,13 +339,13 @@ public class HallOfErosionDefence extends AbstractNpcAI
for (L2PcInstance partyMember : player.getParty().isInCommandChannel() ? player.getParty().getCommandChannel().getMembers() : player.getParty().getMembers())
{
teleportPlayer(partyMember, coords, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
else
{
teleportPlayer(player, coords, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
((HEDWorld) world).finishTask = ThreadPool.schedule(new FinishTask((HEDWorld) world), 20 * 60000);
@ -625,13 +624,15 @@ public class HallOfErosionDefence extends AbstractNpcAI
final Instance inst = InstanceManager.getInstance().getInstance(_world.getInstanceId());
if (inst != null)
{
for (int objId : _world.getAllowed())
for (L2PcInstance player : _world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
final QuestState st = player.getQuestState(Q00697_DefendTheHallOfErosion.class.getSimpleName());
if ((st != null) && (st.getInt("cond") == 1))
if (player != null)
{
st.set("defenceDone", 1);
final QuestState st = player.getQuestState(Q00697_DefendTheHallOfErosion.class.getSimpleName());
if ((st != null) && (st.getInt("cond") == 1))
{
st.set("defenceDone", 1);
}
}
}
broadCastPacket(_world, new ExShowScreenMessage(NpcStringId.CONGRATULATIONS_YOU_HAVE_SUCCEEDED_AT_S1_S2_THE_INSTANCE_WILL_SHORTLY_EXPIRE, 2, 8000));
@ -678,9 +679,8 @@ public class HallOfErosionDefence extends AbstractNpcAI
protected void broadCastPacket(HEDWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == world.getInstanceId()))
{
player.sendPacket(packet);

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -235,14 +234,14 @@ public class HallOfSufferingAttack extends AbstractNpcAI
if (player.getParty() == null)
{
teleportPlayer(player, coords, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
for (L2PcInstance partyMember : player.getParty().getMembers())
{
teleportPlayer(partyMember, coords, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
}
@ -448,12 +447,11 @@ public class HallOfSufferingAttack extends AbstractNpcAI
sm.addInstanceName(INSTANCEID);
// set instance reenter time for all allowed players
for (int objectId : tmpworld.getAllowed())
for (L2PcInstance player : tmpworld.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(player.getObjectId(), INSTANCEID, reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -567,9 +565,8 @@ public class HallOfSufferingAttack extends AbstractNpcAI
cancelQuestTimers("isTwinSeparated");
addSpawn(TEPIOS, TEPIOS_SPAWN[0], TEPIOS_SPAWN[1], TEPIOS_SPAWN[2], 0, false, 0, false, world.getInstanceId());
for (Integer pc : world.getAllowed())
for (L2PcInstance killer : world.getAllowed())
{
final L2PcInstance killer = L2World.getInstance().getPlayer(pc);
if (killer != null)
{
killer.sendPacket(new ExSendUIEvent(killer, true, true, 0, 0, ""));

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -235,14 +234,14 @@ public class HallOfSufferingDefence extends AbstractNpcAI
if (player.getParty() == null)
{
teleportPlayer(player, coords, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
for (L2PcInstance partyMember : player.getParty().getMembers())
{
teleportPlayer(partyMember, coords, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
}
@ -448,12 +447,11 @@ public class HallOfSufferingDefence extends AbstractNpcAI
sm.addInstanceName(INSTANCEID);
// set instance reenter time for all allowed players
for (int objectId : tmpworld.getAllowed())
for (L2PcInstance player : tmpworld.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(player.getObjectId(), INSTANCEID, reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -567,9 +565,8 @@ public class HallOfSufferingDefence extends AbstractNpcAI
cancelQuestTimers("isTwinSeparated");
addSpawn(TEPIOS, TEPIOS_SPAWN[0], TEPIOS_SPAWN[1], TEPIOS_SPAWN[2], 0, false, 0, false, world.getInstanceId());
for (Integer pc : world.getAllowed())
for (L2PcInstance killer : world.getAllowed())
{
final L2PcInstance killer = L2World.getInstance().getPlayer(pc);
if (killer != null)
{
killer.sendPacket(new ExSendUIEvent(killer, true, true, 0, 0, ""));

View File

@ -32,7 +32,6 @@ import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.instancemanager.SoIManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
@ -323,14 +322,14 @@ public class HeartInfinityAttack extends AbstractNpcAI
if ((player.getParty() == null) || (player.getParty().getCommandChannel() == null))
{
teleportPlayer(player, coords, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
for (L2PcInstance partyMember : player.getParty().getCommandChannel().getMembers())
{
teleportPlayer(partyMember, coords, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
if (partyMember.getQuestState(qn) == null)
{
newQuestState(partyMember);
@ -523,12 +522,11 @@ public class HeartInfinityAttack extends AbstractNpcAI
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(INSTANCEID);
for (int objectId : tmpworld.getAllowed())
for (L2PcInstance player : tmpworld.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(player.getObjectId(), INSTANCEID, reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -859,9 +857,8 @@ public class HeartInfinityAttack extends AbstractNpcAI
protected void broadCastPacket(HIAWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == world.getInstanceId()))
{
player.sendPacket(packet);

View File

@ -28,7 +28,6 @@ import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@ -341,20 +340,20 @@ public class HeartInfinityDefence extends AbstractNpcAI
if (player.isGM())
{
teleportPlayer(player, coords, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
if ((player.getParty() == null) || (player.getParty().getCommandChannel() == null))
{
teleportPlayer(player, coords, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
for (L2PcInstance partyMember : player.getParty().getCommandChannel().getMembers())
{
teleportPlayer(partyMember, coords, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
if (partyMember.getQuestState(qn) == null)
{
newQuestState(partyMember);
@ -677,9 +676,8 @@ public class HeartInfinityDefence extends AbstractNpcAI
final Instance inst = InstanceManager.getInstance().getInstance(_world.getInstanceId());
if (inst != null)
{
for (int objId : _world.getAllowed())
for (L2PcInstance player : _world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
final QuestState st = player.getQuestState(Q00697_DefendTheHallOfErosion.class.getSimpleName());
if ((st != null) && (st.getInt("cond") == 1))
{
@ -761,9 +759,8 @@ public class HeartInfinityDefence extends AbstractNpcAI
protected void broadCastPacket(HIDWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == world.getInstanceId()))
{
player.sendPacket(packet);

View File

@ -55,7 +55,7 @@ public final class SecretArea extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, TELEPORTS[ENTER], world.getInstanceId());
}

View File

@ -32,7 +32,6 @@ import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.instancemanager.SoDManager;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@ -930,7 +929,7 @@ public class SeedOfDestruction extends AbstractNpcAI
InstanceManager.getInstance().setInstanceTime(player.getObjectId(), INSTANCE_ID, (System.currentTimeMillis()));
teleportplayer(player, teleto, (SODWorld) world);
removeBuffs(player);
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else if (player.getParty().getCommandChannel() != null)
{
@ -940,7 +939,7 @@ public class SeedOfDestruction extends AbstractNpcAI
InstanceManager.getInstance().setInstanceTime(channelMember.getObjectId(), INSTANCE_ID, (System.currentTimeMillis()));
teleportplayer(channelMember, teleto, (SODWorld) world);
removeBuffs(channelMember);
world.addAllowed(channelMember.getObjectId());
world.addAllowed(channelMember);
}
}
else
@ -951,7 +950,7 @@ public class SeedOfDestruction extends AbstractNpcAI
InstanceManager.getInstance().setInstanceTime(partyMember.getObjectId(), INSTANCE_ID, (System.currentTimeMillis()));
teleportplayer(partyMember, teleto, (SODWorld) world);
removeBuffs(partyMember);
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
return instanceId;
@ -1163,9 +1162,8 @@ public class SeedOfDestruction extends AbstractNpcAI
private void sendScreenMessage(SODWorld world, ExShowScreenMessage message)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if (player != null)
{
player.sendPacket(message);
@ -1275,7 +1273,7 @@ public class SeedOfDestruction extends AbstractNpcAI
{
if (world.getStatus() <= 7)
{
final L2PcInstance target = L2World.getInstance().getPlayer(world.getAllowed().get(Rnd.get(world.getAllowed().size())));
final L2PcInstance target = world.getAllowed().stream().findAny().get();
if ((world.deviceSpawnedMobCount < MAX_DEVICE_SPAWNED_MOB_COUNT) && (target != null) && ((npc != null) && (target.getInstanceId() == npc.getInstanceId())) && !target.isDead())
{
final L2Attackable mob = (L2Attackable) addSpawn(SPAWN_MOB_IDS[Rnd.get(SPAWN_MOB_IDS.length)], npc.getSpawn().getX(), npc.getSpawn().getY(), npc.getSpawn().getZ(), npc.getSpawn().getHeading(), false, 0, false, world.getInstanceId());

View File

@ -84,7 +84,7 @@ public final class DemonPrinceFloor extends AbstractInstance
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
teleportPlayer(player, EXIT_POINT, 0);
}
}
@ -168,7 +168,7 @@ public final class DemonPrinceFloor extends AbstractInstance
{
teleportPlayer(player, ENTRY_POINT, world.getInstanceId());
player.destroyItemByItemId("Quest", SEAL_BREAKER_5, 1, null, true);
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
@ -176,7 +176,7 @@ public final class DemonPrinceFloor extends AbstractInstance
{
teleportPlayer(partyMember, ENTRY_POINT, world.getInstanceId());
partyMember.destroyItemByItemId("Quest", SEAL_BREAKER_5, 1, null, true);
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
}

View File

@ -167,7 +167,7 @@ public final class RankuFloor extends AbstractInstance
{
teleportPlayer(player, ENTRY_POINT, world.getInstanceId());
player.destroyItemByItemId("Quest", SEAL_BREAKER_10, 1, null, true);
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
@ -175,7 +175,7 @@ public final class RankuFloor extends AbstractInstance
{
teleportPlayer(partyMember, ENTRY_POINT, world.getInstanceId());
partyMember.destroyItemByItemId("Quest", SEAL_BREAKER_10, 1, null, true);
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
}

View File

@ -372,14 +372,14 @@ public final class UrbanArea extends AbstractInstance
if (player.getParty() == null)
{
teleportPlayer(player, ENTRY_POINT, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
for (L2PcInstance partyMember : player.getParty().getMembers())
{
teleportPlayer(partyMember, ENTRY_POINT, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
world.setParameter("spawnedAmaskari", addSpawn(AMASKARI, AMASKARI_SPAWN_POINT, false, 0, false, world.getInstanceId()));
@ -438,7 +438,7 @@ public final class UrbanArea extends AbstractInstance
{
if ((partyMember != null) && !partyMember.isDead())
{
_world.removeAllowed(partyMember.getObjectId());
_world.removeAllowed(partyMember);
teleportPlayer(partyMember, EXIT_POINT, 0);
}
}

View File

@ -23,7 +23,6 @@ import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.InstanceReenterTimeHolder;
@ -164,10 +163,8 @@ public abstract class AbstractInstance extends AbstractNpcAI
protected void handleRemoveBuffs(InstanceWorld world)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if (player != null)
{
handleRemoveBuffs(player, world);
@ -189,12 +186,11 @@ public abstract class AbstractInstance extends AbstractNpcAI
*/
protected void setReenterTime(InstanceWorld world, long time)
{
for (int objectId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(player.getObjectId(), world.getTemplateId(), time);
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE).addString(InstanceManager.getInstance().getInstanceIdName(world.getTemplateId())));
}
}

View File

@ -114,14 +114,14 @@ public final class CastleDungeon extends AbstractInstance
if (player.getParty() == null)
{
teleportPlayer(player, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
for (L2PcInstance partyMember : player.getParty().getMembers())
{
teleportPlayer(partyMember, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}

View File

@ -194,7 +194,7 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
private void managePlayerEnter(L2PcInstance player, InstanceWorld world)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
teleportPlayer(player, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId(), false);
}

View File

@ -180,12 +180,11 @@ public abstract class Chamber extends AbstractInstance
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addString(InstanceManager.getInstance().getInstanceIdName(world.getTemplateId()));
// set instance reenter time for all allowed players
for (int objectId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(player.getObjectId(), world.getTemplateId(), reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -285,7 +284,7 @@ public abstract class Chamber extends AbstractInstance
partyMember.getVariables().set(RETURN, partyMember.getX() + ";" + partyMember.getY() + ";" + partyMember.getZ());
partyMember.setInstanceId(world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
changeRoom(world);
@ -355,7 +354,7 @@ public abstract class Chamber extends AbstractInstance
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
world.removeAllowed((player.getObjectId()));
world.removeAllowed((player));
}
}

View File

@ -701,7 +701,7 @@ public final class CrystalCaverns extends AbstractInstance
// this can happen only if debug is true
player.sendMessage("Welcome to Crystal Caverns.");
teleportPlayer(player, START_LOC, world.getInstanceId());
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
@ -709,7 +709,7 @@ public final class CrystalCaverns extends AbstractInstance
{
partyMember.sendMessage("Welcome to Crystal Caverns.");
teleportPlayer(partyMember, START_LOC, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
}
}
runOracle((CCWorld) world);
@ -1042,7 +1042,7 @@ public final class CrystalCaverns extends AbstractInstance
{
// Lucky cheater, the code only kicks his/her ass out of the dungeon
teleportPlayer(attacker, new Location(149361, 172327, -945), 0);
world.removeAllowed(attacker.getObjectId());
world.removeAllowed(attacker);
}
else if (world.tears != npc)
{

View File

@ -282,7 +282,7 @@ public final class DarkCloudMansion extends AbstractInstance
{
newQuestState(partyMember);
}
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
teleportPlayer(partyMember, new Location(146534, 180464, -6117), world.getInstanceId());
}
}
@ -1113,9 +1113,9 @@ public final class DarkCloudMansion extends AbstractInstance
if (npcId == SOTruth)
{
if (world.isAllowed(player.getObjectId()))
if (world.isAllowed(player))
{
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
}
teleportPlayer(player, new Location(139968, 150367, -3111), 0);
final int instanceId = npc.getInstanceId();

View File

@ -40,7 +40,6 @@ import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2Territory;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
@ -502,7 +501,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
{
player.destroyItemByItemId(getName(), DEWDROP_OF_DESTRUCTION_ITEM_ID, player.getInventory().getInventoryItemCount(DEWDROP_OF_DESTRUCTION_ITEM_ID, -1), null, true);
}
world.addAllowed(player.getObjectId());
world.addAllowed(player);
teleportPlayer(player, ENTER_TELEPORT, world.getInstanceId(), false);
}
else
@ -513,7 +512,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
{
channelMember.destroyItemByItemId(getName(), DEWDROP_OF_DESTRUCTION_ITEM_ID, channelMember.getInventory().getInventoryItemCount(DEWDROP_OF_DESTRUCTION_ITEM_ID, -1), null, true);
}
world.addAllowed(channelMember.getObjectId());
world.addAllowed(channelMember);
teleportPlayer(channelMember, ENTER_TELEPORT, world.getInstanceId(), false);
}
}
@ -820,9 +819,8 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
final List<L2Character> targetList = new ArrayList<>();
if (skill.hasEffectType(L2EffectType.STUN) || skill.isDebuff())
{
for (int objId : _world.getAllowed())
for (L2PcInstance player : _world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == _world.getInstanceId()))
{
if (!player.isDead())
@ -1279,9 +1277,8 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
private void stopPc()
{
for (int objId : _world.getAllowed())
for (L2PcInstance player : _world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == _world.getInstanceId()))
{
player.abortAttack();
@ -1297,9 +1294,8 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
private void startPc()
{
for (int objId : _world.getAllowed())
for (L2PcInstance player : _world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == _world.getInstanceId()))
{
player.enableAllSkills();
@ -1310,9 +1306,8 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
private void sendPacketX(IClientOutgoingPacket packet1, IClientOutgoingPacket packet2, int x)
{
for (int objId : _world.getAllowed())
for (L2PcInstance player : _world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == _world.getInstanceId()))
{
if (player.getX() < x)
@ -1386,14 +1381,14 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
private void addAggroToMobs()
{
L2PcInstance target = L2World.getInstance().getPlayer(_world.getAllowed().get(getRandom(_world.getAllowed().size())));
L2PcInstance target = _world.getAllowed().stream().findAny().get();
if ((target == null) || (target.getInstanceId() != _world.getInstanceId()) || target.isDead() || target.isFakeDeath())
{
for (int objId : _world.getAllowed())
for (L2PcInstance plr : _world.getAllowed())
{
target = L2World.getInstance().getPlayer(objId);
if ((target != null) && (target.getInstanceId() == _world.getInstanceId()) && !target.isDead() && !target.isFakeDeath())
if ((plr != null) && (plr.getInstanceId() == _world.getInstanceId()) && !plr.isDead() && !plr.isFakeDeath())
{
target = plr;
break;
}
target = null;
@ -1417,9 +1412,8 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
protected void broadCastPacket(InstanceWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == world.getInstanceId()))
{
player.sendPacket(packet);

View File

@ -122,7 +122,7 @@ public final class IceQueensCastle extends AbstractInstance
qs.setMemoState(3);
qs.setCond(10, true);
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
player.setInstanceId(0);
player.teleToLocation(EXIT_LOC, 0);
}
@ -188,7 +188,7 @@ public final class IceQueensCastle extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
world.setParameter("player", player);
world.openDoor(ICE_QUEEN_DOOR);
}

View File

@ -1243,7 +1243,7 @@ public final class IceQueensCastleBattle extends AbstractInstance
private void managePlayerEnter(L2PcInstance player, InstanceWorld world)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
teleportPlayer(player, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId(), false);
}

View File

@ -61,7 +61,7 @@ public final class JiniaGuildHideout1 extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
}

View File

@ -61,7 +61,7 @@ public final class JiniaGuildHideout2 extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
}

View File

@ -61,7 +61,7 @@ public final class JiniaGuildHideout3 extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
}

View File

@ -61,7 +61,7 @@ public final class JiniaGuildHideout4 extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
}

View File

@ -28,7 +28,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
@ -602,7 +601,7 @@ public final class Kamaloka extends AbstractInstance
final L2Party party = player.getParty();
for (L2PcInstance partyMember : party.getMembers())
{
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
removeBuffs(partyMember);
teleportPlayer(partyMember, TELEPORTS[index], world.getInstanceId());
}
@ -631,13 +630,12 @@ public final class Kamaloka extends AbstractInstance
sm.addInstanceName(world.getTemplateId());
// set instance reenter time for all allowed players
for (int objectId : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
if ((plr != null) && plr.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
obj.sendPacket(sm);
InstanceManager.getInstance().setInstanceTime(plr.getObjectId(), world.getTemplateId(), reenter.getTimeInMillis());
plr.sendPacket(sm);
}
}
@ -761,7 +759,7 @@ public final class Kamaloka extends AbstractInstance
if (world instanceof KamaWorld)
{
// party members must be in the instance
if (world.isAllowed(player.getObjectId()))
if (world.isAllowed(player))
{
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());

View File

@ -136,7 +136,7 @@ public final class MithrilMine extends AbstractInstance
else if (qs.isMemoState(3))
{
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
player.setInstanceId(0);
player.teleToLocation(EXIT_LOC, 0);
giveAdena(player, 296425, true);
@ -224,7 +224,7 @@ public final class MithrilMine extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
}

View File

@ -234,7 +234,7 @@ public final class NornilsGarden extends AbstractInstance
if (inst instanceof NornilsWorld)
{
final NornilsWorld world = ((NornilsWorld) inst);
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
teleportPlayer(player, EXIT_PPL, 0);
}
}
@ -297,7 +297,7 @@ public final class NornilsGarden extends AbstractInstance
{
for (L2PcInstance partyMember : party.getMembers())
{
newWorld.addAllowed(partyMember.getObjectId());
newWorld.addAllowed(partyMember);
teleportPlayer(partyMember, SPAWN_PPL, instanceId);
}
}

View File

@ -82,7 +82,7 @@ public final class NornilsGardenQuest extends AbstractInstance
if ((q236 != null) && q236.isCompleted())
{
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
finishInstance(world, 5000);
player.setInstanceId(0);
player.teleToLocation(world.getParameters().getLocation("ORIGIN_LOC"));
@ -99,7 +99,7 @@ public final class NornilsGardenQuest extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, ENTER_LOC, world.getInstanceId(), false);
}

View File

@ -319,7 +319,7 @@ public final class PailakaDevilsLegacy extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
world.setParameter("lematanNpc", addSpawn(LEMATAN, LEMATAN_SPAWN, false, 0, false, world.getInstanceId()));
}
teleportPlayer(player, TELEPORT, world.getInstanceId());

View File

@ -67,7 +67,7 @@ public final class PailakaSongOfIceAndFire extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, TELEPORT, world.getInstanceId());
}

View File

@ -180,7 +180,7 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
if (firstEntrance)
{
spawnNPC(world);
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, ENTER, world.getInstanceId());
}
@ -445,7 +445,7 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
{
takeItems(talker, SACRED_SWORD_OF_EINHASAD, -1);
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(talker);
world.removeAllowed(talker.getObjectId());
world.removeAllowed(talker);
talker.teleToLocation(EXIT, 0);
htmltext = "32587-01.html";
}

View File

@ -76,7 +76,7 @@ public final class SSQElcadiasTent extends AbstractInstance
else
{
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(talker);
world.removeAllowed(talker.getObjectId());
world.removeAllowed(talker);
talker.setInstanceId(0);
talker.teleToLocation(EXIT_LOC);
}
@ -88,7 +88,7 @@ public final class SSQElcadiasTent extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
}

View File

@ -78,7 +78,7 @@ public final class SSQHideoutOfTheDawn extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, WOOD_LOC, world.getInstanceId(), false);
}

View File

@ -117,7 +117,7 @@ public final class SSQLibraryOfSages extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
spawnElcadia(player, world);

View File

@ -190,7 +190,7 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
spawnElcadia(player, world);

View File

@ -19,7 +19,6 @@ package instances.SSQSanctumOfTheLordsOfDawn;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -170,7 +169,7 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
{
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
world.addAllowed(player);
world.setParameter("save_point1", world.spawnGroup("save_point1"));
world.setParameter("save_point2", world.spawnGroup("save_point2"));
world.setParameter("save_point3", world.spawnGroup("save_point3"));
@ -216,12 +215,11 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
world.openDoor(DOOR_TWO);
world.setParameter("doorst", doorst + 1);
npc.decayMe();
for (int objId : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if (pl != null)
if (plr != null)
{
playMovie(pl, Movie.SSQ_RITUAL_OF_PRIEST);
playMovie(plr, Movie.SSQ_RITUAL_OF_PRIEST);
startQuestTimer("spawn", 35000, null, talker);
}
}
@ -245,7 +243,7 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
case DARKNESS_OF_DAWN:
{
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(talker);
world.removeAllowed(talker.getObjectId());
world.removeAllowed(talker);
talker.teleToLocation(EXIT, 0);
return "32579-01.html";
}

View File

@ -960,7 +960,7 @@ public class Q00144_PailakaInjuredDragon extends Quest
// Check max summon levels.
checkMaxSummonLevel(player);
world.addAllowed(player.getObjectId());
world.addAllowed(player);
teleportPlayer(player, TELEPORT, world.getInstanceId());
}
}

View File

@ -301,14 +301,14 @@ public final class Q00511_AwlUnderFoot extends Quest
if (player.getParty() == null)
{
teleportPlayer(player, coords, instanceId);
world.addAllowed(player.getObjectId());
world.addAllowed(player);
}
else
{
for (L2PcInstance partyMember : party.getMembers())
{
teleportPlayer(partyMember, coords, instanceId);
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
getQuestState(partyMember, true);
}
}

View File

@ -19,7 +19,6 @@ package quests.Q00694_BreakThroughTheHallOfSuffering;
import java.util.Calendar;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.Instance;
@ -293,13 +292,12 @@ public final class Q00694_BreakThroughTheHallOfSuffering extends Quest
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(TEMPLATE_ID);
for (int objectId : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
if ((plr != null) && plr.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, TEMPLATE_ID, reenter.getTimeInMillis());
obj.sendPacket(sm);
InstanceManager.getInstance().setInstanceTime(plr.getObjectId(), TEMPLATE_ID, reenter.getTimeInMillis());
plr.sendPacket(sm);
}
}
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());

View File

@ -20,7 +20,6 @@ import java.util.Calendar;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.instancemanager.SoIManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.Instance;
@ -262,13 +261,12 @@ public final class Q00695_DefendTheHallOfSuffering extends Quest
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(TEMPLATE_ID);
for (int objectId : world.getAllowed())
for (L2PcInstance plr : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
if ((plr != null) && plr.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, TEMPLATE_ID, reenter.getTimeInMillis());
obj.sendPacket(sm);
InstanceManager.getInstance().setInstanceTime(plr.getObjectId(), TEMPLATE_ID, reenter.getTimeInMillis());
plr.sendPacket(sm);
}
}
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());

View File

@ -22,7 +22,6 @@ import java.util.Map;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -283,7 +282,7 @@ public class Q00726_LightWithinTheDarkness extends Quest
for (L2PcInstance partyMember : party.getMembers())
{
teleportPlayer(partyMember, coords, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
if (partyMember.getQuestState(getName()) == null)
{
newQuestState(partyMember);
@ -429,9 +428,8 @@ public class Q00726_LightWithinTheDarkness extends Quest
protected void broadCastPacket(PAWORLD world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline() && (player.getInstanceId() == world.getInstanceId()))
{
player.sendPacket(packet);

View File

@ -333,7 +333,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
{
final CAUWorld world = (CAUWorld) tmpworld;
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
final Location loc = inst.getExitLoc();
@ -646,7 +646,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
for (L2PcInstance partyMember : party.getMembers())
{
teleportPlayer(partyMember, coords, instanceId);
world.addAllowed(partyMember.getObjectId());
world.addAllowed(partyMember);
if (partyMember.getQuestState(getName()) == null)
{
newQuestState(partyMember);

View File

@ -166,7 +166,7 @@ public final class Q10284_AcquisitionOfDivineSword extends Quest
qs.setCond(3, true);
qs.setMemoState(2);
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
player.setInstanceId(0);
htmltext = event;
}

View File

@ -137,7 +137,7 @@ public final class Q10285_MeetingSirra extends Quest
qs.unset("ex");
qs.setMemoState(2);
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
player.setInstanceId(0);
htmltext = event;
}

View File

@ -105,7 +105,7 @@ public final class Q10286_ReunionWithSirra extends Quest
qs.unset("ex");
qs.setMemoState(2);
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
player.setInstanceId(0);
htmltext = event;
}

View File

@ -202,7 +202,7 @@ public final class Q10287_StoryOfThoseLeft extends Quest
qs.unset("ex1");
qs.unset("ex2");
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
world.removeAllowed(player.getObjectId());
world.removeAllowed(player);
player.setInstanceId(0);
htmltext = "32760-05.html";
}

View File

@ -270,7 +270,7 @@ public final class InstanceManager implements IGameXmlReader
{
for (InstanceWorld temp : _instanceWorlds.values())
{
if ((temp != null) && (temp.isAllowed(player.getObjectId())))
if ((temp != null) && (temp.isAllowed(player)))
{
return temp;
}

View File

@ -44,7 +44,6 @@ import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.FortManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@ -2928,12 +2927,11 @@ public abstract class AbstractScript extends ManagedScript
{
if (world != null)
{
for (int objId : world.getAllowed())
for (L2PcInstance player : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && (player.getInstanceId() == world.getInstanceId()))
{
playMovie(L2World.getInstance().getPlayer(objId), movie);
playMovie(player, movie);
}
}
}

View File

@ -17,7 +17,8 @@
package com.l2jmobius.gameserver.model.instancezone;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import com.l2jmobius.commons.util.CommonUtil;
@ -25,6 +26,7 @@ import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* Basic instance zone data transfer object.
@ -33,7 +35,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
public class InstanceWorld
{
private Instance _instance;
private final List<Integer> _allowed = new CopyOnWriteArrayList<>();
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet();
private final StatsSet _parameters = new StatsSet();
/**
@ -63,24 +65,27 @@ public class InstanceWorld
return _instance.getTemplateId();
}
public List<Integer> getAllowed()
public Set<L2PcInstance> getAllowed()
{
return _allowed;
return _players;
}
public void removeAllowed(int id)
public void removeAllowed(L2PcInstance player)
{
_allowed.remove(_allowed.indexOf(Integer.valueOf(id)));
_players.remove(player);
}
public void addAllowed(int id)
public void addAllowed(L2PcInstance player)
{
_allowed.add(id);
if (!_players.contains(player))
{
_players.add(player);
}
}
public boolean isAllowed(int id)
public boolean isAllowed(L2PcInstance player)
{
return _allowed.contains(id);
return _players.contains(player);
}
/**

View File

@ -3424,6 +3424,15 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
*/
public void playMovie(Instance instance, Movie movie)
{
playMovie(instance.getPlayers(), movie);
if (instance != null)
{
for (L2PcInstance player : instance.getPlayers())
{
if ((player != null) && (player.getInstanceWorld() == instance))
{
playMovie(player, movie);
}
}
}
}
}

View File

@ -45,7 +45,6 @@ import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.enums.InstanceTeleportType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType;
@ -84,7 +83,7 @@ public final class Instance implements IIdentifiable, INamable
private final long _startTime;
private long _endTime;
// Advanced instance parameters
private final Set<Integer> _allowed = ConcurrentHashMap.newKeySet(); // ObjectId of players which can enter to instance
private final Set<L2PcInstance> _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet(); // Players inside instance
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance
private final Map<Integer, L2DoorInstance> _doors = new HashMap<>(); // Spawned doors inside instance
@ -223,7 +222,10 @@ public final class Instance implements IIdentifiable, INamable
*/
public void addAllowed(L2PcInstance player)
{
_allowed.add(player.getObjectId());
if (!_allowed.contains(player))
{
_allowed.add(player);
}
}
/**
@ -233,25 +235,25 @@ public final class Instance implements IIdentifiable, INamable
*/
public boolean isAllowed(L2PcInstance player)
{
return _allowed.contains(player.getObjectId());
return _allowed.contains(player);
}
/**
* Returns all players who can enter to instance.
* @return allowed players list
*/
public Set<Integer> getAllowed()
public Set<L2PcInstance> getAllowed()
{
return _allowed;
}
/**
* Remove player from allowed so he can't enter anymore.
* @param objectId object id of player
* @param player to remove
*/
public void removeAllowed(int objectId)
public void removeAllowed(L2PcInstance player)
{
_allowed.remove(objectId);
_allowed.remove(player);
}
/**
@ -817,12 +819,15 @@ public final class Instance implements IIdentifiable, INamable
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
{
// Save to database
for (Integer objId : _allowed)
for (L2PcInstance player : _allowed)
{
ps.setInt(1, objId);
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
if (player != null)
{
ps.setInt(1, player.getObjectId());
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
}
}
ps.executeBatch();
@ -836,13 +841,15 @@ public final class Instance implements IIdentifiable, INamable
{
msg.addString(getName());
}
_allowed.forEach(objId ->
_allowed.forEach(player ->
{
InstanceManager.getInstance().setReenterPenalty(objId, getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline())
if ((player != null))
{
player.sendPacket(msg);
InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time);
if (player.isOnline())
{
player.sendPacket(msg);
}
}
});
}

View File

@ -3424,6 +3424,15 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
*/
public void playMovie(Instance instance, Movie movie)
{
playMovie(instance.getPlayers(), movie);
if (instance != null)
{
for (L2PcInstance player : instance.getPlayers())
{
if ((player != null) && (player.getInstanceWorld() == instance))
{
playMovie(player, movie);
}
}
}
}
}

View File

@ -45,7 +45,6 @@ import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.enums.InstanceTeleportType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType;
@ -84,7 +83,7 @@ public final class Instance implements IIdentifiable, INamable
private final long _startTime;
private long _endTime;
// Advanced instance parameters
private final Set<Integer> _allowed = ConcurrentHashMap.newKeySet(); // ObjectId of players which can enter to instance
private final Set<L2PcInstance> _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet(); // Players inside instance
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance
private final Map<Integer, L2DoorInstance> _doors = new HashMap<>(); // Spawned doors inside instance
@ -223,7 +222,10 @@ public final class Instance implements IIdentifiable, INamable
*/
public void addAllowed(L2PcInstance player)
{
_allowed.add(player.getObjectId());
if (!_allowed.contains(player))
{
_allowed.add(player);
}
}
/**
@ -233,25 +235,25 @@ public final class Instance implements IIdentifiable, INamable
*/
public boolean isAllowed(L2PcInstance player)
{
return _allowed.contains(player.getObjectId());
return _allowed.contains(player);
}
/**
* Returns all players who can enter to instance.
* @return allowed players list
*/
public Set<Integer> getAllowed()
public Set<L2PcInstance> getAllowed()
{
return _allowed;
}
/**
* Remove player from allowed so he can't enter anymore.
* @param objectId object id of player
* @param player to remove
*/
public void removeAllowed(int objectId)
public void removeAllowed(L2PcInstance player)
{
_allowed.remove(objectId);
_allowed.remove(player);
}
/**
@ -817,12 +819,15 @@ public final class Instance implements IIdentifiable, INamable
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
{
// Save to database
for (Integer objId : _allowed)
for (L2PcInstance player : _allowed)
{
ps.setInt(1, objId);
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
if (player != null)
{
ps.setInt(1, player.getObjectId());
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
}
}
ps.executeBatch();
@ -836,13 +841,15 @@ public final class Instance implements IIdentifiable, INamable
{
msg.addString(getName());
}
_allowed.forEach(objId ->
_allowed.forEach(player ->
{
InstanceManager.getInstance().setReenterPenalty(objId, getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline())
if ((player != null))
{
player.sendPacket(msg);
InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time);
if (player.isOnline())
{
player.sendPacket(msg);
}
}
});
}

View File

@ -3424,6 +3424,15 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
*/
public void playMovie(Instance instance, Movie movie)
{
playMovie(instance.getPlayers(), movie);
if (instance != null)
{
for (L2PcInstance player : instance.getPlayers())
{
if ((player != null) && (player.getInstanceWorld() == instance))
{
playMovie(player, movie);
}
}
}
}
}

View File

@ -45,7 +45,6 @@ import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.enums.InstanceTeleportType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.TeleportWhereType;
@ -84,7 +83,7 @@ public final class Instance implements IIdentifiable, INamable
private final long _startTime;
private long _endTime;
// Advanced instance parameters
private final Set<Integer> _allowed = ConcurrentHashMap.newKeySet(); // ObjectId of players which can enter to instance
private final Set<L2PcInstance> _allowed = ConcurrentHashMap.newKeySet(); // Players which can enter to instance
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet(); // Players inside instance
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet(); // Spawned NPCs inside instance
private final Map<Integer, L2DoorInstance> _doors = new HashMap<>(); // Spawned doors inside instance
@ -223,7 +222,10 @@ public final class Instance implements IIdentifiable, INamable
*/
public void addAllowed(L2PcInstance player)
{
_allowed.add(player.getObjectId());
if (!_allowed.contains(player))
{
_allowed.add(player);
}
}
/**
@ -233,25 +235,25 @@ public final class Instance implements IIdentifiable, INamable
*/
public boolean isAllowed(L2PcInstance player)
{
return _allowed.contains(player.getObjectId());
return _allowed.contains(player);
}
/**
* Returns all players who can enter to instance.
* @return allowed players list
*/
public Set<Integer> getAllowed()
public Set<L2PcInstance> getAllowed()
{
return _allowed;
}
/**
* Remove player from allowed so he can't enter anymore.
* @param objectId object id of player
* @param player to remove
*/
public void removeAllowed(int objectId)
public void removeAllowed(L2PcInstance player)
{
_allowed.remove(objectId);
_allowed.remove(player);
}
/**
@ -817,12 +819,15 @@ public final class Instance implements IIdentifiable, INamable
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
{
// Save to database
for (Integer objId : _allowed)
for (L2PcInstance player : _allowed)
{
ps.setInt(1, objId);
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
if (player != null)
{
ps.setInt(1, player.getObjectId());
ps.setInt(2, getTemplateId());
ps.setLong(3, time);
ps.addBatch();
}
}
ps.executeBatch();
@ -836,13 +841,15 @@ public final class Instance implements IIdentifiable, INamable
{
msg.addString(getName());
}
_allowed.forEach(objId ->
_allowed.forEach(player ->
{
InstanceManager.getInstance().setReenterPenalty(objId, getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objId);
if ((player != null) && player.isOnline())
if ((player != null))
{
player.sendPacket(msg);
InstanceManager.getInstance().setReenterPenalty(player.getObjectId(), getTemplateId(), time);
if (player.isOnline())
{
player.sendPacket(msg);
}
}
});
}