Added default capacities to some arraylists

This commit is contained in:
Ceikry
2021-03-12 21:22:15 -06:00
parent 058f5b3044
commit 78a9b8c88e
29 changed files with 86 additions and 89 deletions
@@ -33,7 +33,7 @@ public abstract class CutscenePlugin extends ActivityPlugin {
/**
* The npcs in our cutscene.
*/
protected final List<NPC> npcs = new ArrayList<>();
protected final List<NPC> npcs = new ArrayList<>(100);
/**
* The start pulse used for effect.
@@ -1,14 +1,9 @@
package core.game.content.activity.duel;
import java.util.ArrayList;
import java.util.List;
import rs09.ServerConstants;
import core.cache.def.impl.ObjectDefinition;
import core.game.container.Container;
import core.game.container.impl.EquipmentContainer;
import core.game.content.dialogue.DialogueAction;
import core.game.node.entity.skill.summoning.familiar.Familiar;
import core.game.interaction.Option;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
@@ -19,11 +14,11 @@ import core.game.node.entity.impl.PulseManager;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.HintIconManager;
import core.game.node.entity.player.link.prayer.PrayerType;
import core.game.node.entity.skill.summoning.familiar.Familiar;
import core.game.node.item.GroundItem;
import core.game.node.item.GroundItemManager;
import core.game.node.item.Item;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.map.RegionManager;
import core.game.world.map.zone.MapZone;
@@ -32,6 +27,11 @@ import core.game.world.map.zone.ZoneRestriction;
import core.plugin.Plugin;
import core.tools.RandomFunction;
import core.tools.StringUtils;
import rs09.ServerConstants;
import rs09.game.world.GameWorld;
import java.util.ArrayList;
import java.util.List;
/**
* Represents a dueling area.
@@ -122,8 +122,8 @@ public class DuelArea extends MapZone {
session.getOther().getInterfaceManager().restoreTabs();
session.getPlayer().setAttribute("duel:icon", HintIconManager.registerHintIcon(session.getPlayer(), session.getOther()));
session.getOther().setAttribute("duel:icon", HintIconManager.registerHintIcon(session.getOther(), session.getPlayer()));
session.getPlayer().setAttribute("duel:ammo", new ArrayList<GroundItem>());
session.getOther().setAttribute("duel:ammo", new ArrayList<GroundItem>());
session.getPlayer().setAttribute("duel:ammo", new ArrayList<GroundItem>(100));
session.getOther().setAttribute("duel:ammo", new ArrayList<GroundItem>(100));
session.getPlayer().setAttribute("vengeance", false);
session.getOther().setAttribute("vengeance", false);
GameWorld.getPulser().submit(new Pulse(4, session.getPlayer(), session.getOther()) {
@@ -1,8 +1,5 @@
package core.game.content.activity.mta;
import java.util.ArrayList;
import java.util.List;
import core.game.component.CloseEvent;
import core.game.component.Component;
import core.game.component.ComponentPlugin;
@@ -12,8 +9,11 @@ import core.game.container.access.InterfaceContainer;
import core.game.node.entity.player.Player;
import core.game.node.item.Item;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.plugin.Plugin;
import rs09.game.world.GameWorld;
import java.util.ArrayList;
import java.util.List;
/**
* Represents the mage training arena shop.
@@ -44,7 +44,7 @@ public class MTAShop {
/**
* The viewers.
*/
private final List<Player> viewers = new ArrayList<>();
private final List<Player> viewers = new ArrayList<>(100);
/**
* The shop component.
@@ -48,7 +48,7 @@ public final class DialogueInterpreter {
/**
* a List of dialogue actions.
*/
private final List<DialogueAction> actions = new ArrayList<>();
private final List<DialogueAction> actions = new ArrayList<>(10);
/**
* The currently opened dialogue.
@@ -43,8 +43,8 @@ public abstract class DialoguePlugin implements Plugin<Player> {
public DialogueFile file;
protected ArrayList<String> optionNames = new ArrayList<String>();
protected ArrayList<DialogueFile> optionFiles = new ArrayList<DialogueFile>();
protected ArrayList<String> optionNames = new ArrayList<String>(10);
protected ArrayList<DialogueFile> optionFiles = new ArrayList<DialogueFile>(10);
/**
* Two options interface.
@@ -1,13 +1,13 @@
package core.game.content.dialogue;
import java.util.ArrayList;
import java.util.List;
import core.game.content.global.GodBook;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.plugin.Initializable;
import core.game.node.item.Item;
import core.plugin.Initializable;
import java.util.ArrayList;
import java.util.List;
/**
* Handles the dialogue for jossik.
@@ -86,7 +86,7 @@ public class JossikDialogue extends DialoguePlugin {
stage = 23;
return true;
}
uncompleted = new ArrayList<>();
uncompleted = new ArrayList<>(5);
for (GodBook book : GodBook.values()) {
if (!player.getSavedData().getGlobalData().hasCompletedGodBook(book)) {
uncompleted.add(book);
@@ -1,17 +1,17 @@
package core.game.content.dialogue;
import java.util.ArrayList;
import java.util.List;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.info.Rights;
import core.game.node.entity.player.link.IronmanMode;
import core.game.node.entity.player.link.diary.DiaryType;
import rs09.game.world.GameWorld;
import core.game.world.map.zone.impl.ModeratorZone;
import core.plugin.Initializable;
import core.net.amsc.MSPacketRepository;
import core.plugin.Initializable;
import rs09.game.world.GameWorld;
import java.util.ArrayList;
import java.util.List;
/**
* Represents the lumbridge guide dialogue plugin.
@@ -65,7 +65,7 @@ public final class LumbridgeGuideDialogue extends DialoguePlugin {
stage = 103;
return true;
}
options = new ArrayList<>();
options = new ArrayList<>(5);
options.add("Yes please.");
if (player.getRights() == Rights.PLAYER_MODERATOR && ModeratorZone.isOpen() || player.isAdmin()) {
options.add("I would like to access the P-Mod room.");
@@ -21,7 +21,7 @@ public abstract class HolidayEvent extends MapZone implements Plugin<Object> {
/**
* The list of holiday events.
*/
private static final List<HolidayEvent> EVENTS = new ArrayList<>();
private static final List<HolidayEvent> EVENTS = new ArrayList<>(5);
/**
* The current holiday event.
@@ -1,18 +1,18 @@
package core.game.interaction.item;
import java.util.ArrayList;
import java.util.List;
import core.cache.def.impl.ItemDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.player.Player;
import core.game.node.item.ChanceItem;
import core.game.node.item.Item;
import core.plugin.Plugin;
import core.plugin.Initializable;
import core.plugin.Plugin;
import core.tools.RandomFunction;
import java.util.ArrayList;
import java.util.List;
/**
* Handles the herb box item.
* @author Vexia
@@ -49,7 +49,7 @@ public class HerbBoxPlugin extends OptionHandler {
player.sendMessage("You don't have enough bank space to bank all those herbs.");
break;
}
List<ChanceItem> herbList = new ArrayList<>();
List<ChanceItem> herbList = new ArrayList<>(5);
for (int i = 0; i < herbs; i++) {
herbList.add(RandomFunction.getChanceItem(HERBS));
}
@@ -1,13 +1,6 @@
package core.game.interaction.object;
import java.util.ArrayList;
import java.util.List;
import core.cache.def.impl.ObjectDefinition;
import core.plugin.Initializable;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.skill.firemaking.Log;
import core.game.node.entity.skill.gather.SkillingTool;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.Entity;
@@ -16,18 +9,25 @@ import core.game.node.entity.npc.AbstractNPC;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.npc.drop.DropFrequency;
import core.game.node.entity.player.Player;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.skill.firemaking.Log;
import core.game.node.entity.skill.gather.SkillingTool;
import core.game.node.item.ChanceItem;
import core.game.node.item.Item;
import core.game.node.object.GameObject;
import core.game.node.object.ObjectBuilder;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
import rs09.game.world.repository.Repository;
import core.game.world.update.flag.context.Animation;
import core.plugin.Initializable;
import core.plugin.Plugin;
import rs09.plugin.PluginManager;
import core.tools.RandomFunction;
import rs09.game.world.GameWorld;
import rs09.game.world.repository.Repository;
import rs09.plugin.PluginManager;
import java.util.ArrayList;
import java.util.List;
/**
* Handles the pyre site plugin.
@@ -59,7 +59,7 @@ public final class PyreSitePlugin extends OptionHandler {
/**
* The list of used pyre ship locations.
*/
private static final List<Location> USED_LOCATIONS = new ArrayList<>();
private static final List<Location> USED_LOCATIONS = new ArrayList<>(20);
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
@@ -1,26 +1,26 @@
package core.game.interaction.object;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import core.cache.def.impl.ObjectDefinition;
import core.plugin.Initializable;
import core.game.node.entity.skill.Skills;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.combat.ImpactHandler.HitsplatType;
import core.game.node.entity.impl.Animator.Priority;
import core.game.node.entity.player.Player;
import core.game.node.entity.skill.Skills;
import core.game.node.item.ChanceItem;
import core.game.node.item.Item;
import core.game.node.object.GameObject;
import core.game.node.object.ObjectBuilder;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.update.flag.context.Animation;
import core.plugin.Initializable;
import core.plugin.Plugin;
import core.tools.RandomFunction;
import rs09.game.world.GameWorld;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Represents the thieving guide plugin.
@@ -143,7 +143,7 @@ public class ThievingGuidePlugin extends OptionHandler {
*/
private void addItem(Player player) {
ChanceItem[] l = RandomFunction.random(2) == 1 ? GEMS : COINS;
List<ChanceItem> chances = new ArrayList<>();
List<ChanceItem> chances = new ArrayList<>(20);
for (ChanceItem c : l) {
chances.add(c);
}
@@ -25,7 +25,7 @@ public final class GameAttributes {
/**
* The list of attributes to save.
*/
private final List<String> savedAttributes = new ArrayList<>();
private final List<String> savedAttributes = new ArrayList<>(250);
/**
* Constructs a new {@code GameAttributes} {@code Object}.
@@ -80,7 +80,7 @@ public final class CookingRecipePlugin extends UseWithHandler {
* @return the allowed nodes.
*/
private final static int[] getAllowedNodes() {
List<Integer> bases = new ArrayList<>();
List<Integer> bases = new ArrayList<>(10);
for (Recipe recipe : Recipe.RECIPES) {
for (Item base : recipe.getParts()) {
if (bases.contains(base.getId())) {
@@ -84,7 +84,7 @@ public final class HunterNPC extends AbstractNPC {
@Override
public int[] getIds() {
List<Integer> ids = new ArrayList<>();
List<Integer> ids = new ArrayList<>(10);
for (Traps t : Traps.values()) {
for (TrapNode node : t.getNodes()) {
for (int id : node.getNpcIds()) {
@@ -166,7 +166,7 @@ public final class HunterPlugin extends OptionHandler {
* @return the ids.
*/
public static int[] getIds() {
List<Integer> list = new ArrayList<>();
List<Integer> list = new ArrayList<>(10);
for (Traps trap : Traps.values()) {
for (int id : trap.getSettings().getBaitIds()) {
list.add(id);
@@ -227,7 +227,7 @@ public final class NetTrapSetting extends TrapSetting {
* @return the array.
*/
public static int[] getIds() {
List<Integer> ids = new ArrayList<>();
List<Integer> ids = new ArrayList<>(10);
for (NetTrap trap : NetTrap.values()) {
ids.add(trap.getBent());
ids.add(trap.getCaught());
@@ -21,7 +21,7 @@ public final class TrapWrapper {
/**
* The items to be recieved on trap clearing.
*/
private final List<Item> items = new ArrayList<>();
private final List<Item> items = new ArrayList<>(10);
/**
* The player instance.
@@ -58,7 +58,7 @@ public enum Traps {
/**
* The location hooks for this node.
*/
private final List<TrapHook> hooks = new ArrayList<>();
private final List<TrapHook> hooks = new ArrayList<>(5);
/**
* The trap settings.
@@ -29,7 +29,7 @@ public final class NechryaelNPC extends AbstractNPC {
/**
* The death spawn npcs.
*/
private List<DeathSpawnNPC> spawns = new ArrayList<>();
private List<DeathSpawnNPC> spawns = new ArrayList<>(10);
/**
* The next spawn time.
@@ -1,17 +1,14 @@
package core.game.node.entity.skill.slayer;
import core.cache.def.impl.NPCDefinition;
import rs09.game.system.SystemLogger;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.npc.NPC;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.diary.DiaryType;
import core.game.node.entity.skill.Skills;
import core.tools.RandomFunction;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -165,7 +162,7 @@ public final class SlayerManager {
* @param master the master to give the task.
*/
public void generate(Master master) {
final List<Master.Task> tasks = new ArrayList<>();
final List<Master.Task> tasks = new ArrayList<>(10);
final int[] taskWeightSum = {0};
master.tasks.stream().filter(task -> canBeAssigned(task.task) && task.task.combatCheck <= player.getProperties().getCurrentCombatLevel()).forEach(task -> {
taskWeightSum[0] += task.weight;
@@ -150,7 +150,7 @@ public final class FurnaceOptionPlugin extends OptionHandler {
* @return the ids.
*/
public static final int[] getIds() {
List<Integer> ids = new ArrayList<>();
List<Integer> ids = new ArrayList<>(10);
for (Bar bar : Bar.values()) {
for (Item i : bar.getOres()) {
ids.add(i.getId());
@@ -692,7 +692,7 @@ class Adventurer(val style: CombatStyle): Script() {
var citygroupA = listOf(falador, varrock, draynor, rimmington, lumbridge, edgeville)
var citygroupB = listOf(yanille, ardougne, seers, catherby)
var bankMap = hashMapOf<Location, ZoneBorders>(
var bankMap = mapOf<Location, ZoneBorders>(
falador to ZoneBorders(2950, 3374, 2943, 3368),
varrock to ZoneBorders(3182, 3435, 3189, 3446),
draynor to ZoneBorders(3092, 3240, 3095, 3246),
@@ -25,7 +25,7 @@ class EnchantSpell : MagicSpell {
/**
* The enchantable jewellery array.
*/
private val jewellery: HashMap<Int,Item>?
private val jewellery: Map<Int,Item>?
/**
* Constructs a new `EnchantSpell` `Object`.
@@ -40,7 +40,7 @@ class EnchantSpell : MagicSpell {
* @param jewellery The jewellery this spell is able to echant.
* @param runes The runes required.
*/
constructor(level: Int, experience: Double, jewellery: HashMap<Int,Item>, runes: Array<Item>?) : super(SpellBook.MODERN, level, experience, ANIMATION, GRAPHIC, Audio(115, 1, 0), runes) {
constructor(level: Int, experience: Double, jewellery: Map<Int,Item>, runes: Array<Item>?) : super(SpellBook.MODERN, level, experience, ANIMATION, GRAPHIC, Audio(115, 1, 0), runes) {
this.jewellery = jewellery
}
@@ -109,7 +109,7 @@ class EnchantSpell : MagicSpell {
* Enchant Sapphire Jewelry (Lvl-1 Enchant)
*/
SpellBook.MODERN.register(5, EnchantSpell(7, 17.5,
hashMapOf(
mapOf(
//Begin Jewelry Enchantments
Items.SAPPHIRE_RING_1637 to Item(Items.RING_OF_RECOIL_2550),
Items.SAPPHIRE_NECKLACE_1656 to Item(Items.GAMES_NECKLACE8_3853),
@@ -128,7 +128,7 @@ class EnchantSpell : MagicSpell {
* Enchant Emerald Jewelry (Lvl-2 Enchant)
*/
SpellBook.MODERN.register(16, EnchantSpell(27, 37.0,
hashMapOf(
mapOf(
//Begin Jewelry Enchantments
Items.EMERALD_RING_1639 to Item(Items.RING_OF_DUELLING8_2552),
Items.EMERALD_NECKLACE_1658 to Item(Items.BINDING_NECKLACE_5521),
@@ -147,7 +147,7 @@ class EnchantSpell : MagicSpell {
* Enchant Ruby Jewelry (Lvl-3 Enchant)
*/
SpellBook.MODERN.register(28, EnchantSpell(49, 59.0,
hashMapOf(
mapOf(
//Begin Jewelry Enchantments
Items.RUBY_RING_1641 to Item(Items.RING_OF_FORGING_2568),
Items.RUBY_NECKLACE_1660 to Item(Items.DIGSITE_PENDANT_5_11194),
@@ -166,7 +166,7 @@ class EnchantSpell : MagicSpell {
* Enchant Diamond Jewelry (Lvl-4 Enchant)
*/
SpellBook.MODERN.register(36, EnchantSpell(57, 67.0,
hashMapOf(
mapOf(
Items.DIAMOND_RING_1643 to Item(Items.RING_OF_LIFE_2570),
Items.DIAMOND_NECKLACE_1662 to Item(Items.PHOENIX_NECKLACE_11090),
Items.DIAMOND_AMULET_1700 to Item(Items.AMULET_OF_POWER_1731),
@@ -184,7 +184,7 @@ class EnchantSpell : MagicSpell {
* Enchant Dragonstone Jewelry (Lvl-5 Enchant)
*/
SpellBook.MODERN.register(51, EnchantSpell(68, 78.0,
hashMapOf(
mapOf(
//Begin Jewelry Enchantment
Items.DRAGONSTONE_RING_1645 to Item(14646),
Items.DRAGON_NECKLACE_1664 to Item(Items.SKILLS_NECKLACE4_11105),
@@ -203,7 +203,7 @@ class EnchantSpell : MagicSpell {
* Enchant Onyx Jewelry (Lvl-6 Enchant)
*/
SpellBook.MODERN.register(61, EnchantSpell(87, 97.0,
hashMapOf(
mapOf(
//Begin Jewelry Enchantments
Items.ONYX_RING_6575 to Item(Items.RING_OF_STONE_6583),
Items.ONYX_NECKLACE_6577 to Item(Items.BERSERKER_NECKLACE_11128),
@@ -12,7 +12,7 @@ import rs09.game.world.repository.Repository
* @author Ceikry
*/
class ShootingStar(var level: ShootingStarType = ShootingStarType.values().random()){
val crash_locations = hashMapOf(
val crash_locations = mapOf(
"Canifis Bank" to Location.create(3504, 3487, 0),
"Crafting Guild" to Location.create(2940, 3280, 0),
"Falador East Bank" to Location.create(3030, 3349, 0),
@@ -22,7 +22,7 @@ class WorkForOptionListener : OptionListener() {
Items.MITHRIL_WARHAMMER_1343
)
val gatheringMap = hashMapOf<Int,List<GatheringJobs>>(
val gatheringMap = mapOf<Int,List<GatheringJobs>>(
0 to listOf(GatheringJobs.AIR_RUNE,GatheringJobs.COWHIDES,GatheringJobs.WATER_RUNE),
922 to listOf(GatheringJobs.ASHES,GatheringJobs.AIR_RUNE,GatheringJobs.WATER_RUNE),
3807 to listOf(GatheringJobs.COWHIDES),
@@ -34,7 +34,7 @@ class WorkForOptionListener : OptionListener() {
4906 to listOf(GatheringJobs.LOG,GatheringJobs.OAK,GatheringJobs.WILLOW)
)
val typeMap = hashMapOf(
val typeMap = mapOf(
0 to 0,
705 to 1,
922 to 0,
@@ -24,7 +24,7 @@ import java.nio.ByteBuffer
//TODO: I've done the groundwork, Please someone else take up the task of rearranging these menus
object QCRepository {
val skillIDs = hashMapOf(
val skillIDs = mapOf(
0 to "Agility",
1 to "Attack",
2 to "Construction",
@@ -13,34 +13,34 @@ import kotlinx.coroutines.launch
import org.rs09.consts.Items
import rs09.game.system.SystemLogger
private val LVL_1_ENCHANT = hashMapOf(
private val LVL_1_ENCHANT = mapOf(
Items.SAPPHIRE_RING_1637 to Item(Items.RING_OF_RECOIL_2550),
Items.SAPPHIRE_NECKLACE_1656 to Item(Items.GAMES_NECKLACE8_3853),
Items.SAPPHIRE_AMULET_1694 to Item(Items.AMULET_OF_MAGIC_1727),
Items.SAPPHIRE_BRACELET_11072 to Item(Items.BRACELET_OF_CLAY_11074)
)
private val LVL_2_ENCHANT = hashMapOf(
private val LVL_2_ENCHANT = mapOf(
Items.EMERALD_RING_1639 to Item(Items.RING_OF_DUELLING8_2552),
Items.EMERALD_NECKLACE_1658 to Item(Items.BINDING_NECKLACE_5521),
Items.EMERALD_AMULET_1696 to Item(Items.AMULET_OF_DEFENCE_1729),
Items.EMERALD_BRACELET_11076 to Item(Items.CASTLEWAR_BRACE3_11079)
)
private val LVL_3_ENCHANT = hashMapOf(
private val LVL_3_ENCHANT = mapOf(
Items.RUBY_RING_1641 to Item(Items.RING_OF_FORGING_2568),
Items.RUBY_NECKLACE_1660 to Item(Items.DIGSITE_PENDANT_5_11194),
Items.RUBY_AMULET_1698 to Item(Items.AMULET_OF_STRENGTH_1725),
Items.RUBY_BRACELET_11085 to Item(Items.INOCULATION_BRACE_11088)
)
private val LVL_4_ENCHANT = hashMapOf(
private val LVL_4_ENCHANT = mapOf(
Items.DIAMOND_RING_1643 to Item(Items.RING_OF_LIFE_2570),
Items.DIAMOND_NECKLACE_1662 to Item(Items.PHOENIX_NECKLACE_11090),
Items.DIAMOND_AMULET_1700 to Item(Items.AMULET_OF_POWER_1731),
Items.DIAMOND_BRACELET_11092 to Item(Items.FORINTHRY_BRACE5_11095)
)
private val LVL_5_ENCHANT = hashMapOf(
private val LVL_5_ENCHANT = mapOf(
Items.DRAGONSTONE_RING_1645 to Item(14646),
Items.DRAGON_NECKLACE_1664 to Item(Items.SKILLS_NECKLACE4_11105),
Items.DRAGONSTONE_AMMY_1702 to Item(Items.AMULET_OF_GLORY4_1712),
@@ -8,7 +8,7 @@ import org.rs09.consts.Items
object UseWithBinHandler {
@JvmField
val allowedNodes = ArrayList<Int>()
val allowedNodes = ArrayList<Int>(100)
val fillAnim = Animation(832)
val compostPotionAnimation = Animation(2259)
val scoopAnimation = Animation(8905)
@@ -16,7 +16,7 @@ import rs09.tools.stringtools.colorize
*/
class PouchManager(val player: Player) {
val pouches = hashMapOf(
val pouches = mapOf(
Items.SMALL_POUCH_5509 to RCPouch(3,1),
Items.MEDIUM_POUCH_5510 to RCPouch(6,25),
Items.LARGE_POUCH_5512 to RCPouch(9,50),