Removal of various conversions to arrays.

This commit is contained in:
MobiusDevelopment
2021-04-22 01:53:19 +00:00
parent 6d16bebe1a
commit 6a3556614a
881 changed files with 3876 additions and 3980 deletions

View File

@@ -17,7 +17,6 @@
package org.l2jmobius.gameserver;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -89,9 +88,7 @@ public class RecipeController
return;
}
final List<RecipeList> dwarfRecipes = Arrays.asList(manufacturer.getDwarvenRecipeBook());
final List<RecipeList> commonRecipes = Arrays.asList(manufacturer.getCommonRecipeBook());
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
if (!manufacturer.getDwarvenRecipeBook().contains(recipeList) && !manufacturer.getCommonRecipeBook().contains(recipeList))
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
return;
@@ -134,9 +131,7 @@ public class RecipeController
return;
}
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
if (!player.getDwarvenRecipeBook().contains(recipeList) && !player.getCommonRecipeBook().contains(recipeList))
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
return;

View File

@@ -90,8 +90,7 @@ public class MacroList implements IRestorable
deleteMacroFromDb(removed);
}
final Shortcut[] allShortCuts = _owner.getAllShortCuts();
for (Shortcut sc : allShortCuts)
for (Shortcut sc : _owner.getAllShortCuts())
{
if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
{

View File

@@ -16,6 +16,7 @@
*/
package org.l2jmobius.gameserver.model;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -67,9 +68,9 @@ public class MobGroupTable
return null;
}
public MobGroup[] getGroups()
public Collection<MobGroup> getGroups()
{
return _groupMap.values().toArray(new MobGroup[_groupMap.size()]);
return _groupMap.values();
}
public boolean removeGroup(int groupKey)

View File

@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Level;
@@ -46,9 +47,9 @@ public class ShortCuts implements IRestorable
_owner = owner;
}
public Shortcut[] getAllShortCuts()
public Collection<Shortcut> getAllShortCuts()
{
return _shortCuts.values().toArray(new Shortcut[_shortCuts.values().size()]);
return _shortCuts.values();
}
public Shortcut getShortCut(int slot, int page)

View File

