2
0

AdminTest.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.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", "admin_stats", "admin_skill_test",
  46. "admin_st", "admin_mp", "admin_known"
  47. };
  48. /* (non-Javadoc)
  49. * @see net.sf.l2j.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, net.sf.l2j.gameserver.model.L2PcInstance)
  50. */
  51. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  52. {
  53. if (command.equals("admin_stats"))
  54. {
  55. for (String line : ThreadPoolManager.getInstance().getStats())
  56. {
  57. activeChar.sendMessage(line);
  58. }
  59. }
  60. else if (command.startsWith("admin_skill_test") || command.startsWith("admin_st"))
  61. {
  62. try
  63. {
  64. StringTokenizer st = new StringTokenizer(command);
  65. st.nextToken();
  66. int id = Integer.parseInt(st.nextToken());
  67. adminTestSkill(activeChar,id);
  68. }
  69. catch(NumberFormatException e)
  70. {
  71. activeChar.sendMessage("Command format is //skill_test <ID>");
  72. }
  73. catch(NoSuchElementException nsee)
  74. {
  75. activeChar.sendMessage("Command format is //skill_test <ID>");
  76. }
  77. }
  78. else if (command.startsWith("admin_test uni flush"))
  79. {
  80. Universe.getInstance().flush();
  81. activeChar.sendMessage("Universe Map Saved.");
  82. }
  83. else if (command.startsWith("admin_test uni"))
  84. {
  85. activeChar.sendMessage("Universe Map Size is: "+Universe.getInstance().size());
  86. }
  87. else if (command.equals("admin_mp on"))
  88. {
  89. //.startPacketMonitor();
  90. activeChar.sendMessage("command not working");
  91. }
  92. else if (command.equals("admin_mp off"))
  93. {
  94. //.stopPacketMonitor();
  95. activeChar.sendMessage("command not working");
  96. }
  97. else if (command.equals("admin_mp dump"))
  98. {
  99. //.dumpPacketHistory();
  100. activeChar.sendMessage("command not working");
  101. }
  102. else if (command.equals("admin_known on"))
  103. {
  104. Config.CHECK_KNOWN = true;
  105. }
  106. else if (command.equals("admin_known off"))
  107. {
  108. Config.CHECK_KNOWN = false;
  109. }
  110. return true;
  111. }
  112. /**
  113. * @param activeChar
  114. * @param id
  115. */
  116. private void adminTestSkill(L2PcInstance activeChar, int id)
  117. {
  118. L2Character player;
  119. L2Object target = activeChar.getTarget();
  120. if(!(target instanceof L2Character))
  121. player = activeChar;
  122. else
  123. player = (L2Character)target;
  124. player.broadcastPacket(new MagicSkillUse(activeChar, player, id, 1, 1, 1));
  125. }
  126. /* (non-Javadoc)
  127. * @see net.sf.l2j.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
  128. */
  129. public String[] getAdminCommandList()
  130. {
  131. return ADMIN_COMMANDS;
  132. }
  133. }