Advertisement
Guest User

AccessDenied (faction aCis)

a guest
Jan 17th, 2017
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.83 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java   (revision 5)
  6. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java   (working copy)
  7. @@ -74,6 +74,9 @@
  8.         if (!player.isInsideRadius(storePlayer, 150, true, false))
  9.             return;
  10.        
  11. +       if (player.getFactionId() != storePlayer.getFactionId())
  12. +           return;
  13. +      
  14.         if (storePlayer.getPrivateStoreType() != PrivateStoreType.BUY)
  15.             return;
  16.        
  17. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java
  18. ===================================================================
  19. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java    (revision 5)
  20. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java    (working copy)
  21. @@ -76,6 +76,9 @@
  22.         if (player.isCursedWeaponEquipped())
  23.             return;
  24.        
  25. +       if (player.getFactionId() != storePlayer.getFactionId())
  26. +           return;
  27. +      
  28.         if (!player.isInsideRadius(storePlayer, 150, true, false))
  29.             return;
  30.        
  31. Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
  32. ===================================================================
  33. --- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java  (revision 5)
  34. +++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java  (working copy)
  35. @@ -59,6 +59,9 @@
  36.             return;
  37.         }
  38.        
  39. +       if (target.getFactionId() != player.getFactionId())
  40. +           return;
  41. +      
  42.         // Alt game - Karma punishment
  43.         if (!Config.KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0 || target.getKarma() > 0))
  44.         {
  45. Index: java/net/sf/l2j/gameserver/model/L2World.java
  46. ===================================================================
  47. --- java/net/sf/l2j/gameserver/model/L2World.java   (revision 5)
  48. +++ java/net/sf/l2j/gameserver/model/L2World.java   (working copy)
  49. @@ -140,6 +140,34 @@
  50.         return _pets.get(ownerId);
  51.     }
  52.    
  53. +   public Collection<L2PcInstance> getFactionPlayers(int id)
  54. +   {
  55. +       Map<Integer, L2PcInstance> players = new ConcurrentHashMap<>();
  56. +      
  57. +       for (L2PcInstance player : _players.values())
  58. +       {
  59. +           if (player.getFactionId() == id)
  60. +               players.put(player.getObjectId(), player);
  61. +       }
  62. +      
  63. +       return players.values();
  64. +   }
  65. +  
  66. +   public int getFactionSize(int id)
  67. +   {
  68. +       int size = 0;
  69. +      
  70. +       for (L2PcInstance player : _players.values())
  71. +       {
  72. +           if (player.getFactionId() == id)
  73. +           {
  74. +               size++;
  75. +           }
  76. +       }  
  77. +      
  78. +       return size;
  79. +   }
  80. +  
  81.     /**
  82.      * Add a L2Object in the world.<BR>
  83.      * <BR>
  84. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
  85. ===================================================================
  86. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java  (revision 5)
  87. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java  (working copy)
  88. @@ -52,6 +52,9 @@
  89.             return;
  90.         }
  91.        
  92. +       if (target.getFactionId() != requestor.getFactionId())
  93. +           return;
  94. +      
  95.         if (BlockList.isBlocked(target, requestor))
  96.         {
  97.             requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_ADDED_YOU_TO_IGNORE_LIST).addPcName(target));
  98. Index: java/net/sf/l2j/gameserver/model/actor/L2Character.java
  99. ===================================================================
  100. --- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 5)
  101. +++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
  102. @@ -571,6 +571,52 @@
  103.             return;
  104.         }
  105.        
  106. +       if (this instanceof L2Playable && target instanceof L2Playable)
  107. +       {
  108. +           if (this instanceof L2PcInstance && target instanceof L2PcInstance)
  109. +           {
  110. +               if (this.getActingPlayer().getFactionId() == target.getActingPlayer().getFactionId())
  111. +               {
  112. +                   sendPacket(ActionFailed.STATIC_PACKET);
  113. +                   return;
  114. +               }
  115. +           }
  116. +          
  117. +           if (this instanceof L2Summon && target instanceof L2PcInstance)
  118. +           {
  119. +               L2Summon summon = (L2Summon) this;
  120. +              
  121. +               if (summon.getOwner().getFactionId() != target.getActingPlayer().getFactionId())
  122. +               {
  123. +                   sendPacket(ActionFailed.STATIC_PACKET);
  124. +                   return;
  125. +               }
  126. +           }
  127. +          
  128. +           if (this instanceof L2Summon  && target instanceof L2Summon)
  129. +           {
  130. +               L2Summon summon1 = (L2Summon) this;
  131. +               L2Summon summon2 = (L2Summon) target;
  132. +              
  133. +               if (summon1.getOwner().getFactionId() == summon2.getOwner().getFactionId())
  134. +               {
  135. +                   sendPacket(ActionFailed.STATIC_PACKET);
  136. +                   return;
  137. +               }
  138. +           }
  139. +          
  140. +           if (target instanceof L2Summon)
  141. +           {
  142. +               L2Summon summon = (L2Summon) target;
  143. +              
  144. +               if (summon.getOwner().getFactionId() == this.getActingPlayer().getFactionId())
  145. +               {
  146. +                   sendPacket(ActionFailed.STATIC_PACKET);
  147. +                   return;
  148. +               }
  149. +           }
  150. +       }
  151. +      
  152.         // Checking if target has moved to peace zone
  153.         if (isInsidePeaceZone(this, target))
  154.         {
  155. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java
  156. ===================================================================
  157. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java   (revision 5)
  158. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java   (working copy)
  159. @@ -52,6 +52,9 @@
  160.             return;
  161.         }
  162.        
  163. +       if (target.getFactionId() != activeChar.getFactionId())
  164. +           return;
  165. +      
  166.         if (!clan.checkAllyJoinCondition(activeChar, target))
  167.             return;
  168.        
  169. Index: java/net/sf/l2j/gameserver/model/L2Skill.java
  170. ===================================================================
  171. --- java/net/sf/l2j/gameserver/model/L2Skill.java   (revision 5)
  172. +++ java/net/sf/l2j/gameserver/model/L2Skill.java   (working copy)
  173. @@ -2061,6 +2061,9 @@
  174.             if (targetPlayer.inObserverMode())
  175.                 return false;
  176.            
  177. +           if (player.getFactionId() == targetPlayer.getFactionId() && skill.isOffensive())
  178. +               return false;
  179. +          
  180.             if (skill.isOffensive() && player.getSiegeState() > 0 && player.isInsideZone(ZoneId.SIEGE) && player.getSiegeState() == targetPlayer.getSiegeState())
  181.                 return false;
  182.            
  183. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  184. ===================================================================
  185. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (revision 5)
  186. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (working copy)
  187. @@ -18,6 +18,7 @@
  188.  import net.sf.l2j.gameserver.communitybbs.Manager.MailBBSManager;
  189.  import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
  190.  import net.sf.l2j.gameserver.datatables.AnnouncementTable;
  191. +import net.sf.l2j.gameserver.datatables.Faction;
  192.  import net.sf.l2j.gameserver.datatables.GmListTable;
  193.  import net.sf.l2j.gameserver.datatables.MapRegionTable;
  194.  import net.sf.l2j.gameserver.datatables.SkillTable.FrequentSkill;
  195. @@ -229,6 +230,8 @@
  196.        
  197.         sendPacket(new SkillCoolTime(activeChar));
  198.        
  199. +       Faction.getInstance().onPlayerEnter(activeChar);
  200. +      
  201.         // If player logs back in a stadium, port him in nearest town.
  202.         if (Olympiad.getInstance().playerInStadia(activeChar))
  203.             activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
  204. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java
  205. ===================================================================
  206. --- java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java  (revision 0)
  207. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java  (working copy)
  208. @@ -0,0 +1,85 @@
  209. +/*
  210. + * This program is free software: you can redistribute it and/or modify it under
  211. + * the terms of the GNU General Public License as published by the Free Software
  212. + * Foundation, either version 3 of the License, or (at your option) any later
  213. + * version.
  214. + *
  215. + * This program is distributed in the hope that it will be useful, but WITHOUT
  216. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  217. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  218. + * details.
  219. + *
  220. + * You should have received a copy of the GNU General Public License along with
  221. + * this program. If not, see <http://www.gnu.org/licenses/>.
  222. + */
  223. +package net.sf.l2j.gameserver.model.actor.instance;
  224. +
  225. +import net.sf.l2j.gameserver.ThreadPoolManager;
  226. +import net.sf.l2j.gameserver.datatables.Faction;
  227. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  228. +import net.sf.l2j.gameserver.util.Broadcast;
  229. +
  230. +/**
  231. + * @author AccessDenied
  232. + */
  233. +public class L2FactionInstance extends L2NpcInstance
  234. +{
  235. +  
  236. +   public L2FactionInstance(int objectId, NpcTemplate template)
  237. +   {
  238. +       super(objectId, template);
  239. +   }
  240. +  
  241. +   @Override
  242. +   public void onBypassFeedback(L2PcInstance player, String command)
  243. +   {
  244. +       int id = Integer.parseInt(command);
  245. +      
  246. +       for (Faction.FactionHolder faction : Faction.getInstance().factions.values())
  247. +       {
  248. +           if (faction.getFactionId() == id)
  249. +           {
  250. +               player.getAppearance().setNameColor(Integer.decode("0x" + faction.getFactionColor()));
  251. +               player.setTitle(faction.getFactionName());
  252. +               player.setFactionId(id);
  253. +               player.broadcastTitleInfo();
  254. +               player.broadcastUserInfo();
  255. +              
  256. +               player.sendMessage("You will get teleported to your base soon.");
  257. +               System.out.println("Player " + player.getName() + " choosed " + faction.getFactionName());
  258. +               Broadcast.announceToOnlinePlayers("Player " + player.getName() + " has joined " + faction.getFactionName() + ".");
  259. +              
  260. +               ThreadPoolManager.getInstance().scheduleGeneral(new TeleToBase(player), 5000);
  261. +           }
  262. +       }
  263. +      
  264. +   }
  265. +  
  266. +   private static class TeleToBase implements Runnable
  267. +   {
  268. +
  269. +       L2PcInstance _player = null;
  270. +      
  271. +       public TeleToBase(L2PcInstance player)
  272. +       {
  273. +           _player = player;
  274. +       }
  275. +      
  276. +       @Override
  277. +       public void run()
  278. +       {
  279. +           if (_player !=null)
  280. +           {
  281. +               Faction.getInstance().teleToBase(_player);
  282. +               _player.sendMessage("Have a nice gameplay!");
  283. +           }
  284. +       }
  285. +      
  286. +   }
  287. +  
  288. +   @Override
  289. +   public String getHtmlPath(int npcId, int val)
  290. +   {
  291. +       return "data/html/mods/faction.htm";
  292. +   }
  293. +}
  294. \ No newline at end of file
  295. Index: java/net/sf/l2j/gameserver/GameServer.java
  296. ===================================================================
  297. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 5)
  298. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  299. @@ -46,6 +46,7 @@
  300.  import net.sf.l2j.gameserver.datatables.CharTemplateTable;
  301.  import net.sf.l2j.gameserver.datatables.ClanTable;
  302.  import net.sf.l2j.gameserver.datatables.DoorTable;
  303. +import net.sf.l2j.gameserver.datatables.Faction;
  304.  import net.sf.l2j.gameserver.datatables.FishTable;
  305.  import net.sf.l2j.gameserver.datatables.GmListTable;
  306.  import net.sf.l2j.gameserver.datatables.HelperBuffTable;
  307. @@ -264,6 +265,9 @@
  308.         DayNightSpawnManager.getInstance();
  309.         DimensionalRiftManager.getInstance();
  310.        
  311. +       StringUtil.printSection("Faction");
  312. +       Faction.getInstance();
  313. +      
  314.         StringUtil.printSection("Olympiads & Heroes");
  315.         OlympiadGameManager.getInstance();
  316.         Olympiad.getInstance();
  317. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java
  318. ===================================================================
  319. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java  (revision 5)
  320. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java  (working copy)
  321. @@ -55,6 +55,9 @@
  322.             return;
  323.         }
  324.        
  325. +       if (activeChar.getFactionId() == targetChar.getFactionId())
  326. +           return;
  327. +      
  328.         if (!targetChar.canDuel())
  329.         {
  330.             activeChar.sendPacket(targetChar.getNoDuelReason());
  331. Index: java/net/sf/l2j/gameserver/datatables/Faction.java
  332. ===================================================================
  333. --- java/net/sf/l2j/gameserver/datatables/Faction.java  (revision 0)
  334. +++ java/net/sf/l2j/gameserver/datatables/Faction.java  (working copy)
  335. @@ -0,0 +1,167 @@
  336. +/*
  337. + * This program is free software: you can redistribute it and/or modify it under
  338. + * the terms of the GNU General Public License as published by the Free Software
  339. + * Foundation, either version 3 of the License, or (at your option) any later
  340. + * version.
  341. + *
  342. + * This program is distributed in the hope that it will be useful, but WITHOUT
  343. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  344. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  345. + * details.
  346. + *
  347. + * You should have received a copy of the GNU General Public License along with
  348. + * this program. If not, see <http://www.gnu.org/licenses/>.
  349. + */
  350. +package net.sf.l2j.gameserver.datatables;
  351. +
  352. +import java.sql.Connection;
  353. +import java.sql.PreparedStatement;
  354. +import java.sql.ResultSet;
  355. +import java.util.ArrayList;
  356. +import java.util.Map;
  357. +import java.util.concurrent.ConcurrentHashMap;
  358. +
  359. +import net.sf.l2j.L2DatabaseFactory;
  360. +import net.sf.l2j.commons.random.Rnd;
  361. +import net.sf.l2j.gameserver.model.Location;
  362. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  363. +
  364. +
  365. +/**
  366. + * @author AccessDenied
  367. + */
  368. +public class Faction
  369. +{
  370. +  
  371. +   public Map<Integer, FactionHolder> factions = new ConcurrentHashMap<>();
  372. +   public ArrayList<RewardHolder> rewards = new ArrayList<>();
  373. +  
  374. +   public Faction()
  375. +   {
  376. +       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  377. +       {
  378. +           PreparedStatement statement = con.prepareStatement("SELECT * FROM faction");
  379. +           ResultSet result = statement.executeQuery();
  380. +          
  381. +           while(result.next())
  382. +           {
  383. +               int id = result.getInt("factionId");
  384. +               String name = result.getString("factionName");
  385. +               String[] pos = result.getString("factionPos").split(";");
  386. +               Location loc = new Location(Integer.parseInt(pos[0]), Integer.parseInt(pos[1]), Integer.parseInt(pos[2]));
  387. +               String color = result.getString("factionColor");
  388. +              
  389. +               factions.put(id, new FactionHolder(id, name, loc, color));
  390. +           }
  391. +           result.close();
  392. +           statement.close();
  393. +       }
  394. +       catch (Exception e)
  395. +       {
  396. +           System.out.println("Failed to load factions from database: " + e);
  397. +           return;
  398. +       }
  399. +   }
  400. +  
  401. +   public void teleToBase(L2PcInstance player)
  402. +   {
  403. +       player.teleToLocation(factions.get(player.getFactionId()).getFactionLoc(), 0);
  404. +   }
  405. +  
  406. +   public Location getFactionLocation(L2PcInstance player)
  407. +   {
  408. +       return factions.get(player.getFactionId()).getFactionLoc();
  409. +   }
  410. +  
  411. +   public void onPlayerEnter(L2PcInstance player)
  412. +   {
  413. +       player.setTitle(factions.get(player.getFactionId()).getFactionName());
  414. +       player.getAppearance().setNameColor(Integer.decode("0x" + factions.get(player.getFactionId()).getFactionColor()));
  415. +       teleToBase(player);
  416. +   }
  417. +  
  418. +   public void onReward(L2PcInstance player)
  419. +   {
  420. +       if (rewards.isEmpty())
  421. +           return;
  422. +      
  423. +       for (RewardHolder holder : rewards)
  424. +           if (Rnd.get(100) <= holder.getChance())
  425. +               player.getInventory().addItem("reward", holder.getRewardId(), holder.getRewardCount(), player, player);
  426. +   }
  427. +  
  428. +   public class RewardHolder
  429. +   {
  430. +       private int _id;
  431. +       private int _count;
  432. +       private int _chance;
  433. +      
  434. +       public RewardHolder(int id, int count, int chance)
  435. +       {
  436. +           _id = id;
  437. +           _count = count;
  438. +           _chance = chance;
  439. +       }
  440. +      
  441. +       public int getChance()
  442. +       {
  443. +           return _chance;
  444. +       }
  445. +      
  446. +       public int getRewardId()
  447. +       {
  448. +           return _id;
  449. +       }
  450. +      
  451. +       public int getRewardCount()
  452. +       {
  453. +           return _count;
  454. +       }
  455. +   }
  456. +  
  457. +   public class FactionHolder
  458. +   {
  459. +       private int _id;
  460. +       private String _name;
  461. +       private Location _pos;
  462. +       private String _color;
  463. +      
  464. +       public FactionHolder(int id, String name, Location pos, String color)
  465. +       {
  466. +           _id = id;
  467. +           _name = name;
  468. +           _pos = pos;
  469. +           _color = color;
  470. +       }
  471. +      
  472. +       public String getFactionColor()
  473. +       {
  474. +           return _color;
  475. +       }
  476. +      
  477. +       public int getFactionId()
  478. +       {
  479. +           return _id;
  480. +       }
  481. +      
  482. +       public String getFactionName()
  483. +       {
  484. +           return _name;
  485. +       }
  486. +      
  487. +       public Location getFactionLoc()
  488. +       {
  489. +           return _pos;
  490. +       }
  491. +   }
  492. +  
  493. +   public static Faction getInstance()
  494. +   {
  495. +       return SingletonHolder._instance;
  496. +   }
  497. +  
  498. +   private static class SingletonHolder
  499. +   {
  500. +       protected static final Faction _instance = new Faction();
  501. +   }
  502. +}
  503. \ No newline at end of file
  504. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
  505. ===================================================================
  506. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java   (revision 5)
  507. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java   (working copy)
  508. @@ -15,6 +15,7 @@
  509.  package net.sf.l2j.gameserver.network.clientpackets;
  510.  
  511.  import net.sf.l2j.gameserver.ThreadPoolManager;
  512. +import net.sf.l2j.gameserver.datatables.Faction;
  513.  import net.sf.l2j.gameserver.datatables.MapRegionTable;
  514.  import net.sf.l2j.gameserver.instancemanager.CastleManager;
  515.  import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
  516. @@ -138,7 +139,7 @@
  517.                     break;
  518.                
  519.                 default:
  520. -                   loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Town);
  521. +                   loc = Faction.getInstance().getFactionLocation(activeChar);
  522.                     break;
  523.             }
  524.            
  525. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  526. ===================================================================
  527. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 5)
  528. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  529. @@ -52,6 +52,7 @@
  530.  import net.sf.l2j.gameserver.datatables.CharNameTable;
  531.  import net.sf.l2j.gameserver.datatables.CharTemplateTable;
  532.  import net.sf.l2j.gameserver.datatables.ClanTable;
  533. +import net.sf.l2j.gameserver.datatables.Faction;
  534.  import net.sf.l2j.gameserver.datatables.FishTable;
  535.  import net.sf.l2j.gameserver.datatables.GmListTable;
  536.  import net.sf.l2j.gameserver.datatables.HennaTable;
  537. @@ -313,8 +314,8 @@
  538.     private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
  539.    
  540.     private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,nobless,power_grade,last_recom_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  541. -   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
  542. -   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
  543. +   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?, factionId=? WHERE obj_id=?";
  544. +   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,factionId FROM characters WHERE obj_id=?";
  545.    
  546.     private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
  547.     private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
  548. @@ -4029,6 +4030,9 @@
  549.         {
  550.             L2PcInstance pk = killer.getActingPlayer();
  551.            
  552. +           pk.setPvpKills(pk.getPvpKills() + 1);
  553. +           Faction.getInstance().onReward(pk);
  554. +          
  555.             // Clear resurrect xp calculation
  556.             setExpBeforeDeath(0);
  557.            
  558. @@ -4242,7 +4246,12 @@
  559.         {
  560.             // PK Points are increased only if you kill a player.
  561.             if (target instanceof L2PcInstance)
  562. +           {
  563. +               if (target.getActingPlayer().getFactionId() != 0)
  564. +                   return;
  565. +              
  566.                 setPkKills(getPkKills() + 1);
  567. +           }
  568.            
  569.             // Calculate new karma.
  570.             setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target instanceof L2Summon));
  571. @@ -4257,6 +4266,9 @@
  572.         if (isInsideZone(ZoneId.PVP))
  573.             return;
  574.        
  575. +       if (getFactionId() != 0)
  576. +           return;
  577. +      
  578.         PvpFlagTaskManager.getInstance().add(this, Config.PVP_NORMAL_TIME);
  579.        
  580.         if (getPvpFlag() == 0)
  581. @@ -4272,6 +4284,9 @@
  582.         if (isInDuel() && player.getDuelId() == getDuelId())
  583.             return;
  584.        
  585. +       if (getFactionId() != 0)
  586. +           return;
  587. +      
  588.         if ((!isInsideZone(ZoneId.PVP) || !target.isInsideZone(ZoneId.PVP)) && player.getKarma() == 0)
  589.         {
  590.             PvpFlagTaskManager.getInstance().add(this, checkIfPvP(player) ? Config.PVP_PVP_TIME : Config.PVP_NORMAL_TIME);
  591. @@ -5479,6 +5494,8 @@
  592.                 player.setName(rset.getString("char_name"));
  593.                 player._lastAccess = rset.getLong("lastAccess");
  594.                
  595. +               player.setFactionId(rset.getInt("factionId"));
  596. +              
  597.                 player.getStat().setExp(rset.getLong("exp"));
  598.                 player.setExpBeforeDeath(rset.getLong("expBeforeDeath"));
  599.                 player.getStat().setLevel(rset.getByte("level"));
  600. @@ -5922,7 +5939,8 @@
  601.             statement.setLong(47, getClanCreateExpiryTime());
  602.             statement.setString(48, getName());
  603.             statement.setLong(49, getDeathPenaltyBuffLevel());
  604. -           statement.setInt(50, getObjectId());
  605. +           statement.setInt(50, getFactionId());
  606. +           statement.setInt(51, getObjectId());
  607.            
  608.             statement.execute();
  609.             statement.close();
  610. @@ -10705,4 +10723,16 @@
  611.                 break;
  612.         }
  613.     }
  614. +  
  615. +   private int _factionId;
  616. +  
  617. +   public void setFactionId(int id)
  618. +   {
  619. +       _factionId = id;
  620. +   }
  621. +  
  622. +   public int getFactionId()
  623. +   {
  624. +       return _factionId;
  625. +   }
  626.  }
  627. \ No newline at end of file
  628. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java
  629. ===================================================================
  630. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java   (revision 5)
  631. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java   (working copy)
  632. @@ -55,6 +55,9 @@
  633.             return;
  634.         }
  635.        
  636. +       if (friend.getFactionId() != activeChar.getFactionId())
  637. +           return;
  638. +      
  639.         if (BlockList.isBlocked(activeChar, friend))
  640.         {
  641.             activeChar.sendMessage("You have blocked " + _name + ".");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement