Advertisement
Guest User

AccessDenied (faction aCis)

a guest
Jan 17th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 22.98 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().LoadFaction();
  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,149 @@
  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.Map;
  356. +import java.util.concurrent.ConcurrentHashMap;
  357. +
  358. +import net.sf.l2j.L2DatabaseFactory;
  359. +import net.sf.l2j.gameserver.model.Location;
  360. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  361. +
  362. +
  363. +/**
  364. + * @author AccessDenied
  365. + */
  366. +public class Faction
  367. +{
  368. +  
  369. +   public Map<Integer, FactionHolder> factions = new ConcurrentHashMap<>();
  370. +  
  371. +   public void LoadFaction()
  372. +   {
  373. +       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  374. +       {
  375. +           PreparedStatement statement = con.prepareStatement("SELECT * FROM faction");
  376. +           ResultSet result = statement.executeQuery();
  377. +          
  378. +           while(result.next())
  379. +           {
  380. +               int id = result.getInt("factionId");
  381. +               String name = result.getString("factionName");
  382. +               String[] pos = result.getString("factionPos").split(";");
  383. +               Location loc = new Location(Integer.parseInt(pos[0]), Integer.parseInt(pos[1]), Integer.parseInt(pos[2]));
  384. +               String color = result.getString("factionColor");
  385. +              
  386. +               factions.put(id, new FactionHolder(id, name, loc, color));
  387. +           }
  388. +           result.close();
  389. +           statement.close();
  390. +       }
  391. +       catch (Exception e)
  392. +       {
  393. +           System.out.println("Failed to load factions from database " + e);
  394. +           return;
  395. +       }
  396. +   }
  397. +  
  398. +   public void teleToBase(L2PcInstance player)
  399. +   {
  400. +       for (FactionHolder faction : factions.values())
  401. +       {
  402. +           if (faction.getFactionId() == player.getFactionId())
  403. +           {
  404. +               Location loc = faction.getFactionLoc();
  405. +               player.teleToLocation(loc, 0);
  406. +           }
  407. +       }
  408. +   }
  409. +  
  410. +   public Location getFactionLocation(L2PcInstance player)
  411. +   {
  412. +       Location loc = null;
  413. +      
  414. +       for (FactionHolder faction : factions.values())
  415. +           if (faction.getFactionId() == player.getFactionId())
  416. +               loc = faction.getFactionLoc();
  417. +      
  418. +       return loc;
  419. +   }
  420. +  
  421. +   public void onPlayerEnter(L2PcInstance player)
  422. +   {
  423. +       for (FactionHolder faction : factions.values())
  424. +       {
  425. +           if (faction.getFactionId() == player.getFactionId())
  426. +           {
  427. +               player.setTitle(faction.getFactionName());
  428. +               player.getAppearance().setNameColor(Integer.decode("0x" + faction.getFactionColor()));
  429. +               teleToBase(player);
  430. +           }
  431. +       }
  432. +   }
  433. +  
  434. +   public void onReward(L2PcInstance player)
  435. +   {
  436. +       //TODO
  437. +   }
  438. +  
  439. +   public class FactionHolder
  440. +   {
  441. +       private int _id;
  442. +       private String _name;
  443. +       private Location _pos;
  444. +       private String _color;
  445. +      
  446. +       public FactionHolder(int id, String name, Location pos, String color)
  447. +       {
  448. +           _id = id;
  449. +           _name = name;
  450. +           _pos = pos;
  451. +           _color = color;
  452. +       }
  453. +      
  454. +       public String getFactionColor()
  455. +       {
  456. +           return _color;
  457. +       }
  458. +      
  459. +       public int getFactionId()
  460. +       {
  461. +           return _id;
  462. +       }
  463. +      
  464. +       public String getFactionName()
  465. +       {
  466. +           return _name;
  467. +       }
  468. +      
  469. +       public Location getFactionLoc()
  470. +       {
  471. +           return _pos;
  472. +       }
  473. +   }
  474. +  
  475. +   public static Faction getInstance()
  476. +   {
  477. +       return SingletonHolder._instance;
  478. +   }
  479. +  
  480. +   private static class SingletonHolder
  481. +   {
  482. +       protected static final Faction _instance = new Faction();
  483. +   }
  484. +}
  485. \ No newline at end of file
  486. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
  487. ===================================================================
  488. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java   (revision 5)
  489. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java   (working copy)
  490. @@ -15,6 +15,7 @@
  491.  package net.sf.l2j.gameserver.network.clientpackets;
  492.  
  493.  import net.sf.l2j.gameserver.ThreadPoolManager;
  494. +import net.sf.l2j.gameserver.datatables.Faction;
  495.  import net.sf.l2j.gameserver.datatables.MapRegionTable;
  496.  import net.sf.l2j.gameserver.instancemanager.CastleManager;
  497.  import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
  498. @@ -138,7 +139,7 @@
  499.                     break;
  500.                
  501.                 default:
  502. -                   loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Town);
  503. +                   loc = Faction.getInstance().getFactionLocation(activeChar);
  504.                     break;
  505.             }
  506.            
  507. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  508. ===================================================================
  509. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 5)
  510. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  511. @@ -313,8 +313,8 @@
  512.     private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
  513.    
  514.     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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  515. -   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=?";
  516. -   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=?";
  517. +   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=?";
  518. +   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=?";
  519.    
  520.     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";
  521.     private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
  522. @@ -4029,6 +4029,8 @@
  523.         {
  524.             L2PcInstance pk = killer.getActingPlayer();
  525.            
  526. +           pk.setPvpKills(pk.getPvpKills() + 1);
  527. +          
  528.             // Clear resurrect xp calculation
  529.             setExpBeforeDeath(0);
  530.            
  531. @@ -4242,7 +4244,12 @@
  532.         {
  533.             // PK Points are increased only if you kill a player.
  534.             if (target instanceof L2PcInstance)
  535. +           {
  536. +               if (target.getActingPlayer().getFactionId() != 0)
  537. +                   return;
  538. +              
  539.                 setPkKills(getPkKills() + 1);
  540. +           }
  541.            
  542.             // Calculate new karma.
  543.             setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target instanceof L2Summon));
  544. @@ -4257,6 +4264,9 @@
  545.         if (isInsideZone(ZoneId.PVP))
  546.             return;
  547.        
  548. +       if (getFactionId() != 0)
  549. +           return;
  550. +      
  551.         PvpFlagTaskManager.getInstance().add(this, Config.PVP_NORMAL_TIME);
  552.        
  553.         if (getPvpFlag() == 0)
  554. @@ -4272,6 +4282,9 @@
  555.         if (isInDuel() && player.getDuelId() == getDuelId())
  556.             return;
  557.        
  558. +       if (getFactionId() != 0)
  559. +           return;
  560. +      
  561.         if ((!isInsideZone(ZoneId.PVP) || !target.isInsideZone(ZoneId.PVP)) && player.getKarma() == 0)
  562.         {
  563.             PvpFlagTaskManager.getInstance().add(this, checkIfPvP(player) ? Config.PVP_PVP_TIME : Config.PVP_NORMAL_TIME);
  564. @@ -5479,6 +5492,8 @@
  565.                 player.setName(rset.getString("char_name"));
  566.                 player._lastAccess = rset.getLong("lastAccess");
  567.                
  568. +               player.setFactionId(rset.getInt("factionId"));
  569. +              
  570.                 player.getStat().setExp(rset.getLong("exp"));
  571.                 player.setExpBeforeDeath(rset.getLong("expBeforeDeath"));
  572.                 player.getStat().setLevel(rset.getByte("level"));
  573. @@ -5922,7 +5937,8 @@
  574.             statement.setLong(47, getClanCreateExpiryTime());
  575.             statement.setString(48, getName());
  576.             statement.setLong(49, getDeathPenaltyBuffLevel());
  577. -           statement.setInt(50, getObjectId());
  578. +           statement.setInt(50, getFactionId());
  579. +           statement.setInt(51, getObjectId());
  580.            
  581.             statement.execute();
  582.             statement.close();
  583. @@ -10705,4 +10721,16 @@
  584.                 break;
  585.         }
  586.     }
  587. +  
  588. +   private int _factionId;
  589. +  
  590. +   public void setFactionId(int id)
  591. +   {
  592. +       _factionId = id;
  593. +   }
  594. +  
  595. +   public int getFactionId()
  596. +   {
  597. +       return _factionId;
  598. +   }
  599.  }
  600. \ No newline at end of file
  601. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java
  602. ===================================================================
  603. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java   (revision 5)
  604. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java   (working copy)
  605. @@ -55,6 +55,9 @@
  606.             return;
  607.         }
  608.        
  609. +       if (friend.getFactionId() != activeChar.getFactionId())
  610. +           return;
  611. +      
  612.         if (BlockList.isBlocked(activeChar, friend))
  613.         {
  614.             activeChar.sendMessage("You have blocked " + _name + ".");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement