Advertisement
Guest User

AccessDenied (faction aCis)

a guest
Jan 17th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 16.02 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/GameServer.java
  205. ===================================================================
  206. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 5)
  207. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  208. @@ -46,6 +46,7 @@
  209.  import net.sf.l2j.gameserver.datatables.CharTemplateTable;
  210.  import net.sf.l2j.gameserver.datatables.ClanTable;
  211.  import net.sf.l2j.gameserver.datatables.DoorTable;
  212. +import net.sf.l2j.gameserver.datatables.Faction;
  213.  import net.sf.l2j.gameserver.datatables.FishTable;
  214.  import net.sf.l2j.gameserver.datatables.GmListTable;
  215.  import net.sf.l2j.gameserver.datatables.HelperBuffTable;
  216. @@ -264,6 +265,9 @@
  217.         DayNightSpawnManager.getInstance();
  218.         DimensionalRiftManager.getInstance();
  219.        
  220. +       StringUtil.printSection("Faction");
  221. +       Faction.getInstance().LoadFaction();
  222. +      
  223.         StringUtil.printSection("Olympiads & Heroes");
  224.         OlympiadGameManager.getInstance();
  225.         Olympiad.getInstance();
  226. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java
  227. ===================================================================
  228. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java  (revision 5)
  229. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java  (working copy)
  230. @@ -55,6 +55,9 @@
  231.             return;
  232.         }
  233.        
  234. +       if (activeChar.getFactionId() == targetChar.getFactionId())
  235. +           return;
  236. +      
  237.         if (!targetChar.canDuel())
  238.         {
  239.             activeChar.sendPacket(targetChar.getNoDuelReason());
  240. Index: java/net/sf/l2j/gameserver/datatables/Faction.java
  241. ===================================================================
  242. --- java/net/sf/l2j/gameserver/datatables/Faction.java  (revision 0)
  243. +++ java/net/sf/l2j/gameserver/datatables/Faction.java  (working copy)
  244. @@ -0,0 +1,159 @@
  245. +/*
  246. + * This program is free software: you can redistribute it and/or modify it under
  247. + * the terms of the GNU General Public License as published by the Free Software
  248. + * Foundation, either version 3 of the License, or (at your option) any later
  249. + * version.
  250. + *
  251. + * This program is distributed in the hope that it will be useful, but WITHOUT
  252. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  253. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  254. + * details.
  255. + *
  256. + * You should have received a copy of the GNU General Public License along with
  257. + * this program. If not, see <http://www.gnu.org/licenses/>.
  258. + */
  259. +package net.sf.l2j.gameserver.datatables;
  260. +
  261. +import java.sql.Connection;
  262. +import java.sql.PreparedStatement;
  263. +import java.sql.ResultSet;
  264. +import java.util.Map;
  265. +import java.util.concurrent.ConcurrentHashMap;
  266. +
  267. +import net.sf.l2j.L2DatabaseFactory;
  268. +import net.sf.l2j.gameserver.model.Location;
  269. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  270. +
  271. +
  272. +/**
  273. + * @author AccessDenied
  274. + */
  275. +public class Faction
  276. +{
  277. +  
  278. +   private Map<Integer, FactionHolder> factions = new ConcurrentHashMap<>();
  279. +  
  280. +   public void LoadFaction()
  281. +   {
  282. +       try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  283. +       {
  284. +           PreparedStatement statement = con.prepareStatement("SELECT * FROM faction");
  285. +           ResultSet result = statement.executeQuery();
  286. +          
  287. +           if (result.next())
  288. +           {
  289. +               int id = result.getInt("factionId");
  290. +               String name = result.getString("factionName");
  291. +               String[] pos = result.getString("factionPos").split(";");
  292. +               Location loc = new Location(Integer.parseInt(pos[0]), Integer.parseInt(pos[1]), Integer.parseInt(pos[2]));
  293. +               String color = result.getString("factionColor");
  294. +              
  295. +               factions.put(id, new FactionHolder(id, name, loc, color));
  296. +           }
  297. +           result.close();
  298. +           statement.close();
  299. +       }
  300. +       catch (Exception e)
  301. +       {
  302. +           System.out.println("Failed to load factions from database " + e);
  303. +           return;
  304. +       }
  305. +   }
  306. +  
  307. +   public void teleToBase(L2PcInstance player)
  308. +   {
  309. +       int factionId = player.getFactionId();
  310. +      
  311. +       for (FactionHolder faction : factions.values())
  312. +       {
  313. +           if (faction.getFactionId() == factionId)
  314. +           {
  315. +               Location loc = faction.getFactionLoc();
  316. +               player.teleToLocation(loc, 0);
  317. +           }
  318. +       }
  319. +   }
  320. +  
  321. +   public Location getFactionLocation(L2PcInstance player)
  322. +   {
  323. +       int factionId = player.getFactionId();
  324. +       Location loc = null;
  325. +      
  326. +       for (FactionHolder faction : factions.values())
  327. +       {
  328. +           if (faction.getFactionId() == factionId)
  329. +           {
  330. +               loc = faction.getFactionLoc();
  331. +           }
  332. +       }
  333. +      
  334. +       return loc;
  335. +   }
  336. +  
  337. +   public void onPlayerEnter(L2PcInstance player)
  338. +   {
  339. +       int factionId = player.getFactionId();
  340. +      
  341. +       for (FactionHolder faction : factions.values())
  342. +       {
  343. +           if (faction.getFactionId() == factionId)
  344. +           {
  345. +               player.setTitle(faction.getFactionName());
  346. +               player.getAppearance().setNameColor(Integer.decode("0x" + faction.getFactionColor()));
  347. +
  348. +               teleToBase(player);
  349. +           }
  350. +       }
  351. +   }
  352. +  
  353. +   public void onReward(L2PcInstance player)
  354. +   {
  355. +       //TODO
  356. +   }
  357. +  
  358. +   public class FactionHolder
  359. +   {
  360. +       private int _id;
  361. +       private String _name;
  362. +       private Location _pos;
  363. +       private String _color;
  364. +      
  365. +       public FactionHolder(int id, String name, Location pos, String color)
  366. +       {
  367. +           _id = id;
  368. +           _name = name;
  369. +           _pos = pos;
  370. +           _color = color;
  371. +       }
  372. +      
  373. +       public String getFactionColor()
  374. +       {
  375. +           return _color;
  376. +       }
  377. +      
  378. +       public int getFactionId()
  379. +       {
  380. +           return _id;
  381. +       }
  382. +      
  383. +       public String getFactionName()
  384. +       {
  385. +           return _name;
  386. +       }
  387. +      
  388. +       public Location getFactionLoc()
  389. +       {
  390. +           return _pos;
  391. +       }
  392. +   }
  393. +  
  394. +   public static Faction getInstance()
  395. +   {
  396. +       return SingletonHolder._instance;
  397. +   }
  398. +  
  399. +   private static class SingletonHolder
  400. +   {
  401. +       protected static final Faction _instance = new Faction();
  402. +   }
  403. +}
  404. \ No newline at end of file
  405. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
  406. ===================================================================
  407. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java   (revision 5)
  408. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java   (working copy)
  409. @@ -15,6 +15,7 @@
  410.  package net.sf.l2j.gameserver.network.clientpackets;
  411.  
  412.  import net.sf.l2j.gameserver.ThreadPoolManager;
  413. +import net.sf.l2j.gameserver.datatables.Faction;
  414.  import net.sf.l2j.gameserver.datatables.MapRegionTable;
  415.  import net.sf.l2j.gameserver.instancemanager.CastleManager;
  416.  import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
  417. @@ -138,7 +139,7 @@
  418.                     break;
  419.                
  420.                 default:
  421. -                   loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Town);
  422. +                   loc = Faction.getInstance().getFactionLocation(activeChar);
  423.                     break;
  424.             }
  425.            
  426. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  427. ===================================================================
  428. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 5)
  429. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  430. @@ -4029,6 +4029,8 @@
  431.         {
  432.             L2PcInstance pk = killer.getActingPlayer();
  433.            
  434. +           pk.setPvpKills(pk.getPvpKills() + 1);
  435. +          
  436.             // Clear resurrect xp calculation
  437.             setExpBeforeDeath(0);
  438.            
  439. @@ -4242,7 +4244,12 @@
  440.         {
  441.             // PK Points are increased only if you kill a player.
  442.             if (target instanceof L2PcInstance)
  443. +           {
  444. +               if (target.getActingPlayer().getFactionId() != 0)
  445. +                   return;
  446. +              
  447.                 setPkKills(getPkKills() + 1);
  448. +           }
  449.            
  450.             // Calculate new karma.
  451.             setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target instanceof L2Summon));
  452. @@ -4257,6 +4264,9 @@
  453.         if (isInsideZone(ZoneId.PVP))
  454.             return;
  455.        
  456. +       if (getFactionId() != 0)
  457. +           return;
  458. +      
  459.         PvpFlagTaskManager.getInstance().add(this, Config.PVP_NORMAL_TIME);
  460.        
  461.         if (getPvpFlag() == 0)
  462. @@ -4272,6 +4282,9 @@
  463.         if (isInDuel() && player.getDuelId() == getDuelId())
  464.             return;
  465.        
  466. +       if (getFactionId() != 0)
  467. +           return;
  468. +      
  469.         if ((!isInsideZone(ZoneId.PVP) || !target.isInsideZone(ZoneId.PVP)) && player.getKarma() == 0)
  470.         {
  471.             PvpFlagTaskManager.getInstance().add(this, checkIfPvP(player) ? Config.PVP_PVP_TIME : Config.PVP_NORMAL_TIME);
  472. @@ -10705,4 +10718,16 @@
  473.                 break;
  474.         }
  475.     }
  476. +  
  477. +   private int _factionId;
  478. +  
  479. +   public void setFactionId(int id)
  480. +   {
  481. +       _factionId = id;
  482. +   }
  483. +  
  484. +   public int getFactionId()
  485. +   {
  486. +       return _factionId;
  487. +   }
  488.  }
  489. \ No newline at end of file
  490. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java
  491. ===================================================================
  492. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java   (revision 5)
  493. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java   (working copy)
  494. @@ -55,6 +55,9 @@
  495.             return;
  496.         }
  497.        
  498. +       if (friend.getFactionId() != activeChar.getFactionId())
  499. +           return;
  500. +      
  501.         if (BlockList.isBlocked(activeChar, friend))
  502.         {
  503.             activeChar.sendMessage("You have blocked " + _name + ".");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement