Advertisement
Guest User

NPC Clan Manager aCis 362

a guest
Aug 31st, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.07 KB | None | 0 0
  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 net.sf.l2j.gameserver.model.actor.instance;
  16.  
  17. import net.sf.l2j.gameserver.datatables.SkillTable;
  18. import net.sf.l2j.gameserver.model.L2Skill;
  19. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  20. import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  21. import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  22.  
  23. /**
  24.  * @author Devlin
  25.  * @Modificacoes Tayran.JavaDev
  26.  */
  27. public class L2ClanManagerInstance extends L2NpcInstance
  28. {
  29.     public L2ClanManagerInstance(int objectId, NpcTemplate template)
  30.     {
  31.         super(objectId, template);
  32.     }
  33.    
  34.     @Override
  35.     public void showChatWindow(L2PcInstance player, int val)
  36.     {
  37.         player.sendPacket(ActionFailed.STATIC_PACKET);
  38.         String filename = "data/html/mods/clanManager.htm";
  39.         NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  40.         html.setFile(filename);
  41.         html.replace("%objectId%", String.valueOf(getObjectId()));
  42.         player.sendPacket(html);
  43.     }
  44.    
  45.     public int itemId = 57;
  46.     public int itemCountLevelUp = 10000;
  47.     public int itemCountReputationPoints = 100000;
  48.     public int itemCountClanSkills = 100000000;
  49.     public int clanLevel = 1;
  50.     public int clanReputationScore = 1000;
  51.    
  52.     public int[] clanSkills =
  53.     {
  54.         370,
  55.         371,
  56.         372,
  57.         373,
  58.         374,
  59.         375,
  60.         376,
  61.         377,
  62.         378,
  63.         379,
  64.         380,
  65.         381,
  66.         382,
  67.         383,
  68.         384,
  69.         385,
  70.         386,
  71.         387,
  72.         388,
  73.         389,
  74.         390,
  75.         391
  76.     };
  77.    
  78.     @Override
  79.     public void onBypassFeedback(L2PcInstance player, String command)
  80.     {
  81.         if (command.equals("clanLevelUp"))
  82.         {
  83.             if (clanConditions(player))
  84.             {
  85.                 player.getClan().changeLevel(player.getClan().getLevel() + clanLevel);
  86.                 player.getClan().broadcastClanStatus();
  87.                 player.getInventory().destroyItemByItemId("Init.", itemId, itemCountLevelUp, player, player);
  88.                 player.sendMessage("Your clan's level has been changed to " + player.getClan().getLevel());
  89.             }
  90.             else
  91.             {
  92.                 return;
  93.             }
  94.         }
  95.         else if (command.equals("clanReputationPoints"))
  96.         {
  97.             if (clanConditions(player))
  98.             {
  99.                 player.getClan().addReputationScore(clanReputationScore);
  100.                 player.getClan().broadcastClanStatus();
  101.                 player.getInventory().destroyItemByItemId("Init.", itemId, itemCountReputationPoints, player, player);
  102.                 player.sendMessage("Your clan's reputation score has been changed to " + player.getClan().getReputationScore());
  103.             }
  104.             else
  105.             {
  106.                 return;
  107.             }
  108.         }
  109.         else if (command.equals("clanSkills"))
  110.         {
  111.             if (clanConditions(player))
  112.             {
  113.                 for (int s : clanSkills)
  114.                 {
  115.                     L2Skill clanSkill = SkillTable.getInstance().getInfo(s, SkillTable.getInstance().getMaxLevel(s));
  116.                     player.getClan().addNewSkill(clanSkill);
  117.                     player.getClan().broadcastClanStatus();
  118.                     player.getInventory().destroyItemByItemId("Init.", itemId, itemCountClanSkills, player, player);
  119.                     player.sendMessage("Your clan has learned all clan skills.");
  120.                 }
  121.             }
  122.             else
  123.             {
  124.                 return;
  125.             }
  126.         }
  127.     }
  128.    
  129.     /**
  130.      * @param player
  131.      * @return true if clan ok
  132.      */
  133.     private boolean clanConditions(L2PcInstance player)
  134.     {
  135.         if (player.getClan() != null)
  136.         {
  137.             player.sendMessage("You don't have a clan.");
  138.             return false;
  139.         }
  140.         else if (!player.isClanLeader())
  141.         {
  142.             player.sendMessage("You aren't the leader of your clan.");
  143.             return false;
  144.         }
  145.         else if (player.getInventory().getItemByItemId(itemId).getCount() > itemCountLevelUp)
  146.         {
  147.             player.sendMessage("You don't have enough items.");
  148.             return false;
  149.         }
  150.        
  151.         return true;
  152.     }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement