Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java (working copy)
- @@ -74,6 +74,9 @@
- if (!player.isInsideRadius(storePlayer, 150, true, false))
- return;
- + if (player.getFactionId() != storePlayer.getFactionId())
- + return;
- +
- if (storePlayer.getPrivateStoreType() != PrivateStoreType.BUY)
- return;
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java (working copy)
- @@ -76,6 +76,9 @@
- if (player.isCursedWeaponEquipped())
- return;
- + if (player.getFactionId() != storePlayer.getFactionId())
- + return;
- +
- if (!player.isInsideRadius(storePlayer, 150, true, false))
- return;
- Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (working copy)
- @@ -59,6 +59,9 @@
- return;
- }
- + if (target.getFactionId() != player.getFactionId())
- + return;
- +
- // Alt game - Karma punishment
- if (!Config.KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0 || target.getKarma() > 0))
- {
- Index: java/net/sf/l2j/gameserver/model/L2World.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/L2World.java (revision 5)
- +++ java/net/sf/l2j/gameserver/model/L2World.java (working copy)
- @@ -140,6 +140,34 @@
- return _pets.get(ownerId);
- }
- + public Collection<L2PcInstance> getFactionPlayers(int id)
- + {
- + Map<Integer, L2PcInstance> players = new ConcurrentHashMap<>();
- +
- + for (L2PcInstance player : _players.values())
- + {
- + if (player.getFactionId() == id)
- + players.put(player.getObjectId(), player);
- + }
- +
- + return players.values();
- + }
- +
- + public int getFactionSize(int id)
- + {
- + int size = 0;
- +
- + for (L2PcInstance player : _players.values())
- + {
- + if (player.getFactionId() == id)
- + {
- + size++;
- + }
- + }
- +
- + return size;
- + }
- +
- /**
- * Add a L2Object in the world.<BR>
- * <BR>
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
- @@ -52,6 +52,9 @@
- return;
- }
- + if (target.getFactionId() != requestor.getFactionId())
- + return;
- +
- if (BlockList.isBlocked(target, requestor))
- {
- requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_ADDED_YOU_TO_IGNORE_LIST).addPcName(target));
- Index: java/net/sf/l2j/gameserver/model/actor/L2Character.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 5)
- +++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
- @@ -571,6 +571,52 @@
- return;
- }
- + if (this instanceof L2Playable && target instanceof L2Playable)
- + {
- + if (this instanceof L2PcInstance && target instanceof L2PcInstance)
- + {
- + if (this.getActingPlayer().getFactionId() == target.getActingPlayer().getFactionId())
- + {
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + }
- +
- + if (this instanceof L2Summon && target instanceof L2PcInstance)
- + {
- + L2Summon summon = (L2Summon) this;
- +
- + if (summon.getOwner().getFactionId() != target.getActingPlayer().getFactionId())
- + {
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + }
- +
- + if (this instanceof L2Summon && target instanceof L2Summon)
- + {
- + L2Summon summon1 = (L2Summon) this;
- + L2Summon summon2 = (L2Summon) target;
- +
- + if (summon1.getOwner().getFactionId() == summon2.getOwner().getFactionId())
- + {
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + }
- +
- + if (target instanceof L2Summon)
- + {
- + L2Summon summon = (L2Summon) target;
- +
- + if (summon.getOwner().getFactionId() == this.getActingPlayer().getFactionId())
- + {
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + }
- + }
- +
- // Checking if target has moved to peace zone
- if (isInsidePeaceZone(this, target))
- {
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java (working copy)
- @@ -52,6 +52,9 @@
- return;
- }
- + if (target.getFactionId() != activeChar.getFactionId())
- + return;
- +
- if (!clan.checkAllyJoinCondition(activeChar, target))
- return;
- Index: java/net/sf/l2j/gameserver/model/L2Skill.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/L2Skill.java (revision 5)
- +++ java/net/sf/l2j/gameserver/model/L2Skill.java (working copy)
- @@ -2061,6 +2061,9 @@
- if (targetPlayer.inObserverMode())
- return false;
- + if (player.getFactionId() == targetPlayer.getFactionId() && skill.isOffensive())
- + return false;
- +
- if (skill.isOffensive() && player.getSiegeState() > 0 && player.isInsideZone(ZoneId.SIEGE) && player.getSiegeState() == targetPlayer.getSiegeState())
- return false;
- Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -18,6 +18,7 @@
- import net.sf.l2j.gameserver.communitybbs.Manager.MailBBSManager;
- import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
- import net.sf.l2j.gameserver.datatables.AnnouncementTable;
- +import net.sf.l2j.gameserver.datatables.Faction;
- import net.sf.l2j.gameserver.datatables.GmListTable;
- import net.sf.l2j.gameserver.datatables.MapRegionTable;
- import net.sf.l2j.gameserver.datatables.SkillTable.FrequentSkill;
- @@ -229,6 +230,8 @@
- sendPacket(new SkillCoolTime(activeChar));
- + Faction.getInstance().onPlayerEnter(activeChar);
- +
- // If player logs back in a stadium, port him in nearest town.
- if (Olympiad.getInstance().playerInStadia(activeChar))
- activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 5)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -46,6 +46,7 @@
- import net.sf.l2j.gameserver.datatables.CharTemplateTable;
- import net.sf.l2j.gameserver.datatables.ClanTable;
- import net.sf.l2j.gameserver.datatables.DoorTable;
- +import net.sf.l2j.gameserver.datatables.Faction;
- import net.sf.l2j.gameserver.datatables.FishTable;
- import net.sf.l2j.gameserver.datatables.GmListTable;
- import net.sf.l2j.gameserver.datatables.HelperBuffTable;
- @@ -264,6 +265,9 @@
- DayNightSpawnManager.getInstance();
- DimensionalRiftManager.getInstance();
- + StringUtil.printSection("Faction");
- + Faction.getInstance().LoadFaction();
- +
- StringUtil.printSection("Olympiads & Heroes");
- OlympiadGameManager.getInstance();
- Olympiad.getInstance();
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java (working copy)
- @@ -55,6 +55,9 @@
- return;
- }
- + if (activeChar.getFactionId() == targetChar.getFactionId())
- + return;
- +
- if (!targetChar.canDuel())
- {
- activeChar.sendPacket(targetChar.getNoDuelReason());
- Index: java/net/sf/l2j/gameserver/datatables/Faction.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/datatables/Faction.java (revision 0)
- +++ java/net/sf/l2j/gameserver/datatables/Faction.java (working copy)
- @@ -0,0 +1,159 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.datatables;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.Map;
- +import java.util.concurrent.ConcurrentHashMap;
- +
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.model.Location;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +
- +/**
- + * @author AccessDenied
- + */
- +public class Faction
- +{
- +
- + private Map<Integer, FactionHolder> factions = new ConcurrentHashMap<>();
- +
- + public void LoadFaction()
- + {
- + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- + {
- + PreparedStatement statement = con.prepareStatement("SELECT * FROM faction");
- + ResultSet result = statement.executeQuery();
- +
- + if (result.next())
- + {
- + int id = result.getInt("factionId");
- + String name = result.getString("factionName");
- + String[] pos = result.getString("factionPos").split(";");
- + Location loc = new Location(Integer.parseInt(pos[0]), Integer.parseInt(pos[1]), Integer.parseInt(pos[2]));
- + String color = result.getString("factionColor");
- +
- + factions.put(id, new FactionHolder(id, name, loc, color));
- + }
- + result.close();
- + statement.close();
- + }
- + catch (Exception e)
- + {
- + System.out.println("Failed to load factions from database " + e);
- + return;
- + }
- + }
- +
- + public void teleToBase(L2PcInstance player)
- + {
- + int factionId = player.getFactionId();
- +
- + for (FactionHolder faction : factions.values())
- + {
- + if (faction.getFactionId() == factionId)
- + {
- + Location loc = faction.getFactionLoc();
- + player.teleToLocation(loc, 0);
- + }
- + }
- + }
- +
- + public Location getFactionLocation(L2PcInstance player)
- + {
- + int factionId = player.getFactionId();
- + Location loc = null;
- +
- + for (FactionHolder faction : factions.values())
- + {
- + if (faction.getFactionId() == factionId)
- + {
- + loc = faction.getFactionLoc();
- + }
- + }
- +
- + return loc;
- + }
- +
- + public void onPlayerEnter(L2PcInstance player)
- + {
- + int factionId = player.getFactionId();
- +
- + for (FactionHolder faction : factions.values())
- + {
- + if (faction.getFactionId() == factionId)
- + {
- + player.setTitle(faction.getFactionName());
- + player.getAppearance().setNameColor(Integer.decode("0x" + faction.getFactionColor()));
- +
- + teleToBase(player);
- + }
- + }
- + }
- +
- + public void onReward(L2PcInstance player)
- + {
- + //TODO
- + }
- +
- + public class FactionHolder
- + {
- + private int _id;
- + private String _name;
- + private Location _pos;
- + private String _color;
- +
- + public FactionHolder(int id, String name, Location pos, String color)
- + {
- + _id = id;
- + _name = name;
- + _pos = pos;
- + _color = color;
- + }
- +
- + public String getFactionColor()
- + {
- + return _color;
- + }
- +
- + public int getFactionId()
- + {
- + return _id;
- + }
- +
- + public String getFactionName()
- + {
- + return _name;
- + }
- +
- + public Location getFactionLoc()
- + {
- + return _pos;
- + }
- + }
- +
- + public static Faction getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final Faction _instance = new Faction();
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
- @@ -15,6 +15,7 @@
- package net.sf.l2j.gameserver.network.clientpackets;
- import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.datatables.Faction;
- import net.sf.l2j.gameserver.datatables.MapRegionTable;
- import net.sf.l2j.gameserver.instancemanager.CastleManager;
- import net.sf.l2j.gameserver.instancemanager.ClanHallManager;
- @@ -138,7 +139,7 @@
- break;
- default:
- - loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Town);
- + loc = Faction.getInstance().getFactionLocation(activeChar);
- break;
- }
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 5)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -4029,6 +4029,8 @@
- {
- L2PcInstance pk = killer.getActingPlayer();
- + pk.setPvpKills(pk.getPvpKills() + 1);
- +
- // Clear resurrect xp calculation
- setExpBeforeDeath(0);
- @@ -4242,7 +4244,12 @@
- {
- // PK Points are increased only if you kill a player.
- if (target instanceof L2PcInstance)
- + {
- + if (target.getActingPlayer().getFactionId() != 0)
- + return;
- +
- setPkKills(getPkKills() + 1);
- + }
- // Calculate new karma.
- setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target instanceof L2Summon));
- @@ -4257,6 +4264,9 @@
- if (isInsideZone(ZoneId.PVP))
- return;
- + if (getFactionId() != 0)
- + return;
- +
- PvpFlagTaskManager.getInstance().add(this, Config.PVP_NORMAL_TIME);
- if (getPvpFlag() == 0)
- @@ -4272,6 +4282,9 @@
- if (isInDuel() && player.getDuelId() == getDuelId())
- return;
- + if (getFactionId() != 0)
- + return;
- +
- if ((!isInsideZone(ZoneId.PVP) || !target.isInsideZone(ZoneId.PVP)) && player.getKarma() == 0)
- {
- PvpFlagTaskManager.getInstance().add(this, checkIfPvP(player) ? Config.PVP_PVP_TIME : Config.PVP_NORMAL_TIME);
- @@ -10705,4 +10718,16 @@
- break;
- }
- }
- +
- + private int _factionId;
- +
- + public void setFactionId(int id)
- + {
- + _factionId = id;
- + }
- +
- + public int getFactionId()
- + {
- + return _factionId;
- + }
- }
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java (revision 5)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java (working copy)
- @@ -55,6 +55,9 @@
- return;
- }
- + if (friend.getFactionId() != activeChar.getFactionId())
- + return;
- +
- if (BlockList.isBlocked(activeChar, friend))
- {
- activeChar.sendMessage("You have blocked " + _name + ".");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement