Removal of various conversions to arrays.
This commit is contained in:
@@ -594,9 +594,8 @@ public class AdminMobGroup implements IAdminCommandHandler
|
||||
|
||||
private void showGroupList(PlayerInstance activeChar)
|
||||
{
|
||||
final MobGroup[] mobGroupList = MobGroupTable.getInstance().getGroups();
|
||||
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() + ")");
|
||||
}
|
||||
|
||||
@@ -99,9 +99,8 @@ public class ItemAuctionLink implements IBypassHandler
|
||||
}
|
||||
else if ("cancel".equalsIgnoreCase(cmd))
|
||||
{
|
||||
final ItemAuction[] auctions = au.getAuctionsByBidder(player.getObjectId());
|
||||
boolean returned = false;
|
||||
for (ItemAuction auction : auctions)
|
||||
for (ItemAuction auction : au.getAuctionsByBidder(player.getObjectId()))
|
||||
{
|
||||
if (auction.cancelBid(player))
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package handlers.bypasshandlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -91,7 +92,7 @@ public class QuestLink implements IBypassHandler
|
||||
* @param npc The table containing quests of the NpcInstance
|
||||
* @param quests
|
||||
*/
|
||||
private static void showQuestChooseWindow(PlayerInstance player, Npc npc, Quest[] quests)
|
||||
private static void showQuestChooseWindow(PlayerInstance player, Npc npc, Collection<Quest> quests)
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(128);
|
||||
sb.append("<html><body>");
|
||||
@@ -340,7 +341,7 @@ public class QuestLink implements IBypassHandler
|
||||
}
|
||||
else if ((options.size() > 1) || ((player.getApprentice() > 0) && (World.getInstance().getPlayer(player.getApprentice()) != null) && options.stream().anyMatch(q -> q.getId() == TO_LEAD_AND_BE_LED)))
|
||||
{
|
||||
showQuestChooseWindow(player, npc, options.toArray(new Quest[options.size()]));
|
||||
showQuestChooseWindow(player, npc, options);
|
||||
}
|
||||
else if (options.size() == 1)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package handlers.effecthandlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.model.Elementals;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
@@ -85,7 +87,7 @@ public class ConvertItem extends AbstractEffect
|
||||
|
||||
final int enchantLevel = wpn.getEnchantLevel();
|
||||
final Elementals elementals = wpn.getElementals() == null ? null : wpn.getElementals()[0];
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
|
||||
final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance item : unequiped)
|
||||
{
|
||||
@@ -93,10 +95,11 @@ public class ConvertItem extends AbstractEffect
|
||||
}
|
||||
player.sendPacket(iu);
|
||||
|
||||
if (unequiped.length <= 0)
|
||||
if (unequiped.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
byte count = 0;
|
||||
for (ItemInstance item : unequiped)
|
||||
{
|
||||
@@ -121,7 +124,7 @@ public class ConvertItem extends AbstractEffect
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
|
||||
if (count == unequiped.length)
|
||||
if (count == unequiped.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ public class Recipes implements IItemHandler
|
||||
{
|
||||
canCraft = player.hasDwarvenCraft();
|
||||
recipeLevel = (rp.getLevel() > player.getDwarvenCraft());
|
||||
recipeLimit = (player.getDwarvenRecipeBook().length >= player.getDwarfRecipeLimit());
|
||||
recipeLimit = (player.getDwarvenRecipeBook().size() >= player.getDwarfRecipeLimit());
|
||||
}
|
||||
else
|
||||
{
|
||||
canCraft = player.hasCommonCraft();
|
||||
recipeLevel = (rp.getLevel() > player.getCommonCraft());
|
||||
recipeLimit = (player.getCommonRecipeBook().length >= player.getCommonRecipeLimit());
|
||||
recipeLimit = (player.getCommonRecipeBook().size() >= player.getCommonRecipeLimit());
|
||||
}
|
||||
|
||||
if (!canCraft)
|
||||
|
||||
@@ -264,8 +264,7 @@ public class ScarletVanHalisha extends AbstractNpcAI
|
||||
}
|
||||
if (!result.isEmpty() && (result.size() != 0))
|
||||
{
|
||||
final Object[] characters = result.toArray();
|
||||
return (Creature) characters[Rnd.get(characters.length)];
|
||||
return getRandomEntry(result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.l2jmobius.gameserver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -88,9 +87,7 @@ public class RecipeController
|
||||
return;
|
||||
}
|
||||
|
||||
final List<RecipeList> dwarfRecipes = Arrays.asList(manufacturer.getDwarvenRecipeBook());
|
||||
final List<RecipeList> commonRecipes = Arrays.asList(manufacturer.getCommonRecipeBook());
|
||||
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
|
||||
if (!manufacturer.getDwarvenRecipeBook().contains(recipeList) && !manufacturer.getCommonRecipeBook().contains(recipeList))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
@@ -133,9 +130,7 @@ public class RecipeController
|
||||
return;
|
||||
}
|
||||
|
||||
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
|
||||
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
|
||||
if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
|
||||
if (!player.getDwarvenRecipeBook().contains(recipeList) && !player.getCommonRecipeBook().contains(recipeList))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
|
||||
@@ -396,16 +396,16 @@ public class AutoSpawnHandler
|
||||
return;
|
||||
}
|
||||
|
||||
final Location[] locationList = spawnInst.getLocationList();
|
||||
final List<Location> locationList = spawnInst.getLocationList();
|
||||
|
||||
// If there are no set co-ordinates, cancel the spawn task.
|
||||
if (locationList.length == 0)
|
||||
if (locationList.isEmpty())
|
||||
{
|
||||
LOGGER.info("AutoSpawnHandler: No location co-ords specified for spawn instance (Object ID = " + _objectId + ").");
|
||||
return;
|
||||
}
|
||||
|
||||
final int locationCount = locationList.length;
|
||||
final int locationCount = locationList.size();
|
||||
int locationIndex = Rnd.get(locationCount);
|
||||
|
||||
// If random spawning is disabled, the spawn at the next set of co-ordinates after the last.
|
||||
@@ -422,10 +422,10 @@ public class AutoSpawnHandler
|
||||
}
|
||||
|
||||
// Set the X, Y and Z co-ordinates, where this spawn will take place.
|
||||
final int x = locationList[locationIndex].getX();
|
||||
final int y = locationList[locationIndex].getY();
|
||||
final int z = locationList[locationIndex].getZ();
|
||||
final int heading = locationList[locationIndex].getHeading();
|
||||
final int x = locationList.get(locationIndex).getX();
|
||||
final int y = locationList.get(locationIndex).getY();
|
||||
final int z = locationList.get(locationIndex).getZ();
|
||||
final int heading = locationList.get(locationIndex).getHeading();
|
||||
final Spawn newSpawn = new Spawn(spawnInst.getId());
|
||||
newSpawn.setXYZ(x, y, z);
|
||||
if (heading != -1)
|
||||
@@ -469,7 +469,7 @@ public class AutoSpawnHandler
|
||||
while (!World.getInstance().getVisibleObjectsInRange(npcInst, Npc.class, 5).isEmpty())
|
||||
{
|
||||
// LOGGER.log(Level.INFO, "AutoSpawnHandler: Random spawn location " + npcInst.getLocation() + " for " + npcInst + " is occupied. Teleporting...");
|
||||
npcInst.teleToLocation(locationList[Rnd.get(locationList.length)]);
|
||||
npcInst.teleToLocation(locationList.get(Rnd.get(locationList.size())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,9 +628,9 @@ public class AutoSpawnHandler
|
||||
return _spawnCount;
|
||||
}
|
||||
|
||||
public Location[] getLocationList()
|
||||
public List<Location> getLocationList()
|
||||
{
|
||||
return _locList.toArray(new Location[_locList.size()]);
|
||||
return _locList;
|
||||
}
|
||||
|
||||
public Queue<Npc> getNPCInstanceList()
|
||||
|
||||
@@ -94,8 +94,7 @@ public class MacroList implements IRestorable
|
||||
deleteMacroFromDb(removed);
|
||||
}
|
||||
|
||||
final Shortcut[] allShortCuts = _owner.getAllShortCuts();
|
||||
for (Shortcut sc : allShortCuts)
|
||||
for (Shortcut sc : _owner.getAllShortCuts())
|
||||
{
|
||||
if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -67,9 +68,9 @@ public class MobGroupTable
|
||||
return null;
|
||||
}
|
||||
|
||||
public MobGroup[] getGroups()
|
||||
public Collection<MobGroup> getGroups()
|
||||
{
|
||||
return _groupMap.values().toArray(new MobGroup[_groupMap.size()]);
|
||||
return _groupMap.values();
|
||||
}
|
||||
|
||||
public boolean removeGroup(int groupKey)
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
@@ -46,9 +47,9 @@ public class ShortCuts implements IRestorable
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public Shortcut[] getAllShortCuts()
|
||||
public Collection<Shortcut> getAllShortCuts()
|
||||
{
|
||||
return _shortCuts.values().toArray(new Shortcut[_shortCuts.values().size()]);
|
||||
return _shortCuts.values();
|
||||
}
|
||||
|
||||
public Shortcut getShortCut(int slot, int page)
|
||||
|
||||
@@ -107,9 +107,9 @@ public class TradeList
|
||||
/**
|
||||
* @return all items from TradeList
|
||||
*/
|
||||
public TradeItem[] getItems()
|
||||
public Collection<TradeItem> getItems()
|
||||
{
|
||||
return _items.toArray(new TradeItem[_items.size()]);
|
||||
return _items;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1272,17 +1272,17 @@ public class PlayerInstance extends Playable
|
||||
/**
|
||||
* @return a table 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.
|
||||
*/
|
||||
public RecipeList[] getDwarvenRecipeBook()
|
||||
public Collection<RecipeList> getDwarvenRecipeBook()
|
||||
{
|
||||
return _dwarvenRecipeBook.values().toArray(new RecipeList[_dwarvenRecipeBook.values().size()]);
|
||||
return _dwarvenRecipeBook.values();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1526,9 +1526,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();
|
||||
}
|
||||
@@ -2137,7 +2137,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
// Equip or unEquip
|
||||
ItemInstance[] items = null;
|
||||
Collection<ItemInstance> items = null;
|
||||
final boolean isEquiped = item.isEquipped();
|
||||
final int oldInvLimit = getInventoryLimit();
|
||||
SystemMessage sm = null;
|
||||
@@ -2205,7 +2205,7 @@ public class PlayerInstance extends Playable
|
||||
broadcastUserInfo();
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItems(Arrays.asList(items));
|
||||
iu.addItems(items);
|
||||
sendPacket(iu);
|
||||
|
||||
if (abortAttack)
|
||||
@@ -6161,9 +6161,9 @@ public class PlayerInstance extends Playable
|
||||
return false;
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
|
||||
final List<ItemInstance> unequipped = _inventory.unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : unequipped)
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
@@ -6173,19 +6173,20 @@ public class PlayerInstance extends Playable
|
||||
broadcastUserInfo();
|
||||
|
||||
// This can be 0 if the user pressed the right mousebutton twice very fast.
|
||||
if (unequiped.length > 0)
|
||||
if (!unequipped.isEmpty())
|
||||
{
|
||||
final SystemMessage sm;
|
||||
if (unequiped[0].getEnchantLevel() > 0)
|
||||
final ItemInstance unequippedItem = unequipped.get(0);
|
||||
if (unequippedItem.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addInt(unequiped[0].getEnchantLevel());
|
||||
sm.addInt(unequippedItem.getEnchantLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_DISARMED);
|
||||
}
|
||||
sm.addItemName(unequiped[0]);
|
||||
sm.addItemName(unequippedItem);
|
||||
sendPacket(sm);
|
||||
}
|
||||
return true;
|
||||
@@ -6200,9 +6201,9 @@ public class PlayerInstance extends Playable
|
||||
final ItemInstance sld = _inventory.getPaperdollItem(Inventory.PAPERDOLL_LHAND);
|
||||
if (sld != null)
|
||||
{
|
||||
final ItemInstance[] unequiped = _inventory.unEquipItemInBodySlotAndRecord(sld.getItem().getBodyPart());
|
||||
final List<ItemInstance> unequipped = _inventory.unEquipItemInBodySlotAndRecord(sld.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : unequipped)
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
@@ -6212,19 +6213,20 @@ public class PlayerInstance extends Playable
|
||||
broadcastUserInfo();
|
||||
|
||||
// this can be 0 if the user pressed the right mousebutton twice very fast
|
||||
if (unequiped.length > 0)
|
||||
if (!unequipped.isEmpty())
|
||||
{
|
||||
SystemMessage sm = null;
|
||||
if (unequiped[0].getEnchantLevel() > 0)
|
||||
final ItemInstance unequippedItem = unequipped.get(0);
|
||||
if (unequippedItem.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addInt(unequiped[0].getEnchantLevel());
|
||||
sm.addInt(unequippedItem.getEnchantLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_DISARMED);
|
||||
}
|
||||
sm.addItemName(unequiped[0]);
|
||||
sm.addItemName(unequippedItem);
|
||||
sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2566,9 +2566,8 @@ public abstract class AbstractScript extends ManagedScript
|
||||
{
|
||||
if (item.isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart()))
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ public class ItemAuctionInstance
|
||||
return _auctions.get(auctionId);
|
||||
}
|
||||
|
||||
public ItemAuction[] getAuctionsByBidder(int bidderObjId)
|
||||
public List<ItemAuction> getAuctionsByBidder(int bidderObjId)
|
||||
{
|
||||
final Collection<ItemAuction> auctions = getAuctions();
|
||||
final List<ItemAuction> stack = new ArrayList<>(auctions.size());
|
||||
@@ -355,7 +355,7 @@ public class ItemAuctionInstance
|
||||
stack.add(auction);
|
||||
}
|
||||
}
|
||||
return stack.toArray(new ItemAuction[stack.size()]);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public Collection<ItemAuction> getAuctions()
|
||||
|
||||
@@ -20,9 +20,8 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -112,7 +111,7 @@ public abstract class Inventory extends ItemContainer
|
||||
private static final class ChangeRecorder implements PaperdollListener
|
||||
{
|
||||
private final Inventory _inventory;
|
||||
private final Set<ItemInstance> _changed = ConcurrentHashMap.newKeySet();
|
||||
private final List<ItemInstance> _changed = new ArrayList<>(1);
|
||||
|
||||
/**
|
||||
* Constructor of the ChangeRecorder
|
||||
@@ -150,11 +149,11 @@ public abstract class Inventory extends ItemContainer
|
||||
|
||||
/**
|
||||
* Returns alterations in inventory
|
||||
* @return ItemInstance[] : array of altered items
|
||||
* @return Collection<ItemInstance> : Collection of altered items
|
||||
*/
|
||||
public ItemInstance[] getChangedItems()
|
||||
public List<ItemInstance> getChangedItems()
|
||||
{
|
||||
return _changed.toArray(new ItemInstance[_changed.size()]);
|
||||
return _changed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1260,12 +1259,11 @@ public abstract class Inventory extends ItemContainer
|
||||
* Unequips item in body slot and returns alterations.<br>
|
||||
* <b>If you dont need return value use {@link Inventory#unEquipItemInBodySlot(int)} instead</b>
|
||||
* @param slot : int designating the slot of the paperdoll
|
||||
* @return ItemInstance[] : list of changes
|
||||
* @return List<ItemInstance> : List of changes
|
||||
*/
|
||||
public ItemInstance[] unEquipItemInBodySlotAndRecord(int slot)
|
||||
public List<ItemInstance> unEquipItemInBodySlotAndRecord(int slot)
|
||||
{
|
||||
final ChangeRecorder recorder = newRecorder();
|
||||
|
||||
try
|
||||
{
|
||||
unEquipItemInBodySlot(slot);
|
||||
@@ -1291,12 +1289,11 @@ public abstract class Inventory extends ItemContainer
|
||||
* Unequips item in slot and returns alterations<br>
|
||||
* <b>If you dont need return value use {@link Inventory#unEquipItemInSlot(int)} instead</b>
|
||||
* @param slot : int designating the slot
|
||||
* @return ItemInstance[] : list of items altered
|
||||
* @return Collection<ItemInstance> : Collection of items altered
|
||||
*/
|
||||
public ItemInstance[] unEquipItemInSlotAndRecord(int slot)
|
||||
public Collection<ItemInstance> unEquipItemInSlotAndRecord(int slot)
|
||||
{
|
||||
final ChangeRecorder recorder = newRecorder();
|
||||
|
||||
try
|
||||
{
|
||||
unEquipItemInSlot(slot);
|
||||
@@ -1454,12 +1451,11 @@ public abstract class Inventory extends ItemContainer
|
||||
* Equips item and returns list of alterations<br>
|
||||
* <b>If you don't need return value use {@link Inventory#equipItem(ItemInstance)} instead</b>
|
||||
* @param item : ItemInstance corresponding to the item
|
||||
* @return ItemInstance[] : list of alterations
|
||||
* @return Collection<ItemInstance> : Collection of alterations
|
||||
*/
|
||||
public ItemInstance[] equipItemAndRecord(ItemInstance item)
|
||||
public Collection<ItemInstance> equipItemAndRecord(ItemInstance item)
|
||||
{
|
||||
final ChangeRecorder recorder = newRecorder();
|
||||
|
||||
try
|
||||
{
|
||||
equipItem(item);
|
||||
|
||||
@@ -1305,9 +1305,8 @@ public class ItemInstance extends WorldObject
|
||||
// unequip
|
||||
if (isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance item : unequiped)
|
||||
for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
|
||||
{
|
||||
item.unChargeAllShots();
|
||||
iu.addModifiedItem(item);
|
||||
@@ -1776,9 +1775,8 @@ public class ItemInstance extends WorldObject
|
||||
|
||||
if (isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance item : unequiped)
|
||||
for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot()))
|
||||
{
|
||||
item.unChargeAllShots();
|
||||
iu.addModifiedItem(item);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.partymatching;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -66,9 +67,9 @@ public class PartyMatchRoomList
|
||||
return _rooms.get(id);
|
||||
}
|
||||
|
||||
public PartyMatchRoom[] getRooms()
|
||||
public Collection<PartyMatchRoom> getRooms()
|
||||
{
|
||||
return _rooms.values().toArray(new PartyMatchRoom[_rooms.size()]);
|
||||
return _rooms.values();
|
||||
}
|
||||
|
||||
public int getPartyMatchRoomCount()
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -72,7 +73,7 @@ public class GameClient extends ChannelInboundHandler<GameClient>
|
||||
private SessionKey _sessionId;
|
||||
private PlayerInstance _player;
|
||||
private SecondaryPasswordAuth _secondaryAuth;
|
||||
private CharSelectInfoPackage[] _charSlotMapping = null;
|
||||
private List<CharSelectInfoPackage> _charSlotMapping = null;
|
||||
private volatile boolean _isDetached = false;
|
||||
private boolean _isAuthedGG;
|
||||
private boolean _protocolOk;
|
||||
@@ -578,21 +579,18 @@ public class GameClient extends ChannelInboundHandler<GameClient>
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chars
|
||||
*/
|
||||
public void setCharSelection(CharSelectInfoPackage[] chars)
|
||||
public void setCharSelection(List<CharSelectInfoPackage> characters)
|
||||
{
|
||||
_charSlotMapping = chars;
|
||||
_charSlotMapping = characters;
|
||||
}
|
||||
|
||||
public CharSelectInfoPackage getCharSelection(int charslot)
|
||||
{
|
||||
if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.length))
|
||||
if ((_charSlotMapping == null) || (charslot < 0) || (charslot >= _charSlotMapping.size()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _charSlotMapping[charslot];
|
||||
return _charSlotMapping.get(charslot);
|
||||
}
|
||||
|
||||
public SecondaryPasswordAuth getSecondaryAuth()
|
||||
|
||||
@@ -175,9 +175,8 @@ public class RequestCrystallizeItem implements IClientIncomingPacket
|
||||
SystemMessage sm;
|
||||
if (itemToRemove.isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance item : unequiped)
|
||||
for (ItemInstance item : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
|
||||
{
|
||||
iu.addModifiedItem(item);
|
||||
}
|
||||
|
||||
@@ -175,9 +175,8 @@ public class RequestDestroyItem implements IClientIncomingPacket
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()))
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
|
||||
@@ -202,9 +202,8 @@ public class RequestDropItem implements IClientIncomingPacket
|
||||
|
||||
if (item.isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()))
|
||||
{
|
||||
itm.unChargeAllShots();
|
||||
iu.addModifiedItem(itm);
|
||||
|
||||
@@ -286,12 +286,10 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()))
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
|
||||
player.sendPacket(iu);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import static org.l2jmobius.gameserver.model.itemcontainer.Inventory.MAX_ADENA;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.data.xml.RecipeData;
|
||||
@@ -106,14 +103,11 @@ public class RequestRecipeShopListSet implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
final List<RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
|
||||
final List<RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
|
||||
player.getManufactureItems().clear();
|
||||
|
||||
for (ManufactureItem i : _items)
|
||||
{
|
||||
final RecipeList list = RecipeData.getInstance().getRecipeList(i.getRecipeId());
|
||||
if (!dwarfRecipes.contains(list) && !commonRecipes.contains(list))
|
||||
if (!player.getDwarvenRecipeBook().contains(list) && !player.getCommonRecipeBook().contains(list))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Warning!! Player " + player.getName() + " of account " + player.getAccountName() + " tried to set recipe which he dont have.", Config.DEFAULT_PUNISH);
|
||||
return;
|
||||
|
||||
@@ -97,9 +97,8 @@ public class RequestRefine extends AbstractRefinePacket
|
||||
// unequip item
|
||||
if (targetItem.isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
|
||||
@@ -148,8 +148,7 @@ public class RequestRefineCancel implements IClientIncomingPacket
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
if (targetItem.isEquipped())
|
||||
{
|
||||
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
|
||||
for (ItemInstance itm : unequiped)
|
||||
for (ItemInstance itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
|
||||
{
|
||||
iu.addModifiedItem(itm);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.PlayerCondOverride;
|
||||
@@ -99,27 +99,28 @@ public class RequestUnEquipItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemInstance[] unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
|
||||
final List<ItemInstance> unequipped = player.getInventory().unEquipItemInBodySlotAndRecord(_slot);
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// This can be 0 if the user pressed the right mouse button twice very fast.
|
||||
if (unequipped.length > 0)
|
||||
if (!unequipped.isEmpty())
|
||||
{
|
||||
SystemMessage sm = null;
|
||||
if (unequipped[0].getEnchantLevel() > 0)
|
||||
final ItemInstance unequippedItem = unequipped.get(0);
|
||||
if (unequippedItem.getEnchantLevel() > 0)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
|
||||
sm.addInt(unequipped[0].getEnchantLevel());
|
||||
sm.addInt(unequippedItem.getEnchantLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.S1_HAS_BEEN_DISARMED);
|
||||
}
|
||||
sm.addItemName(unequipped[0]);
|
||||
sm.addItemName(unequippedItem);
|
||||
player.sendPacket(sm);
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItems(Arrays.asList(unequipped));
|
||||
iu.addItems(unequipped);
|
||||
player.sendPacket(iu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class AbstractInventoryUpdate extends AbstractItemPacket
|
||||
_items.put(item.getObjectId(), new ItemInfo(item, 3));
|
||||
}
|
||||
|
||||
public void addItems(List<ItemInstance> items)
|
||||
public void addItems(Collection<ItemInstance> items)
|
||||
{
|
||||
for (ItemInstance item : items)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
private final String _loginName;
|
||||
private final int _sessionId;
|
||||
private int _activeId;
|
||||
private final CharSelectInfoPackage[] _characterPackages;
|
||||
private final List<CharSelectInfoPackage> _characterPackages;
|
||||
|
||||
/**
|
||||
* Constructor for CharSelectionInfo.
|
||||
@@ -68,7 +68,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
_activeId = activeId;
|
||||
}
|
||||
|
||||
public CharSelectInfoPackage[] getCharInfo()
|
||||
public List<CharSelectInfoPackage> getCharInfo()
|
||||
{
|
||||
return _characterPackages;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
{
|
||||
OutgoingPackets.CHARACTER_SELECTION_INFO.writeId(packet);
|
||||
|
||||
final int size = _characterPackages.length;
|
||||
final int size = _characterPackages.size();
|
||||
packet.writeD(size); // Created character count
|
||||
|
||||
packet.writeD(Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT); // Can prevent players from creating new characters (if 0); (if 1, the client will ask if chars may be created (0x13) Response: (0x0D) )
|
||||
@@ -89,9 +89,9 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (lastAccess < _characterPackages[i].getLastAccess())
|
||||
if (lastAccess < _characterPackages.get(i).getLastAccess())
|
||||
{
|
||||
lastAccess = _characterPackages[i].getLastAccess();
|
||||
lastAccess = _characterPackages.get(i).getLastAccess();
|
||||
_activeId = i;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
final CharSelectInfoPackage charInfoPackage = _characterPackages[i];
|
||||
final CharSelectInfoPackage charInfoPackage = _characterPackages.get(i);
|
||||
packet.writeS(charInfoPackage.getName()); // Character name
|
||||
packet.writeD(charInfoPackage.getObjectId()); // Character ID
|
||||
packet.writeS(_loginName); // Account name
|
||||
@@ -171,7 +171,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
return true;
|
||||
}
|
||||
|
||||
private static CharSelectInfoPackage[] loadCharacterSelectInfo(String loginName)
|
||||
private static List<CharSelectInfoPackage> loadCharacterSelectInfo(String loginName)
|
||||
{
|
||||
CharSelectInfoPackage charInfopackage;
|
||||
final List<CharSelectInfoPackage> characterList = new LinkedList<>();
|
||||
@@ -197,13 +197,13 @@ public class CharSelectionInfo implements IClientOutgoingPacket
|
||||
}
|
||||
}
|
||||
}
|
||||
return characterList.toArray(new CharSelectInfoPackage[characterList.size()]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Could not restore char info: " + e.getMessage(), e);
|
||||
}
|
||||
return new CharSelectInfoPackage[0];
|
||||
|
||||
return characterList;
|
||||
}
|
||||
|
||||
private static void loadCharacterSubclassInfo(CharSelectInfoPackage charInfopackage, int objectId, int activeClassId)
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PrivateStoreListSell extends AbstractItemPacket
|
||||
packet.writeD(_seller.getObjectId());
|
||||
packet.writeD(_seller.getSellList().isPackaged() ? 1 : 0);
|
||||
packet.writeQ(_player.getAdena());
|
||||
packet.writeD(_seller.getSellList().getItems().length);
|
||||
packet.writeD(_seller.getSellList().getItems().size());
|
||||
for (TradeItem item : _seller.getSellList().getItems())
|
||||
{
|
||||
writeItem(packet, item);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PrivateStoreManageListBuy extends AbstractItemPacket
|
||||
private final int _objId;
|
||||
private final long _playerAdena;
|
||||
private final Collection<ItemInstance> _itemList;
|
||||
private final TradeItem[] _buyList;
|
||||
private final Collection<TradeItem> _buyList;
|
||||
|
||||
public PrivateStoreManageListBuy(PlayerInstance player)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ public class PrivateStoreManageListBuy extends AbstractItemPacket
|
||||
}
|
||||
|
||||
// section 3
|
||||
packet.writeD(_buyList.length); // count for all items already added for buy
|
||||
packet.writeD(_buyList.size()); // count for all items already added for buy
|
||||
for (TradeItem item : _buyList)
|
||||
{
|
||||
writeItem(packet, item);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PrivateStoreManageListSell extends AbstractItemPacket
|
||||
private final long _playerAdena;
|
||||
private final boolean _packageSale;
|
||||
private final Collection<TradeItem> _itemList;
|
||||
private final TradeItem[] _sellList;
|
||||
private final Collection<TradeItem> _sellList;
|
||||
|
||||
public PrivateStoreManageListSell(PlayerInstance player, boolean isPackageSale)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ public class PrivateStoreManageListSell extends AbstractItemPacket
|
||||
packet.writeQ(item.getItem().getReferencePrice() * 2);
|
||||
}
|
||||
// section 3
|
||||
packet.writeD(_sellList.length); // count for any items already added for sell
|
||||
packet.writeD(_sellList.size()); // count for any items already added for sell
|
||||
for (TradeItem item : _sellList)
|
||||
{
|
||||
writeItem(packet, item);
|
||||
|
||||
@@ -16,13 +16,15 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.RecipeList;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
public class RecipeBookItemList implements IClientOutgoingPacket
|
||||
{
|
||||
private RecipeList[] _recipes;
|
||||
private Collection<RecipeList> _recipes;
|
||||
private final boolean _isDwarvenCraft;
|
||||
private final int _maxMp;
|
||||
|
||||
@@ -32,7 +34,7 @@ public class RecipeBookItemList implements IClientOutgoingPacket
|
||||
_maxMp = maxMp;
|
||||
}
|
||||
|
||||
public void addRecipes(RecipeList[] recipeBook)
|
||||
public void addRecipes(Collection<RecipeList> recipeBook)
|
||||
{
|
||||
_recipes = recipeBook;
|
||||
}
|
||||
@@ -50,11 +52,13 @@ public class RecipeBookItemList implements IClientOutgoingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(_recipes.length); // number of items in recipe book
|
||||
for (int i = 0; i < _recipes.length; i++)
|
||||
packet.writeD(_recipes.size()); // number of items in recipe book
|
||||
int count = 0;
|
||||
for (RecipeList recipe : _recipes)
|
||||
{
|
||||
packet.writeD(_recipes[i].getId());
|
||||
packet.writeD(i + 1);
|
||||
count++;
|
||||
packet.writeD(recipe.getId());
|
||||
packet.writeD(count);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
@@ -28,7 +29,7 @@ public class RecipeShopManageList implements IClientOutgoingPacket
|
||||
{
|
||||
private final PlayerInstance _seller;
|
||||
private final boolean _isDwarven;
|
||||
private RecipeList[] _recipes;
|
||||
private Collection<RecipeList> _recipes;
|
||||
|
||||
public RecipeShopManageList(PlayerInstance seller, boolean isDwarven)
|
||||
{
|
||||
@@ -72,13 +73,13 @@ public class RecipeShopManageList implements IClientOutgoingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(_recipes.length); // number of items in recipe book
|
||||
|
||||
for (int i = 0; i < _recipes.length; i++)
|
||||
packet.writeD(_recipes.size()); // number of items in recipe book
|
||||
int count = 0;
|
||||
for (RecipeList recipe : _recipes)
|
||||
{
|
||||
final RecipeList temp = _recipes[i];
|
||||
packet.writeD(temp.getId());
|
||||
packet.writeD(i + 1);
|
||||
count++;
|
||||
packet.writeD(recipe.getId());
|
||||
packet.writeD(count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.Shortcut;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
@@ -23,7 +25,7 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
public class ShortCutInit implements IClientOutgoingPacket
|
||||
{
|
||||
private Shortcut[] _shortCuts;
|
||||
private Collection<Shortcut> _shortCuts;
|
||||
|
||||
public ShortCutInit(PlayerInstance player)
|
||||
{
|
||||
@@ -39,7 +41,7 @@ public class ShortCutInit implements IClientOutgoingPacket
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.SHORT_CUT_INIT.writeId(packet);
|
||||
packet.writeD(_shortCuts.length);
|
||||
packet.writeD(_shortCuts.size());
|
||||
for (Shortcut sc : _shortCuts)
|
||||
{
|
||||
packet.writeD(sc.getType().ordinal());
|
||||
|
||||
Reference in New Issue
Block a user