@@ -107,9 +107,9 @@ public class TradeList
/**
* @return all items from TradeList
*/
public TradeItem[] getItems()
public Collection<TradeItem> getItems()
{
return _items.toArray(new TradeItem[_items.size()]);
return _items;
}
/**
@@ -863,7 +863,7 @@ public class TradeList
final InventoryUpdate playerIU = new InventoryUpdate();
long totalPrice = 0;
final TradeItem[] sellerItems = _items.toArray(new TradeItem[0]);
final TradeItem[] sellerItems = _items.toArray(new TradeItem[_items.size()]);
for (ItemRequest item : requestedItems)
{
// searching item in tradelist using itemId

View File

@@ -1243,19 +1243,19 @@ public class PlayerInstance extends Playable
}
/**
* @return a table containing all Common RecipeList of the PlayerInstance.
* @return a collection containing all Common RecipeList of the PlayerInstance.
*/
public RecipeList[] getCommonRecipeBook()
public Collection<RecipeList> getCommonRecipeBook()
{
return _commonRecipeBook.values().toArray(new RecipeList[_commonRecipeBook.values().size()]);
return _commonRecipeBook.values();
}
/**
* @return a table containing all Dwarf RecipeList of the PlayerInstance.
* @return a collection containing all Dwarf RecipeList of the PlayerInstance.
*/
public RecipeList[] getDwarvenRecipeBook()
public Collection<RecipeList> getDwarvenRecipeBook()
{
return _dwarvenRecipeBook.values().toArray(new RecipeList[_dwarvenRecipeBook.values().size()]);
return _dwarvenRecipeBook.values();
}
/**
@@ -1523,9 +1523,9 @@ public class PlayerInstance extends Playable
}
/**
* @return a table containing all ShortCut of the PlayerInstance.
* @return a collection containing all ShortCut of the PlayerInstance.
*/
public Shortcut[] getAllShortCuts()
public Collection<Shortcut> getAllShortCuts()
{
return _shortCuts.getAllShortCuts();
}
@@ -2179,7 +2179,7 @@ public class PlayerInstance extends Playable
}
// Equip or unEquip
ItemInstance[] items = null;
List<ItemInstance> items = null;
final boolean isEquiped = item.isEquipped();
final int oldInvLimit = getInventoryLimit();
SystemMessage sm = null;
@@ -2248,7 +2248,7 @@ public class PlayerInstance extends Playable
broadcastUserInfo();
final InventoryUpdate iu = new InventoryUpdate();
iu.addItems(Arrays.asList(items));
iu.addItems(items);
sendInventoryUpdate(iu);
if (abortAttack)
@@ -5817,9 +5817,9 @@ public class PlayerInstance extends Playable
return false;
}
final ItemInstance[] unequiped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final List<ItemInstance> unequipped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped)
for (ItemInstance itm : unequipped)
{
iu.addModifiedItem(itm);
}
@@ -5829,19 +5829,20 @@ public class PlayerInstance extends Playable
broadcastUserInfo();
// This can be 0 if the user pressed the right mousebutton twice very fast.
if (unequiped.length > 0)
if (!unequipped.isEmpty())
{
final SystemMessage sm;
if (unequiped[0].getEnchantLevel() > 0)
final ItemInstance unequippedItem = unequipped.get(0);
if (unequippedItem.getEnchantLevel() > 0)
{
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel());
sm.addItemName(unequiped[0]);
sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequippedItem);
}
else
{
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]);
sm.addItemName(unequippedItem);
}
sendPacket(sm);
}
@@ -5857,9 +5858,9 @@ public class PlayerInstance extends Playable
final ItemInstance sld = _inventory.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
if (sld != null)
{
final ItemInstance[] unequiped = _inventory.unEquipItemInBodySlotAndRecord(sld.getItem().getBodyPart());
final List<ItemInstance> unequipped = _inventory.unEquipItemInBodySlotAndRecord(sld.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped)
for (ItemInstance itm : unequipped)
{
iu.addModifiedItem(itm);
}
@@ -5869,19 +5870,20 @@ public class PlayerInstance extends Playable
broadcastUserInfo();
// this can be 0 if the user pressed the right mousebutton twice very fast
if (unequiped.length > 0)
if (!unequipped.isEmpty())
{
SystemMessage sm = null;
if (unequiped[0].getEnchantLevel() > 0)
final ItemInstance unequippedItem = unequipped.get(0);
if (unequippedItem.getEnchantLevel() > 0)
{
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel());
sm.addItemName(unequiped[0]);
sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequippedItem);
}
else
{
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]);
sm.addItemName(unequippedItem);
}
sendPacket(sm);
}

View File

@@ -22,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -163,7 +164,7 @@ public class Clan implements IIdentifiable, INamable
private ClanRewardBonus _lastMembersOnlineBonus = null;
private ClanRewardBonus _lastHuntingBonus = null;
private ClanVariables _vars;
private volatile ClanVariables _vars;
/**
* Called if a clan is referenced only by id. In this case all other data needs to be fetched from db
@@ -1289,9 +1290,13 @@ public class Clan implements IIdentifiable, INamable
/**
* @return all the clan skills.
*/
public Skill[] getAllSkills()
public Collection<Skill> getAllSkills()
{
return _skills.values().toArray(new Skill[_skills.values().size()]);
if (_skills == null)
{
return Collections.emptyList();
}
return _skills.values();
}
/**
@@ -1794,7 +1799,7 @@ public class Clan implements IIdentifiable, INamable
*/
public SubPledge getSubPledge(int pledgeType)
{
return _subPledges.get(pledgeType);
return _subPledges == null ? null : _subPledges.get(pledgeType);
}
/**
@@ -1804,6 +1809,11 @@ public class Clan implements IIdentifiable, INamable
*/
public SubPledge getSubPledge(String pledgeName)
{
if (_subPledges == null)
{
return null;
}
for (SubPledge sp : _subPledges.values())
{
if (sp.getName().equalsIgnoreCase(pledgeName))
@@ -1818,9 +1828,13 @@ public class Clan implements IIdentifiable, INamable
* Used to retrieve all subPledges
* @return
*/
public SubPledge[] getAllSubPledges()
public Collection<SubPledge> getAllSubPledges()
{
return _subPledges.values().toArray(new SubPledge[_subPledges.values().size()]);
if (_subPledges == null)
{
return Collections.emptyList();
}
return _subPledges.values();
}
public SubPledge createSubPledge(PlayerInstance player, int pledgeTypeValue, int leaderId, String subPledgeName)
@@ -2047,9 +2061,9 @@ public class Clan implements IIdentifiable, INamable
/**
* @return all RankPrivs.
*/
public RankPrivs[] getAllRankPrivs()
public Collection<RankPrivs> getAllRankPrivs()
{
return _privs.values().toArray(new RankPrivs[_privs.values().size()]);
return _privs == null ? Collections.emptyList() : _privs.values();
}
public int getLeaderSubPledge(int leaderId)
@@ -2794,7 +2808,7 @@ public class Clan implements IIdentifiable, INamable
return false;
}
public SubPledgeSkill[] getAllSubSkills()
public List<SubPledgeSkill> getAllSubSkills()
{
final List<SubPledgeSkill> list = new LinkedList<>();
for (Skill skill : _subPledgeSkills.values())
@@ -2808,7 +2822,7 @@ public class Clan implements IIdentifiable, INamable
list.add(new SubPledgeSkill(subunit.getId(), skill.getId(), skill.getLevel()));
}
}
return list.toArray(new SubPledgeSkill[list.size()]);
return list;
}
public void setNewLeaderId(int objectId, boolean storeInDb)

