AdminTest.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * $Header: AdminTest.java, 25/07/2005 17:15:21 luisantonioa Exp $
  3. *
  4. * $Author: luisantonioa $
  5. * $Date: 25/07/2005 17:15:21 $
  6. * $Revision: 1 $
  7. * $Log: AdminTest.java,v $
  8. * Revision 1 25/07/2005 17:15:21 luisantonioa
  9. * Added copyright notice
  10. *
  11. *
  12. * This program is free software: you can redistribute it and/or modify it under
  13. * the terms of the GNU General Public License as published by the Free Software
  14. * Foundation, either version 3 of the License, or (at your option) any later
  15. * version.
  16. *
  17. * This program is distributed in the hope that it will be useful, but WITHOUT
  18. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  19. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  20. * details.
  21. *
  22. * You should have received a copy of the GNU General Public License along with
  23. * this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. package net.sf.l2j.gameserver.handler.admincommandhandlers;
  26. import java.util.NoSuchElementException;
  27. import java.util.StringTokenizer;
  28. import net.sf.l2j.Config;
  29. import net.sf.l2j.gameserver.ThreadPoolManager;
  30. import net.sf.l2j.gameserver.Universe;
  31. import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  32. import net.sf.l2j.gameserver.model.L2Character;
  33. import net.sf.l2j.gameserver.model.L2Object;
  34. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  35. import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  36. /**
  37. * This class ...
  38. *
  39. * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
  40. */
  41. public class AdminTest implements IAdminCommandHandler
  42. {
  43. private static final String[] ADMIN_COMMANDS =
  44. {
  45. "admin_test",
  46. "admin_stats",
  47. "admin_skill_test",
  48. "admin_st",
  49. "admin_mp",
  50. "admin_known"
  51. };
  52. /* (non-Javadoc)
  53. * @see net.sf.l2j.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, net.sf.l2j.gameserver.model.L2PcInstance)
  54. */
  55. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  56. {
  57. if (command.equals("admin_stats"))
  58. {
  59. for (String line : ThreadPoolManager.getInstance().getStats())
  60. {
  61. activeChar.sendMessage(line);
  62. }
  63. }
  64. else if (command.startsWith("admin_skill_test") || command.startsWith("admin_st"))
  65. {
  66. try
  67. {
  68. StringTokenizer st = new StringTokenizer(command);
  69. st.nextToken();
  70. int id = Integer.parseInt(st.nextToken());
  71. adminTestSkill(activeChar, id);
  72. }
  73. catch (NumberFormatException e)
  74. {
  75. activeChar.sendMessage("Command format is //skill_test <ID>");
  76. }
  77. catch (NoSuchElementException nsee)
  78. {
  79. activeChar.sendMessage("Command format is //skill_test <ID>");
  80. }
  81. }
  82. else if (command.startsWith("admin_test uni flush"))
  83. {
  84. Universe.getInstance().flush();
  85. activeChar.sendMessage("Universe Map Saved.");
  86. }
  87. else if (command.startsWith("admin_test uni"))
  88. {
  89. activeChar.sendMessage("Universe Map Size is: " + Universe.getInstance().size());
  90. }
  91. else if (command.equals("admin_mp on"))
  92. {
  93. //.startPacketMonitor();
  94. activeChar.sendMessage("command not working");
  95. }
  96. else if (command.equals("admin_mp off"))
  97. {
  98. //.stopPacketMonitor();
  99. activeChar.sendMessage("command not working");
  100. }
  101. else if (command.equals("admin_mp dump"))
  102. {
  103. //.dumpPacketHistory();
  104. activeChar.sendMessage("command not working");
  105. }
  106. else if (command.equals("admin_known on"))
  107. {
  108. Config.CHECK_KNOWN = true;
  109. }
  110. else if (command.equals("admin_known off"))
  111. {
  112. Config.CHECK_KNOWN = false;
  113. }
  114. return true;
  115. }
  116. /**
  117. * @param activeChar
  118. * @param id
  119. */
  120. private void adminTestSkill(L2PcInstance activeChar, int id)
  121. {
  122. L2Character player;
  123. L2Object target = activeChar.getTarget();
  124. if (!(target instanceof L2Character))
  125. player = activeChar;
  126. else
  127. player = (L2Character) target;
  128. player.broadcastPacket(new MagicSkillUse(activeChar, player, id, 1, 1, 1));
  129. }
  130. /* (non-Javadoc)
  131. * @see net.sf.l2j.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
  132. */
  133. public String[] getAdminCommandList()
  134. {
  135. return ADMIN_COMMANDS;
  136. }
  137. }