Removal of various conversions to arrays.

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

View File

@@ -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() + ")");
}

View File

@@ -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))
{

View File

@@ -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)
{

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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;
}