View File

@@ -2937,9 +2937,8 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
// Destroy the quantity of items wanted
if (item.isEquipped())
{
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped)
for (ItemInstance itm : player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart()))
{
iu.addModifiedItem(itm);
}

View File

@@ -347,7 +347,7 @@ public class ItemAuctionInstance
return _auctions.get(auctionId);
}
public ItemAuction[] getAuctionsByBidder(int bidderObjId)
public ArrayList<ItemAuction> getAuctionsByBidder(int bidderObjId)
{
final Collection<ItemAuction> auctions = getAuctions();
final ArrayList<ItemAuction> stack = new ArrayList<>(auctions.size());
@@ -362,7 +362,7 @@ public class ItemAuctionInstance
}
}
}
return stack.toArray(new ItemAuction[stack.size()]);
return stack;
}
public Collection<ItemAuction> getAuctions()

View File

@@ -25,8 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.logging.Level;
@@ -143,7 +141,7 @@ public abstract class Inventory extends ItemContainer
private static final class ChangeRecorder implements PaperdollListener
{
private final Inventory _inventory;
private final Set<ItemInstance> _changed = ConcurrentHashMap.newKeySet();
private final List<ItemInstance> _changed = new ArrayList<>(1);
/**
* Constructor of the ChangeRecorder
@@ -183,9 +181,9 @@ public abstract class Inventory extends ItemContainer
* Returns alterations in inventory
* @return ItemInstance[] : array of altered items
*/
public ItemInstance[] getChangedItems()
public List<ItemInstance> getChangedItems()
{
return _changed.toArray(new ItemInstance[_changed.size()]);
return _changed;
}
}
@@ -1527,12 +1525,11 @@ public abstract class Inventory extends ItemContainer
* Unequips item in body slot and returns alterations.<br>
* <b>If you dont need return value use {@link Inventory#unEquipItemInBodySlot(int)} instead</b>
* @param slot : int designating the slot of the paperdoll
* @return ItemInstance[] : list of changes
* @return List<ItemInstance> : List of changes
*/
public ItemInstance[] unEquipItemInBodySlotAndRecord(int slot)
public List<ItemInstance> unEquipItemInBodySlotAndRecord(int slot)
{
final ChangeRecorder recorder = newRecorder();
try
{
unEquipItemInBodySlot(slot);
@@ -1558,12 +1555,11 @@ public abstract class Inventory extends ItemContainer
* Unequips item in slot and returns alterations<br>
* <b>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</b>
* @param slot : int designating the slot
* @return ItemInstance[] : list of items altered
* @return List<ItemInstance> : List of items altered
*/
public ItemInstance[] unEquipItemInSlotAndRecord(int slot)
public List<ItemInstance> unEquipItemInSlotAndRecord(int slot)
{
final ChangeRecorder recorder = newRecorder();
try
{
unEquipItemInSlot(slot);
@@ -1731,12 +1727,11 @@ public abstract class Inventory extends ItemContainer
* Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(ItemInstance)} instead</b>
* @param item : ItemInstance corresponding to the item
* @return ItemInstance[] : list of alterations
* @return List<ItemInstance> : List of alterations
*/
public ItemInstance[] equipItemAndRecord(ItemInstance item)
public List<ItemInstance> equipItemAndRecord(ItemInstance item)
{
final ChangeRecorder recorder = newRecorder();
try
{
equipItem(item);

View File

@@ -1367,9 +1367,8 @@ public class ItemInstance extends WorldObject
// unequip
if (isEquipped())
{
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped)
for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
{
iu.addModifiedItem(item);
}
@@ -1793,9 +1792,8 @@ public class ItemInstance extends WorldObject
{
if (isEquipped())
{
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped)
for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
{
iu.addModifiedItem(item);
}

View File

@@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -78,7 +79,7 @@ public class GameClient extends ChannelInboundHandler<GameClient>
private PlayerInstance _player;
private SecondaryPasswordAuth _secondaryAuth;
private ClientHardwareInfoHolder _hardwareInfo;
private CharSelectInfoPackage[] _charSlotMapping = null;
private List<CharSelectInfoPackage> _charSlotMapping = null;
private volatile boolean _isDetached = false;
private boolean _isAuthedGG;
private boolean _protocolOk;
@@ -562,21 +563,18 @@ public class GameClient extends ChannelInboundHandler<GameClient>
return player;
}
/**
* @param chars
*/
public void setCharSelection(CharSelectInfoPackage[] chars)
public void setCharSelection(List<CharSelectInfoPackage> characters)
{
_charSlotMapping = chars;
_charSlotMapping = characters;
}
public CharSelectInfoPackage getCharSelection(int charslot)
{
if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.length))
if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.size()))
{
return null;
}
return _charSlotMapping[charslot];
return _charSlotMapping.get(charslot);
}
public SecondaryPasswordAuth getSecondaryAuth()

View File

@@ -202,9 +202,8 @@ public class RequestCrystallizeItem implements IClientIncomingPacket
SystemMessage sm;
if (itemToRemove.isEquipped())
{
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped)
for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
{
iu.addModifiedItem(item);
}

View File

@@ -193,9 +193,8 @@ public class RequestDestroyItem implements IClientIncomingPacket
client.sendPacket(sm);
}
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped)
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
{
iu.addModifiedItem(itm);
}

