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
@@ -594,9 +594,8 @@ public class AdminMobGroup implements IAdminCommandHandler
private void showGroupList(PlayerInstance activeChar) private void showGroupList(PlayerInstance activeChar)
{ {
final MobGroup[] mobGroupList = MobGroupTable.getInstance().getGroups();
BuilderUtil.sendSysMessage(activeChar, "======= <Mob Groups> ======="); BuilderUtil.sendSysMessage(activeChar, "======= <Mob Groups> =======");
for (MobGroup mobGroup : mobGroupList) for (MobGroup mobGroup : MobGroupTable.getInstance().getGroups())
{ {
activeChar.sendMessage(mobGroup.getGroupId() + ": " + mobGroup.getActiveMobCount() + " alive out of " + mobGroup.getMaxMobCount() + " of NPC ID " + mobGroup.getTemplate().getId() + " (" + mobGroup.getStatus() + ")"); activeChar.sendMessage(mobGroup.getGroupId() + ": " + mobGroup.getActiveMobCount() + " alive out of " + mobGroup.getMaxMobCount() + " of NPC ID " + mobGroup.getTemplate().getId() + " (" + mobGroup.getStatus() + ")");
} }
@@ -99,9 +99,8 @@ public class ItemAuctionLink implements IBypassHandler
} }
else if ("cancel".equalsIgnoreCase(cmd)) else if ("cancel".equalsIgnoreCase(cmd))
{ {
final ItemAuction[] auctions = au.getAuctionsByBidder(player.getObjectId());
boolean returned = false; boolean returned = false;
for (ItemAuction auction : auctions) for (ItemAuction auction : au.getAuctionsByBidder(player.getObjectId()))
{ {
if (auction.cancelBid(player)) if (auction.cancelBid(player))
{ {
@@ -16,6 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.List;
import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -84,7 +86,7 @@ public class ConvertItem extends AbstractEffect
final int enchantLevel = wpn.getEnchantLevel(); final int enchantLevel = wpn.getEnchantLevel();
final AttributeHolder elementals = wpn.getAttributes() == null ? null : wpn.getAttackAttribute(); final AttributeHolder elementals = wpn.getAttributes() == null ? null : wpn.getAttackAttribute();
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart()); final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance unequippedItem : unequiped) for (ItemInstance unequippedItem : unequiped)
{ {
@@ -92,10 +94,11 @@ public class ConvertItem extends AbstractEffect
} }
player.sendInventoryUpdate(iu); player.sendInventoryUpdate(iu);
if (unequiped.length <= 0) if (unequiped.isEmpty())
{ {
return; return;
} }
byte count = 0; byte count = 0;
for (ItemInstance unequippedItem : unequiped) for (ItemInstance unequippedItem : unequiped)
{ {
@@ -120,7 +123,7 @@ public class ConvertItem extends AbstractEffect
player.sendPacket(sm); player.sendPacket(sm);
} }
if (count == unequiped.length) if (count == unequiped.size())
{ {
return; return;
} }
@@ -16,6 +16,7 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -67,11 +68,11 @@ public class Disarmor extends AbstractEffect
} }
final PlayerInstance player = effected.getActingPlayer(); final PlayerInstance player = effected.getActingPlayer();
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot); final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -79,20 +80,21 @@ public class Disarmor extends AbstractEffect
player.broadcastUserInfo(); player.broadcastUserInfo();
SystemMessage sm = null; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
player.sendPacket(sm); player.sendPacket(sm);
effected.getInventory().blockItemSlot(_slot); effected.getInventory().blockItemSlot(_slot);
_unequippedItems.put(effected.getObjectId(), unequiped[0].getObjectId()); _unequippedItems.put(effected.getObjectId(), unequippedItem.getObjectId());
} }
} }
@@ -81,7 +81,7 @@ public class ChangeAttributeCrystal implements IItemHandler
return false; return false;
} }
player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList.toArray(new ItemInfo[itemList.size()]))); player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList));
return true; return true;
} }
} }
@@ -72,13 +72,13 @@ public class Recipes implements IItemHandler
{ {
canCraft = player.hasDwarvenCraft(); canCraft = player.hasDwarvenCraft();
recipeLevel = (rp.getLevel() > player.getDwarvenCraft()); recipeLevel = (rp.getLevel() > player.getDwarvenCraft());
recipeLimit = (player.getDwarvenRecipeBook().length >= player.getDwarfRecipeLimit()); recipeLimit = (player.getDwarvenRecipeBook().size() >= player.getDwarfRecipeLimit());
} }
else else
{ {
canCraft = player.hasCommonCraft(); canCraft = player.hasCommonCraft();
recipeLevel = (rp.getLevel() > player.getCommonCraft()); recipeLevel = (rp.getLevel() > player.getCommonCraft());
recipeLimit = (player.getCommonRecipeBook().length >= player.getCommonRecipeLimit()); recipeLimit = (player.getCommonRecipeBook().size() >= player.getCommonRecipeLimit());
} }
if (!canCraft) if (!canCraft)
@@ -17,7 +17,6 @@
package org.l2jmobius.gameserver; package org.l2jmobius.gameserver;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -89,9 +88,7 @@ public class RecipeController
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(manufacturer.getDwarvenRecipeBook()); if (!manufacturer.getDwarvenRecipeBook().contains(recipeList) && !manufacturer.getCommonRecipeBook().contains(recipeList))
final List<RecipeList> commonRecipes = Arrays.asList(manufacturer.getCommonRecipeBook());
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
{ {
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
return; return;
@@ -134,9 +131,7 @@ public class RecipeController
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook()); if (!player.getDwarvenRecipeBook().contains(recipeList) && !player.getCommonRecipeBook().contains(recipeList))
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
{ {
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
return; return;
@@ -90,8 +90,7 @@ public class MacroList implements IRestorable
deleteMacroFromDb(removed); deleteMacroFromDb(removed);
} }
final Shortcut[] allShortCuts = _owner.getAllShortCuts(); for (Shortcut sc : _owner.getAllShortCuts())
for (Shortcut sc : allShortCuts)
{ {
if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO)) if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
{ {
@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model; package org.l2jmobius.gameserver.model;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -67,9 +68,9 @@ public class MobGroupTable
return null; 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) public boolean removeGroup(int groupKey)
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.logging.Level; import java.util.logging.Level;
@@ -46,9 +47,9 @@ public class ShortCuts implements IRestorable
_owner = owner; _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) public Shortcut getShortCut(int slot, int page)
@@ -105,9 +105,9 @@ public class TradeList
/** /**
* @return all items from TradeList * @return all items from TradeList
*/ */
public TradeItem[] getItems() public Collection<TradeItem> getItems()
{ {
return _items.toArray(new TradeItem[_items.size()]); return _items;
} }
/** /**
@@ -857,7 +857,7 @@ public class TradeList
final InventoryUpdate playerIU = new InventoryUpdate(); final InventoryUpdate playerIU = new InventoryUpdate();
long totalPrice = 0; long totalPrice = 0;
final TradeItem[] sellerItems = _items.toArray(new TradeItem[0]); final TradeItem[] sellerItems = _items.toArray(new TradeItem[_items.size()]);
for (ItemRequest item : requestedItems) for (ItemRequest item : requestedItems)
{ {
// searching item in tradelist using itemId // searching item in tradelist using itemId
@@ -1277,19 +1277,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();
} }
/** /**
@@ -1557,9 +1557,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(); return _shortCuts.getAllShortCuts();
} }
@@ -2213,7 +2213,7 @@ public class PlayerInstance extends Playable
} }
// Equip or unEquip // Equip or unEquip
ItemInstance[] items = null; List<ItemInstance> items = null;
final boolean isEquiped = item.isEquipped(); final boolean isEquiped = item.isEquipped();
final int oldInvLimit = getInventoryLimit(); final int oldInvLimit = getInventoryLimit();
SystemMessage sm = null; SystemMessage sm = null;
@@ -2282,7 +2282,7 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
iu.addItems(Arrays.asList(items)); iu.addItems(items);
sendInventoryUpdate(iu); sendInventoryUpdate(iu);
if (abortAttack) if (abortAttack)
@@ -5859,9 +5859,9 @@ public class PlayerInstance extends Playable
return false; return false;
} }
final ItemInstance[] unequiped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart()); final List<ItemInstance> unequipped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -5871,19 +5871,20 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
// This can be 0 if the user pressed the right mousebutton twice very fast. // This can be 0 if the user pressed the right mousebutton twice very fast.
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
final SystemMessage sm; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
sendPacket(sm); sendPacket(sm);
} }
@@ -5899,9 +5900,9 @@ public class PlayerInstance extends Playable
final ItemInstance sld = _inventory.getPaperdollItem(Inventory.PAPERDOLL_LHAND); final ItemInstance sld = _inventory.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
if (sld != null) 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(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -5911,19 +5912,20 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
// this can be 0 if the user pressed the right mousebutton twice very fast // this can be 0 if the user pressed the right mousebutton twice very fast
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
SystemMessage sm = null; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
sendPacket(sm); sendPacket(sm);
} }
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -1288,13 +1289,13 @@ public class Clan implements IIdentifiable, INamable
/** /**
* @return all the clan skills. * @return all the clan skills.
*/ */
public Skill[] getAllSkills() public Collection<Skill> getAllSkills()
{ {
if (_skills == null) if (_skills == null)
{ {
return new Skill[0]; return Collections.emptyList();
} }
return _skills.values().toArray(new Skill[_skills.values().size()]); return _skills.values();
} }
/** /**
@@ -1829,13 +1830,13 @@ public class Clan implements IIdentifiable, INamable
* Used to retrieve all subPledges * Used to retrieve all subPledges
* @return * @return
*/ */
public SubPledge[] getAllSubPledges() public Collection<SubPledge> getAllSubPledges()
{ {
if (_subPledges == null) if (_subPledges == null)
{ {
return new SubPledge[0]; return Collections.emptyList();
} }
return _subPledges.values().toArray(new SubPledge[_subPledges.values().size()]); return _subPledges.values();
} }
public SubPledge createSubPledge(PlayerInstance player, int pledgeTypeValue, int leaderId, String subPledgeName) public SubPledge createSubPledge(PlayerInstance player, int pledgeTypeValue, int leaderId, String subPledgeName)
@@ -2068,9 +2069,9 @@ public class Clan implements IIdentifiable, INamable
/** /**
* @return all RankPrivs. * @return all RankPrivs.
*/ */
public RankPrivs[] getAllRankPrivs() public Collection<RankPrivs> getAllRankPrivs()
{ {
return _privs == null ? new RankPrivs[0] : _privs.values().toArray(new RankPrivs[_privs.values().size()]); return _privs == null ? Collections.emptyList() : _privs.values();
} }
public int getLeaderSubPledge(int leaderId) public int getLeaderSubPledge(int leaderId)
@@ -2930,7 +2931,7 @@ public class Clan implements IIdentifiable, INamable
return false; return false;
} }
public SubPledgeSkill[] getAllSubSkills() public List<SubPledgeSkill> getAllSubSkills()
{ {
final List<SubPledgeSkill> list = new LinkedList<>(); final List<SubPledgeSkill> list = new LinkedList<>();
for (Skill skill : _subPledgeSkills.values()) for (Skill skill : _subPledgeSkills.values())
@@ -2944,7 +2945,7 @@ public class Clan implements IIdentifiable, INamable
list.add(new SubPledgeSkill(subunit.getId(), skill.getId(), skill.getLevel())); 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) public void setNewLeaderId(int objectId, boolean storeInDb)
@@ -2962,9 +2962,8 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
// Destroy the quantity of items wanted // Destroy the quantity of items wanted
if (item.isEquipped()) if (item.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart()))
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -347,7 +347,7 @@ public class ItemAuctionInstance
return _auctions.get(auctionId); return _auctions.get(auctionId);
} }
public ItemAuction[] getAuctionsByBidder(int bidderObjId) public ArrayList<ItemAuction> getAuctionsByBidder(int bidderObjId)
{ {
final Collection<ItemAuction> auctions = getAuctions(); final Collection<ItemAuction> auctions = getAuctions();
final ArrayList<ItemAuction> stack = new ArrayList<>(auctions.size()); 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() public Collection<ItemAuction> getAuctions()
@@ -25,8 +25,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.logging.Level; import java.util.logging.Level;
@@ -143,7 +141,7 @@ public abstract class Inventory extends ItemContainer
private static final class ChangeRecorder implements PaperdollListener private static final class ChangeRecorder implements PaperdollListener
{ {
private final Inventory _inventory; private final Inventory _inventory;
private final Set<ItemInstance> _changed = ConcurrentHashMap.newKeySet(); private final List<ItemInstance> _changed = new ArrayList<>(1);
/** /**
* Constructor of the ChangeRecorder * Constructor of the ChangeRecorder
@@ -183,9 +181,9 @@ public abstract class Inventory extends ItemContainer
* Returns alterations in inventory * Returns alterations in inventory
* @return ItemInstance[] : array of altered items * @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> * Unequips item in body slot and returns alterations.<br>
* <b>If you dont need return value use {@link Inventory#unEquipItemInBodySlot(int)} instead</b> * <b>If you dont need return value use {@link Inventory#unEquipItemInBodySlot(int)} instead</b>
* @param slot : int designating the slot of the paperdoll * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
unEquipItemInBodySlot(slot); unEquipItemInBodySlot(slot);
@@ -1558,12 +1555,11 @@ public abstract class Inventory extends ItemContainer
* Unequips item in slot and returns alterations<br> * Unequips item in slot and returns alterations<br>
* <b>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</b> * <b>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</b>
* @param slot : int designating the slot * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
unEquipItemInSlot(slot); unEquipItemInSlot(slot);
@@ -1731,12 +1727,11 @@ public abstract class Inventory extends ItemContainer
* Equips item and returns list of alterations<br> * Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(ItemInstance)} instead</b> * <b>If you don't need return value use {@link Inventory#equipItem(ItemInstance)} instead</b>
* @param item : ItemInstance corresponding to the item * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
equipItem(item); equipItem(item);
@@ -1370,9 +1370,8 @@ public class ItemInstance extends WorldObject
// unequip // unequip
if (isEquipped()) if (isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -1800,9 +1799,8 @@ public class ItemInstance extends WorldObject
{ {
if (isEquipped()) if (isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -78,7 +79,7 @@ public class GameClient extends ChannelInboundHandler<GameClient>
private PlayerInstance _player; private PlayerInstance _player;
private SecondaryPasswordAuth _secondaryAuth; private SecondaryPasswordAuth _secondaryAuth;
private ClientHardwareInfoHolder _hardwareInfo; private ClientHardwareInfoHolder _hardwareInfo;
private CharSelectInfoPackage[] _charSlotMapping = null; private List<CharSelectInfoPackage> _charSlotMapping = null;
private volatile boolean _isDetached = false; private volatile boolean _isDetached = false;
private boolean _isAuthedGG; private boolean _isAuthedGG;
private boolean _protocolOk; private boolean _protocolOk;
@@ -568,21 +569,18 @@ public class GameClient extends ChannelInboundHandler<GameClient>
return player; return player;
} }
/** public void setCharSelection(List<CharSelectInfoPackage> characters)
* @param chars
*/
public void setCharSelection(CharSelectInfoPackage[] chars)
{ {
_charSlotMapping = chars; _charSlotMapping = characters;
} }
public CharSelectInfoPackage getCharSelection(int charslot) public CharSelectInfoPackage getCharSelection(int charslot)
{ {
if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.length)) if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.size()))
{ {
return null; return null;
} }
return _charSlotMapping[charslot]; return _charSlotMapping.get(charslot);
} }
public SecondaryPasswordAuth getSecondaryAuth() public SecondaryPasswordAuth getSecondaryAuth()
@@ -202,9 +202,8 @@ public class RequestCrystallizeItem implements IClientIncomingPacket
SystemMessage sm; SystemMessage sm;
if (itemToRemove.isEquipped()) if (itemToRemove.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -193,9 +193,8 @@ public class RequestDestroyItem implements IClientIncomingPacket
client.sendPacket(sm); client.sendPacket(sm);
} }
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -309,12 +309,10 @@ public class RequestEnchantItem implements IClientIncomingPacket
client.sendPacket(sm); client.sendPacket(sm);
} }
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()); for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()))
for (ItemInstance itm : unequiped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
player.sendInventoryUpdate(iu); player.sendInventoryUpdate(iu);
player.broadcastUserInfo(); player.broadcastUserInfo();
} }
@@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan; 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.GameClient;
import org.l2jmobius.gameserver.network.serverpackets.PledgePowerGradeList; import org.l2jmobius.gameserver.network.serverpackets.PledgePowerGradeList;
@@ -47,8 +46,7 @@ public class RequestPledgePowerGradeList implements IClientIncomingPacket
final Clan clan = player.getClan(); final Clan clan = player.getClan();
if (clan != null) if (clan != null)
{ {
final RankPrivs[] privs = clan.getAllRankPrivs(); player.sendPacket(new PledgePowerGradeList(clan.getAllRankPrivs()));
player.sendPacket(new PledgePowerGradeList(privs));
} }
} }
} }
@@ -18,9 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import static org.l2jmobius.gameserver.model.itemcontainer.Inventory.MAX_ADENA; 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.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.xml.RecipeData; import org.l2jmobius.gameserver.data.xml.RecipeData;
@@ -100,14 +97,11 @@ public class RequestRecipeShopListSet implements IClientIncomingPacket
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
player.getManufactureItems().clear(); player.getManufactureItems().clear();
for (ManufactureItem i : _items) for (ManufactureItem i : _items)
{ {
final RecipeList list = RecipeData.getInstance().getRecipeList(i.getRecipeId()); 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); Util.handleIllegalPlayerAction(player, "Warning!! Player " + player.getName() + " of account " + player.getAccountName() + " tried to set recipe which he dont have.", Config.DEFAULT_PUNISH);
return; return;
@@ -109,8 +109,7 @@ public class RequestRefine extends AbstractRefinePacket
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped()) if (targetItem.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()); for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
for (ItemInstance itm : unequiped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -92,8 +92,7 @@ public class RequestRefineCancel implements IClientIncomingPacket
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped()) if (targetItem.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()); for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
for (ItemInstance itm : unequiped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -16,7 +16,7 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Arrays; import java.util.List;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.PlayerCondOverride; import org.l2jmobius.gameserver.model.PlayerCondOverride;
@@ -99,27 +99,28 @@ public class RequestUnEquipItem implements IClientIncomingPacket
return; return;
} }
final ItemInstance[] unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
player.broadcastUserInfo(); player.broadcastUserInfo();
// This can be 0 if the user pressed the right mouse button twice very fast. // 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; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequipped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
} }
sm.addItemName(unequipped[0]); sm.addItemName(unequippedItem);
client.sendPacket(sm); client.sendPacket(sm);
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
iu.addItems(Arrays.asList(unequipped)); iu.addItems(unequipped);
player.sendInventoryUpdate(iu); player.sendInventoryUpdate(iu);
} }
} }
@@ -69,7 +69,7 @@ public abstract class AbstractInventoryUpdate extends AbstractItemPacket
_items.put(item.getObjectId(), new ItemInfo(item, 3)); _items.put(item.getObjectId(), new ItemInfo(item, 3));
} }
public void addItems(List<ItemInstance> items) public void addItems(Collection<ItemInstance> items)
{ {
for (ItemInstance item : items) for (ItemInstance item : items)
{ {
@@ -47,7 +47,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
private final String _loginName; private final String _loginName;
private final int _sessionId; private final int _sessionId;
private int _activeId; private int _activeId;
private final CharSelectInfoPackage[] _characterPackages; private final List<CharSelectInfoPackage> _characterPackages;
private static final int[] PAPERDOLL_ORDER_VISUAL_ID = new int[] private static final int[] PAPERDOLL_ORDER_VISUAL_ID = new int[]
{ {
@@ -83,7 +83,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
_activeId = activeId; _activeId = activeId;
} }
public CharSelectInfoPackage[] getCharInfo() public List<CharSelectInfoPackage> getCharInfo()
{ {
return _characterPackages; return _characterPackages;
} }
@@ -93,7 +93,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
{ {
OutgoingPackets.CHARACTER_SELECTION_INFO.writeId(packet); OutgoingPackets.CHARACTER_SELECTION_INFO.writeId(packet);
final int size = _characterPackages.length; final int size = _characterPackages.size();
packet.writeD(size); // Created character count 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) ) 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++) 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; _activeId = i;
} }
} }
@@ -117,7 +117,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
for (int i = 0; i < size; i++) 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.writeS(charInfoPackage.getName()); // Character name
packet.writeD(charInfoPackage.getObjectId()); // Character ID packet.writeD(charInfoPackage.getObjectId()); // Character ID
packet.writeS(_loginName); // Account name packet.writeS(_loginName); // Account name
@@ -219,7 +219,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
return true; return true;
} }
private static CharSelectInfoPackage[] loadCharacterSelectInfo(String loginName) private static List<CharSelectInfoPackage> loadCharacterSelectInfo(String loginName)
{ {
CharSelectInfoPackage charInfopackage; CharSelectInfoPackage charInfopackage;
final List<CharSelectInfoPackage> characterList = new LinkedList<>(); final List<CharSelectInfoPackage> characterList = new LinkedList<>();
@@ -245,13 +245,13 @@ public class CharSelectionInfo implements IClientOutgoingPacket
} }
} }
} }
return characterList.toArray(new CharSelectInfoPackage[characterList.size()]);
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.log(Level.WARNING, "Could not restore char info: " + e.getMessage(), 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) private static void loadCharacterSubclassInfo(CharSelectInfoPackage charInfopackage, int objectId, int activeClassId)
@@ -16,6 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.sql.ClanTable; import org.l2jmobius.gameserver.data.sql.ClanTable;
import org.l2jmobius.gameserver.model.clan.Clan; import org.l2jmobius.gameserver.model.clan.Clan;
@@ -39,12 +41,12 @@ public class ExPledgeRecruitInfo implements IClientOutgoingPacket
{ {
OutgoingPackets.EX_PLEDGE_RECRUIT_INFO.writeId(packet); 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.getName());
packet.writeS(_clan.getLeaderName()); packet.writeS(_clan.getLeaderName());
packet.writeD(_clan.getLevel()); packet.writeD(_clan.getLevel());
packet.writeD(_clan.getMembersCount()); packet.writeD(_clan.getMembersCount());
packet.writeD(subPledges.length); packet.writeD(subPledges.size());
for (SubPledge subPledge : subPledges) for (SubPledge subPledge : subPledges)
{ {
packet.writeD(subPledge.getId()); packet.writeD(subPledge.getId());
@@ -16,15 +16,17 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.clan.Clan.RankPrivs; import org.l2jmobius.gameserver.model.clan.Clan.RankPrivs;
import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.OutgoingPackets;
public class PledgePowerGradeList implements IClientOutgoingPacket 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; _privs = privs;
} }
@@ -33,8 +35,7 @@ public class PledgePowerGradeList implements IClientOutgoingPacket
public boolean write(PacketWriter packet) public boolean write(PacketWriter packet)
{ {
OutgoingPackets.PLEDGE_POWER_GRADE_LIST.writeId(packet); OutgoingPackets.PLEDGE_POWER_GRADE_LIST.writeId(packet);
packet.writeD(_privs.size());
packet.writeD(_privs.length);
for (RankPrivs temp : _privs) for (RankPrivs temp : _privs)
{ {
packet.writeD(temp.getRank()); packet.writeD(temp.getRank());
@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.clan.Clan; import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@@ -26,8 +29,8 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
*/ */
public class PledgeSkillList implements IClientOutgoingPacket public class PledgeSkillList implements IClientOutgoingPacket
{ {
private final Skill[] _skills; private final Collection<Skill> _skills;
private final SubPledgeSkill[] _subSkills; private final List<SubPledgeSkill> _subSkills;
public static class SubPledgeSkill public static class SubPledgeSkill
{ {
@@ -53,9 +56,8 @@ public class PledgeSkillList implements IClientOutgoingPacket
public boolean write(PacketWriter packet) public boolean write(PacketWriter packet)
{ {
OutgoingPackets.PLEDGE_SKILL_LIST.writeId(packet); OutgoingPackets.PLEDGE_SKILL_LIST.writeId(packet);
packet.writeD(_skills.size());
packet.writeD(_skills.length); packet.writeD(_subSkills.size()); // Squad skill length
packet.writeD(_subSkills.length); // Squad skill length
for (Skill sk : _skills) for (Skill sk : _skills)
{ {
packet.writeD(sk.getDisplayId()); packet.writeD(sk.getDisplayId());
@@ -48,7 +48,7 @@ public class PrivateStoreListSell extends AbstractItemPacket
packet.writeD(_seller.getSellList().isPackaged() ? 1 : 0); packet.writeD(_seller.getSellList().isPackaged() ? 1 : 0);
packet.writeQ(_player.getAdena()); packet.writeQ(_player.getAdena());
packet.writeD(0x00); packet.writeD(0x00);
packet.writeD(_seller.getSellList().getItems().length); packet.writeD(_seller.getSellList().getItems().size());
for (TradeItem item : _seller.getSellList().getItems()) for (TradeItem item : _seller.getSellList().getItems())
{ {
writeItem(packet, item); writeItem(packet, item);
@@ -29,7 +29,7 @@ public class PrivateStoreManageListBuy extends AbstractItemPacket
private final int _objId; private final int _objId;
private final long _playerAdena; private final long _playerAdena;
private final Collection<ItemInstance> _itemList; private final Collection<ItemInstance> _itemList;
private final TradeItem[] _buyList; private final Collection<TradeItem> _buyList;
public PrivateStoreManageListBuy(PlayerInstance player) public PrivateStoreManageListBuy(PlayerInstance player)
{ {
@@ -54,7 +54,7 @@ public class PrivateStoreManageListBuy extends AbstractItemPacket
packet.writeQ(item.getItem().getReferencePrice() * 2); 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) for (TradeItem item : _buyList)
{ {
writeItem(packet, item); writeItem(packet, item);
@@ -29,7 +29,7 @@ public class PrivateStoreManageListSell extends AbstractItemPacket
private final long _playerAdena; private final long _playerAdena;
private final boolean _packageSale; private final boolean _packageSale;
private final Collection<TradeItem> _itemList; private final Collection<TradeItem> _itemList;
private final TradeItem[] _sellList; private final Collection<TradeItem> _sellList;
public PrivateStoreManageListSell(PlayerInstance player, boolean isPackageSale) public PrivateStoreManageListSell(PlayerInstance player, boolean isPackageSale)
{ {
@@ -57,7 +57,7 @@ public class PrivateStoreManageListSell extends AbstractItemPacket
packet.writeQ(item.getItem().getReferencePrice() * 2); 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) for (TradeItem item : _sellList)
{ {
writeItem(packet, item); writeItem(packet, item);
@@ -16,13 +16,15 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.RecipeList; import org.l2jmobius.gameserver.model.RecipeList;
import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.OutgoingPackets;
public class RecipeBookItemList implements IClientOutgoingPacket public class RecipeBookItemList implements IClientOutgoingPacket
{ {
private RecipeList[] _recipes; private Collection<RecipeList> _recipes;
private final boolean _isDwarvenCraft; private final boolean _isDwarvenCraft;
private final int _maxMp; private final int _maxMp;
@@ -32,7 +34,7 @@ public class RecipeBookItemList implements IClientOutgoingPacket
_maxMp = maxMp; _maxMp = maxMp;
} }
public void addRecipes(RecipeList[] recipeBook) public void addRecipes(Collection<RecipeList> recipeBook)
{ {
_recipes = recipeBook; _recipes = recipeBook;
} }
@@ -51,11 +53,13 @@ public class RecipeBookItemList implements IClientOutgoingPacket
} }
else else
{ {
packet.writeD(_recipes.length); // number of items in recipe book packet.writeD(_recipes.size()); // number of items in recipe book
for (int i = 0; i < _recipes.length; i++) int count = 0;
for (RecipeList recipe : _recipes)
{ {
packet.writeD(_recipes[i].getId()); count++;
packet.writeD(i + 1); packet.writeD(recipe.getId());
packet.writeD(count);
} }
} }
return true; return true;
@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
@@ -28,7 +29,7 @@ public class RecipeShopManageList implements IClientOutgoingPacket
{ {
private final PlayerInstance _seller; private final PlayerInstance _seller;
private final boolean _isDwarven; private final boolean _isDwarven;
private RecipeList[] _recipes; private Collection<RecipeList> _recipes;
public RecipeShopManageList(PlayerInstance seller, boolean isDwarven) public RecipeShopManageList(PlayerInstance seller, boolean isDwarven)
{ {
@@ -73,13 +74,13 @@ public class RecipeShopManageList implements IClientOutgoingPacket
} }
else else
{ {
packet.writeD(_recipes.length); // number of items in recipe book packet.writeD(_recipes.size()); // number of items in recipe book
int count = 0;
for (int i = 0; i < _recipes.length; i++) for (RecipeList recipe : _recipes)
{ {
final RecipeList temp = _recipes[i]; count++;
packet.writeD(temp.getId()); packet.writeD(recipe.getId());
packet.writeD(i + 1); packet.writeD(count);
} }
} }
@@ -16,6 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.Shortcut; import org.l2jmobius.gameserver.model.Shortcut;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -23,7 +25,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
public class ShortCutInit implements IClientOutgoingPacket public class ShortCutInit implements IClientOutgoingPacket
{ {
private Shortcut[] _shortCuts; private Collection<Shortcut> _shortCuts;
public ShortCutInit(PlayerInstance player) public ShortCutInit(PlayerInstance player)
{ {
@@ -40,7 +42,7 @@ public class ShortCutInit implements IClientOutgoingPacket
{ {
OutgoingPackets.SHORT_CUT_INIT.writeId(packet); OutgoingPackets.SHORT_CUT_INIT.writeId(packet);
packet.writeD(_shortCuts.length); packet.writeD(_shortCuts.size());
for (Shortcut sc : _shortCuts) for (Shortcut sc : _shortCuts)
{ {
packet.writeD(sc.getType().ordinal()); packet.writeD(sc.getType().ordinal());
@@ -16,6 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets.attributechange; package org.l2jmobius.gameserver.network.serverpackets.attributechange;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.ItemInfo; import org.l2jmobius.gameserver.model.ItemInfo;
import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.OutgoingPackets;
@@ -26,13 +28,13 @@ import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
*/ */
public class ExChangeAttributeItemList extends AbstractItemPacket public class ExChangeAttributeItemList extends AbstractItemPacket
{ {
private final ItemInfo[] _itemsList; private final List<ItemInfo> _itemsList;
private final int _itemId; private final int _itemId;
public ExChangeAttributeItemList(int itemId, ItemInfo[] itemsList) public ExChangeAttributeItemList(int itemId, List<ItemInfo> itemList)
{ {
_itemId = itemId; _itemId = itemId;
_itemsList = itemsList; _itemsList = itemList;
} }
@Override @Override
@@ -40,7 +42,7 @@ public class ExChangeAttributeItemList extends AbstractItemPacket
{ {
OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet); OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet);
packet.writeD(_itemId); packet.writeD(_itemId);
packet.writeD(_itemsList.length); packet.writeD(_itemsList.size());
for (ItemInfo item : _itemsList) for (ItemInfo item : _itemsList)
{ {
writeItem(packet, item); writeItem(packet, item);
@@ -594,9 +594,8 @@ public class AdminMobGroup implements IAdminCommandHandler
private void showGroupList(PlayerInstance activeChar) private void showGroupList(PlayerInstance activeChar)
{ {
final MobGroup[] mobGroupList = MobGroupTable.getInstance().getGroups();
BuilderUtil.sendSysMessage(activeChar, "======= <Mob Groups> ======="); BuilderUtil.sendSysMessage(activeChar, "======= <Mob Groups> =======");
for (MobGroup mobGroup : mobGroupList) for (MobGroup mobGroup : MobGroupTable.getInstance().getGroups())
{ {
activeChar.sendMessage(mobGroup.getGroupId() + ": " + mobGroup.getActiveMobCount() + " alive out of " + mobGroup.getMaxMobCount() + " of NPC ID " + mobGroup.getTemplate().getId() + " (" + mobGroup.getStatus() + ")"); activeChar.sendMessage(mobGroup.getGroupId() + ": " + mobGroup.getActiveMobCount() + " alive out of " + mobGroup.getMaxMobCount() + " of NPC ID " + mobGroup.getTemplate().getId() + " (" + mobGroup.getStatus() + ")");
} }
@@ -99,9 +99,8 @@ public class ItemAuctionLink implements IBypassHandler
} }
else if ("cancel".equalsIgnoreCase(cmd)) else if ("cancel".equalsIgnoreCase(cmd))
{ {
final ItemAuction[] auctions = au.getAuctionsByBidder(player.getObjectId());
boolean returned = false; boolean returned = false;
for (ItemAuction auction : auctions) for (ItemAuction auction : au.getAuctionsByBidder(player.getObjectId()))
{ {
if (auction.cancelBid(player)) if (auction.cancelBid(player))
{ {
@@ -16,6 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.List;
import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -84,7 +86,7 @@ public class ConvertItem extends AbstractEffect
final int enchantLevel = wpn.getEnchantLevel(); final int enchantLevel = wpn.getEnchantLevel();
final AttributeHolder elementals = wpn.getAttributes() == null ? null : wpn.getAttackAttribute(); final AttributeHolder elementals = wpn.getAttributes() == null ? null : wpn.getAttackAttribute();
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart()); final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance unequippedItem : unequiped) for (ItemInstance unequippedItem : unequiped)
{ {
@@ -92,10 +94,11 @@ public class ConvertItem extends AbstractEffect
} }
player.sendInventoryUpdate(iu); player.sendInventoryUpdate(iu);
if (unequiped.length <= 0) if (unequiped.isEmpty())
{ {
return; return;
} }
byte count = 0; byte count = 0;
for (ItemInstance unequippedItem : unequiped) for (ItemInstance unequippedItem : unequiped)
{ {
@@ -120,7 +123,7 @@ public class ConvertItem extends AbstractEffect
player.sendPacket(sm); player.sendPacket(sm);
} }
if (count == unequiped.length) if (count == unequiped.size())
{ {
return; return;
} }
@@ -16,6 +16,7 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -67,11 +68,11 @@ public class Disarmor extends AbstractEffect
} }
final PlayerInstance player = effected.getActingPlayer(); final PlayerInstance player = effected.getActingPlayer();
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot); final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -79,20 +80,21 @@ public class Disarmor extends AbstractEffect
player.broadcastUserInfo(); player.broadcastUserInfo();
SystemMessage sm = null; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
player.sendPacket(sm); player.sendPacket(sm);
effected.getInventory().blockItemSlot(_slot); effected.getInventory().blockItemSlot(_slot);
_unequippedItems.put(effected.getObjectId(), unequiped[0].getObjectId()); _unequippedItems.put(effected.getObjectId(), unequippedItem.getObjectId());
} }
} }
@@ -82,7 +82,7 @@ public class ChangeAttributeCrystal implements IItemHandler
return false; return false;
} }
player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList.toArray(new ItemInfo[itemList.size()]))); player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList));
return true; return true;
} }
} }
@@ -72,13 +72,13 @@ public class Recipes implements IItemHandler
{ {
canCraft = player.hasDwarvenCraft(); canCraft = player.hasDwarvenCraft();
recipeLevel = (rp.getLevel() > player.getDwarvenCraft()); recipeLevel = (rp.getLevel() > player.getDwarvenCraft());
recipeLimit = (player.getDwarvenRecipeBook().length >= player.getDwarfRecipeLimit()); recipeLimit = (player.getDwarvenRecipeBook().size() >= player.getDwarfRecipeLimit());
} }
else else
{ {
canCraft = player.hasCommonCraft(); canCraft = player.hasCommonCraft();
recipeLevel = (rp.getLevel() > player.getCommonCraft()); recipeLevel = (rp.getLevel() > player.getCommonCraft());
recipeLimit = (player.getCommonRecipeBook().length >= player.getCommonRecipeLimit()); recipeLimit = (player.getCommonRecipeBook().size() >= player.getCommonRecipeLimit());
} }
if (!canCraft) if (!canCraft)
@@ -17,7 +17,6 @@
package org.l2jmobius.gameserver; package org.l2jmobius.gameserver;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -89,9 +88,7 @@ public class RecipeController
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(manufacturer.getDwarvenRecipeBook()); if (!manufacturer.getDwarvenRecipeBook().contains(recipeList) && !manufacturer.getCommonRecipeBook().contains(recipeList))
final List<RecipeList> commonRecipes = Arrays.asList(manufacturer.getCommonRecipeBook());
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
{ {
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
return; return;
@@ -134,9 +131,7 @@ public class RecipeController
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook()); if (!player.getDwarvenRecipeBook().contains(recipeList) && !player.getCommonRecipeBook().contains(recipeList))
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
{ {
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
return; return;
@@ -90,8 +90,7 @@ public class MacroList implements IRestorable
deleteMacroFromDb(removed); deleteMacroFromDb(removed);
} }
final Shortcut[] allShortCuts = _owner.getAllShortCuts(); for (Shortcut sc : _owner.getAllShortCuts())
for (Shortcut sc : allShortCuts)
{ {
if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO)) if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
{ {
@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model; package org.l2jmobius.gameserver.model;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -67,9 +68,9 @@ public class MobGroupTable
return null; 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) public boolean removeGroup(int groupKey)
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.logging.Level; import java.util.logging.Level;
@@ -46,9 +47,9 @@ public class ShortCuts implements IRestorable
_owner = owner; _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) public Shortcut getShortCut(int slot, int page)
@@ -105,9 +105,9 @@ public class TradeList
/** /**
* @return all items from TradeList * @return all items from TradeList
*/ */
public TradeItem[] getItems() public Collection<TradeItem> getItems()
{ {
return _items.toArray(new TradeItem[_items.size()]); return _items;
} }
/** /**
@@ -857,7 +857,7 @@ public class TradeList
final InventoryUpdate playerIU = new InventoryUpdate(); final InventoryUpdate playerIU = new InventoryUpdate();
long totalPrice = 0; long totalPrice = 0;
final TradeItem[] sellerItems = _items.toArray(new TradeItem[0]); final TradeItem[] sellerItems = _items.toArray(new TradeItem[_items.size()]);
for (ItemRequest item : requestedItems) for (ItemRequest item : requestedItems)
{ {
// searching item in tradelist using itemId // searching item in tradelist using itemId
@@ -1283,19 +1283,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();
} }
/** /**
@@ -1563,9 +1563,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(); return _shortCuts.getAllShortCuts();
} }
@@ -2219,7 +2219,7 @@ public class PlayerInstance extends Playable
} }
// Equip or unEquip // Equip or unEquip
ItemInstance[] items = null; List<ItemInstance> items = null;
final boolean isEquiped = item.isEquipped(); final boolean isEquiped = item.isEquipped();
final int oldInvLimit = getInventoryLimit(); final int oldInvLimit = getInventoryLimit();
SystemMessage sm = null; SystemMessage sm = null;
@@ -2288,7 +2288,7 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
iu.addItems(Arrays.asList(items)); iu.addItems(items);
sendInventoryUpdate(iu); sendInventoryUpdate(iu);
if (abortAttack) if (abortAttack)
@@ -5865,9 +5865,9 @@ public class PlayerInstance extends Playable
return false; return false;
} }
final ItemInstance[] unequiped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart()); final List<ItemInstance> unequipped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -5877,19 +5877,20 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
// This can be 0 if the user pressed the right mousebutton twice very fast. // This can be 0 if the user pressed the right mousebutton twice very fast.
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
final SystemMessage sm; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
sendPacket(sm); sendPacket(sm);
} }
@@ -5905,9 +5906,9 @@ public class PlayerInstance extends Playable
final ItemInstance sld = _inventory.getPaperdollItem(Inventory.PAPERDOLL_LHAND); final ItemInstance sld = _inventory.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
if (sld != null) 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(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -5917,19 +5918,20 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
// this can be 0 if the user pressed the right mousebutton twice very fast // this can be 0 if the user pressed the right mousebutton twice very fast
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
SystemMessage sm = null; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
sendPacket(sm); sendPacket(sm);
} }
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -1289,13 +1290,13 @@ public class Clan implements IIdentifiable, INamable
/** /**
* @return all the clan skills. * @return all the clan skills.
*/ */
public Skill[] getAllSkills() public Collection<Skill> getAllSkills()
{ {
if (_skills == null) if (_skills == null)
{ {
return new Skill[0]; return Collections.emptyList();
} }
return _skills.values().toArray(new Skill[_skills.values().size()]); return _skills.values();
} }
/** /**
@@ -1830,13 +1831,13 @@ public class Clan implements IIdentifiable, INamable
* Used to retrieve all subPledges * Used to retrieve all subPledges
* @return * @return
*/ */
public SubPledge[] getAllSubPledges() public Collection<SubPledge> getAllSubPledges()
{ {
if (_subPledges == null) if (_subPledges == null)
{ {
return new SubPledge[0]; return Collections.emptyList();
} }
return _subPledges.values().toArray(new SubPledge[_subPledges.values().size()]); return _subPledges.values();
} }
public SubPledge createSubPledge(PlayerInstance player, int pledgeTypeValue, int leaderId, String subPledgeName) public SubPledge createSubPledge(PlayerInstance player, int pledgeTypeValue, int leaderId, String subPledgeName)
@@ -2069,9 +2070,9 @@ public class Clan implements IIdentifiable, INamable
/** /**
* @return all RankPrivs. * @return all RankPrivs.
*/ */
public RankPrivs[] getAllRankPrivs() public Collection<RankPrivs> getAllRankPrivs()
{ {
return _privs == null ? new RankPrivs[0] : _privs.values().toArray(new RankPrivs[_privs.values().size()]); return _privs == null ? Collections.emptyList() : _privs.values();
} }
public int getLeaderSubPledge(int leaderId) public int getLeaderSubPledge(int leaderId)
@@ -2931,7 +2932,7 @@ public class Clan implements IIdentifiable, INamable
return false; return false;
} }
public SubPledgeSkill[] getAllSubSkills() public List<SubPledgeSkill> getAllSubSkills()
{ {
final List<SubPledgeSkill> list = new LinkedList<>(); final List<SubPledgeSkill> list = new LinkedList<>();
for (Skill skill : _subPledgeSkills.values()) for (Skill skill : _subPledgeSkills.values())
@@ -2945,7 +2946,7 @@ public class Clan implements IIdentifiable, INamable
list.add(new SubPledgeSkill(subunit.getId(), skill.getId(), skill.getLevel())); 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) public void setNewLeaderId(int objectId, boolean storeInDb)
@@ -2962,9 +2962,8 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
// Destroy the quantity of items wanted // Destroy the quantity of items wanted
if (item.isEquipped()) if (item.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart()))
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -347,7 +347,7 @@ public class ItemAuctionInstance
return _auctions.get(auctionId); return _auctions.get(auctionId);
} }
public ItemAuction[] getAuctionsByBidder(int bidderObjId) public ArrayList<ItemAuction> getAuctionsByBidder(int bidderObjId)
{ {
final Collection<ItemAuction> auctions = getAuctions(); final Collection<ItemAuction> auctions = getAuctions();
final ArrayList<ItemAuction> stack = new ArrayList<>(auctions.size()); 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() public Collection<ItemAuction> getAuctions()
@@ -25,8 +25,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.logging.Level; import java.util.logging.Level;
@@ -143,7 +141,7 @@ public abstract class Inventory extends ItemContainer
private static final class ChangeRecorder implements PaperdollListener private static final class ChangeRecorder implements PaperdollListener
{ {
private final Inventory _inventory; private final Inventory _inventory;
private final Set<ItemInstance> _changed = ConcurrentHashMap.newKeySet(); private final List<ItemInstance> _changed = new ArrayList<>(1);
/** /**
* Constructor of the ChangeRecorder * Constructor of the ChangeRecorder
@@ -183,9 +181,9 @@ public abstract class Inventory extends ItemContainer
* Returns alterations in inventory * Returns alterations in inventory
* @return ItemInstance[] : array of altered items * @return ItemInstance[] : array of altered items
*/ */
public ItemInstance[] getChangedItems() public List<ItemInstance> getChangedItems()
{ {
return _changed.toArray(new ItemInstance[_changed.size()]); return _changed;
} }
} }
@@ -1533,12 +1531,11 @@ public abstract class Inventory extends ItemContainer
* Unequips item in body slot and returns alterations.<br> * Unequips item in body slot and returns alterations.<br>
* <b>If you dont need return value use {@link Inventory#unEquipItemInBodySlot(int)} instead</b> * <b>If you dont need return value use {@link Inventory#unEquipItemInBodySlot(int)} instead</b>
* @param slot : int designating the slot of the paperdoll * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
unEquipItemInBodySlot(slot); unEquipItemInBodySlot(slot);
@@ -1564,12 +1561,11 @@ public abstract class Inventory extends ItemContainer
* Unequips item in slot and returns alterations<br> * Unequips item in slot and returns alterations<br>
* <b>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</b> * <b>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</b>
* @param slot : int designating the slot * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
unEquipItemInSlot(slot); unEquipItemInSlot(slot);
@@ -1737,12 +1733,11 @@ public abstract class Inventory extends ItemContainer
* Equips item and returns list of alterations<br> * Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(ItemInstance)} instead</b> * <b>If you don't need return value use {@link Inventory#equipItem(ItemInstance)} instead</b>
* @param item : ItemInstance corresponding to the item * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
equipItem(item); equipItem(item);
@@ -1375,9 +1375,8 @@ public class ItemInstance extends WorldObject
// unequip // unequip
if (isEquipped()) if (isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -1811,9 +1810,8 @@ public class ItemInstance extends WorldObject
{ {
if (isEquipped()) if (isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -78,7 +79,7 @@ public class GameClient extends ChannelInboundHandler<GameClient>
private PlayerInstance _player; private PlayerInstance _player;
private SecondaryPasswordAuth _secondaryAuth; private SecondaryPasswordAuth _secondaryAuth;
private ClientHardwareInfoHolder _hardwareInfo; private ClientHardwareInfoHolder _hardwareInfo;
private CharSelectInfoPackage[] _charSlotMapping = null; private List<CharSelectInfoPackage> _charSlotMapping = null;
private volatile boolean _isDetached = false; private volatile boolean _isDetached = false;
private boolean _isAuthedGG; private boolean _isAuthedGG;
private boolean _protocolOk; private boolean _protocolOk;
@@ -568,21 +569,18 @@ public class GameClient extends ChannelInboundHandler<GameClient>
return player; return player;
} }
/** public void setCharSelection(List<CharSelectInfoPackage> characters)
* @param chars
*/
public void setCharSelection(CharSelectInfoPackage[] chars)
{ {
_charSlotMapping = chars; _charSlotMapping = characters;
} }
public CharSelectInfoPackage getCharSelection(int charslot) public CharSelectInfoPackage getCharSelection(int charslot)
{ {
if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.length)) if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.size()))
{ {
return null; return null;
} }
return _charSlotMapping[charslot]; return _charSlotMapping.get(charslot);
} }
public SecondaryPasswordAuth getSecondaryAuth() public SecondaryPasswordAuth getSecondaryAuth()
@@ -202,9 +202,8 @@ public class RequestCrystallizeItem implements IClientIncomingPacket
SystemMessage sm; SystemMessage sm;
if (itemToRemove.isEquipped()) if (itemToRemove.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -193,9 +193,8 @@ public class RequestDestroyItem implements IClientIncomingPacket
client.sendPacket(sm); client.sendPacket(sm);
} }
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -309,12 +309,10 @@ public class RequestEnchantItem implements IClientIncomingPacket
client.sendPacket(sm); client.sendPacket(sm);
} }
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()); for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()))
for (ItemInstance itm : unequiped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
player.sendInventoryUpdate(iu); player.sendInventoryUpdate(iu);
player.broadcastUserInfo(); player.broadcastUserInfo();
} }
@@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan; 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.GameClient;
import org.l2jmobius.gameserver.network.serverpackets.PledgePowerGradeList; import org.l2jmobius.gameserver.network.serverpackets.PledgePowerGradeList;
@@ -47,8 +46,7 @@ public class RequestPledgePowerGradeList implements IClientIncomingPacket
final Clan clan = player.getClan(); final Clan clan = player.getClan();
if (clan != null) if (clan != null)
{ {
final RankPrivs[] privs = clan.getAllRankPrivs(); player.sendPacket(new PledgePowerGradeList(clan.getAllRankPrivs()));
player.sendPacket(new PledgePowerGradeList(privs));
} }
} }
} }
@@ -18,9 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import static org.l2jmobius.gameserver.model.itemcontainer.Inventory.MAX_ADENA; 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.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.xml.RecipeData; import org.l2jmobius.gameserver.data.xml.RecipeData;
@@ -100,14 +97,11 @@ public class RequestRecipeShopListSet implements IClientIncomingPacket
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
player.getManufactureItems().clear(); player.getManufactureItems().clear();
for (ManufactureItem i : _items) for (ManufactureItem i : _items)
{ {
final RecipeList list = RecipeData.getInstance().getRecipeList(i.getRecipeId()); 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); Util.handleIllegalPlayerAction(player, "Warning!! Player " + player.getName() + " of account " + player.getAccountName() + " tried to set recipe which he dont have.", Config.DEFAULT_PUNISH);
return; return;
@@ -109,8 +109,7 @@ public class RequestRefine extends AbstractRefinePacket
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped()) if (targetItem.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()); for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
for (ItemInstance itm : unequiped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -92,8 +92,7 @@ public class RequestRefineCancel implements IClientIncomingPacket
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped()) if (targetItem.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()); for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
for (ItemInstance itm : unequiped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -16,7 +16,7 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Arrays; import java.util.List;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.PlayerCondOverride; import org.l2jmobius.gameserver.model.PlayerCondOverride;
@@ -99,27 +99,28 @@ public class RequestUnEquipItem implements IClientIncomingPacket
return; return;
} }
final ItemInstance[] unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
player.broadcastUserInfo(); player.broadcastUserInfo();
// This can be 0 if the user pressed the right mouse button twice very fast. // 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; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequipped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
} }
sm.addItemName(unequipped[0]); sm.addItemName(unequippedItem);
client.sendPacket(sm); client.sendPacket(sm);
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
iu.addItems(Arrays.asList(unequipped)); iu.addItems(unequipped);
player.sendInventoryUpdate(iu); player.sendInventoryUpdate(iu);
} }
} }
@@ -69,7 +69,7 @@ public abstract class AbstractInventoryUpdate extends AbstractItemPacket
_items.put(item.getObjectId(), new ItemInfo(item, 3)); _items.put(item.getObjectId(), new ItemInfo(item, 3));
} }
public void addItems(List<ItemInstance> items) public void addItems(Collection<ItemInstance> items)
{ {
for (ItemInstance item : items) for (ItemInstance item : items)
{ {
@@ -47,7 +47,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
private final String _loginName; private final String _loginName;
private final int _sessionId; private final int _sessionId;
private int _activeId; private int _activeId;
private final CharSelectInfoPackage[] _characterPackages; private final List<CharSelectInfoPackage> _characterPackages;
private static final int[] PAPERDOLL_ORDER_VISUAL_ID = new int[] private static final int[] PAPERDOLL_ORDER_VISUAL_ID = new int[]
{ {
@@ -83,7 +83,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
_activeId = activeId; _activeId = activeId;
} }
public CharSelectInfoPackage[] getCharInfo() public List<CharSelectInfoPackage> getCharInfo()
{ {
return _characterPackages; return _characterPackages;
} }
@@ -93,7 +93,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
{ {
OutgoingPackets.CHARACTER_SELECTION_INFO.writeId(packet); OutgoingPackets.CHARACTER_SELECTION_INFO.writeId(packet);
final int size = _characterPackages.length; final int size = _characterPackages.size();
packet.writeD(size); // Created character count 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) ) 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++) 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; _activeId = i;
} }
} }
@@ -117,7 +117,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
for (int i = 0; i < size; i++) 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.writeS(charInfoPackage.getName()); // Character name
packet.writeD(charInfoPackage.getObjectId()); // Character ID packet.writeD(charInfoPackage.getObjectId()); // Character ID
packet.writeS(_loginName); // Account name packet.writeS(_loginName); // Account name
@@ -218,7 +218,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
return true; return true;
} }
private static CharSelectInfoPackage[] loadCharacterSelectInfo(String loginName) private static List<CharSelectInfoPackage> loadCharacterSelectInfo(String loginName)
{ {
CharSelectInfoPackage charInfopackage; CharSelectInfoPackage charInfopackage;
final List<CharSelectInfoPackage> characterList = new LinkedList<>(); 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) catch (Exception e)
{ {
LOGGER.log(Level.WARNING, "Could not restore char info: " + e.getMessage(), 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) private static void loadCharacterSubclassInfo(CharSelectInfoPackage charInfopackage, int objectId, int activeClassId)
@@ -16,6 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.sql.ClanTable; import org.l2jmobius.gameserver.data.sql.ClanTable;
import org.l2jmobius.gameserver.model.clan.Clan; import org.l2jmobius.gameserver.model.clan.Clan;
@@ -39,12 +41,12 @@ public class ExPledgeRecruitInfo implements IClientOutgoingPacket
{ {
OutgoingPackets.EX_PLEDGE_RECRUIT_INFO.writeId(packet); 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.getName());
packet.writeS(_clan.getLeaderName()); packet.writeS(_clan.getLeaderName());
packet.writeD(_clan.getLevel()); packet.writeD(_clan.getLevel());
packet.writeD(_clan.getMembersCount()); packet.writeD(_clan.getMembersCount());
packet.writeD(subPledges.length); packet.writeD(subPledges.size());
for (SubPledge subPledge : subPledges) for (SubPledge subPledge : subPledges)
{ {
packet.writeD(subPledge.getId()); packet.writeD(subPledge.getId());
@@ -16,15 +16,17 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.clan.Clan.RankPrivs; import org.l2jmobius.gameserver.model.clan.Clan.RankPrivs;
import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.OutgoingPackets;
public class PledgePowerGradeList implements IClientOutgoingPacket 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; _privs = privs;
} }
@@ -33,8 +35,7 @@ public class PledgePowerGradeList implements IClientOutgoingPacket
public boolean write(PacketWriter packet) public boolean write(PacketWriter packet)
{ {
OutgoingPackets.PLEDGE_POWER_GRADE_LIST.writeId(packet); OutgoingPackets.PLEDGE_POWER_GRADE_LIST.writeId(packet);
packet.writeD(_privs.size());
packet.writeD(_privs.length);
for (RankPrivs temp : _privs) for (RankPrivs temp : _privs)
{ {
packet.writeD(temp.getRank()); packet.writeD(temp.getRank());
@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.clan.Clan; import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
@@ -26,8 +29,8 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
*/ */
public class PledgeSkillList implements IClientOutgoingPacket public class PledgeSkillList implements IClientOutgoingPacket
{ {
private final Skill[] _skills; private final Collection<Skill> _skills;
private final SubPledgeSkill[] _subSkills; private final List<SubPledgeSkill> _subSkills;
public static class SubPledgeSkill public static class SubPledgeSkill
{ {
@@ -53,9 +56,8 @@ public class PledgeSkillList implements IClientOutgoingPacket
public boolean write(PacketWriter packet) public boolean write(PacketWriter packet)
{ {
OutgoingPackets.PLEDGE_SKILL_LIST.writeId(packet); OutgoingPackets.PLEDGE_SKILL_LIST.writeId(packet);
packet.writeD(_skills.size());
packet.writeD(_skills.length); packet.writeD(_subSkills.size()); // Squad skill length
packet.writeD(_subSkills.length); // Squad skill length
for (Skill sk : _skills) for (Skill sk : _skills)
{ {
packet.writeD(sk.getDisplayId()); packet.writeD(sk.getDisplayId());
@@ -48,7 +48,7 @@ public class PrivateStoreListSell extends AbstractItemPacket
packet.writeD(_seller.getSellList().isPackaged() ? 1 : 0); packet.writeD(_seller.getSellList().isPackaged() ? 1 : 0);
packet.writeQ(_player.getAdena()); packet.writeQ(_player.getAdena());
packet.writeD(0x00); packet.writeD(0x00);
packet.writeD(_seller.getSellList().getItems().length); packet.writeD(_seller.getSellList().getItems().size());
for (TradeItem item : _seller.getSellList().getItems()) for (TradeItem item : _seller.getSellList().getItems())
{ {
writeItem(packet, item); writeItem(packet, item);
@@ -29,7 +29,7 @@ public class PrivateStoreManageListBuy extends AbstractItemPacket
private final int _objId; private final int _objId;
private final long _playerAdena; private final long _playerAdena;
private final Collection<ItemInstance> _itemList; private final Collection<ItemInstance> _itemList;
private final TradeItem[] _buyList; private final Collection<TradeItem> _buyList;
public PrivateStoreManageListBuy(PlayerInstance player) public PrivateStoreManageListBuy(PlayerInstance player)
{ {
@@ -54,7 +54,7 @@ public class PrivateStoreManageListBuy extends AbstractItemPacket
packet.writeQ(item.getItem().getReferencePrice() * 2); 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) for (TradeItem item : _buyList)
{ {
writeItem(packet, item); writeItem(packet, item);
@@ -29,7 +29,7 @@ public class PrivateStoreManageListSell extends AbstractItemPacket
private final long _playerAdena; private final long _playerAdena;
private final boolean _packageSale; private final boolean _packageSale;
private final Collection<TradeItem> _itemList; private final Collection<TradeItem> _itemList;
private final TradeItem[] _sellList; private final Collection<TradeItem> _sellList;
public PrivateStoreManageListSell(PlayerInstance player, boolean isPackageSale) public PrivateStoreManageListSell(PlayerInstance player, boolean isPackageSale)
{ {
@@ -57,7 +57,7 @@ public class PrivateStoreManageListSell extends AbstractItemPacket
packet.writeQ(item.getItem().getReferencePrice() * 2); 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) for (TradeItem item : _sellList)
{ {
writeItem(packet, item); writeItem(packet, item);
@@ -16,13 +16,15 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.RecipeList; import org.l2jmobius.gameserver.model.RecipeList;
import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.OutgoingPackets;
public class RecipeBookItemList implements IClientOutgoingPacket public class RecipeBookItemList implements IClientOutgoingPacket
{ {
private RecipeList[] _recipes; private Collection<RecipeList> _recipes;
private final boolean _isDwarvenCraft; private final boolean _isDwarvenCraft;
private final int _maxMp; private final int _maxMp;
@@ -32,7 +34,7 @@ public class RecipeBookItemList implements IClientOutgoingPacket
_maxMp = maxMp; _maxMp = maxMp;
} }
public void addRecipes(RecipeList[] recipeBook) public void addRecipes(Collection<RecipeList> recipeBook)
{ {
_recipes = recipeBook; _recipes = recipeBook;
} }
@@ -51,11 +53,13 @@ public class RecipeBookItemList implements IClientOutgoingPacket
} }
else else
{ {
packet.writeD(_recipes.length); // number of items in recipe book packet.writeD(_recipes.size()); // number of items in recipe book
for (int i = 0; i < _recipes.length; i++) int count = 0;
for (RecipeList recipe : _recipes)
{ {
packet.writeD(_recipes[i].getId()); count++;
packet.writeD(i + 1); packet.writeD(recipe.getId());
packet.writeD(count);
} }
} }
return true; return true;
@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
@@ -28,7 +29,7 @@ public class RecipeShopManageList implements IClientOutgoingPacket
{ {
private final PlayerInstance _seller; private final PlayerInstance _seller;
private final boolean _isDwarven; private final boolean _isDwarven;
private RecipeList[] _recipes; private Collection<RecipeList> _recipes;
public RecipeShopManageList(PlayerInstance seller, boolean isDwarven) public RecipeShopManageList(PlayerInstance seller, boolean isDwarven)
{ {
@@ -73,13 +74,13 @@ public class RecipeShopManageList implements IClientOutgoingPacket
} }
else else
{ {
packet.writeD(_recipes.length); // number of items in recipe book packet.writeD(_recipes.size()); // number of items in recipe book
int count = 0;
for (int i = 0; i < _recipes.length; i++) for (RecipeList recipe : _recipes)
{ {
final RecipeList temp = _recipes[i]; count++;
packet.writeD(temp.getId()); packet.writeD(recipe.getId());
packet.writeD(i + 1); packet.writeD(count);
} }
} }
@@ -16,6 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.Shortcut; import org.l2jmobius.gameserver.model.Shortcut;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -23,7 +25,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
public class ShortCutInit implements IClientOutgoingPacket public class ShortCutInit implements IClientOutgoingPacket
{ {
private Shortcut[] _shortCuts; private Collection<Shortcut> _shortCuts;
public ShortCutInit(PlayerInstance player) public ShortCutInit(PlayerInstance player)
{ {
@@ -40,7 +42,7 @@ public class ShortCutInit implements IClientOutgoingPacket
{ {
OutgoingPackets.SHORT_CUT_INIT.writeId(packet); OutgoingPackets.SHORT_CUT_INIT.writeId(packet);
packet.writeD(_shortCuts.length); packet.writeD(_shortCuts.size());
for (Shortcut sc : _shortCuts) for (Shortcut sc : _shortCuts)
{ {
packet.writeD(sc.getType().ordinal()); packet.writeD(sc.getType().ordinal());
@@ -16,6 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.serverpackets.attributechange; package org.l2jmobius.gameserver.network.serverpackets.attributechange;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.ItemInfo; import org.l2jmobius.gameserver.model.ItemInfo;
import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.OutgoingPackets;
@@ -26,13 +28,13 @@ import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
*/ */
public class ExChangeAttributeItemList extends AbstractItemPacket public class ExChangeAttributeItemList extends AbstractItemPacket
{ {
private final ItemInfo[] _itemsList; private final List<ItemInfo> _itemsList;
private final int _itemId; private final int _itemId;
public ExChangeAttributeItemList(int itemId, ItemInfo[] itemsList) public ExChangeAttributeItemList(int itemId, List<ItemInfo> itemList)
{ {
_itemId = itemId; _itemId = itemId;
_itemsList = itemsList; _itemsList = itemList;
} }
@Override @Override
@@ -40,7 +42,7 @@ public class ExChangeAttributeItemList extends AbstractItemPacket
{ {
OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet); OutgoingPackets.EX_CHANGE_ATTRIBUTE_ITEM_LIST.writeId(packet);
packet.writeD(_itemId); packet.writeD(_itemId);
packet.writeD(_itemsList.length); packet.writeD(_itemsList.size());
for (ItemInfo item : _itemsList) for (ItemInfo item : _itemsList)
{ {
writeItem(packet, item); writeItem(packet, item);
@@ -594,9 +594,8 @@ public class AdminMobGroup implements IAdminCommandHandler
private void showGroupList(PlayerInstance activeChar) private void showGroupList(PlayerInstance activeChar)
{ {
final MobGroup[] mobGroupList = MobGroupTable.getInstance().getGroups();
BuilderUtil.sendSysMessage(activeChar, "======= <Mob Groups> ======="); BuilderUtil.sendSysMessage(activeChar, "======= <Mob Groups> =======");
for (MobGroup mobGroup : mobGroupList) for (MobGroup mobGroup : MobGroupTable.getInstance().getGroups())
{ {
activeChar.sendMessage(mobGroup.getGroupId() + ": " + mobGroup.getActiveMobCount() + " alive out of " + mobGroup.getMaxMobCount() + " of NPC ID " + mobGroup.getTemplate().getId() + " (" + mobGroup.getStatus() + ")"); activeChar.sendMessage(mobGroup.getGroupId() + ": " + mobGroup.getActiveMobCount() + " alive out of " + mobGroup.getMaxMobCount() + " of NPC ID " + mobGroup.getTemplate().getId() + " (" + mobGroup.getStatus() + ")");
} }
@@ -99,9 +99,8 @@ public class ItemAuctionLink implements IBypassHandler
} }
else if ("cancel".equalsIgnoreCase(cmd)) else if ("cancel".equalsIgnoreCase(cmd))
{ {
final ItemAuction[] auctions = au.getAuctionsByBidder(player.getObjectId());
boolean returned = false; boolean returned = false;
for (ItemAuction auction : auctions) for (ItemAuction auction : au.getAuctionsByBidder(player.getObjectId()))
{ {
if (auction.cancelBid(player)) if (auction.cancelBid(player))
{ {
@@ -16,6 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.List;
import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -84,7 +86,7 @@ public class ConvertItem extends AbstractEffect
final int enchantLevel = wpn.getEnchantLevel(); final int enchantLevel = wpn.getEnchantLevel();
final AttributeHolder elementals = wpn.getAttributes() == null ? null : wpn.getAttackAttribute(); final AttributeHolder elementals = wpn.getAttributes() == null ? null : wpn.getAttackAttribute();
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart()); final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance unequippedItem : unequiped) for (ItemInstance unequippedItem : unequiped)
{ {
@@ -92,10 +94,11 @@ public class ConvertItem extends AbstractEffect
} }
player.sendInventoryUpdate(iu); player.sendInventoryUpdate(iu);
if (unequiped.length <= 0) if (unequiped.isEmpty())
{ {
return; return;
} }
byte count = 0; byte count = 0;
for (ItemInstance unequippedItem : unequiped) for (ItemInstance unequippedItem : unequiped)
{ {
@@ -120,7 +123,7 @@ public class ConvertItem extends AbstractEffect
player.sendPacket(sm); player.sendPacket(sm);
} }
if (count == unequiped.length) if (count == unequiped.size())
{ {
return; return;
} }
@@ -16,6 +16,7 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -67,11 +68,11 @@ public class Disarmor extends AbstractEffect
} }
final PlayerInstance player = effected.getActingPlayer(); final PlayerInstance player = effected.getActingPlayer();
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot); final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -79,20 +80,21 @@ public class Disarmor extends AbstractEffect
player.broadcastUserInfo(); player.broadcastUserInfo();
SystemMessage sm = null; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
player.sendPacket(sm); player.sendPacket(sm);
effected.getInventory().blockItemSlot(_slot); effected.getInventory().blockItemSlot(_slot);
_unequippedItems.put(effected.getObjectId(), unequiped[0].getObjectId()); _unequippedItems.put(effected.getObjectId(), unequippedItem.getObjectId());
} }
} }
@@ -82,7 +82,7 @@ public class ChangeAttributeCrystal implements IItemHandler
return false; return false;
} }
player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList.toArray(new ItemInfo[itemList.size()]))); player.sendPacket(new ExChangeAttributeItemList(item.getId(), itemList));
return true; return true;
} }
} }
@@ -72,13 +72,13 @@ public class Recipes implements IItemHandler
{ {
canCraft = player.hasDwarvenCraft(); canCraft = player.hasDwarvenCraft();
recipeLevel = (rp.getLevel() > player.getDwarvenCraft()); recipeLevel = (rp.getLevel() > player.getDwarvenCraft());
recipeLimit = (player.getDwarvenRecipeBook().length >= player.getDwarfRecipeLimit()); recipeLimit = (player.getDwarvenRecipeBook().size() >= player.getDwarfRecipeLimit());
} }
else else
{ {
canCraft = player.hasCommonCraft(); canCraft = player.hasCommonCraft();
recipeLevel = (rp.getLevel() > player.getCommonCraft()); recipeLevel = (rp.getLevel() > player.getCommonCraft());
recipeLimit = (player.getCommonRecipeBook().length >= player.getCommonRecipeLimit()); recipeLimit = (player.getCommonRecipeBook().size() >= player.getCommonRecipeLimit());
} }
if (!canCraft) if (!canCraft)
@@ -17,7 +17,6 @@
package org.l2jmobius.gameserver; package org.l2jmobius.gameserver;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -89,9 +88,7 @@ public class RecipeController
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(manufacturer.getDwarvenRecipeBook()); if (!manufacturer.getDwarvenRecipeBook().contains(recipeList) && !manufacturer.getCommonRecipeBook().contains(recipeList))
final List<RecipeList> commonRecipes = Arrays.asList(manufacturer.getCommonRecipeBook());
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
{ {
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
return; return;
@@ -134,9 +131,7 @@ public class RecipeController
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook()); if (!player.getDwarvenRecipeBook().contains(recipeList) && !player.getCommonRecipeBook().contains(recipeList))
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
{ {
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
return; return;
@@ -90,8 +90,7 @@ public class MacroList implements IRestorable
deleteMacroFromDb(removed); deleteMacroFromDb(removed);
} }
final Shortcut[] allShortCuts = _owner.getAllShortCuts(); for (Shortcut sc : _owner.getAllShortCuts())
for (Shortcut sc : allShortCuts)
{ {
if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO)) if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
{ {
@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model; package org.l2jmobius.gameserver.model;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -67,9 +68,9 @@ public class MobGroupTable
return null; 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) public boolean removeGroup(int groupKey)
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.logging.Level; import java.util.logging.Level;
@@ -46,9 +47,9 @@ public class ShortCuts implements IRestorable
_owner = owner; _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) public Shortcut getShortCut(int slot, int page)
@@ -105,9 +105,9 @@ public class TradeList
/** /**
* @return all items from TradeList * @return all items from TradeList
*/ */
public TradeItem[] getItems() public Collection<TradeItem> getItems()
{ {
return _items.toArray(new TradeItem[_items.size()]); return _items;
} }
/** /**
@@ -857,7 +857,7 @@ public class TradeList
final InventoryUpdate playerIU = new InventoryUpdate(); final InventoryUpdate playerIU = new InventoryUpdate();
long totalPrice = 0; long totalPrice = 0;
final TradeItem[] sellerItems = _items.toArray(new TradeItem[0]); final TradeItem[] sellerItems = _items.toArray(new TradeItem[_items.size()]);
for (ItemRequest item : requestedItems) for (ItemRequest item : requestedItems)
{ {
// searching item in tradelist using itemId // searching item in tradelist using itemId
@@ -1285,19 +1285,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();
} }
/** /**
@@ -1565,9 +1565,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(); return _shortCuts.getAllShortCuts();
} }
@@ -2221,7 +2221,7 @@ public class PlayerInstance extends Playable
} }
// Equip or unEquip // Equip or unEquip
ItemInstance[] items = null; List<ItemInstance> items = null;
final boolean isEquiped = item.isEquipped(); final boolean isEquiped = item.isEquipped();
final int oldInvLimit = getInventoryLimit(); final int oldInvLimit = getInventoryLimit();
SystemMessage sm = null; SystemMessage sm = null;
@@ -2290,7 +2290,7 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
iu.addItems(Arrays.asList(items)); iu.addItems(items);
sendInventoryUpdate(iu); sendInventoryUpdate(iu);
if (abortAttack) if (abortAttack)
@@ -5867,9 +5867,9 @@ public class PlayerInstance extends Playable
return false; return false;
} }
final ItemInstance[] unequiped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart()); final List<ItemInstance> unequipped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -5879,19 +5879,20 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
// This can be 0 if the user pressed the right mousebutton twice very fast. // This can be 0 if the user pressed the right mousebutton twice very fast.
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
final SystemMessage sm; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
sendPacket(sm); sendPacket(sm);
} }
@@ -5907,9 +5908,9 @@ public class PlayerInstance extends Playable
final ItemInstance sld = _inventory.getPaperdollItem(Inventory.PAPERDOLL_LHAND); final ItemInstance sld = _inventory.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
if (sld != null) 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(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : unequipped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -5919,19 +5920,20 @@ public class PlayerInstance extends Playable
broadcastUserInfo(); broadcastUserInfo();
// this can be 0 if the user pressed the right mousebutton twice very fast // this can be 0 if the user pressed the right mousebutton twice very fast
if (unequiped.length > 0) if (!unequipped.isEmpty())
{ {
SystemMessage sm = null; 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 = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
sm.addInt(unequiped[0].getEnchantLevel()); sm.addInt(unequippedItem.getEnchantLevel());
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
else else
{ {
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
sm.addItemName(unequiped[0]); sm.addItemName(unequippedItem);
} }
sendPacket(sm); sendPacket(sm);
} }
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -1289,13 +1290,13 @@ public class Clan implements IIdentifiable, INamable
/** /**
* @return all the clan skills. * @return all the clan skills.
*/ */
public Skill[] getAllSkills() public Collection<Skill> getAllSkills()
{ {
if (_skills == null) if (_skills == null)
{ {
return new Skill[0]; return Collections.emptyList();
} }
return _skills.values().toArray(new Skill[_skills.values().size()]); return _skills.values();
} }
/** /**
@@ -1830,13 +1831,13 @@ public class Clan implements IIdentifiable, INamable
* Used to retrieve all subPledges * Used to retrieve all subPledges
* @return * @return
*/ */
public SubPledge[] getAllSubPledges() public Collection<SubPledge> getAllSubPledges()
{ {
if (_subPledges == null) if (_subPledges == null)
{ {
return new SubPledge[0]; return Collections.emptyList();
} }
return _subPledges.values().toArray(new SubPledge[_subPledges.values().size()]); return _subPledges.values();
} }
public SubPledge createSubPledge(PlayerInstance player, int pledgeTypeValue, int leaderId, String subPledgeName) public SubPledge createSubPledge(PlayerInstance player, int pledgeTypeValue, int leaderId, String subPledgeName)
@@ -2069,9 +2070,9 @@ public class Clan implements IIdentifiable, INamable
/** /**
* @return all RankPrivs. * @return all RankPrivs.
*/ */
public RankPrivs[] getAllRankPrivs() public Collection<RankPrivs> getAllRankPrivs()
{ {
return _privs == null ? new RankPrivs[0] : _privs.values().toArray(new RankPrivs[_privs.values().size()]); return _privs == null ? Collections.emptyList() : _privs.values();
} }
public int getLeaderSubPledge(int leaderId) public int getLeaderSubPledge(int leaderId)
@@ -2931,7 +2932,7 @@ public class Clan implements IIdentifiable, INamable
return false; return false;
} }
public SubPledgeSkill[] getAllSubSkills() public List<SubPledgeSkill> getAllSubSkills()
{ {
final List<SubPledgeSkill> list = new LinkedList<>(); final List<SubPledgeSkill> list = new LinkedList<>();
for (Skill skill : _subPledgeSkills.values()) for (Skill skill : _subPledgeSkills.values())
@@ -2945,7 +2946,7 @@ public class Clan implements IIdentifiable, INamable
list.add(new SubPledgeSkill(subunit.getId(), skill.getId(), skill.getLevel())); 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) public void setNewLeaderId(int objectId, boolean storeInDb)
@@ -2963,9 +2963,8 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
// Destroy the quantity of items wanted // Destroy the quantity of items wanted
if (item.isEquipped()) if (item.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart()))
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -347,7 +347,7 @@ public class ItemAuctionInstance
return _auctions.get(auctionId); return _auctions.get(auctionId);
} }
public ItemAuction[] getAuctionsByBidder(int bidderObjId) public ArrayList<ItemAuction> getAuctionsByBidder(int bidderObjId)
{ {
final Collection<ItemAuction> auctions = getAuctions(); final Collection<ItemAuction> auctions = getAuctions();
final ArrayList<ItemAuction> stack = new ArrayList<>(auctions.size()); 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() public Collection<ItemAuction> getAuctions()
@@ -25,8 +25,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.logging.Level; import java.util.logging.Level;
@@ -143,7 +141,7 @@ public abstract class Inventory extends ItemContainer
private static final class ChangeRecorder implements PaperdollListener private static final class ChangeRecorder implements PaperdollListener
{ {
private final Inventory _inventory; private final Inventory _inventory;
private final Set<ItemInstance> _changed = ConcurrentHashMap.newKeySet(); private final List<ItemInstance> _changed = new ArrayList<>(1);
/** /**
* Constructor of the ChangeRecorder * Constructor of the ChangeRecorder
@@ -183,9 +181,9 @@ public abstract class Inventory extends ItemContainer
* Returns alterations in inventory * Returns alterations in inventory
* @return ItemInstance[] : array of altered items * @return ItemInstance[] : array of altered items
*/ */
public ItemInstance[] getChangedItems() public List<ItemInstance> getChangedItems()
{ {
return _changed.toArray(new ItemInstance[_changed.size()]); return _changed;
} }
} }
@@ -1533,12 +1531,11 @@ public abstract class Inventory extends ItemContainer
* Unequips item in body slot and returns alterations.<br> * Unequips item in body slot and returns alterations.<br>
* <b>If you dont need return value use {@link Inventory#unEquipItemInBodySlot(int)} instead</b> * <b>If you dont need return value use {@link Inventory#unEquipItemInBodySlot(int)} instead</b>
* @param slot : int designating the slot of the paperdoll * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
unEquipItemInBodySlot(slot); unEquipItemInBodySlot(slot);
@@ -1564,12 +1561,11 @@ public abstract class Inventory extends ItemContainer
* Unequips item in slot and returns alterations<br> * Unequips item in slot and returns alterations<br>
* <b>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</b> * <b>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</b>
* @param slot : int designating the slot * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
unEquipItemInSlot(slot); unEquipItemInSlot(slot);
@@ -1737,12 +1733,11 @@ public abstract class Inventory extends ItemContainer
* Equips item and returns list of alterations<br> * Equips item and returns list of alterations<br>
* <b>If you don't need return value use {@link Inventory#equipItem(ItemInstance)} instead</b> * <b>If you don't need return value use {@link Inventory#equipItem(ItemInstance)} instead</b>
* @param item : ItemInstance corresponding to the item * @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(); final ChangeRecorder recorder = newRecorder();
try try
{ {
equipItem(item); equipItem(item);
@@ -1375,9 +1375,8 @@ public class ItemInstance extends WorldObject
// unequip // unequip
if (isEquipped()) if (isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -1811,9 +1810,8 @@ public class ItemInstance extends WorldObject
{ {
if (isEquipped()) if (isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -78,7 +79,7 @@ public class GameClient extends ChannelInboundHandler<GameClient>
private PlayerInstance _player; private PlayerInstance _player;
private SecondaryPasswordAuth _secondaryAuth; private SecondaryPasswordAuth _secondaryAuth;
private ClientHardwareInfoHolder _hardwareInfo; private ClientHardwareInfoHolder _hardwareInfo;
private CharSelectInfoPackage[] _charSlotMapping = null; private List<CharSelectInfoPackage> _charSlotMapping = null;
private volatile boolean _isDetached = false; private volatile boolean _isDetached = false;
private boolean _isAuthedGG; private boolean _isAuthedGG;
private boolean _protocolOk; private boolean _protocolOk;
@@ -568,21 +569,18 @@ public class GameClient extends ChannelInboundHandler<GameClient>
return player; return player;
} }
/** public void setCharSelection(List<CharSelectInfoPackage> characters)
* @param chars
*/
public void setCharSelection(CharSelectInfoPackage[] chars)
{ {
_charSlotMapping = chars; _charSlotMapping = characters;
} }
public CharSelectInfoPackage getCharSelection(int charslot) public CharSelectInfoPackage getCharSelection(int charslot)
{ {
if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.length)) if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.size()))
{ {
return null; return null;
} }
return _charSlotMapping[charslot]; return _charSlotMapping.get(charslot);
} }
public SecondaryPasswordAuth getSecondaryAuth() public SecondaryPasswordAuth getSecondaryAuth()
@@ -202,9 +202,8 @@ public class RequestCrystallizeItem implements IClientIncomingPacket
SystemMessage sm; SystemMessage sm;
if (itemToRemove.isEquipped()) if (itemToRemove.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : unequiped) for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
{ {
iu.addModifiedItem(item); iu.addModifiedItem(item);
} }
@@ -193,9 +193,8 @@ public class RequestDestroyItem implements IClientIncomingPacket
client.sendPacket(sm); client.sendPacket(sm);
} }
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance itm : unequiped) for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
@@ -309,12 +309,10 @@ public class RequestEnchantItem implements IClientIncomingPacket
client.sendPacket(sm); client.sendPacket(sm);
} }
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()); for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()))
for (ItemInstance itm : unequiped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }
player.sendInventoryUpdate(iu); player.sendInventoryUpdate(iu);
player.broadcastUserInfo(); player.broadcastUserInfo();
} }
@@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan; 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.GameClient;
import org.l2jmobius.gameserver.network.serverpackets.PledgePowerGradeList; import org.l2jmobius.gameserver.network.serverpackets.PledgePowerGradeList;
@@ -47,8 +46,7 @@ public class RequestPledgePowerGradeList implements IClientIncomingPacket
final Clan clan = player.getClan(); final Clan clan = player.getClan();
if (clan != null) if (clan != null)
{ {
final RankPrivs[] privs = clan.getAllRankPrivs(); player.sendPacket(new PledgePowerGradeList(clan.getAllRankPrivs()));
player.sendPacket(new PledgePowerGradeList(privs));
} }
} }
} }
@@ -18,9 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import static org.l2jmobius.gameserver.model.itemcontainer.Inventory.MAX_ADENA; 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.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.xml.RecipeData; import org.l2jmobius.gameserver.data.xml.RecipeData;
@@ -100,14 +97,11 @@ public class RequestRecipeShopListSet implements IClientIncomingPacket
return; return;
} }
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
player.getManufactureItems().clear(); player.getManufactureItems().clear();
for (ManufactureItem i : _items) for (ManufactureItem i : _items)
{ {
final RecipeList list = RecipeData.getInstance().getRecipeList(i.getRecipeId()); 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); Util.handleIllegalPlayerAction(player, "Warning!! Player " + player.getName() + " of account " + player.getAccountName() + " tried to set recipe which he dont have.", Config.DEFAULT_PUNISH);
return; return;
@@ -109,8 +109,7 @@ public class RequestRefine extends AbstractRefinePacket
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped()) if (targetItem.isEquipped())
{ {
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()); for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
for (ItemInstance itm : unequiped)
{ {
iu.addModifiedItem(itm); iu.addModifiedItem(itm);
} }

Some files were not shown because too many files have changed in this diff Show More