AdminGeoEditor.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package handlers.admincommandhandlers;
  16. import java.util.StringTokenizer;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.geoeditorcon.GeoEditorListener;
  19. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. /**
  22. * @author Luno, Dezmond
  23. */
  24. public class AdminGeoEditor implements IAdminCommandHandler
  25. {
  26. private static final String[] ADMIN_COMMANDS =
  27. {
  28. "admin_ge_status",
  29. "admin_ge_mode",
  30. "admin_ge_join",
  31. "admin_ge_leave"
  32. };
  33. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  34. {
  35. if (!Config.ACCEPT_GEOEDITOR_CONN)
  36. {
  37. activeChar.sendMessage("Server do not accepts geoeditor connections now.");
  38. return true;
  39. }
  40. if (command.startsWith("admin_ge_status"))
  41. {
  42. activeChar.sendMessage(GeoEditorListener.getInstance().getStatus());
  43. }
  44. else if (command.startsWith("admin_ge_mode"))
  45. {
  46. if (GeoEditorListener.getInstance().getThread() == null)
  47. {
  48. activeChar.sendMessage("Geoeditor not connected.");
  49. return true;
  50. }
  51. try
  52. {
  53. String val = command.substring("admin_ge_mode".length());
  54. StringTokenizer st = new StringTokenizer(val);
  55. if (st.countTokens() < 1)
  56. {
  57. activeChar.sendMessage("Usage: //ge_mode X");
  58. activeChar.sendMessage("Mode 0: Don't send coordinates to geoeditor.");
  59. activeChar.sendMessage("Mode 1: Send coordinates at ValidatePosition from clients.");
  60. activeChar.sendMessage("Mode 2: Send coordinates each second.");
  61. return true;
  62. }
  63. int m;
  64. m = Integer.parseInt(st.nextToken());
  65. GeoEditorListener.getInstance().getThread().setMode(m);
  66. activeChar.sendMessage("Geoeditor connection mode set to " + m + ".");
  67. }
  68. catch (Exception e)
  69. {
  70. activeChar.sendMessage("Usage: //ge_mode X");
  71. activeChar.sendMessage("Mode 0: Don't send coordinates to geoeditor.");
  72. activeChar.sendMessage("Mode 1: Send coordinates at ValidatePosition from clients.");
  73. activeChar.sendMessage("Mode 2: Send coordinates each second.");
  74. e.printStackTrace();
  75. }
  76. return true;
  77. }
  78. else if (command.equals("admin_ge_join"))
  79. {
  80. if (GeoEditorListener.getInstance().getThread() == null)
  81. {
  82. activeChar.sendMessage("Geoeditor not connected.");
  83. return true;
  84. }
  85. GeoEditorListener.getInstance().getThread().addGM(activeChar);
  86. activeChar.sendMessage("You added to list for geoeditor.");
  87. }
  88. else if (command.equals("admin_ge_leave"))
  89. {
  90. if (GeoEditorListener.getInstance().getThread() == null)
  91. {
  92. activeChar.sendMessage("Geoeditor not connected.");
  93. return true;
  94. }
  95. GeoEditorListener.getInstance().getThread().removeGM(activeChar);
  96. activeChar.sendMessage("You removed from list for geoeditor.");
  97. }
  98. return true;
  99. }
  100. public String[] getAdminCommandList()
  101. {
  102. return ADMIN_COMMANDS;
  103. }
  104. }