RegionBoard.java 3.4 KB

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