AdminEventEngine.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.admincommandhandlers;
  20. import java.io.BufferedInputStream;
  21. import java.io.BufferedReader;
  22. import java.io.DataInputStream;
  23. import java.io.File;
  24. import java.io.FileInputStream;
  25. import java.io.FileOutputStream;
  26. import java.io.InputStreamReader;
  27. import java.io.PrintStream;
  28. import java.util.StringTokenizer;
  29. import com.l2jserver.Config;
  30. import com.l2jserver.gameserver.data.xml.impl.AdminData;
  31. import com.l2jserver.gameserver.data.xml.impl.TransformData;
  32. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  33. import com.l2jserver.gameserver.model.L2World;
  34. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  35. import com.l2jserver.gameserver.model.entity.L2Event;
  36. import com.l2jserver.gameserver.model.entity.L2Event.EventState;
  37. import com.l2jserver.gameserver.network.serverpackets.CharInfo;
  38. import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
  39. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  40. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  41. import com.l2jserver.gameserver.network.serverpackets.UserInfo;
  42. import com.l2jserver.gameserver.util.Broadcast;
  43. import com.l2jserver.util.Rnd;
  44. import com.l2jserver.util.StringUtil;
  45. /**
  46. * This class handles following admin commands: - admin = shows menu
  47. * @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
  48. */
  49. public class AdminEventEngine implements IAdminCommandHandler
  50. {
  51. private static final String[] ADMIN_COMMANDS =
  52. {
  53. "admin_event",
  54. "admin_event_new",
  55. "admin_event_choose",
  56. "admin_event_store",
  57. "admin_event_set",
  58. "admin_event_change_teams_number",
  59. "admin_event_announce",
  60. "admin_event_panel",
  61. "admin_event_control_begin",
  62. "admin_event_control_teleport",
  63. "admin_add",
  64. "admin_event_see",
  65. "admin_event_del",
  66. "admin_delete_buffer",
  67. "admin_event_control_sit",
  68. "admin_event_name",
  69. "admin_event_control_kill",
  70. "admin_event_control_res",
  71. "admin_event_control_poly",
  72. "admin_event_control_unpoly",
  73. "admin_event_control_transform",
  74. "admin_event_control_untransform",
  75. "admin_event_control_prize",
  76. "admin_event_control_chatban",
  77. "admin_event_control_kick",
  78. "admin_event_control_finish"
  79. };
  80. private static String tempBuffer = "";
  81. private static String tempName = "";
  82. private static boolean npcsDeleted = false;
  83. @Override
  84. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  85. {
  86. StringTokenizer st = new StringTokenizer(command);
  87. String actualCommand = st.nextToken();
  88. try
  89. {
  90. if (actualCommand.equals("admin_event"))
  91. {
  92. if (L2Event.eventState != EventState.OFF)
  93. {
  94. showEventControl(activeChar);
  95. }
  96. else
  97. {
  98. showMainPage(activeChar);
  99. }
  100. }
  101. else if (actualCommand.equals("admin_event_new"))
  102. {
  103. showNewEventPage(activeChar);
  104. }
  105. else if (actualCommand.startsWith("admin_add"))
  106. {
  107. // There is an exception here for not using the ST. We use spaces (ST delim) for the event info.
  108. tempBuffer += command.substring(10);
  109. showNewEventPage(activeChar);
  110. }
  111. else if (actualCommand.startsWith("admin_event_see"))
  112. {
  113. // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
  114. String eventName = command.substring(16);
  115. try
  116. {
  117. final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  118. DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(Config.DATAPACK_ROOT + "/data/events/" + eventName)));
  119. BufferedReader inbr = new BufferedReader(new InputStreamReader(in));
  120. adminReply.setFile("en", "data/html/mods/EventEngine/Participation.htm");
  121. adminReply.replace("%eventName%", eventName);
  122. adminReply.replace("%eventCreator%", inbr.readLine());
  123. adminReply.replace("%eventInfo%", inbr.readLine());
  124. adminReply.replace("npc_%objectId%_event_participate", "admin_event"); // Weird, but nice hack, isnt it? :)
  125. adminReply.replace("button value=\"Participate\"", "button value=\"Back\"");
  126. activeChar.sendPacket(adminReply);
  127. inbr.close();
  128. }
  129. catch (Exception e)
  130. {
  131. e.printStackTrace();
  132. }
  133. }
  134. else if (actualCommand.startsWith("admin_event_del"))
  135. {
  136. // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
  137. String eventName = command.substring(16);
  138. File file = new File(Config.DATAPACK_ROOT + "/data/events/" + eventName);
  139. file.delete();
  140. showMainPage(activeChar);
  141. }
  142. else if (actualCommand.startsWith("admin_event_name"))
  143. {
  144. // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
  145. tempName += command.substring(17);
  146. showNewEventPage(activeChar);
  147. }
  148. else if (actualCommand.equalsIgnoreCase("admin_delete_buffer"))
  149. {
  150. tempBuffer = "";
  151. showNewEventPage(activeChar);
  152. }
  153. else if (actualCommand.startsWith("admin_event_store"))
  154. {
  155. try
  156. {
  157. FileOutputStream file = new FileOutputStream(new File(Config.DATAPACK_ROOT, "data/events/" + tempName));
  158. PrintStream p = new PrintStream(file);
  159. p.println(activeChar.getName());
  160. p.println(tempBuffer);
  161. file.close();
  162. p.close();
  163. }
  164. catch (Exception e)
  165. {
  166. e.printStackTrace();
  167. }
  168. tempBuffer = "";
  169. tempName = "";
  170. showMainPage(activeChar);
  171. }
  172. else if (actualCommand.startsWith("admin_event_set"))
  173. {
  174. // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
  175. L2Event._eventName = command.substring(16);
  176. showEventParameters(activeChar, 2);
  177. }
  178. else if (actualCommand.startsWith("admin_event_change_teams_number"))
  179. {
  180. showEventParameters(activeChar, Integer.parseInt(st.nextToken()));
  181. }
  182. else if (actualCommand.startsWith("admin_event_panel"))
  183. {
  184. showEventControl(activeChar);
  185. }
  186. else if (actualCommand.startsWith("admin_event_announce"))
  187. {
  188. L2Event._npcId = Integer.parseInt(st.nextToken());
  189. L2Event._teamsNumber = Integer.parseInt(st.nextToken());
  190. String temp = " ";
  191. String temp2 = "";
  192. while (st.hasMoreElements())
  193. {
  194. temp += st.nextToken() + " ";
  195. }
  196. st = new StringTokenizer(temp, "-");
  197. Integer i = 1;
  198. while (st.hasMoreElements())
  199. {
  200. temp2 = st.nextToken();
  201. if (!temp2.equals(" "))
  202. {
  203. L2Event._teamNames.put(i++, temp2.substring(1, temp2.length() - 1));
  204. }
  205. }
  206. activeChar.sendMessage(L2Event.startEventParticipation());
  207. Broadcast.toAllOnlinePlayers(activeChar.getName() + " has started an event. You will find a participation NPC somewhere around you.");
  208. PlaySound _snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
  209. activeChar.sendPacket(_snd);
  210. activeChar.broadcastPacket(_snd);
  211. final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  212. final String replyMSG = StringUtil.concat("<html><title>[ L2J EVENT ENGINE ]</title><body><br>", "<center>The event <font color=\"LEVEL\">", L2Event._eventName, "</font> has been announced, now you can type //event_panel to see the event panel control</center><br>", "</body></html>");
  213. adminReply.setHtml(replyMSG);
  214. activeChar.sendPacket(adminReply);
  215. }
  216. else if (actualCommand.startsWith("admin_event_control_begin"))
  217. {
  218. // Starts the event and sends a message of the result
  219. activeChar.sendMessage(L2Event.startEvent());
  220. showEventControl(activeChar);
  221. }
  222. else if (actualCommand.startsWith("admin_event_control_finish"))
  223. {
  224. // Finishes the event and sends a message of the result
  225. activeChar.sendMessage(L2Event.finishEvent());
  226. }
  227. else if (actualCommand.startsWith("admin_event_control_teleport"))
  228. {
  229. while (st.hasMoreElements()) // Every next ST should be a team number
  230. {
  231. int teamId = Integer.parseInt(st.nextToken());
  232. for (L2PcInstance player : L2Event._teams.get(teamId))
  233. {
  234. player.setTitle(L2Event._teamNames.get(teamId));
  235. player.teleToLocation(activeChar.getLocation(), true);
  236. player.setInstanceId(activeChar.getInstanceId());
  237. }
  238. }
  239. showEventControl(activeChar);
  240. }
  241. else if (actualCommand.startsWith("admin_event_control_sit"))
  242. {
  243. while (st.hasMoreElements()) // Every next ST should be a team number
  244. {
  245. // Integer.parseInt(st.nextToken()) == teamId
  246. for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
  247. {
  248. if (player.getEventStatus() == null)
  249. {
  250. continue;
  251. }
  252. player.getEventStatus().setSitForced(!player.getEventStatus().isSitForced());
  253. if (player.getEventStatus().isSitForced())
  254. {
  255. player.sitDown();
  256. }
  257. else
  258. {
  259. player.standUp();
  260. }
  261. }
  262. }
  263. showEventControl(activeChar);
  264. }
  265. else if (actualCommand.startsWith("admin_event_control_kill"))
  266. {
  267. while (st.hasMoreElements()) // Every next ST should be a team number
  268. {
  269. for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
  270. {
  271. player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, activeChar, null);
  272. }
  273. }
  274. showEventControl(activeChar);
  275. }
  276. else if (actualCommand.startsWith("admin_event_control_res"))
  277. {
  278. while (st.hasMoreElements()) // Every next ST should be a team number
  279. {
  280. for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
  281. {
  282. if ((player == null) || !player.isDead())
  283. {
  284. continue;
  285. }
  286. player.restoreExp(100.0);
  287. player.doRevive();
  288. player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  289. player.setCurrentCp(player.getMaxCp());
  290. }
  291. }
  292. showEventControl(activeChar);
  293. }
  294. else if (actualCommand.startsWith("admin_event_control_poly"))
  295. {
  296. int teamId = Integer.parseInt(st.nextToken());
  297. String[] polyIds = new String[st.countTokens()];
  298. int i = 0;
  299. while (st.hasMoreElements()) // Every next ST should be a polymorph ID
  300. {
  301. polyIds[i++] = st.nextToken();
  302. }
  303. for (L2PcInstance player : L2Event._teams.get(teamId))
  304. {
  305. player.getPoly().setPolyInfo("npc", polyIds[Rnd.get(polyIds.length)]);
  306. player.teleToLocation(player.getLocation(), true);
  307. CharInfo info1 = new CharInfo(player);
  308. player.broadcastPacket(info1);
  309. UserInfo info2 = new UserInfo(player);
  310. player.sendPacket(info2);
  311. player.broadcastPacket(new ExBrExtraUserInfo(player));
  312. }
  313. showEventControl(activeChar);
  314. }
  315. else if (actualCommand.startsWith("admin_event_control_unpoly"))
  316. {
  317. while (st.hasMoreElements()) // Every next ST should be a team number
  318. {
  319. for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
  320. {
  321. player.getPoly().setPolyInfo(null, "1");
  322. player.decayMe();
  323. player.spawnMe(player.getX(), player.getY(), player.getZ());
  324. CharInfo info1 = new CharInfo(player);
  325. player.broadcastPacket(info1);
  326. UserInfo info2 = new UserInfo(player);
  327. player.sendPacket(info2);
  328. player.broadcastPacket(new ExBrExtraUserInfo(player));
  329. }
  330. }
  331. showEventControl(activeChar);
  332. }
  333. else if (actualCommand.startsWith("admin_event_control_transform"))
  334. {
  335. int teamId = Integer.parseInt(st.nextToken());
  336. int[] transIds = new int[st.countTokens()];
  337. int i = 0;
  338. while (st.hasMoreElements()) // Every next ST should be a transform ID
  339. {
  340. transIds[i++] = Integer.parseInt(st.nextToken());
  341. }
  342. for (L2PcInstance player : L2Event._teams.get(teamId))
  343. {
  344. int transId = transIds[Rnd.get(transIds.length)];
  345. if (!TransformData.getInstance().transformPlayer(transId, player))
  346. {
  347. AdminData.getInstance().broadcastMessageToGMs("EventEngine: Unknow transformation id: " + transId);
  348. }
  349. }
  350. showEventControl(activeChar);
  351. }
  352. else if (actualCommand.startsWith("admin_event_control_untransform"))
  353. {
  354. while (st.hasMoreElements()) // Every next ST should be a team number
  355. {
  356. for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
  357. {
  358. player.stopTransformation(true);
  359. }
  360. }
  361. showEventControl(activeChar);
  362. }
  363. else if (actualCommand.startsWith("admin_event_control_kick"))
  364. {
  365. if (st.hasMoreElements()) // If has next token, it should be player name.
  366. {
  367. while (st.hasMoreElements())
  368. {
  369. L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
  370. if (player != null)
  371. {
  372. L2Event.removeAndResetPlayer(player);
  373. }
  374. }
  375. }
  376. else
  377. {
  378. if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
  379. {
  380. L2Event.removeAndResetPlayer((L2PcInstance) activeChar.getTarget());
  381. }
  382. }
  383. showEventControl(activeChar);
  384. }
  385. else if (actualCommand.startsWith("admin_event_control_prize"))
  386. {
  387. int[] teamIds = new int[st.countTokens() - 2];
  388. int i = 0;
  389. while ((st.countTokens() - 2) > 0) // The last 2 tokens are used for "n" and "item id"
  390. {
  391. teamIds[i++] = Integer.parseInt(st.nextToken());
  392. }
  393. String[] n = st.nextToken().split("\\*");
  394. int itemId = Integer.parseInt(st.nextToken());
  395. for (int teamId : teamIds)
  396. {
  397. rewardTeam(activeChar, teamId, Integer.parseInt(n[0]), itemId, n.length == 2 ? n[1] : "");
  398. }
  399. showEventControl(activeChar);
  400. }
  401. }
  402. catch (Exception e)
  403. {
  404. e.printStackTrace();
  405. AdminData.getInstance().broadcastMessageToGMs("EventEngine: Error! Possible blank boxes while executing a command which requires a value in the box?");
  406. }
  407. return true;
  408. }
  409. @Override
  410. public String[] getAdminCommandList()
  411. {
  412. return ADMIN_COMMANDS;
  413. }
  414. private String showStoredEvents()
  415. {
  416. final File dir = new File(Config.DATAPACK_ROOT, "/data/events");
  417. if (dir.isFile())
  418. {
  419. return "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' is a file or is corrupted!</font><br>";
  420. }
  421. String note = "";
  422. if (!dir.exists())
  423. {
  424. note = "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' does not exist!</font><br><font color=\"0099FF\">Trying to create it now...<br></font><br>";
  425. if (dir.mkdirs())
  426. {
  427. note += "<font color=\"006600\">The directory '" + dir.getAbsolutePath() + "' has been created!</font><br>";
  428. }
  429. else
  430. {
  431. note += "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' hasn't been created!</font><br>";
  432. return note;
  433. }
  434. }
  435. final String[] files = dir.list();
  436. final StringBuilder result = new StringBuilder(files.length * 500);
  437. result.append("<table>");
  438. for (String fileName : files)
  439. {
  440. StringUtil.append(result, "<tr><td align=center>", fileName, " </td></tr><tr><td><table cellspacing=0><tr><td><button value=\"Select Event\" action=\"bypass -h admin_event_set ", fileName, "\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"View Event\" action=\"bypass -h admin_event_see ", fileName, "\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Delete Event\" action=\"bypass -h admin_event_del ", fileName, "\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table></td></tr>", "<tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr>");
  441. }
  442. result.append("</table>");
  443. return note + result.toString();
  444. }
  445. public void showMainPage(L2PcInstance activeChar)
  446. {
  447. final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  448. final String replyMSG = StringUtil.concat("<html><title>[ L2J EVENT ENGINE ]</title><body>" + "<br><center><button value=\"Create NEW event \" action=\"bypass -h admin_event_new\" width=150 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "<center><br><font color=LEVEL>Stored Events:</font><br></center>", showStoredEvents(), "</body></html>");
  449. adminReply.setHtml(replyMSG);
  450. activeChar.sendPacket(adminReply);
  451. }
  452. public void showNewEventPage(L2PcInstance activeChar)
  453. {
  454. final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  455. final StringBuilder replyMSG = StringUtil.startAppend(500, "<html><title>[ L2J EVENT ENGINE ]</title><body><br><br><center><font color=LEVEL>Event name:</font><br>");
  456. if (tempName.isEmpty())
  457. {
  458. replyMSG.append("You can also use //event_name text to insert a new title");
  459. replyMSG.append("<center><multiedit var=\"name\" width=260 height=24> <button value=\"Set Event Name\" action=\"bypass -h admin_event_name $name\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  460. }
  461. else
  462. {
  463. replyMSG.append(tempName);
  464. }
  465. replyMSG.append("<br><br><font color=LEVEL>Event description:</font><br></center>");
  466. if (tempBuffer.isEmpty())
  467. {
  468. replyMSG.append("You can also use //add text to add text or //delete_buffer to remove the text.");
  469. }
  470. else
  471. {
  472. replyMSG.append(tempBuffer);
  473. }
  474. replyMSG.append("<center><multiedit var=\"txt\" width=270 height=100> <button value=\"Add text\" action=\"bypass -h admin_add $txt\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  475. replyMSG.append("<button value=\"Remove text\" action=\"bypass -h admin_delete_buffer\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  476. if (!(tempName.isEmpty() && tempBuffer.isEmpty()))
  477. {
  478. replyMSG.append("<br><button value=\"Store Event Data\" action=\"bypass -h admin_event_store\" width=160 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  479. }
  480. replyMSG.append("</center></body></html>");
  481. adminReply.setHtml(replyMSG.toString());
  482. activeChar.sendPacket(adminReply);
  483. }
  484. public void showEventParameters(L2PcInstance activeChar, int teamnumbers)
  485. {
  486. final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  487. StringBuilder sb = new StringBuilder();
  488. sb.append("<html><body><title>[ L2J EVENT ENGINE ]</title><br><center> Current event: <font color=\"LEVEL\">");
  489. sb.append(L2Event._eventName);
  490. sb.append("</font></center><br>INFO: To start an event, you must first set the number of teams, then type their names in the boxes and finally type the NPC ID that will be the event manager (can be any existing npc) next to the \"Announce Event!\" button.<br><table width=100%>");
  491. sb.append("<tr><td><button value=\"Announce Event!\" action=\"bypass -h admin_event_announce $event_npcid ");
  492. sb.append(teamnumbers);
  493. sb.append(" ");
  494. for (int i = 1; (i - 1) < teamnumbers; i++) // Event announce params
  495. {
  496. sb.append("$event_teams_name");
  497. sb.append(i);
  498. sb.append(" - ");
  499. }
  500. sb.append("\" width=140 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  501. sb.append("<td><edit var=\"event_npcid\" width=100 height=20></td></tr>");
  502. sb.append("<tr><td><button value=\"Set number of teams\" action=\"bypass -h admin_event_change_teams_number $event_teams_number\" width=140 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  503. sb.append("<td><edit var=\"event_teams_number\" width=100 height=20></td></tr>");
  504. sb.append("</table><br><center> <br><br>");
  505. sb.append("<font color=\"LEVEL\">Teams' names:</font><br><table width=100% cellspacing=8>");
  506. for (int i = 1; (i - 1) < teamnumbers; i++) // Team names params
  507. {
  508. sb.append("<tr><td align=center>Team #");
  509. sb.append(i);
  510. sb.append(" name:</td><td><edit var=\"event_teams_name");
  511. sb.append(i);
  512. sb.append("\" width=150 height=15></td></tr>");
  513. }
  514. sb.append("</table></body></html>");
  515. adminReply.setHtml(sb.toString());
  516. activeChar.sendPacket(adminReply);
  517. }
  518. private void showEventControl(L2PcInstance activeChar)
  519. {
  520. final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  521. StringBuilder sb = new StringBuilder();
  522. sb.append("<html><title>[ L2J EVENT ENGINE ]</title><body><br><center>Current event: <font color=\"LEVEL\">");
  523. sb.append(L2Event._eventName);
  524. sb.append("</font></center><br><table cellspacing=-1 width=280><tr><td align=center>Type the team ID(s) that will be affected by the commands. Commands with '*' work with only 1 team ID in the field, while '!' - none.</td></tr><tr><td align=center><edit var=\"team_number\" width=100 height=15></td></tr>");
  525. sb.append("<tr><td>&nbsp;</td></tr><tr><td><table width=200>");
  526. if (!npcsDeleted)
  527. {
  528. sb.append("<tr><td><button value=\"Start!\" action=\"bypass -h admin_event_control_begin\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Destroys all event npcs so no more people can't participate now on</font></td></tr>");
  529. }
  530. sb.append("<tr><td>&nbsp;</td></tr>" + "<tr><td><button value=\"Teleport\" action=\"bypass -h admin_event_control_teleport $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Teleports the specified team to your position</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><button value=\"Sit/Stand\" action=\"bypass -h admin_event_control_sit $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Sits/Stands up the team</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><button value=\"Kill\" action=\"bypass -h admin_event_control_kill $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Finish with the life of all the players in the selected team</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><button value=\"Resurrect\" action=\"bypass -h admin_event_control_res $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Resurrect Team's members</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><table cellspacing=-1><tr><td><button value=\"Polymorph*\" action=\"bypass -h admin_event_control_poly $team_number $poly_id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"poly_id\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Polymorphs the team into the NPC with the ID specified. Multiple IDs result in randomly chosen one for each player.</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><button value=\"UnPolymorph\" action=\"bypass -h admin_event_control_unpoly $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Unpolymorph the team</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><table cellspacing=-1><tr><td><button value=\"Transform*\" action=\"bypass -h admin_event_control_transform $team_number $transf_id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"transf_id\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Transforms the team into the transformation with the ID specified. Multiple IDs result in randomly chosen one for each player.</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><button value=\"UnTransform\" action=\"bypass -h admin_event_control_untransform $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Untransforms the team</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><table cellspacing=-1><tr><td><button value=\"Give Item\" action=\"bypass -h admin_event_control_prize $team_number $n $id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><table><tr><td width=32>Num</td><td><edit var=\"n\" width=60 height=15></td></tr><tr><td>ID</td><td><edit var=\"id\" width=60 height=15></td></tr></table></td><td><font color=\"LEVEL\">Give the specified item id to every single member of the team, you can put 5*level, 5*kills or 5 in the number field for example</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><table cellspacing=-1><tr><td><button value=\"Kick Player\" action=\"bypass -h admin_event_control_kick $player_name\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"player_name\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Kicks the specified player(s) from the event. Blank field kicks target.</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "<tr><td><button value=\"End!\" action=\"bypass -h admin_event_control_finish\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Will finish the event teleporting back all the players</font></td></tr>" + "<tr><td>&nbsp;</td></tr>" + "</table></td></tr></table></body></html>");
  531. adminReply.setHtml(sb.toString());
  532. activeChar.sendPacket(adminReply);
  533. }
  534. private void rewardTeam(L2PcInstance activeChar, int team, int n, int id, String type)
  535. {
  536. int num = n;
  537. for (L2PcInstance player : L2Event._teams.get(team))
  538. {
  539. if (type.equalsIgnoreCase("level"))
  540. {
  541. num = n * player.getLevel();
  542. }
  543. else if (type.equalsIgnoreCase("kills") && (player.getEventStatus() != null))
  544. {
  545. num = n * player.getEventStatus().getKills().size();
  546. }
  547. else
  548. {
  549. num = n;
  550. }
  551. player.addItem("Event", id, num, activeChar, true);
  552. final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  553. adminReply.setHtml("<html><body> CONGRATULATIONS! You should have been rewarded. </body></html>");
  554. player.sendPacket(adminReply);
  555. }
  556. }
  557. }