|
@@ -18,16 +18,15 @@ import java.util.logging.Level;
|
|
|
|
|
|
import com.l2jserver.gameserver.handler.IBypassHandler;
|
|
import com.l2jserver.gameserver.handler.IBypassHandler;
|
|
import com.l2jserver.gameserver.model.actor.L2Character;
|
|
import com.l2jserver.gameserver.model.actor.L2Character;
|
|
|
|
+import com.l2jserver.gameserver.model.actor.L2Npc;
|
|
import com.l2jserver.gameserver.model.actor.instance.L2OlympiadManagerInstance;
|
|
import com.l2jserver.gameserver.model.actor.instance.L2OlympiadManagerInstance;
|
|
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
|
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
|
import com.l2jserver.gameserver.model.entity.TvTEvent;
|
|
import com.l2jserver.gameserver.model.entity.TvTEvent;
|
|
-import com.l2jserver.gameserver.model.olympiad.Olympiad;
|
|
|
|
import com.l2jserver.gameserver.model.olympiad.OlympiadGameManager;
|
|
import com.l2jserver.gameserver.model.olympiad.OlympiadGameManager;
|
|
import com.l2jserver.gameserver.model.olympiad.OlympiadGameTask;
|
|
import com.l2jserver.gameserver.model.olympiad.OlympiadGameTask;
|
|
import com.l2jserver.gameserver.model.olympiad.OlympiadManager;
|
|
import com.l2jserver.gameserver.model.olympiad.OlympiadManager;
|
|
import com.l2jserver.gameserver.network.SystemMessageId;
|
|
import com.l2jserver.gameserver.network.SystemMessageId;
|
|
-import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
|
|
|
-import com.l2jserver.util.StringUtil;
|
|
|
|
|
|
+import com.l2jserver.gameserver.network.serverpackets.ExOlympiadMatchList;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author DS
|
|
* @author DS
|
|
@@ -36,7 +35,7 @@ public class OlympiadObservation implements IBypassHandler
|
|
{
|
|
{
|
|
private static final String[] COMMANDS =
|
|
private static final String[] COMMANDS =
|
|
{
|
|
{
|
|
- "arenalist",
|
|
|
|
|
|
+ "watchmatch",
|
|
"arenachange"
|
|
"arenachange"
|
|
};
|
|
};
|
|
|
|
|
|
@@ -45,167 +44,20 @@ public class OlympiadObservation implements IBypassHandler
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- final boolean isManager = target instanceof L2OlympiadManagerInstance;
|
|
|
|
- if (!isManager)
|
|
|
|
- {
|
|
|
|
- // without npc command can be used only in observer mode on arena
|
|
|
|
- if (!activeChar.inObserverMode() || activeChar.isInOlympiadMode() || (activeChar.getOlympiadGameId() < 0))
|
|
|
|
- {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ final L2Npc olymanager = activeChar.getLastFolkNPC();
|
|
|
|
|
|
if (command.startsWith(COMMANDS[0])) // list
|
|
if (command.startsWith(COMMANDS[0])) // list
|
|
{
|
|
{
|
|
- NpcHtmlMessage message = new NpcHtmlMessage(0);
|
|
|
|
- if (command.length() < 10)
|
|
|
|
- {
|
|
|
|
- if (isManager)
|
|
|
|
- {
|
|
|
|
- message.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "olympiad_observe.htm");
|
|
|
|
- message.replace("%objectId%", String.valueOf(target.getObjectId()));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- message.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "olympiad_arena_observe.htm");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- activeChar.sendPacket(message);
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- final int firstArena, lastArena;
|
|
|
|
- switch (Integer.parseInt(command.substring(10).trim()))
|
|
|
|
- {
|
|
|
|
- case 1:
|
|
|
|
- firstArena = 0;
|
|
|
|
- lastArena = 21;
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- firstArena = 22;
|
|
|
|
- lastArena = 43;
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- firstArena = 44;
|
|
|
|
- lastArena = 65;
|
|
|
|
- break;
|
|
|
|
- case 4:
|
|
|
|
- firstArena = 66;
|
|
|
|
- lastArena = 87;
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- StringBuilder list = new StringBuilder(3500);
|
|
|
|
- OlympiadGameTask task;
|
|
|
|
-
|
|
|
|
- if (isManager)
|
|
|
|
- {
|
|
|
|
- message.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "olympiad_observe_list.htm");
|
|
|
|
- for (int i = firstArena; i <= lastArena; i++)
|
|
|
|
- {
|
|
|
|
- task = OlympiadGameManager.getInstance().getOlympiadTask(i);
|
|
|
|
- if (task != null)
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "<a action=\"bypass -h npc_%objectId%_arenachange ", String.valueOf(i), "\">Arena ", String.valueOf(i + 1), " ");
|
|
|
|
-
|
|
|
|
- if (task.isGameStarted())
|
|
|
|
- {
|
|
|
|
- if (task.isBattleStarted())
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$1719;"); // Playing
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$1718;"); // Standby
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- StringUtil.append(list, " ", task.getGame().getPlayerNames()[0], " : ", task.getGame().getPlayerNames()[1]);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$906;", // Initial State
|
|
|
|
- "</td><td> ");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- StringUtil.append(list, "</a><br>");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- message.replace("%list%", list.toString());
|
|
|
|
- message.replace("%objectId%", String.valueOf(target.getObjectId()));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- message.setFile(activeChar.getHtmlPrefix(), Olympiad.OLYMPIAD_HTML_PATH + "olympiad_arena_observe_list.htm");
|
|
|
|
- for (int i = firstArena; i <= lastArena; i++)
|
|
|
|
- {
|
|
|
|
- task = OlympiadGameManager.getInstance().getOlympiadTask(i);
|
|
|
|
- if (task != null)
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "<tr><td fixwidth=30><a action=\"bypass arenachange ", String.valueOf(i), "\">", String.valueOf(i + 1), "</a></td><td fixwidth=60>");
|
|
|
|
-
|
|
|
|
- if (task.isGameStarted())
|
|
|
|
- {
|
|
|
|
- if (task.isBattleStarted())
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$1719;"); // Playing
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$1718;"); // Standby
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- StringUtil.append(list, "</td><td>", task.getGame().getPlayerNames()[0], " ", task.getGame().getPlayerNames()[1]);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$906;", // Initial State
|
|
|
|
- "</td><td> ");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- StringUtil.append(list, "</td><td><font color=\"aaccff\"></font></td></tr>");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (int i = firstArena; i <= lastArena; i++)
|
|
|
|
- {
|
|
|
|
- task = OlympiadGameManager.getInstance().getOlympiadTask(i);
|
|
|
|
- if (task != null)
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "<tr><td fixwidth=30><a action=\"bypass arenachange ", String.valueOf(i), "\">", String.valueOf(i + 1), "</a></td><td fixwidth=60>");
|
|
|
|
-
|
|
|
|
- if (task.isGameStarted())
|
|
|
|
- {
|
|
|
|
- if (task.isBattleStarted())
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$1719;"); // Playing
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$1718;"); // Standby
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- StringUtil.append(list, "</td><td>", task.getGame().getPlayerNames()[0], " ", task.getGame().getPlayerNames()[1]);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- StringUtil.append(list, "&$906;", // Initial State
|
|
|
|
- "</td><td> ");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- StringUtil.append(list, "</td><td><font color=\"aaccff\"></font></td></tr>");
|
|
|
|
- }
|
|
|
|
- message.replace("%list%", list.toString());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- activeChar.sendPacket(message);
|
|
|
|
- return true;
|
|
|
|
|
|
+ activeChar.sendPacket(new ExOlympiadMatchList());
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (isManager)
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
|
|
+ if (olymanager == null || !(olymanager instanceof L2OlympiadManagerInstance))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if (!activeChar.inObserverMode() && !activeChar.isInsideRadius(olymanager, 300, false, false))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
|
|
if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
|
|
{
|
|
{
|
|
activeChar.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
|
|
activeChar.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
|
|
@@ -216,16 +68,17 @@ public class OlympiadObservation implements IBypassHandler
|
|
activeChar.sendMessage("You can not observe games while registered for TvT");
|
|
activeChar.sendMessage("You can not observe games while registered for TvT");
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ final int arenaId = Integer.parseInt(command.substring(12).trim());
|
|
|
|
+ final OlympiadGameTask nextArena = OlympiadGameManager.getInstance().getOlympiadTask(arenaId);
|
|
|
|
+ if (nextArena != null)
|
|
|
|
+ {
|
|
|
|
+ activeChar.enterOlympiadObserverMode(nextArena.getZone().getSpawns().get(0), arenaId);
|
|
|
|
+ activeChar.setInstanceId(OlympiadGameManager.getInstance().getOlympiadTask(arenaId).getZone().getInstanceId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
|
|
|
|
- final int arenaId = Integer.parseInt(command.substring(12).trim());
|
|
|
|
- final OlympiadGameTask nextArena = OlympiadGameManager.getInstance().getOlympiadTask(arenaId);
|
|
|
|
- if (nextArena != null)
|
|
|
|
- {
|
|
|
|
- activeChar.enterOlympiadObserverMode(nextArena.getZone().getSpawns().get(0), arenaId);
|
|
|
|
- activeChar.setInstanceId(OlympiadGameManager.getInstance().getOlympiadTask(arenaId).getZone().getInstanceId());
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|