View File

@@ -310,12 +310,10 @@ public class RequestEnchantItem implements IClientIncomingPacket
client.sendPacket(sm);
}
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
for (ItemInstance itm : unequiped)
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()))
{
iu.addModifiedItem(itm);
}
player.sendInventoryUpdate(iu);
player.broadcastUserInfo();
}

View File

@@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.Clan.RankPrivs;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.serverpackets.PledgePowerGradeList;
@@ -47,8 +46,7 @@ public class RequestPledgePowerGradeList implements IClientIncomingPacket
final Clan clan = player.getClan();
if (clan != null)
{
final RankPrivs[] privs = clan.getAllRankPrivs();
player.sendPacket(new PledgePowerGradeList(privs));
player.sendPacket(new PledgePowerGradeList(clan.getAllRankPrivs()));
}
}
}

View File

@@ -18,9 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import static org.l2jmobius.gameserver.model.itemcontainer.Inventory.MAX_ADENA;
import java.util.Arrays;
import java.util.List;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.xml.RecipeData;
@@ -100,14 +97,11 @@ public class RequestRecipeShopListSet implements IClientIncomingPacket
return;
}
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
player.getManufactureItems().clear();
for (ManufactureItem i : _items)
{
final RecipeList list = RecipeData.getInstance().getRecipeList(i.getRecipeId());
if (!dwarfRecipes.contains(list) && !commonRecipes.contains(list))
if (!player.getDwarvenRecipeBook().contains(list) && !player.getCommonRecipeBook().contains(list))
{
Util.handleIllegalPlayerAction(player, "Warning!! Player " + player.getName() + " of account " + player.getAccountName() + " tried to set recipe which he dont have.", Config.DEFAULT_PUNISH);
return;

View File

@@ -109,8 +109,7 @@ public class RequestRefine extends AbstractRefinePacket
final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped())
{
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
for (ItemInstance itm : unequiped)
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
{
iu.addModifiedItem(itm);
}

View File

@@ -92,8 +92,7 @@ public class RequestRefineCancel implements IClientIncomingPacket
final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped())
{
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
for (ItemInstance itm : unequiped)
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
{
iu.addModifiedItem(itm);
}

View File

@@ -16,7 +16,7 @@
*/
package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Arrays;
import java.util.List;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.PlayerCondOverride;
@@ -99,27 +99,28 @@ public class RequestUnEquipItem implements IClientIncomingPacket
return;
}
final ItemInstance[] unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
player.broadcastUserInfo();
// This can be 0 if the user pressed the right mouse button twice very fast.
if (unequipped.length > 0)
final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
if (!unequipped.isEmpty())
{
SystemMessage sm = null;
if (unequipped[0].getEnchantLevel() > 0)
final ItemInstance unequippedItem = unequipped.get(0);
if (unequippedItem.getEnchantLevel() > 0)
{
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequipped[0].getEnchantLevel());
sm.addInt(unequippedItem.getEnchantLevel());
}
else
{
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
}
sm.addItemName(unequipped[0]);
sm.addItemName(unequippedItem);
client.sendPacket(sm);
final InventoryUpdate iu = new InventoryUpdate();
iu.addItems(Arrays.asList(unequipped));
iu.addItems(unequipped);
player.sendInventoryUpdate(iu);
}
}

