RegionBoard.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2004-2015 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.communityboard;
  20. import java.util.List;
  21. import com.l2jserver.gameserver.cache.HtmCache;
  22. import com.l2jserver.gameserver.data.sql.impl.ClanTable;
  23. import com.l2jserver.gameserver.handler.CommunityBoardHandler;
  24. import com.l2jserver.gameserver.handler.IWriteBoardHandler;
  25. import com.l2jserver.gameserver.instancemanager.CastleManager;
  26. import com.l2jserver.gameserver.model.L2Clan;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.entity.Castle;
  29. import com.l2jserver.gameserver.util.Util;
  30. /**
  31. * Region board.
  32. * @author Zoey76
  33. */
  34. public class RegionBoard implements IWriteBoardHandler
  35. {
  36. // Region data
  37. // @formatter:off
  38. private static final int[] REGIONS = { 1049, 1052, 1053, 1057, 1060, 1059, 1248, 1247, 1056 };
  39. // @formatter:on
  40. private static final String[] COMMANDS =
  41. {
  42. "_bbsloc"
  43. };
  44. @Override
  45. public String[] getCommunityBoardCommands()
  46. {
  47. return COMMANDS;
  48. }
  49. @Override
  50. public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
  51. {
  52. if (command.equals("_bbsloc"))
  53. {
  54. CommunityBoardHandler.getInstance().addBypass(activeChar, "Region", command);
  55. final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/region_list.html");
  56. final StringBuilder sb = new StringBuilder();
  57. final List<Castle> castles = CastleManager.getInstance().getCastles();
  58. for (int i = 0; i < REGIONS.length; i++)
  59. {
  60. final Castle castle = castles.get(i);
  61. final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
  62. String link = list.replaceAll("%region_id%", String.valueOf(i));
  63. link = link.replace("%region_name%", String.valueOf(REGIONS[i]));
  64. link = link.replace("%region_owning_clan%", (clan != null ? clan.getName() : "NPC"));
  65. link = link.replace("%region_owning_clan_alliance%", ((clan != null) && (clan.getAllyName() != null) ? clan.getAllyName() : ""));
  66. link = link.replace("%region_tax_rate%", String.valueOf(castle.getTaxRate() * 100) + "%");
  67. sb.append(link);
  68. }
  69. String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/region.html");
  70. html = html.replace("%region_list%", sb.toString());
  71. CommunityBoardHandler.separateAndSend(html, activeChar);
  72. }
  73. else if (command.startsWith("_bbsloc;"))
  74. {
  75. CommunityBoardHandler.getInstance().addBypass(activeChar, "Region>", command);
  76. final String id = command.replace("_bbsloc;", "");
  77. if (!Util.isDigit(id))
  78. {
  79. LOG.warning(RegionBoard.class.getSimpleName() + ": Player " + activeChar + " sent and invalid region bypass " + command + "!");
  80. return false;
  81. }
  82. // TODO: Implement.
  83. }
  84. return true;
  85. }
  86. @Override
  87. public boolean writeCommunityBoardCommand(L2PcInstance activeChar, String arg1, String arg2, String arg3, String arg4, String arg5)
  88. {
  89. // TODO: Implement.
  90. return false;
  91. }
  92. }