ServerStatus.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 com.l2jserver.loginserver.gameserverpackets;
  16. import java.util.logging.Logger;
  17. import com.l2jserver.loginserver.GameServerTable;
  18. import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
  19. import com.l2jserver.util.network.BaseRecievePacket;
  20. /**
  21. * @author -Wooden-
  22. *
  23. */
  24. public class ServerStatus extends BaseRecievePacket
  25. {
  26. protected static Logger _log = Logger.getLogger(ServerStatus.class.getName());
  27. public static final String [] STATUS_STRING = {"Auto", "Good", "Normal", "Full", "Down", "Gm Only"};
  28. public static final int SERVER_LIST_STATUS = 0x01;
  29. public static final int SERVER_LIST_CLOCK = 0x02;
  30. public static final int SERVER_LIST_SQUARE_BRACKET = 0x03;
  31. public static final int MAX_PLAYERS = 0x04;
  32. public static final int TEST_SERVER = 0x05;
  33. public static final int STATUS_AUTO = 0x00;
  34. public static final int STATUS_GOOD = 0x01;
  35. public static final int STATUS_NORMAL = 0x02;
  36. public static final int STATUS_FULL = 0x03;
  37. public static final int STATUS_DOWN = 0x04;
  38. public static final int STATUS_GM_ONLY = 0x05;
  39. public static final int ON = 0x01;
  40. public static final int OFF = 0x00;
  41. /**
  42. * @param decrypt
  43. */
  44. public ServerStatus(byte[] decrypt, int serverId)
  45. {
  46. super(decrypt);
  47. GameServerInfo gsi = GameServerTable.getInstance().getRegisteredGameServerById(serverId);
  48. if (gsi != null)
  49. {
  50. int size = readD();
  51. for (int i = 0; i < size; i++)
  52. {
  53. int type = readD();
  54. int value = readD();
  55. switch (type)
  56. {
  57. case SERVER_LIST_STATUS:
  58. gsi.setStatus(value);
  59. break;
  60. case SERVER_LIST_CLOCK:
  61. gsi.setShowingClock(value == ON);
  62. break;
  63. case SERVER_LIST_SQUARE_BRACKET:
  64. gsi.setShowingBrackets(value == ON);
  65. break;
  66. case TEST_SERVER:
  67. gsi.setTestServer(value == ON);
  68. break;
  69. case MAX_PLAYERS:
  70. gsi.setMaxPlayers(value);
  71. break;
  72. }
  73. }
  74. }
  75. }
  76. }