View File

@@ -69,7 +69,7 @@ public abstract class AbstractInventoryUpdate extends AbstractItemPacket
_items.put(item.getObjectId(), new ItemInfo(item, 3));
}
public void addItems(List<ItemInstance> items)
public void addItems(Collection<ItemInstance> items)
{
for (ItemInstance item : items)
{

View File

@@ -47,7 +47,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
private final String _loginName;
private final int _sessionId;
private int _activeId;
private final CharSelectInfoPackage[] _characterPackages;
private final List<CharSelectInfoPackage> _characterPackages;
private static final int[] PAPERDOLL_ORDER_VISUAL_ID = new int[]
{
@@ -83,7 +83,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
_activeId = activeId;
}
public CharSelectInfoPackage[] getCharInfo()
public List<CharSelectInfoPackage> getCharInfo()
{
return _characterPackages;
}
@@ -93,7 +93,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
{
OutgoingPackets.CHARACTER_SELECTION_INFO.writeId(packet);
final int size = _characterPackages.length;
final int size = _characterPackages.size();
packet.writeD(size); // Created character count
packet.writeD(Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT); // Can prevent players from creating new characters (if 0); (if 1, the client will ask if chars may be created (0x13) Response: (0x0D) )
@@ -107,9 +107,9 @@ public class CharSelectionInfo implements IClientOutgoingPacket
{
for (int i = 0; i < size; i++)
{
if (lastAccess < _characterPackages[i].getLastAccess())
if (lastAccess < _characterPackages.get(i).getLastAccess())
{
lastAccess = _characterPackages[i].getLastAccess();
lastAccess = _characterPackages.get(i).getLastAccess();
_activeId = i;
}
}
@@ -117,7 +117,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
for (int i = 0; i < size; i++)
{
final CharSelectInfoPackage charInfoPackage = _characterPackages[i];
final CharSelectInfoPackage charInfoPackage = _characterPackages.get(i);
packet.writeS(charInfoPackage.getName()); // Character name
packet.writeD(charInfoPackage.getObjectId()); // Character ID
packet.writeS(_loginName); // Account name
@@ -218,7 +218,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
return true;
}
private static CharSelectInfoPackage[] loadCharacterSelectInfo(String loginName)
private static List<CharSelectInfoPackage> loadCharacterSelectInfo(String loginName)
{
CharSelectInfoPackage charInfopackage;
final List<CharSelectInfoPackage> characterList = new LinkedList<>();
@@ -244,13 +244,13 @@ public class CharSelectionInfo implements IClientOutgoingPacket
}
}
}
return characterList.toArray(new CharSelectInfoPackage[characterList.size()]);
}
catch (Exception e)
{
LOGGER.log(Level.WARNING, "Could not restore char info: " + e.getMessage(), e);
}
return new CharSelectInfoPackage[0];
return characterList;
}
private static void loadCharacterSubclassInfo(CharSelectInfoPackage charInfopackage, int objectId, int activeClassId)

