Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: Java  |  size: 12.65 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.gameserver.communitybbs;
  16.  
  17. import java.util.StringTokenizer;
  18.  
  19. import com.l2jserver.Config;
  20. import com.l2jserver.gameserver.communitybbs.Manager.BuffBBSManager;
  21. import com.l2jserver.gameserver.communitybbs.Manager.ClanBBSManager;
  22. import com.l2jserver.gameserver.communitybbs.Manager.ClassBBSManager;
  23. import com.l2jserver.gameserver.communitybbs.Manager.PostBBSManager;
  24. import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
  25. import com.l2jserver.gameserver.model.L2Clan;
  26. import com.l2jserver.gameserver.network.serverpackets.WareHouseDepositList;
  27. import com.l2jserver.gameserver.network.serverpackets.WareHouseWithdrawalList;
  28. import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
  29. import com.l2jserver.gameserver.communitybbs.Manager.TeleportBBSManager;
  30. import com.l2jserver.gameserver.communitybbs.Manager.TopBBSManager;
  31. import com.l2jserver.gameserver.communitybbs.Manager.TopicBBSManager;
  32. import com.l2jserver.gameserver.datatables.MultiSell;
  33. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  34. import com.l2jserver.gameserver.model.entity.TvTEvent;
  35. import com.l2jserver.gameserver.network.L2GameClient;
  36. import com.l2jserver.gameserver.network.SystemMessageId;
  37. import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
  38. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  39.  
  40. public class CommunityBoard
  41. {
  42.         private CommunityBoard()
  43.         {
  44.         }
  45.        
  46.         public static CommunityBoard getInstance()
  47.         {
  48.                 return SingletonHolder._instance;
  49.         }
  50.        
  51.         public void handleCommands(L2GameClient client, String command)
  52.         {
  53.                 L2PcInstance activeChar = client.getActiveChar();
  54.                 if (activeChar == null)
  55.                         return;
  56.                  if(activeChar.isDead() || activeChar.isAlikeDead() || activeChar.isCastingNow() || activeChar.isInCombat() || activeChar.isAttackingNow() || activeChar.isFlying() || activeChar.isInSiege() || activeChar.isCombatFlagEquipped())
  57.                 {
  58.                    
  59.                 }
  60.                 if(activeChar.isInJail())
  61.                 {
  62.                     activeChar.sendMessage("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u0432 \u0442\u044E\u0440\u043C\u0435.");
  63.                     return;
  64.                 }
  65.                 if(activeChar.isInDuel())
  66.                 {
  67.                     activeChar.sendMessage("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u0432\u043E \u0432\u0440\u0435\u043C\u044F \u0434\u0443\u0435\u043B\u0438.");
  68.                     return;
  69.                 }
  70.                 if(activeChar.isInOlympiadMode())
  71.                 {
  72.                     activeChar.sendMessage("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u0432\u043E \u0432\u0440\u0435\u043C\u044F \u041E\u043B\u0438\u043C\u043F\u0438\u0430\u0434\u044B.");
  73.                     return;
  74.                 }
  75.                 if(activeChar.getPvpFlag() != 0 || activeChar.getKarma() > 0)
  76.                 {
  77.                     activeChar.sendMessage("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C CommunityBoard \u0432 \u0442\u0430\u043A\u043E\u043C \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0438.");
  78.                     return;
  79.                 }
  80.                 if(TvTEvent.isStarted())
  81.                 {
  82.                     activeChar.sendMessage("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u0432\u043E \u0432\u0440\u0435\u043C\u044F TVT \u0435\u0432\u0435\u043D\u0442\u0430.");
  83.                     return;
  84.                 }
  85.                 if(activeChar.isInsideZone((byte)0))
  86.                 {
  87.                     activeChar.sendMessage("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u0432 \u0431\u043E\u0435\u0432\u043E\u0439 \u0437\u043E\u043D\u0435.");
  88.                     return;
  89.                 }
  90.                 if(activeChar.isInsideZone((byte)2))
  91.                 {
  92.                     activeChar.sendMessage("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u0432 \u0437\u043E\u043D\u0435 \u043E\u0441\u0430\u0434\u044B.");
  93.                     return;
  94.                 }
  95.                 switch (Config.COMMUNITY_TYPE)
  96.                 {
  97.                         default:
  98.                         case 0: //disabled
  99.                                 activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CB_OFFLINE));
  100.                                 break;
  101.                         case 1: // old
  102.                                 RegionBBSManager.getInstance().parsecmd(command, activeChar);
  103.                                 break;
  104.                         case 2: // new
  105.                                 if (command.startsWith("_bbsclan"))
  106.                                 {
  107.                                         ClanBBSManager.getInstance().parsecmd(command, activeChar);
  108.                                 }
  109.                                 else if (command.startsWith("_bbsmemo"))
  110.                                 {
  111.                                         TopicBBSManager.getInstance().parsecmd(command, activeChar);
  112.                                 }
  113.                                 else if (command.startsWith("_bbstopics"))
  114.                                 {
  115.                                         TopicBBSManager.getInstance().parsecmd(command, activeChar);
  116.                                 }
  117.                                 else if (command.startsWith("_bbsposts"))
  118.                                 {
  119.                                         PostBBSManager.getInstance().parsecmd(command, activeChar);
  120.                                 }
  121.                                 else if (command.startsWith("_bbsMyWD"))
  122.                                  {
  123.                                  if (Config.ALLOW_WAREHOUSE_CB)
  124.                                  {
  125.                                  activeChar.setActiveWarehouse(activeChar.getWarehouse());
  126.                                  activeChar.sendPacket(new WareHouseDepositList(activeChar, WareHouseDepositList.PRIVATE));
  127.                                  }
  128.                                  else
  129.                                  {
  130.                                  activeChar.sendPacket(new ExShowScreenMessage("Эта функция отключена администратором!", 3000));
  131.                                  }
  132.                                  }
  133.                                 else if (command.startsWith("_bbsMyWW"))
  134.                                  {
  135.                                  if (Config.ALLOW_WAREHOUSE_CB)
  136.                                  {
  137.                                  activeChar.setActiveWarehouse(activeChar.getWarehouse());
  138.                                  if (activeChar.getActiveWarehouse().getSize() == 0)
  139.                                  {
  140.                                  activeChar.sendPacket(new SystemMessage(SystemMessageId.NO_ITEM_DEPOSITED_IN_WH));
  141.                                  return;
  142.                                  }
  143.                                  else
  144.                                  activeChar.sendPacket(new WareHouseWithdrawalList(activeChar, WareHouseWithdrawalList.PRIVATE));
  145.                                  }
  146.                                  else
  147.                                  {
  148.                                  activeChar.sendPacket(new ExShowScreenMessage("Эта функция отключена администратором!", 3000));
  149.                                  }
  150.                                  }
  151.                                 else if (command.startsWith("_bbsClanWD"))
  152.                                  {
  153.                                  if (Config.ALLOW_WAREHOUSE_CB)
  154.                                  {
  155.                                  if (activeChar.getClan() != null)
  156.                                  {
  157.                                  if (activeChar.getClan().getLevel() == 0)
  158.                                  activeChar.sendPacket(new SystemMessage(SystemMessageId.ONLY_LEVEL_1_CLAN_OR_HIGHER_CAN_USE_WAREHOUSE));
  159.                                  else
  160.                                  {
  161.                                  activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse());
  162.                                  WareHouseDepositList dl = new WareHouseDepositList(activeChar, WareHouseDepositList.CLAN);
  163.                                  activeChar.sendPacket(dl);
  164.                                  }
  165.                                  }
  166.                                  else
  167.                                  activeChar.sendPacket(new ExShowScreenMessage("Вы не являетесь членом какого-либо клана!", 3000));
  168.                                  }
  169.                                  else
  170.                                  {
  171.                                  activeChar.sendPacket(new ExShowScreenMessage("Эта функция отключена администратором!", 3000));
  172.                                  }
  173.                                  }
  174.                                 else if (command.startsWith("_bbsClanWW"))
  175.                                  {
  176.                                  if (Config.ALLOW_WAREHOUSE_CB)
  177.                                  {
  178.                                  if (activeChar.getClan() != null)
  179.                                  {
  180.                                  if ((activeChar.getClanPrivileges() & L2Clan.CP_CL_VIEW_WAREHOUSE) != L2Clan.CP_CL_VIEW_WAREHOUSE)
  181.                                  {
  182.                                  activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_CLAN_WAREHOUSE));
  183.                                  return;
  184.                                  }
  185.                                  else
  186.                                  {
  187.                                  if (activeChar.getClan().getLevel() == 0)
  188.                                  activeChar.sendPacket(new SystemMessage(SystemMessageId.ONLY_LEVEL_1_CLAN_OR_HIGHER_CAN_USE_WAREHOUSE));
  189.                                  else
  190.                                  {
  191.                                  activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse());
  192.                                  activeChar.sendPacket(new WareHouseWithdrawalList(activeChar, WareHouseWithdrawalList.CLAN));
  193.                                  }
  194.                                  }
  195.                                  }
  196.                                  else
  197.                                  activeChar.sendPacket(new ExShowScreenMessage("Вы не являетесь членом какого-либо клана!", 3000));
  198.                                  }
  199.                                  else
  200.                                  {
  201.                                  activeChar.sendPacket(new ExShowScreenMessage("Эта функция отключена администратором!", 3000));
  202.                                  }
  203.                                  }
  204.                                 else if (command.startsWith("_bbstop"))
  205.                                 {
  206.                                         TopBBSManager.getInstance().parsecmd(command, activeChar);
  207.                                 }
  208.                                 else if (command.startsWith("_bbshome"))
  209.                                 {
  210.                                         TopBBSManager.getInstance().parsecmd(command, activeChar);
  211.                                 }
  212.                                 else if(command.startsWith("_bbsclass"))
  213.                     {
  214.                    ClassBBSManager.getInstance().parsecmd(command, activeChar);
  215.                         break;
  216.                     }
  217.                          else if (command.startsWith("_bbs_buff"))
  218.                         {
  219.                                 BuffBBSManager.getInstance().parsecmd(command, activeChar);
  220.                         }
  221.                          else if (command.startsWith("_bbsteleport;"))
  222.                         {
  223.                                  TeleportBBSManager.getInstance().parsecmd(command, activeChar);
  224.                         }
  225.                          else if (command.startsWith("_bbsmultisell;"))
  226.                         {
  227.                                  if(activeChar.isDead() || activeChar.isAlikeDead() || TvTEvent.isStarted() || activeChar.isInSiege() || activeChar.isCastingNow() || activeChar.isInCombat() || activeChar.isAttackingNow() || activeChar.isInOlympiadMode() || activeChar.isInJail() || activeChar.isFlying() || activeChar.getKarma() > 0 || activeChar.isInDuel()){
  228.                                  activeChar.sendMessage("В данных условиях использовать Шоп запрещено");
  229.                                  return;
  230.                         }
  231.                                 StringTokenizer st = new StringTokenizer(command, ";");
  232.                             st.nextToken();
  233.                             TopBBSManager.getInstance().parsecmd("_bbstop;" + st.nextToken(), activeChar);
  234.                                 int multisell = Integer.parseInt(st.nextToken());
  235.                                 MultiSell.getInstance().separateAndSend(multisell, activeChar, null, false);
  236.                                                                 }
  237.                                 else if (command.startsWith("_bbsloc"))
  238.                                 {
  239.                                         RegionBBSManager.getInstance().parsecmd(command, activeChar);
  240.                                 }
  241.                                 else
  242.                                 {
  243.                                         ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command
  244.                                                         + " is not implemented yet</center><br><br></body></html>", "101");
  245.                                         activeChar.sendPacket(sb);
  246.                                         activeChar.sendPacket(new ShowBoard(null, "102"));
  247.                                         activeChar.sendPacket(new ShowBoard(null, "103"));
  248.                                 }
  249.                                 break;
  250.                 }
  251.         }
  252.        
  253.         /**
  254.          * @param client
  255.          * @param url
  256.          * @param arg1
  257.          * @param arg2
  258.          * @param arg3
  259.          * @param arg4
  260.          * @param arg5
  261.          */
  262.         public void handleWriteCommands(L2GameClient client, String url, String arg1, String arg2, String arg3, String arg4, String arg5)
  263.         {
  264.                 L2PcInstance activeChar = client.getActiveChar();
  265.                 if (activeChar == null)
  266.                         return;
  267.                
  268.                 switch (Config.COMMUNITY_TYPE)
  269.                 {
  270.                         case 2:
  271.                                 if (url.equals("Topic"))
  272.                                 {
  273.                                         TopicBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  274.                                 }
  275.                                 else if (url.equals("Post"))
  276.                                 {
  277.                                         PostBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  278.                                 }
  279.                                 else if (url.equals("Region"))
  280.                                 {
  281.                                         RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  282.                                 }
  283.                                 else if (url.equals("Notice"))
  284.                                 {
  285.                                         ClanBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  286.                                 }
  287.                                 else
  288.                                 {
  289.                                         ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + url
  290.                                                         + " is not implemented yet</center><br><br></body></html>", "101");
  291.                                         activeChar.sendPacket(sb);
  292.                                         activeChar.sendPacket(new ShowBoard(null, "102"));
  293.                                         activeChar.sendPacket(new ShowBoard(null, "103"));
  294.                                 }
  295.                                 break;
  296.                         case 1:
  297.                                 RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  298.                                 break;
  299.                         default:
  300.                         case 0:
  301.                                 ShowBoard sb = new ShowBoard("<html><body><br><br><center>The Community board is currently disabled</center><br><br></body></html>", "101");
  302.                                 activeChar.sendPacket(sb);
  303.                                 activeChar.sendPacket(new ShowBoard(null, "102"));
  304.                                 activeChar.sendPacket(new ShowBoard(null, "103"));
  305.                                 break;
  306.                 }
  307.         }
  308.        
  309.         @SuppressWarnings("synthetic-access")
  310.         private static class SingletonHolder
  311.         {
  312.                 protected static final CommunityBoard _instance = new CommunityBoard();
  313.         }
  314. }