Browse Source

BETA: Reworking party distribution type from int to enum (`PartyDistributionType`).
* Converted some anonymous classes to lambdas.
* Removed useless `Config#EOL` from `EnterWorld` it was causing an exception in new `Base64` decoder.

Nos 11 năm trước cách đây
mục cha
commit
5d94699ba1

+ 1 - 10
L2J_Server_BETA/java/com/l2jserver/gameserver/ItemsAutoDestroy.java

@@ -41,7 +41,7 @@ public class ItemsAutoDestroy
 		{
 			_sleep = 3600000;
 		}
-		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new CheckItemsForDestroy(), 5000, 5000);
+		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this::removeItems, 5000, 5000);
 	}
 	
 	public static ItemsAutoDestroy getInstance()
@@ -111,15 +111,6 @@ public class ItemsAutoDestroy
 		}
 	}
 	
-	protected class CheckItemsForDestroy extends Thread
-	{
-		@Override
-		public void run()
-		{
-			removeItems();
-		}
-	}
-	
 	private static class SingletonHolder
 	{
 		protected static final ItemsAutoDestroy _instance = new ItemsAutoDestroy();

+ 80 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/enums/PartyDistributionType.java

@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2004-2014 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server 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.
+ * 
+ * L2J Server 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 com.l2jserver.gameserver.enums;
+
+/**
+ * @author Nos
+ */
+public enum PartyDistributionType
+{
+	FINDERS_KEEPERS(0, 487),
+	RANDOM(1, 488),
+	RANDOM_INCLUDING_SPOIL(2, 798),
+	BY_TURN(3, 799),
+	BY_TURN_INCLUDING_SPOIL(4, 800);
+	
+	private final int _id;
+	private final int _sysStringId;
+	
+	/**
+	 * Constructs a party distribution type.
+	 * @param id the id used by packets.
+	 * @param sysStringId the sysstring id
+	 */
+	private PartyDistributionType(int id, int sysStringId)
+	{
+		_id = id;
+		_sysStringId = sysStringId;
+	}
+	
+	/**
+	 * Gets the id used by packets.
+	 * @return the id
+	 */
+	public int getId()
+	{
+		return _id;
+	}
+	
+	/**
+	 * Gets the sysstring id used by system messages.
+	 * @return the sysstring-e id
+	 */
+	public int getSysStringId()
+	{
+		return _sysStringId;
+	}
+	
+	/**
+	 * Finds the {@code PartyDistributionType} by its id
+	 * @param id the id
+	 * @return the {@code PartyDistributionType} if its found, {@code null} otherwise.
+	 */
+	public static PartyDistributionType findById(int id)
+	{
+		for (PartyDistributionType partyDistributionType : values())
+		{
+			if (partyDistributionType.getId() == id)
+			{
+				return partyDistributionType;
+			}
+		}
+		return null;
+	}
+}

+ 67 - 99
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2Party.java

@@ -18,9 +18,12 @@
  */
 package com.l2jserver.gameserver.model;
 
+import java.time.Duration;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.NoSuchElementException;
+import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -32,6 +35,7 @@ import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.SevenSignsFestival;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.datatables.ItemTable;
+import com.l2jserver.gameserver.enums.PartyDistributionType;
 import com.l2jserver.gameserver.instancemanager.DuelManager;
 import com.l2jserver.gameserver.model.actor.L2Attackable;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -67,37 +71,28 @@ import com.l2jserver.util.Rnd;
 public class L2Party extends AbstractPlayerGroup
 {
 	private static final Logger _log = Logger.getLogger(L2Party.class.getName());
+	
 	// @formatter:off
 	private static final double[] BONUS_EXP_SP =
 	{
 		1.0, 1.10, 1.20, 1.30, 1.40, 1.50, 2.0, 2.10, 2.20
 	};
-	// TODO: JIV - unhardcode to some SysString enum (sysstring-e.dat)
-	private static final int[] LOOT_SYSSTRINGS =
-	{
-		487, 488, 798, 799, 800
-	};
 	// @formatter:on
-	private static final int PARTY_POSITION_BROADCAST_DELAY = 12000;
 	
-	public static final byte ITEM_LOOTER = 0;
-	public static final byte ITEM_RANDOM = 1;
-	public static final byte ITEM_RANDOM_SPOIL = 2;
-	public static final byte ITEM_ORDER = 3;
-	public static final byte ITEM_ORDER_SPOIL = 4;
+	private static final Duration PARTY_POSITION_BROADCAST_INTERVAL = Duration.ofSeconds(12);
+	private static final Duration PARTY_DISTRIBUTION_TYPE_REQUEST_TIMEOUT = Duration.ofSeconds(45);
 	
 	private final FastList<L2PcInstance> _members;
 	private boolean _pendingInvitation = false;
 	private long _pendingInviteTimeout;
 	private int _partyLvl = 0;
-	private int _itemDistribution = 0;
+	private volatile PartyDistributionType _distributionType = PartyDistributionType.FINDERS_KEEPERS;
+	private volatile PartyDistributionType _changeRequestDistributionType;
+	private volatile Future<?> _changeDistributionTypeRequestTask = null;
+	private volatile Set<Integer> _changeDistributionTypeAnswers = null;
 	private int _itemLastLoot = 0;
 	private L2CommandChannel _commandChannel = null;
 	private DimensionalRift _dr;
-	private byte _requestChangeLoot = -1;
-	private List<Integer> _changeLootAnswers = null;
-	protected long _requestChangeLootTimer = 0;
-	private Future<?> _checkTask = null;
 	private Future<?> _positionBroadcastTask = null;
 	protected PartyMemberPosition _positionPacket;
 	private boolean _disbanding = false;
@@ -116,14 +111,14 @@ public class L2Party extends AbstractPlayerGroup
 	/**
 	 * Construct a new L2Party object with a single member - the leader.
 	 * @param leader the leader of this party
-	 * @param itemDistribution the item distribution rule of this party
+	 * @param partyDistributionType the item distribution rule of this party
 	 */
-	public L2Party(L2PcInstance leader, int itemDistribution)
+	public L2Party(L2PcInstance leader, PartyDistributionType partyDistributionType)
 	{
 		_members = new FastList<L2PcInstance>().shared();
 		_members.add(leader);
 		_partyLvl = leader.getLevel();
-		_itemDistribution = itemDistribution;
+		_distributionType = partyDistributionType;
 	}
 	
 	/**
@@ -221,35 +216,31 @@ public class L2Party extends AbstractPlayerGroup
 	 */
 	private L2PcInstance getActualLooter(L2PcInstance player, int ItemId, boolean spoil, L2Character target)
 	{
-		L2PcInstance looter = player;
+		L2PcInstance looter = null;
 		
-		switch (_itemDistribution)
+		switch (_distributionType)
 		{
-			case ITEM_RANDOM:
+			case RANDOM:
 				if (!spoil)
 				{
 					looter = getCheckedRandomMember(ItemId, target);
 				}
 				break;
-			case ITEM_RANDOM_SPOIL:
+			case RANDOM_INCLUDING_SPOIL:
 				looter = getCheckedRandomMember(ItemId, target);
 				break;
-			case ITEM_ORDER:
+			case BY_TURN:
 				if (!spoil)
 				{
 					looter = getCheckedNextLooter(ItemId, target);
 				}
 				break;
-			case ITEM_ORDER_SPOIL:
+			case BY_TURN_INCLUDING_SPOIL:
 				looter = getCheckedNextLooter(ItemId, target);
 				break;
 		}
 		
-		if (looter == null)
-		{
-			looter = player;
-		}
-		return looter;
+		return looter != null ? looter : player;
 	}
 	
 	/**
@@ -296,7 +287,7 @@ public class L2Party extends AbstractPlayerGroup
 			return;
 		}
 		
-		if (_requestChangeLoot != -1)
+		if (_changeRequestDistributionType != null)
 		{
 			finishLootRequest(false); // cancel on invite
 		}
@@ -368,7 +359,18 @@ public class L2Party extends AbstractPlayerGroup
 		
 		if (_positionBroadcastTask == null)
 		{
-			_positionBroadcastTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new PositionBroadcast(), PARTY_POSITION_BROADCAST_DELAY / 2, PARTY_POSITION_BROADCAST_DELAY);
+			_positionBroadcastTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
+			{
+				if (_positionPacket == null)
+				{
+					_positionPacket = new PartyMemberPosition(this);
+				}
+				else
+				{
+					_positionPacket.reuse(this);
+				}
+				broadcastPacket(_positionPacket);
+			}, PARTY_POSITION_BROADCAST_INTERVAL.toMillis() / 2, PARTY_POSITION_BROADCAST_INTERVAL.toMillis());
 		}
 	}
 	
@@ -496,10 +498,10 @@ public class L2Party extends AbstractPlayerGroup
 						DuelManager.getInstance().onRemoveFromParty(getLeader());
 					}
 				}
-				if (_checkTask != null)
+				if (_changeDistributionTypeRequestTask != null)
 				{
-					_checkTask.cancel(true);
-					_checkTask = null;
+					_changeDistributionTypeRequestTask.cancel(true);
+					_changeDistributionTypeRequestTask = null;
 				}
 				if (_positionBroadcastTask != null)
 				{
@@ -938,9 +940,9 @@ public class L2Party extends AbstractPlayerGroup
 		return _partyLvl;
 	}
 	
-	public int getLootDistribution()
+	public PartyDistributionType getDistributionType()
 	{
-		return _itemDistribution;
+		return _distributionType;
 	}
 	
 	public boolean isInCommandChannel()
@@ -989,47 +991,43 @@ public class L2Party extends AbstractPlayerGroup
 		}
 	}
 	
-	public void requestLootChange(byte type)
+	public synchronized void requestLootChange(PartyDistributionType partyDistributionType)
 	{
-		if (_requestChangeLoot != -1)
+		if (_changeRequestDistributionType != null)
 		{
-			if (System.currentTimeMillis() > _requestChangeLootTimer)
-			{
-				finishLootRequest(false); // timeout 45sec, guess
-			}
-			else
-			{
-				return;
-			}
+			return;
 		}
-		_requestChangeLoot = type;
-		int additionalTime = L2PcInstance.REQUEST_TIMEOUT * 3000;
-		_requestChangeLootTimer = System.currentTimeMillis() + additionalTime;
-		_changeLootAnswers = FastList.newInstance();
-		_checkTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ChangeLootCheck(), additionalTime + 1000, 5000);
-		broadcastToPartyMembers(getLeader(), new ExAskModifyPartyLooting(getLeader().getName(), type));
-		SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.REQUESTING_APPROVAL_CHANGE_PARTY_LOOT_S1);
-		sm.addSystemString(LOOT_SYSSTRINGS[type]);
+		_changeRequestDistributionType = partyDistributionType;
+		_changeDistributionTypeAnswers = new HashSet<>();
+		_changeDistributionTypeRequestTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> finishLootRequest(false), PARTY_DISTRIBUTION_TYPE_REQUEST_TIMEOUT.toMillis());
+		
+		broadcastToPartyMembers(getLeader(), new ExAskModifyPartyLooting(getLeader().getName(), partyDistributionType));
+		
+		final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.REQUESTING_APPROVAL_CHANGE_PARTY_LOOT_S1);
+		sm.addSystemString(partyDistributionType.getSysStringId());
 		getLeader().sendPacket(sm);
 	}
 	
 	public synchronized void answerLootChangeRequest(L2PcInstance member, boolean answer)
 	{
-		if (_requestChangeLoot == -1)
+		if (_changeRequestDistributionType == null)
 		{
 			return;
 		}
-		if (_changeLootAnswers.contains(member.getObjectId()))
+		
+		if (_changeDistributionTypeAnswers.contains(member.getObjectId()))
 		{
 			return;
 		}
+		
 		if (!answer)
 		{
 			finishLootRequest(false);
 			return;
 		}
-		_changeLootAnswers.add(member.getObjectId());
-		if (_changeLootAnswers.size() >= (getMemberCount() - 1))
+		
+		_changeDistributionTypeAnswers.add(member.getObjectId());
+		if (_changeDistributionTypeAnswers.size() >= (getMemberCount() - 1))
 		{
 			finishLootRequest(true);
 		}
@@ -1037,60 +1035,30 @@ public class L2Party extends AbstractPlayerGroup
 	
 	protected synchronized void finishLootRequest(boolean success)
 	{
-		if (_requestChangeLoot == -1)
+		if (_changeRequestDistributionType == null)
 		{
 			return;
 		}
-		if (_checkTask != null)
+		if (_changeDistributionTypeRequestTask != null)
 		{
-			_checkTask.cancel(false);
-			_checkTask = null;
+			_changeDistributionTypeRequestTask.cancel(false);
+			_changeDistributionTypeRequestTask = null;
 		}
 		if (success)
 		{
-			broadcastPacket(new ExSetPartyLooting(1, _requestChangeLoot));
-			_itemDistribution = _requestChangeLoot;
+			broadcastPacket(new ExSetPartyLooting(1, _changeRequestDistributionType));
+			_distributionType = _changeRequestDistributionType;
 			SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PARTY_LOOT_CHANGED_S1);
-			sm.addSystemString(LOOT_SYSSTRINGS[_requestChangeLoot]);
+			sm.addSystemString(_changeRequestDistributionType.getSysStringId());
 			broadcastPacket(sm);
 		}
 		else
 		{
-			broadcastPacket(new ExSetPartyLooting(0, (byte) 0));
+			broadcastPacket(new ExSetPartyLooting(0, _distributionType));
 			broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.PARTY_LOOT_CHANGE_CANCELLED));
 		}
-		_requestChangeLoot = -1;
-		FastList.recycle((FastList<?>) _changeLootAnswers);
-		_requestChangeLootTimer = 0;
-	}
-	
-	protected class ChangeLootCheck implements Runnable
-	{
-		@Override
-		public void run()
-		{
-			if (System.currentTimeMillis() > _requestChangeLootTimer)
-			{
-				finishLootRequest(false);
-			}
-		}
-	}
-	
-	protected class PositionBroadcast implements Runnable
-	{
-		@Override
-		public void run()
-		{
-			if (_positionPacket == null)
-			{
-				_positionPacket = new PartyMemberPosition(L2Party.this);
-			}
-			else
-			{
-				_positionPacket.reuse(L2Party.this);
-			}
-			broadcastPacket(_positionPacket);
-		}
+		_changeRequestDistributionType = null;
+		_changeDistributionTypeAnswers = null;
 	}
 	
 	/**

+ 2 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -89,6 +89,7 @@ import com.l2jserver.gameserver.enums.HtmlActionScope;
 import com.l2jserver.gameserver.enums.IllegalActionPunishmentType;
 import com.l2jserver.gameserver.enums.InstanceType;
 import com.l2jserver.gameserver.enums.MountType;
+import com.l2jserver.gameserver.enums.PartyDistributionType;
 import com.l2jserver.gameserver.enums.PcRace;
 import com.l2jserver.gameserver.enums.PlayerAction;
 import com.l2jserver.gameserver.enums.PrivateStoreType;
@@ -4693,7 +4694,7 @@ public final class L2PcInstance extends L2Playable
 				return;
 			}
 			
-			if (((isInParty() && (getParty().getLootDistribution() == L2Party.ITEM_LOOTER)) || !isInParty()) && !_inventory.validateCapacity(target))
+			if (((isInParty() && (getParty().getDistributionType() == PartyDistributionType.FINDERS_KEEPERS)) || !isInParty()) && !_inventory.validateCapacity(target))
 			{
 				sendPacket(ActionFailed.STATIC_PACKET);
 				sendPacket(SystemMessageId.SLOTS_FULL);

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PetInstance.java

@@ -40,6 +40,7 @@ import com.l2jserver.gameserver.datatables.SummonEffectsTable;
 import com.l2jserver.gameserver.datatables.SummonEffectsTable.SummonEffect;
 import com.l2jserver.gameserver.enums.InstanceType;
 import com.l2jserver.gameserver.enums.ItemLocation;
+import com.l2jserver.gameserver.enums.PartyDistributionType;
 import com.l2jserver.gameserver.handler.IItemHandler;
 import com.l2jserver.gameserver.handler.ItemHandler;
 import com.l2jserver.gameserver.idfactory.IdFactory;
@@ -47,7 +48,6 @@ import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
 import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager;
 import com.l2jserver.gameserver.model.L2Object;
-import com.l2jserver.gameserver.model.L2Party;
 import com.l2jserver.gameserver.model.L2PetData;
 import com.l2jserver.gameserver.model.L2PetLevelData;
 import com.l2jserver.gameserver.model.L2World;
@@ -560,7 +560,7 @@ public class L2PetInstance extends L2Summon
 				return;
 			}
 			
-			if (((isInParty() && (getParty().getLootDistribution() == L2Party.ITEM_LOOTER)) || !isInParty()) && !_inventory.validateCapacity(target))
+			if (((isInParty() && (getParty().getDistributionType() == PartyDistributionType.FINDERS_KEEPERS)) || !isInParty()) && !_inventory.validateCapacity(target))
 			{
 				sendPacket(ActionFailed.STATIC_PACKET);
 				sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_ANY_MORE_ITEMS);
@@ -650,7 +650,7 @@ public class L2PetInstance extends L2Summon
 			}
 			
 			// If owner is in party and it isnt finders keepers, distribute the item instead of stealing it -.-
-			if (getOwner().isInParty() && (getOwner().getParty().getLootDistribution() != L2Party.ITEM_LOOTER))
+			if (getOwner().isInParty() && (getOwner().getParty().getDistributionType() != PartyDistributionType.FINDERS_KEEPERS))
 			{
 				getOwner().getParty().distributeItem(getOwner(), target);
 			}

+ 4 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java

@@ -452,8 +452,8 @@ public class EnterWorld extends L2GameClientPacket
 		
 		activeChar.sendPacket(SystemMessageId.WELCOME_TO_LINEAGE);
 		
-		activeChar.sendMessage(getText("VGhpcyBTZXJ2ZXIgdXNlcyBMMkosIGEgUHJvamVjdCBmb3VuZGVkIGJ5IEwyQ2hlZg==" + Config.EOL));
-		activeChar.sendMessage(getText("YW5kIGRldmVsb3BlZCBieSBMMkogVGVhbSBhdCB3d3cubDJqc2VydmVyLmNvbQ==" + Config.EOL));
+		activeChar.sendMessage(getText("VGhpcyBTZXJ2ZXIgdXNlcyBMMkosIGEgUHJvamVjdCBmb3VuZGVkIGJ5IEwyQ2hlZg=="));
+		activeChar.sendMessage(getText("YW5kIGRldmVsb3BlZCBieSBMMkogVGVhbSBhdCB3d3cubDJqc2VydmVyLmNvbQ=="));
 		
 		if (Config.DISPLAY_SERVER_VERSION)
 		{
@@ -467,8 +467,8 @@ public class EnterWorld extends L2GameClientPacket
 				activeChar.sendMessage(getText("TDJKIERhdGFQYWNrIFZlcnNpb246") + " " + Config.DATAPACK_VERSION);
 			}
 		}
-		activeChar.sendMessage(getText("Q29weXJpZ2h0IDIwMDQtMjAxNA==" + Config.EOL));
-		activeChar.sendMessage(getText("VGhhbmsgeW91IGZvciAxMCB5ZWFycyE=" + Config.EOL));
+		activeChar.sendMessage(getText("Q29weXJpZ2h0IDIwMDQtMjAxNA=="));
+		activeChar.sendMessage(getText("VGhhbmsgeW91IGZvciAxMCB5ZWFycyE="));
 		
 		SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
 		Announcements.getInstance().showAnnouncements(activeChar);

+ 12 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestJoinParty.java

@@ -19,6 +19,7 @@
 package com.l2jserver.gameserver.network.clientpackets;
 
 import com.l2jserver.Config;
+import com.l2jserver.gameserver.enums.PartyDistributionType;
 import com.l2jserver.gameserver.model.BlockList;
 import com.l2jserver.gameserver.model.L2Party;
 import com.l2jserver.gameserver.model.L2World;
@@ -37,13 +38,13 @@ public final class RequestJoinParty extends L2GameClientPacket
 	private static final String _C__42_REQUESTJOINPARTY = "[C] 42 RequestJoinParty";
 	
 	private String _name;
-	private int _itemDistribution;
+	private int _partyDistributionTypeId;
 	
 	@Override
 	protected void readImpl()
 	{
 		_name = readS();
-		_itemDistribution = readD();
+		_partyDistributionTypeId = readD();
 	}
 	
 	@Override
@@ -183,7 +184,7 @@ public final class RequestJoinParty extends L2GameClientPacket
 		{
 			requestor.onTransactionRequest(target);
 			// in case a leader change has happened, use party's mode
-			target.sendPacket(new AskJoinParty(requestor.getName(), party.getLootDistribution()));
+			target.sendPacket(new AskJoinParty(requestor.getName(), party.getDistributionType()));
 			party.setPendingInvitation(true);
 			
 			if (Config.DEBUG)
@@ -211,12 +212,18 @@ public final class RequestJoinParty extends L2GameClientPacket
 	 */
 	private void createNewParty(L2PcInstance target, L2PcInstance requestor)
 	{
+		PartyDistributionType partyDistributionType = PartyDistributionType.findById(_partyDistributionTypeId);
+		if (partyDistributionType == null)
+		{
+			return;
+		}
+		
 		if (!target.isProcessingRequest())
 		{
-			requestor.setParty(new L2Party(requestor, _itemDistribution));
+			requestor.setParty(new L2Party(requestor, partyDistributionType));
 			
 			requestor.onTransactionRequest(target);
-			target.sendPacket(new AskJoinParty(requestor.getName(), _itemDistribution));
+			target.sendPacket(new AskJoinParty(requestor.getName(), partyDistributionType));
 			requestor.getParty().setPendingInvitation(true);
 			
 			if (Config.DEBUG)

+ 11 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestPartyLootModification.java

@@ -18,6 +18,7 @@
  */
 package com.l2jserver.gameserver.network.clientpackets;
 
+import com.l2jserver.gameserver.enums.PartyDistributionType;
 import com.l2jserver.gameserver.model.L2Party;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
@@ -28,32 +29,35 @@ public class RequestPartyLootModification extends L2GameClientPacket
 {
 	private static final String _C__D0_78_REQUESTPARTYLOOTMODIFICATION = "[C] D0:78 RequestPartyLootModification";
 	
-	private byte _mode;
+	private int _partyDistributionTypeId;
 	
 	@Override
 	protected void readImpl()
 	{
-		_mode = (byte) readD();
+		_partyDistributionTypeId = readD();
 	}
 	
 	@Override
 	protected void runImpl()
 	{
-		L2PcInstance activeChar = getClient().getActiveChar();
+		final L2PcInstance activeChar = getClient().getActiveChar();
 		if (activeChar == null)
 		{
 			return;
 		}
-		if ((_mode < 0) || (_mode > L2Party.ITEM_ORDER_SPOIL))
+		
+		final PartyDistributionType partyDistributionType = PartyDistributionType.findById(_partyDistributionTypeId);
+		if (partyDistributionType == null)
 		{
 			return;
 		}
-		L2Party party = activeChar.getParty();
-		if ((party == null) || !party.isLeader(activeChar) || (_mode == party.getLootDistribution()))
+		
+		final L2Party party = activeChar.getParty();
+		if ((party == null) || !party.isLeader(activeChar) || (partyDistributionType == party.getDistributionType()))
 		{
 			return;
 		}
-		party.requestLootChange(_mode);
+		party.requestLootChange(partyDistributionType);
 	}
 	
 	@Override

+ 7 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/AskJoinParty.java

@@ -18,19 +18,21 @@
  */
 package com.l2jserver.gameserver.network.serverpackets;
 
+import com.l2jserver.gameserver.enums.PartyDistributionType;
+
 public class AskJoinParty extends L2GameServerPacket
 {
 	private final String _requestorName;
-	private final int _itemDistribution;
+	private final PartyDistributionType _partyDistributionType;
 	
 	/**
 	 * @param requestorName
-	 * @param itemDistribution
+	 * @param partyDistributionType
 	 */
-	public AskJoinParty(String requestorName, int itemDistribution)
+	public AskJoinParty(String requestorName, PartyDistributionType partyDistributionType)
 	{
 		_requestorName = requestorName;
-		_itemDistribution = itemDistribution;
+		_partyDistributionType = partyDistributionType;
 	}
 	
 	@Override
@@ -38,6 +40,6 @@ public class AskJoinParty extends L2GameServerPacket
 	{
 		writeC(0x39);
 		writeS(_requestorName);
-		writeD(_itemDistribution);
+		writeD(_partyDistributionType.getId());
 	}
 }

+ 6 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ExAskModifyPartyLooting.java

@@ -18,18 +18,20 @@
  */
 package com.l2jserver.gameserver.network.serverpackets;
 
+import com.l2jserver.gameserver.enums.PartyDistributionType;
+
 /**
  * @author JIV
  */
 public class ExAskModifyPartyLooting extends L2GameServerPacket
 {
 	private final String _requestor;
-	private final byte _mode;
+	private final PartyDistributionType _partyDistributionType;
 	
-	public ExAskModifyPartyLooting(String name, byte mode)
+	public ExAskModifyPartyLooting(String name, PartyDistributionType partyDistributionType)
 	{
 		_requestor = name;
-		_mode = mode;
+		_partyDistributionType = partyDistributionType;
 	}
 	
 	@Override
@@ -38,6 +40,6 @@ public class ExAskModifyPartyLooting extends L2GameServerPacket
 		writeC(0xFE);
 		writeH(0xBF);
 		writeS(_requestor);
-		writeD(_mode);
+		writeD(_partyDistributionType.getId());
 	}
 }

+ 6 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ExSetPartyLooting.java

@@ -18,18 +18,20 @@
  */
 package com.l2jserver.gameserver.network.serverpackets;
 
+import com.l2jserver.gameserver.enums.PartyDistributionType;
+
 /**
  * @author JIV
  */
 public class ExSetPartyLooting extends L2GameServerPacket
 {
 	private final int _result;
-	private final byte _mode;
+	private final PartyDistributionType _partyDistributionType;
 	
-	public ExSetPartyLooting(int result, byte mode)
+	public ExSetPartyLooting(int result, PartyDistributionType partyDistributionType)
 	{
 		_result = result;
-		_mode = mode;
+		_partyDistributionType = partyDistributionType;
 	}
 	
 	@Override
@@ -38,6 +40,6 @@ public class ExSetPartyLooting extends L2GameServerPacket
 		writeC(0xFE);
 		writeH(0xC0);
 		writeD(_result);
-		writeD(_mode);
+		writeD(_partyDistributionType.getId());
 	}
 }

+ 4 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/PartySmallWindowAdd.java

@@ -23,24 +23,21 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 public final class PartySmallWindowAdd extends L2GameServerPacket
 {
-	
 	private final L2PcInstance _member;
-	private final int _leaderId;
-	private final int _distribution;
+	private final L2Party _party;
 	
 	public PartySmallWindowAdd(L2PcInstance member, L2Party party)
 	{
 		_member = member;
-		_leaderId = party.getLeaderObjectId();
-		_distribution = party.getLootDistribution();
+		_party = party;
 	}
 	
 	@Override
 	protected final void writeImpl()
 	{
 		writeC(0x4F);
-		writeD(_leaderId); // c3
-		writeD(_distribution);// writeD(0x04); ?? //c3
+		writeD(_party.getLeaderObjectId()); // c3
+		writeD(_party.getDistributionType().getId());// writeD(0x04); ?? //c3
 		writeD(_member.getObjectId());
 		writeS(_member.getName());
 		writeD((int) _member.getCurrentCp()); // c4

+ 2 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/PartySmallWindowAll.java

@@ -25,22 +25,19 @@ public final class PartySmallWindowAll extends L2GameServerPacket
 {
 	private final L2Party _party;
 	private final L2PcInstance _exclude;
-	private final int _dist, _LeaderOID;
 	
 	public PartySmallWindowAll(L2PcInstance exclude, L2Party party)
 	{
 		_exclude = exclude;
 		_party = party;
-		_LeaderOID = _party.getLeaderObjectId();
-		_dist = _party.getLootDistribution();
 	}
 	
 	@Override
 	protected final void writeImpl()
 	{
 		writeC(0x4e);
-		writeD(_LeaderOID);
-		writeD(_dist);
+		writeD(_party.getLeaderObjectId());
+		writeD(_party.getDistributionType().getId());
 		writeD(_party.getMemberCount() - 1);
 		
 		for (L2PcInstance member : _party.getMembers())