View File

@@ -16,6 +16,8 @@
*/
package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.sql.ClanTable;
import org.l2jmobius.gameserver.model.clan.Clan;
@@ -39,12 +41,12 @@ public class ExPledgeRecruitInfo implements IClientOutgoingPacket
{
OutgoingPackets.EX_PLEDGE_RECRUIT_INFO.writeId(packet);
final SubPledge[] subPledges = _clan.getAllSubPledges();
final Collection<SubPledge> subPledges = _clan.getAllSubPledges();
packet.writeS(_clan.getName());
packet.writeS(_clan.getLeaderName());
packet.writeD(_clan.getLevel());
packet.writeD(_clan.getMembersCount());
packet.writeD(subPledges.length);
packet.writeD(subPledges.size());
for (SubPledge subPledge : subPledges)
{
packet.writeD(subPledge.getId());

View File

@@ -16,15 +16,17 @@
*/
package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.clan.Clan.RankPrivs;
import org.l2jmobius.gameserver.network.OutgoingPackets;
public class PledgePowerGradeList implements IClientOutgoingPacket
{
private final RankPrivs[] _privs;
private final Collection<RankPrivs> _privs;
public PledgePowerGradeList(RankPrivs[] privs)
public PledgePowerGradeList(Collection<RankPrivs> privs)
{
_privs = privs;
}
@@ -33,8 +35,7 @@ public class PledgePowerGradeList implements IClientOutgoingPacket
public boolean write(PacketWriter packet)
{
OutgoingPackets.PLEDGE_POWER_GRADE_LIST.writeId(packet);
packet.writeD(_privs.length);
packet.writeD(_privs.size());
for (RankPrivs temp : _privs)
{
packet.writeD(temp.getRank());

View File

@@ -16,6 +16,9 @@
*/
package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.skills.Skill;
@@ -26,8 +29,8 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
*/
public class PledgeSkillList implements IClientOutgoingPacket
{
private final Skill[] _skills;
private final SubPledgeSkill[] _subSkills;
private final Collection<Skill> _skills;
private final List<SubPledgeSkill> _subSkills;
public static class SubPledgeSkill
{
@@ -53,9 +56,8 @@ public class PledgeSkillList implements IClientOutgoingPacket
public boolean write(PacketWriter packet)
{
OutgoingPackets.PLEDGE_SKILL_LIST.writeId(packet);
packet.writeD(_skills.length);
packet.writeD(_subSkills.length); // Squad skill length
packet.writeD(_skills.size());
packet.writeD(_subSkills.size()); // Squad skill length
for (Skill sk : _skills)
{
packet.writeD(sk.getDisplayId());

View File

@@ -48,7 +48,7 @@ public class PrivateStoreListSell extends AbstractItemPacket
packet.writeD(_seller.getSellList().isPackaged() ? 1 : 0);
packet.writeQ(_player.getAdena());
packet.writeD(0x00);
packet.writeD(_seller.getSellList().getItems().length);
packet.writeD(_seller.getSellList().getItems().size());
for (TradeItem item : _seller.getSellList().getItems())
{
writeItem(packet, item);

View File

@@ -29,7 +29,7 @@ public class PrivateStoreManageListBuy extends AbstractItemPacket
private final int _objId;
private final long _playerAdena;
private final Collection<ItemInstance> _itemList;
private final TradeItem[] _buyList;
private final Collection<TradeItem> _buyList;
public PrivateStoreManageListBuy(PlayerInstance player)
{
@@ -54,7 +54,7 @@ public class PrivateStoreManageListBuy extends AbstractItemPacket
packet.writeQ(item.getItem().getReferencePrice() * 2);
}
packet.writeD(_buyList.length); // count for all items already added for buy
packet.writeD(_buyList.size()); // count for all items already added for buy
for (TradeItem item : _buyList)
{
writeItem(packet, item);

View File

@@ -29,7 +29,7 @@ public class PrivateStoreManageListSell extends AbstractItemPacket
private final long _playerAdena;
private final boolean _packageSale;
private final Collection<TradeItem> _itemList;
private final TradeItem[] _sellList;
private final Collection<TradeItem> _sellList;
public PrivateStoreManageListSell(PlayerInstance player, boolean isPackageSale)
{
@@ -57,7 +57,7 @@ public class PrivateStoreManageListSell extends AbstractItemPacket
packet.writeQ(item.getItem().getReferencePrice() * 2);
}
packet.writeD(_sellList.length); // count for any items already added for sell
packet.writeD(_sellList.size()); // count for any items already added for sell
for (TradeItem item : _sellList)
{
writeItem(packet, item);

View File

@@ -16,13 +16,15 @@
*/
package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.RecipeList;
import org.l2jmobius.gameserver.network.OutgoingPackets;
public class RecipeBookItemList implements IClientOutgoingPacket
{
private RecipeList[] _recipes;
private Collection<RecipeList> _recipes;
private final boolean _isDwarvenCraft;
private final int _maxMp;
@@ -32,7 +34,7 @@ public class RecipeBookItemList implements IClientOutgoingPacket
_maxMp = maxMp;
}
public void addRecipes(RecipeList[] recipeBook)
public void addRecipes(Collection<RecipeList> recipeBook)
{
_recipes = recipeBook;
}
@@ -51,11 +53,13 @@ public class RecipeBookItemList implements IClientOutgoingPacket
}
else
{
packet.writeD(_recipes.length); // number of items in recipe book
for (int i = 0; i < _recipes.length; i++)
packet.writeD(_recipes.size()); // number of items in recipe book
int count = 0;
for (RecipeList recipe : _recipes)
{
packet.writeD(_recipes[i].getId());
packet.writeD(i + 1);
count++;
packet.writeD(recipe.getId());
packet.writeD(count);
}
}
return true;

View File

@@ -16,6 +16,7 @@
*/
package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import java.util.Iterator;
import org.l2jmobius.commons.network.PacketWriter;
@@ -28,7 +29,7 @@ public class RecipeShopManageList implements IClientOutgoingPacket
{
private final PlayerInstance _seller;
private final boolean _isDwarven;
private RecipeList[] _recipes;
private Collection<RecipeList> _recipes;
public RecipeShopManageList(PlayerInstance seller, boolean isDwarven)
{
@@ -73,13 +74,13 @@ public class RecipeShopManageList implements IClientOutgoingPacket
}
else
{
packet.writeD(_recipes.length); // number of items in recipe book
for (int i = 0; i < _recipes.length; i++)
packet.writeD(_recipes.size()); // number of items in recipe book
int count = 0;
for (RecipeList recipe : _recipes)
{
final RecipeList temp = _recipes[i];
packet.writeD(temp.getId());
packet.writeD(i + 1);
count++;
packet.writeD(recipe.getId());
packet.writeD(count);
}
}

View File

@@ -16,6 +16,8 @@
*/
package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.Shortcut;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -23,7 +25,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
public class ShortCutInit implements IClientOutgoingPacket
{
private Shortcut[] _shortCuts;
private Collection<Shortcut> _shortCuts;
public ShortCutInit(PlayerInstance player)
{
@@ -40,7 +42,7 @@ public class ShortCutInit implements IClientOutgoingPacket
{
OutgoingPackets.SHORT_CUT_INIT.writeId(packet);
packet.writeD(_shortCuts.length);
packet.writeD(_shortCuts.size());
for (Shortcut sc : _shortCuts)
{
packet.writeD(sc.getType().ordinal());

View File

@@ -16,6 +16,8 @@
*/
package org.l2jmobius.gameserver.network.serverpackets.attributechange;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.ItemInfo;
import org.l2jmobius.gameserver.network.OutgoingPackets;
@@ -26,13 +28,13 @@ import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
*/
public class ExChangeAttributeItemList extends AbstractItemPacket
{
private final ItemInfo[] _itemsList;
private final List<ItemInfo> _itemsList;
private final int _itemId;
public ExChangeAttributeItemList(int itemId, ItemInfo[] itemsList)
public ExChangeAttributeItemList(int itemId, List<ItemInfo> itemList)
{
_itemId = itemId;
_itemsList = itemsList;
_itemsList = itemList;
}
@Override
@@ -40,7 +42,7 @@ public class ExChangeAttributeItemList extends AbstractItemPacket
{
OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet);
packet.writeD(_itemId);
packet.writeD(_itemsList.length);
packet.writeD(_itemsList.size());
for (ItemInfo item : _itemsList)
{
writeItem(packet, item);