|
@@ -49,6 +49,9 @@ public class Instance
|
|
private FastList<L2DoorInstance> _doors = new FastList<L2DoorInstance>();
|
|
private FastList<L2DoorInstance> _doors = new FastList<L2DoorInstance>();
|
|
private int[] _spawnLoc = new int[3];
|
|
private int[] _spawnLoc = new int[3];
|
|
private boolean _allowSummon = true;
|
|
private boolean _allowSummon = true;
|
|
|
|
+ private long _emptyDestroyTime = -1;
|
|
|
|
+ private long _lastLeft = -1;
|
|
|
|
+ private long _instanceEndTime = -1;
|
|
private boolean _isPvPInstance = false;
|
|
private boolean _isPvPInstance = false;
|
|
|
|
|
|
protected ScheduledFuture<?> _CheckTimeUpTask = null;
|
|
protected ScheduledFuture<?> _CheckTimeUpTask = null;
|
|
@@ -120,7 +123,7 @@ public class Instance
|
|
if (_CheckTimeUpTask != null)
|
|
if (_CheckTimeUpTask != null)
|
|
_CheckTimeUpTask.cancel(true);
|
|
_CheckTimeUpTask.cancel(true);
|
|
|
|
|
|
- _CheckTimeUpTask = ThreadPoolManager.getInstance().scheduleGeneral(new CheckTimeUp(duration * 60000), 15000);
|
|
|
|
|
|
+ _CheckTimeUpTask = ThreadPoolManager.getInstance().scheduleGeneral(new CheckTimeUp(duration), 500);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -153,6 +156,11 @@ public class Instance
|
|
{
|
|
{
|
|
if (_players.contains(objectId))
|
|
if (_players.contains(objectId))
|
|
_players.remove(objectId);
|
|
_players.remove(objectId);
|
|
|
|
+ if (_players.isEmpty() && _emptyDestroyTime >= 0)
|
|
|
|
+ {
|
|
|
|
+ _lastLeft = System.currentTimeMillis();
|
|
|
|
+ setDuration((int) (_instanceEndTime - System.currentTimeMillis() - 1000));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -173,6 +181,11 @@ public class Instance
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void addNpc(L2Npc npc)
|
|
|
|
+ {
|
|
|
|
+ _npcs.add(npc);
|
|
|
|
+ }
|
|
|
|
+
|
|
public void removeNpc(L2Spawn spawn)
|
|
public void removeNpc(L2Spawn spawn)
|
|
{
|
|
{
|
|
_npcs.remove(spawn);
|
|
_npcs.remove(spawn);
|
|
@@ -344,7 +357,10 @@ public class Instance
|
|
{
|
|
{
|
|
a = n.getAttributes().getNamedItem("val");
|
|
a = n.getAttributes().getNamedItem("val");
|
|
if (a != null)
|
|
if (a != null)
|
|
|
|
+ {
|
|
_CheckTimeUpTask = ThreadPoolManager.getInstance().scheduleGeneral(new CheckTimeUp(Integer.parseInt(a.getNodeValue()) * 60000), 15000);
|
|
_CheckTimeUpTask = ThreadPoolManager.getInstance().scheduleGeneral(new CheckTimeUp(Integer.parseInt(a.getNodeValue()) * 60000), 15000);
|
|
|
|
+ _instanceEndTime = System.currentTimeMillis() + Long.parseLong(a.getNodeValue()) * 60000 + 15000;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/* else if ("timeDelay".equalsIgnoreCase(n.getNodeName()))
|
|
/* else if ("timeDelay".equalsIgnoreCase(n.getNodeName()))
|
|
{
|
|
{
|
|
@@ -358,6 +374,12 @@ public class Instance
|
|
if (a != null)
|
|
if (a != null)
|
|
setAllowSummon(Boolean.parseBoolean(a.getNodeValue()));
|
|
setAllowSummon(Boolean.parseBoolean(a.getNodeValue()));
|
|
}
|
|
}
|
|
|
|
+ else if ("emptyDestroyTime".equalsIgnoreCase(n.getNodeName()))
|
|
|
|
+ {
|
|
|
|
+ a = n.getAttributes().getNamedItem("val");
|
|
|
|
+ if (a != null)
|
|
|
|
+ _emptyDestroyTime = Long.parseLong(a.getNodeValue()) * 1000;
|
|
|
|
+ }
|
|
else if ("PvPInstance".equalsIgnoreCase(n.getNodeName()))
|
|
else if ("PvPInstance".equalsIgnoreCase(n.getNodeName()))
|
|
{
|
|
{
|
|
a = n.getAttributes().getNamedItem("val");
|
|
a = n.getAttributes().getNamedItem("val");
|
|
@@ -445,7 +467,42 @@ public class Instance
|
|
int timeLeft;
|
|
int timeLeft;
|
|
int interval;
|
|
int interval;
|
|
|
|
|
|
- if (remaining > 300000)
|
|
|
|
|
|
+ if (_players.isEmpty() && _emptyDestroyTime == 0)
|
|
|
|
+ {
|
|
|
|
+ remaining = 0;
|
|
|
|
+ interval = 500;
|
|
|
|
+ }
|
|
|
|
+ else if (_players.isEmpty() && _emptyDestroyTime > 0)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ Long emptyTimeLeft = _lastLeft + _emptyDestroyTime - System.currentTimeMillis();
|
|
|
|
+ if (emptyTimeLeft <= 0)
|
|
|
|
+ {
|
|
|
|
+ interval = 0;
|
|
|
|
+ remaining = 0;
|
|
|
|
+ }
|
|
|
|
+ else if (remaining > 300000 && emptyTimeLeft > 300000)
|
|
|
|
+ {
|
|
|
|
+ interval = 300000;
|
|
|
|
+ remaining = remaining - 300000;
|
|
|
|
+ }
|
|
|
|
+ else if (remaining > 60000 && emptyTimeLeft > 60000)
|
|
|
|
+ {
|
|
|
|
+ interval = 60000;
|
|
|
|
+ remaining = remaining - 60000;
|
|
|
|
+ }
|
|
|
|
+ else if (remaining > 30000 && emptyTimeLeft > 30000)
|
|
|
|
+ {
|
|
|
|
+ interval = 30000;
|
|
|
|
+ remaining = remaining - 30000;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ interval = 10000;
|
|
|
|
+ remaining = remaining - 10000;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (remaining > 300000)
|
|
{
|
|
{
|
|
timeLeft = remaining / 60000;
|
|
timeLeft = remaining / 60000;
|
|
interval = 300000;
|
|
interval = 300000;
|