if (!Config.ENABLE_OLYMPIAD)
{
return;
}
int val = Integer.parseInt(command.substring(14));
NpcHtmlMessage html = new NpcHtmlMessage(player, this);
switch (val)
{
case 1:
Olympiad.unRegisterNoble(player);
showChatWindow(player, 0);
break;
case 2:
if (Olympiad.isRegistered(player))
{
player.sendPacket(html.setFile(Olympiad.OLYMPIAD_HTML_PATH + "manager_noregister.htm"));
}
else
{
int nowWeek = Calendar.getInstance().get(Calendar.WEEK_OF_MONTH);
if (nowWeek < 4)
{
html.setFile(Olympiad.OLYMPIAD_HTML_PATH + "manager_register_noclass.htm");
}
else
{
html.setFile(Olympiad.OLYMPIAD_HTML_PATH + "manager_register_class.htm");
}
player.sendPacket(html);
}
break;
case 4:
Olympiad.registerNoble(player, CompType.NON_CLASSED);
break;
case 5:
Olympiad.registerNoble(player, CompType.CLASSED);
break;
case 6:
int passes = Olympiad.getNoblessePasses(player);
if (passes > 0)
{
player.getInventory().addItem(Config.ALT_OLY_COMP_RITEM, passes);
player.sendPacket(SystemMessage2.obtainItems(Config.ALT_OLY_COMP_RITEM, passes, 0));
}
else
{
player.sendPacket(html.setFile(Olympiad.OLYMPIAD_HTML_PATH + "manager_nopoints.htm"));
}
break;
case 7:
MultiSellHolder.getInstance().SeparateAndSend(102, player, 0);
break;
case 9:
MultiSellHolder.getInstance().SeparateAndSend(103, player, 0);
break;
default:
_log.warn("Olympiad System: Couldnt send packet for request " + val);
break;
}
}
else if (command.startsWith("Olympiad"))
{
if (!Config.ENABLE_OLYMPIAD)
{
return;
}
int val = Integer.parseInt(command.substring(9, 10));
NpcHtmlMessage reply = new NpcHtmlMessage(player, this);
switch (val)
{
case 1:
if (!Olympiad.inCompPeriod() || Olympiad.isOlympiadEnd())
{
player.sendPacket(SystemMsg.THE_GRAND_OLYMPIAD_GAMES_ARE_NOT_CURRENTLY_IN_PROGRESS);
return;
}
player.sendPacket(new ExReceiveOlympiad.MatchList());
break;
case 2:
int classId = Integer.parseInt(command.substring(11));
if (classId >= 139)
{
reply.setFile(Olympiad.OLYMPIAD_HTML_PATH + "manager_ranking.htm");
List<String> names = OlympiadDatabase.getClassLeaderBoard(classId);
int index = 1;
for (String name : names)
{
reply.replace("%place" + index + "%", String.valueOf(index));
reply.replace("%rank" + index + "%", name);
index++;
if (index > 10)
{
break;
}
}
for (; index <= 10; index++)
{
reply.replace("%place" + index + "%", "");
reply.replace("%rank" + index + "%", "");
}
player.sendPacket(reply);
}
break;
case 3:
if (!Config.ENABLE_OLYMPIAD_SPECTATING)
{
break;
}
Olympiad.addSpectator(Integer.parseInt(command.substring(11)), player);
break;
case 4:
player.sendPacket(new ExHeroList());
break;
case 5:
if (Hero.getInstance().isInactiveHero(player.getObjectId()))
{
Hero.getInstance().activateHero(player);
reply.setFile(Olympiad.OLYMPIAD_HTML_PATH + "monument_give_hero.htm");
}
else
{
reply.setFile(Olympiad.OLYMPIAD_HTML_PATH + "monument_dont_hero.htm");
}
player.sendPacket(reply);
break;
default:
_log.warn("Olympiad System: Couldnt send packet for request " + val);