{
if(param.length < 1)
{
throw new IllegalArgumentException();
}
L2Player player = (L2Player) getSelf();
if(player == null)
{
return;
}
if(player.isInParty())
{
player.sendPacket(Msg.YOU_CANNOT_ENTER_DUE_TO_THE_PARTY_HAVING_EXCEEDED_THE_LIMIT);
return;
}
KamalokaNightmare r = ReflectionTable.getInstance().findSoloKamaloka(player.getObjectId());
if(r != null)
{
player.setVar("backCoords", r.getReturnLoc().toXYZString());
player.teleToLocation(r.getTeleportLoc(), r.getId());
return;
}
if(param[0].equals("-1"))
{
player.sendPacket(Msg.SYSTEM_ERROR);
return;
}
if(Config.ALT_KAMALOKA_NIGHTMARES_PREMIUM_ONLY && player.getBonus().RATE_XP <= 1)
{
player.sendMessage(new CustomMessage("common.PremiumOnly", player));
return;
}
InstancedZoneManager izm = InstancedZoneManager.getInstance();
FastMap<Integer, InstancedZone> izs = InstancedZoneManager.getInstance().getById(Integer.parseInt(param[0]));
if(izs == null)
{
player.sendPacket(Msg.SYSTEM_ERROR);
return;
}
InstancedZone iz = izs.get(0);
assert iz != null;
String name = iz.getName();
int timelimit = iz.getTimelimit();
int min_level = iz.getMinLevel();
int max_level = iz.getMaxLevel();
if(player.getLevel() < min_level || player.getLevel() > max_level)
{
player.sendPacket(new SystemMessage(SystemMessage.C1S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED).addName(player));
return;
}
if(izm.getTimeToNextEnterInstance(name, player) > 0)
{
player.sendPacket(new SystemMessage(SystemMessage.C1_MAY_NOT_RE_ENTER_YET).addName(player));
return;
}
if(player.isCursedWeaponEquipped())
{
player.sendPacket(new SystemMessage(SystemMessage.C1S_QUEST_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED).addName(player));
return;
}
r = new KamalokaNightmare(player);
for(InstancedZone i : izs.values())
{
if(r.getTeleportLoc() == null)
{
r.setTeleportLoc(i.getTeleportCoords());
}
r.FillSpawns(i.getSpawnsInfo());
r.FillDoors(i.getDoors());
}
player.setVar(name, String.valueOf(System.currentTimeMillis()));
r.setReturnLoc(player.getLoc());
player.setVar("backCoords", r.getReturnLoc().toXYZString());
player.teleToLocation(r.getTeleportLoc(), r.getId());
ReflectionTable.getInstance().addSoloKamaloka(player.getObjectId(), r);
if(timelimit > 0)
{
r.startCollapseTimer(timelimit * 60 * 1000L);
player.sendPacket(new SystemMessage(SystemMessage.THIS_DUNGEON_WILL_EXPIRE_IN_S1_MINUTES).addNumber(timelimit));
}
}