AdminGeoEditor.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (C) 2004-2014 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.util.StringTokenizer;
  21. import com.l2jserver.Config;
  22. import com.l2jserver.gameserver.geoeditorcon.GeoEditorListener;
  23. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. /**
  26. * @author Luno, Dezmond
  27. */
  28. public class AdminGeoEditor implements IAdminCommandHandler
  29. {
  30. private static final String[] ADMIN_COMMANDS =
  31. {
  32. "admin_ge_status",
  33. "admin_ge_mode",
  34. "admin_ge_join",
  35. "admin_ge_leave"
  36. };
  37. @Override
  38. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  39. {
  40. if (!Config.ACCEPT_GEOEDITOR_CONN)
  41. {
  42. activeChar.sendMessage("Server do not accepts geoeditor connections now.");
  43. return true;
  44. }
  45. if (command.startsWith("admin_ge_status"))
  46. {
  47. activeChar.sendMessage(GeoEditorListener.getInstance().getStatus());
  48. }
  49. else if (command.startsWith("admin_ge_mode"))
  50. {
  51. if (GeoEditorListener.getInstance().getThread() == null)
  52. {
  53. activeChar.sendMessage("Geoeditor not connected.");
  54. return true;
  55. }
  56. try
  57. {
  58. String val = command.substring("admin_ge_mode".length());
  59. StringTokenizer st = new StringTokenizer(val);
  60. if (st.countTokens() < 1)
  61. {
  62. activeChar.sendMessage("Usage: //ge_mode X");
  63. activeChar.sendMessage("Mode 0: Don't send coordinates to geoeditor.");
  64. activeChar.sendMessage("Mode 1: Send coordinates at ValidatePosition from clients.");
  65. activeChar.sendMessage("Mode 2: Send coordinates each second.");
  66. return true;
  67. }
  68. int m;
  69. m = Integer.parseInt(st.nextToken());
  70. GeoEditorListener.getInstance().getThread().setMode(m);
  71. activeChar.sendMessage("Geoeditor connection mode set to " + m + ".");
  72. }
  73. catch (Exception e)
  74. {
  75. activeChar.sendMessage("Usage: //ge_mode X");
  76. activeChar.sendMessage("Mode 0: Don't send coordinates to geoeditor.");
  77. activeChar.sendMessage("Mode 1: Send coordinates at ValidatePosition from clients.");
  78. activeChar.sendMessage("Mode 2: Send coordinates each second.");
  79. e.printStackTrace();
  80. }
  81. return true;
  82. }
  83. else if (command.equals("admin_ge_join"))
  84. {
  85. if (GeoEditorListener.getInstance().getThread() == null)
  86. {
  87. activeChar.sendMessage("Geoeditor not connected.");
  88. return true;
  89. }
  90. GeoEditorListener.getInstance().getThread().addGM(activeChar);
  91. activeChar.sendMessage("You added to list for geoeditor.");
  92. }
  93. else if (command.equals("admin_ge_leave"))
  94. {
  95. if (GeoEditorListener.getInstance().getThread() == null)
  96. {
  97. activeChar.sendMessage("Geoeditor not connected.");
  98. return true;
  99. }
  100. GeoEditorListener.getInstance().getThread().removeGM(activeChar);
  101. activeChar.sendMessage("You removed from list for geoeditor.");
  102. }
  103. return true;
  104. }
  105. @Override
  106. public String[] getAdminCommandList()
  107. {
  108. return ADMIN_COMMANDS;
  109. }
  110. }