diff --git a/src/org/apollo/Server.java b/src/org/apollo/Server.java index 1b855521..766e8923 100644 --- a/src/org/apollo/Server.java +++ b/src/org/apollo/Server.java @@ -99,7 +99,7 @@ public final class Server { /** * Creates the Apollo server. * - * @throws Exception if an error occurs whilst creating services. + * @throws Exception If an error occurs whilst creating services. */ public Server() throws Exception { logger.info("Starting Apollo..."); @@ -110,9 +110,9 @@ public final class Server { * Initialises the server. * * @param releaseClassName The class name of the current active {@link Release}. - * @throws ClassNotFoundException if the release class could not be found. - * @throws IllegalAccessException if the release class could not be accessed. - * @throws InstantiationException if the release class could not be instantiated. + * @throws ClassNotFoundException If the release class could not be found. + * @throws IllegalAccessException If the release class could not be accessed. + * @throws InstantiationException If the release class could not be instantiated. */ public void init(String releaseClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { @@ -155,7 +155,7 @@ public final class Server { httpBootstrap.bind(httpAddress); } catch (Throwable t) { logger.log(Level.WARNING, - "Binding to HTTP failed: client will use JAGGRAB as a fallback (not reccomended)!", t); + "Binding to HTTP failed: client will use JAGGRAB as a fallback (not recommended)!", t); } logger.info("Binding JAGGRAB listener to address: " + jagGrabAddress + "..."); @@ -167,7 +167,7 @@ public final class Server { /** * Starts the server. * - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public void start() throws Exception { PluginManager mgr = new PluginManager(new PluginContext(context)); @@ -181,4 +181,4 @@ public final class Server { World.getWorld().init(releaseNo, fs, mgr); } -} +} \ No newline at end of file diff --git a/src/org/apollo/ServiceManager.java b/src/org/apollo/ServiceManager.java index 725c44bb..904fd509 100644 --- a/src/org/apollo/ServiceManager.java +++ b/src/org/apollo/ServiceManager.java @@ -29,7 +29,7 @@ public final class ServiceManager { /** * Creates and initializes the {@link ServiceManager}. * - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public ServiceManager() throws Exception { init(); @@ -38,7 +38,7 @@ public final class ServiceManager { /** * Initializes this service manager. * - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ @SuppressWarnings("unchecked") private void init() throws Exception { @@ -118,4 +118,4 @@ public final class ServiceManager { } } -} +} \ No newline at end of file diff --git a/src/org/apollo/fs/Index.java b/src/org/apollo/fs/Index.java index 9009cce0..b15f3e66 100644 --- a/src/org/apollo/fs/Index.java +++ b/src/org/apollo/fs/Index.java @@ -12,7 +12,7 @@ public final class Index { * * @param buffer The buffer. * @return The decoded {@link Index}. - * @throws IllegalArgumentException if the buffer length is invalid. + * @throws IllegalArgumentException If the buffer length is invalid. */ public static Index decode(byte[] buffer) { if (buffer.length != FileSystemConstants.INDEX_SIZE) { diff --git a/src/org/apollo/fs/IndexedFileSystem.java b/src/org/apollo/fs/IndexedFileSystem.java index 0d79a16a..e5649d87 100644 --- a/src/org/apollo/fs/IndexedFileSystem.java +++ b/src/org/apollo/fs/IndexedFileSystem.java @@ -41,7 +41,7 @@ public final class IndexedFileSystem implements Closeable { * * @param base The base directory. * @param readOnly A flag indicating if the file system will be read only. - * @throws Exception if the file system is invalid. + * @throws Exception If the file system is invalid. */ public IndexedFileSystem(File base, boolean readOnly) throws Exception { this.readOnly = readOnly; @@ -61,7 +61,7 @@ public final class IndexedFileSystem implements Closeable { * Automatically detect the layout of the specified directory. * * @param base The base directory. - * @throws Exception if the file system is invalid. + * @throws Exception If the file system is invalid. */ private void detectLayout(File base) throws Exception { int indexCount = 0; @@ -92,7 +92,7 @@ public final class IndexedFileSystem implements Closeable { * * @param fd The {@link FileDescriptor} which points to the file. * @return The {@link Index}. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ private Index getIndex(FileDescriptor fd) throws IOException { int index = fd.getType(); @@ -120,7 +120,7 @@ public final class IndexedFileSystem implements Closeable { * * @param type The type. * @return The number of files. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ private int getFileCount(int type) throws IOException { if (type < 0 || type >= indices.length) { @@ -137,7 +137,7 @@ public final class IndexedFileSystem implements Closeable { * Gets the CRC table. * * @return The CRC table. - * @throws IOException if an I/O erorr occurs. + * @throws IOException If an I/O erorr occurs. */ public ByteBuffer getCrcTable() throws IOException { if (readOnly) { @@ -195,7 +195,7 @@ public final class IndexedFileSystem implements Closeable { * @param type The file type. * @param file The file id. * @return A {@link ByteBuffer} which contains the contents of the file. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public ByteBuffer getFile(int type, int file) throws IOException { return getFile(new FileDescriptor(type, file)); @@ -206,7 +206,7 @@ public final class IndexedFileSystem implements Closeable { * * @param fd The {@link FileDescriptor} which points to the file. * @return A {@link ByteBuffer} which contains the contents of the file. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public ByteBuffer getFile(FileDescriptor fd) throws IOException { Index index = getIndex(fd); diff --git a/src/org/apollo/fs/archive/Archive.java b/src/org/apollo/fs/archive/Archive.java index c405c14b..02e8af16 100644 --- a/src/org/apollo/fs/archive/Archive.java +++ b/src/org/apollo/fs/archive/Archive.java @@ -19,7 +19,7 @@ public final class Archive { * * @param buffer The buffer. * @return The archive. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public static Archive decode(ByteBuffer buffer) throws IOException { int extractedSize = ByteBufferUtil.readUnsignedTriByte(buffer); @@ -80,7 +80,7 @@ public final class Archive { * * @param name The name. * @return The entry. - * @throws FileNotFoundException if the file could not be found. + * @throws FileNotFoundException If the file could not be found. */ public ArchiveEntry getEntry(String name) throws FileNotFoundException { int hash = 0; diff --git a/src/org/apollo/fs/parser/ItemDefinitionParser.java b/src/org/apollo/fs/parser/ItemDefinitionParser.java index ba88ea63..edd28945 100644 --- a/src/org/apollo/fs/parser/ItemDefinitionParser.java +++ b/src/org/apollo/fs/parser/ItemDefinitionParser.java @@ -33,7 +33,7 @@ public final class ItemDefinitionParser { * Parses the item definitions. * * @return The item definitions. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public ItemDefinition[] parse() throws IOException { Archive config = Archive.decode(fs.getFile(0, 2)); diff --git a/src/org/apollo/game/GameService.java b/src/org/apollo/game/GameService.java index 27b7b567..9d04afd5 100644 --- a/src/org/apollo/game/GameService.java +++ b/src/org/apollo/game/GameService.java @@ -58,7 +58,7 @@ public final class GameService extends Service { /** * Creates the game service. * - * @throws Exception if an error occurs during initialization. + * @throws Exception If an error occurs during initialization. */ public GameService() throws Exception { init(); @@ -76,7 +76,7 @@ public final class GameService extends Service { /** * Initializes the game service. * - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ private void init() throws Exception { InputStream is = new FileInputStream("data/events.xml"); diff --git a/src/org/apollo/game/event/handler/impl/BankEventHandler.java b/src/org/apollo/game/event/handler/impl/BankEventHandler.java index 198bf446..1c74781c 100644 --- a/src/org/apollo/game/event/handler/impl/BankEventHandler.java +++ b/src/org/apollo/game/event/handler/impl/BankEventHandler.java @@ -21,7 +21,7 @@ public final class BankEventHandler extends EventHandler { * * @param option The option. * @return The amount. - * @throws IllegalArgumentException if the option is not legal. + * @throws IllegalArgumentException If the option is not legal. */ private static final int optionToAmount(int option) { switch (option) { diff --git a/src/org/apollo/game/event/handler/impl/EquipEventHandler.java b/src/org/apollo/game/event/handler/impl/EquipEventHandler.java index d759dd53..8996cc87 100644 --- a/src/org/apollo/game/event/handler/impl/EquipEventHandler.java +++ b/src/org/apollo/game/event/handler/impl/EquipEventHandler.java @@ -12,6 +12,7 @@ import org.apollo.game.model.SkillSet; import org.apollo.game.model.def.EquipmentDefinition; import org.apollo.game.model.def.ItemDefinition; import org.apollo.game.model.inv.SynchronizationInventoryListener; +import org.apollo.util.LanguageUtil; /** * An event handler which equips items. @@ -23,119 +24,84 @@ public final class EquipEventHandler extends EventHandler { @Override public void handle(EventHandlerContext ctx, Player player, EquipEvent event) { if (event.getInterfaceId() == SynchronizationInventoryListener.INVENTORY_ID) { - int slot = event.getSlot(); - if (slot < 0 || slot >= player.getInventory().capacity()) { + int inventorySlot = event.getSlot(); + Item equipping = player.getInventory().get(inventorySlot); + int equippingId = equipping.getId(); + EquipmentDefinition equippingDef = EquipmentDefinition.forId(equippingId); + + if (equippingDef == null) { ctx.breakHandlerChain(); return; } - Item item = player.getInventory().get(slot); - if (item == null || item.getId() != event.getId()) { - ctx.breakHandlerChain(); - return; - } + for (int id = 0; id < 5; id++) { + int requirement = equippingDef.getLevel(id); - ItemDefinition itemDef = item.getDefinition(); - EquipmentDefinition equipDef = EquipmentDefinition.forId(item.getId()); - if (equipDef == null) { - ctx.breakHandlerChain(); - return; - } + if (player.getSkillSet().getSkill(id).getMaximumLevel() < requirement) { + String skillName = Skill.getName(id); + String article = LanguageUtil.getIndefiniteArticle(skillName); - SkillSet skillSet = player.getSkillSet(); - if (skillSet.getSkill(Skill.ATTACK).getMaximumLevel() < equipDef.getAttackLevel()) { - player.sendMessage("You need an Attack level of " + equipDef.getAttackLevel() + " to equip this item."); - ctx.breakHandlerChain(); - return; - } - if (skillSet.getSkill(Skill.STRENGTH).getMaximumLevel() < equipDef.getStrengthLevel()) { - player.sendMessage("You need a Strength level of " + equipDef.getStrengthLevel() - + " to equip this item."); - ctx.breakHandlerChain(); - return; - } - if (skillSet.getSkill(Skill.DEFENCE).getMaximumLevel() < equipDef.getDefenceLevel()) { - player.sendMessage("You need a Defence level of " + equipDef.getDefenceLevel() + " to equip this item."); - ctx.breakHandlerChain(); - return; - } - if (skillSet.getSkill(Skill.RANGED).getMaximumLevel() < equipDef.getRangedLevel()) { - player.sendMessage("You need a Ranged level of " + equipDef.getRangedLevel() + " to equip this item."); - ctx.breakHandlerChain(); - return; - } - if (skillSet.getSkill(Skill.MAGIC).getMaximumLevel() < equipDef.getMagicLevel()) { - player.sendMessage("You need a Magic level of " + equipDef.getMagicLevel() + " to equip this item."); - ctx.breakHandlerChain(); - return; + player.sendMessage("You need " + article + " " + skillName + " level of " + requirement + + " to equip this item."); + ctx.breakHandlerChain(); + return; + } } Inventory inventory = player.getInventory(); Inventory equipment = player.getEquipment(); - int equipmentSlot = equipDef.getSlot(); + // start - // TODO: equip event decoder for 317, and remove event decoder for both - // TODO: put all this into another method somewhere + int equipmentSlot = equippingDef.getSlot(); + Item currentlyEquipped = equipment.get(equipmentSlot); - // check if there is enough space for a two handed weapon - if (equipDef.isTwoHanded()) { - if (equipment.get(EquipmentConstants.SHIELD) != null) { - Item shield = equipment.reset(EquipmentConstants.SHIELD); + if (equipping.getDefinition().isStackable() + && (currentlyEquipped == null || currentlyEquipped.getId() == equippingId)) { + equipment.set(equippingDef.getSlot(), equipping); + inventory.reset(inventorySlot); + ctx.breakHandlerChain(); + return; + } + + Item weapon = equipment.get(EquipmentConstants.WEAPON); + Item shield = equipment.get(EquipmentConstants.SHIELD); + + if (equippingDef.isTwoHanded()) { + int slotsRequired = weapon != null ? (shield != null ? 1 : 0) : 0; + if (inventory.freeSlots() < slotsRequired) { + ctx.breakHandlerChain(); + return; + } + + equipment.reset(EquipmentConstants.WEAPON); + equipment.reset(EquipmentConstants.SHIELD); + equipment.set(EquipmentConstants.WEAPON, inventory.reset(inventorySlot)); + + if (shield != null) { inventory.add(shield); } - } - - // check if a shield is being added with a two handed weapon - boolean removeWeapon = false; - if (equipmentSlot == EquipmentConstants.SHIELD) { - Item currentWeapon = equipment.get(EquipmentConstants.WEAPON); - if (currentWeapon != null) { - EquipmentDefinition weaponDef = EquipmentDefinition.forId(currentWeapon.getId()); - if (weaponDef.isTwoHanded()) { - if (inventory.freeSlots() < 1) { - inventory.forceCapacityExceeded(); - ctx.breakHandlerChain(); - return; - } - removeWeapon = true; - } + if (weapon != null) { + inventory.add(weapon); } + return; + } else if (equippingDef.getSlot() == EquipmentConstants.SHIELD && weapon != null + && EquipmentDefinition.forId(weapon.getId()).isTwoHanded()) { + equipment.set(EquipmentConstants.SHIELD, inventory.reset(inventorySlot)); + inventory.add(equipment.reset(EquipmentConstants.WEAPON)); + return; } - Item previous = equipment.get(equipmentSlot); - if (itemDef.isStackable() && previous != null && previous.getId() == item.getId()) { - // we know the item is there, so we can let the inventory class do its stacking magic - inventory.remove(item); - Item tmp = equipment.add(item); - if (tmp != null) { - inventory.add(tmp); - } - } else { - // swap the weapons around - Item tmp = equipment.reset(equipmentSlot); - equipment.set(equipmentSlot, item); - inventory.reset(slot); - if (tmp != null) { - inventory.add(tmp); - } - } - - // remove the shield if this weapon is two handed - if (equipDef.isTwoHanded()) { - Item tmp = equipment.reset(EquipmentConstants.SHIELD); - // we know tmp will not be null from the check above - inventory.add(tmp); - } - - if (removeWeapon) { - Item tmp = equipment.reset(EquipmentConstants.WEAPON); - // we know tmp will not be null from the check about - inventory.add(tmp); + Item previous = equipment.reset(equipmentSlot); + inventory.remove(equipping); // no need for fancy stuff here as we + // know the item isn't stackable. + equipment.set(equipmentSlot, equipping); + if (previous != null) { + inventory.add(previous); } ctx.breakHandlerChain(); } } -} +} \ No newline at end of file diff --git a/src/org/apollo/game/model/Inventory.java b/src/org/apollo/game/model/Inventory.java index 73f8b82c..5b00c9ff 100644 --- a/src/org/apollo/game/model/Inventory.java +++ b/src/org/apollo/game/model/Inventory.java @@ -73,7 +73,7 @@ public final class Inventory implements Cloneable { * Creates an inventory. * * @param capacity The capacity. - * @throws IllegalArgumentException if the capacity is negative. + * @throws IllegalArgumentException If the capacity is negative. */ public Inventory(int capacity) { this(capacity, StackMode.STACK_STACKABLE_ITEMS); @@ -84,8 +84,8 @@ public final class Inventory implements Cloneable { * * @param capacity The capacity. * @param mode The stacking mode. - * @throws IllegalArgumentException if the capacity is negative. - * @throws NullPointerException if the mode is {@code null}. + * @throws IllegalArgumentException If the capacity is negative. + * @throws NullPointerException If the mode is {@code null}. */ public Inventory(int capacity, StackMode mode) { if (capacity < 0) { @@ -168,7 +168,7 @@ public final class Inventory implements Cloneable { * * @param slot The slot. * @return The item, or {@code null} if the slot is empty. - * @throws IndexOutOfBoundsException if the slot is out of bounds. + * @throws IndexOutOfBoundsException If the slot is out of bounds. */ public Item get(int slot) { checkBounds(slot); @@ -181,7 +181,7 @@ public final class Inventory implements Cloneable { * @param slot The slot. * @param item The item, or {@code null} to remove the item that is in the slot. * @return The item that was in the slot. - * @throws IndexOutOfBoundsException if the slot is out of bounds. + * @throws IndexOutOfBoundsException If the slot is out of bounds. */ public Item set(int slot, Item item) { if (item == null) { @@ -203,7 +203,7 @@ public final class Inventory implements Cloneable { * * @param slot * @return The item that was in the slot. - * @throws IndexOutOfBoundsException if the slot is out of bounds. + * @throws IndexOutOfBoundsException If the slot is out of bounds. */ public Item reset(int slot) { checkBounds(slot); @@ -394,7 +394,7 @@ public final class Inventory implements Cloneable { * * @param oldSlot The old slot. * @param newSlot The new slot. - * @throws IndexOutOufBoundsException if the slot is out of bounds. + * @throws IndexOutOufBoundsException If the slot is out of bounds. */ public void swap(int oldSlot, int newSlot) { swap(false, oldSlot, newSlot); @@ -406,7 +406,7 @@ public final class Inventory implements Cloneable { * @param insert If the swap should be done in insertion mode. * @param oldSlot The old slot. * @param newSlot The new slot. - * @throws IndexOutOfBoundsException if the slot is out of bounds. + * @throws IndexOutOfBoundsException If the slot is out of bounds. */ public void swap(boolean insert, int oldSlot, int newSlot) { checkBounds(oldSlot); @@ -495,7 +495,7 @@ public final class Inventory implements Cloneable { * Checks the bounds of the specified slot. * * @param slot The slot. - * @throws IndexOutOfBoundsException if the slot is out of bounds. + * @throws IndexOutOfBoundsException If the slot is out of bounds. */ private void checkBounds(int slot) { if (slot < 0 || slot >= capacity) { diff --git a/src/org/apollo/game/model/Item.java b/src/org/apollo/game/model/Item.java index 9265572e..b9af4e95 100644 --- a/src/org/apollo/game/model/Item.java +++ b/src/org/apollo/game/model/Item.java @@ -33,7 +33,7 @@ public final class Item { * * @param id The item's id. * @param amount The amount. - * @throws IllegalArgumentException if the amount is negative. + * @throws IllegalArgumentException If the amount is negative. */ public Item(int id, int amount) { if (amount < 0) { diff --git a/src/org/apollo/game/model/Player.java b/src/org/apollo/game/model/Player.java index 7ef19511..337c5707 100644 --- a/src/org/apollo/game/model/Player.java +++ b/src/org/apollo/game/model/Player.java @@ -53,7 +53,7 @@ public final class Player extends Character { * * @param numericalLevel The numerical level. * @return The privilege level. - * @throws IllegalArgumentException if the numerical level is invalid. + * @throws IllegalArgumentException If the numerical level is invalid. */ public static PrivilegeLevel valueOf(int numericalLevel) { for (PrivilegeLevel level : values()) { diff --git a/src/org/apollo/game/model/SkillSet.java b/src/org/apollo/game/model/SkillSet.java index fc9daa92..ae522982 100644 --- a/src/org/apollo/game/model/SkillSet.java +++ b/src/org/apollo/game/model/SkillSet.java @@ -72,7 +72,7 @@ public final class SkillSet { * * @param id The id. * @return The skill. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ public Skill getSkill(int id) { checkBounds(id); @@ -219,7 +219,7 @@ public final class SkillSet { * * @param id The id. * @param skill The skill. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ public void setSkill(int id, Skill skill) { checkBounds(id); @@ -231,7 +231,7 @@ public final class SkillSet { * Checks the bounds of the id. * * @param id The id. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ private void checkBounds(int id) { if (id < 0 || id >= skills.length) { @@ -243,7 +243,7 @@ public final class SkillSet { * Notifies listeners that a skill has been levelled up. * * @param id The skill's id. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ private void notifyLevelledUp(int id) { checkBounds(id); @@ -258,7 +258,7 @@ public final class SkillSet { * Notifies listeners that a skill has been updated. * * @param id The skill's id. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ private void notifySkillUpdated(int id) { checkBounds(id); diff --git a/src/org/apollo/game/model/World.java b/src/org/apollo/game/model/World.java index 86767edd..297cf6bf 100644 --- a/src/org/apollo/game/model/World.java +++ b/src/org/apollo/game/model/World.java @@ -103,7 +103,7 @@ public final class World { * @param release The release number. * @param fs The file system. * @param mgr The plugin manager. TODO move this. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public void init(int release, IndexedFileSystem fs, PluginManager mgr) throws IOException { logger.info("Loading item definitions..."); diff --git a/src/org/apollo/game/model/def/EquipmentDefinition.java b/src/org/apollo/game/model/def/EquipmentDefinition.java index 53570fd8..e5615985 100644 --- a/src/org/apollo/game/model/def/EquipmentDefinition.java +++ b/src/org/apollo/game/model/def/EquipmentDefinition.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map; import org.apollo.game.model.Item; +import org.apollo.game.model.Skill; /** * Represents a type of {@link Item} which may be equipped. @@ -27,23 +28,33 @@ public final class EquipmentDefinition { EquipmentDefinition def = definitions[id]; if (def != null) { if (def.getId() != id) { - throw new RuntimeException("Item definition id mismatch!"); + throw new RuntimeException("Equipment definition id mismatch!"); } EquipmentDefinition.definitions.put(def.getId(), def); } } } + public int count() { + return definitions.size(); + } + + /** + * The array of skill requirement levels. + */ + private int[] levels = { 1, 1, 1, 1, 1, 1, 1 }; + /** * Gets an equipment definition by its id. * * @param id The id. * @return {@code null} if the item is not equipment, the definition otherwise. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ public static EquipmentDefinition forId(int id) { if (id < 0 || id >= ItemDefinition.count()) { - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException(EquipmentDefinition.class.getName() + " lookup index " + id + + " out of bounds."); } return definitions.get(id); } @@ -58,11 +69,6 @@ public final class EquipmentDefinition { */ private int slot; - /** - * The required levels. - */ - private int attack = 1, strength = 1, defence = 1, ranged = 1, magic = 1; - /** * Various flags. */ @@ -77,6 +83,24 @@ public final class EquipmentDefinition { this.id = id; } + /** + * Gets the minimum attack level. + * + * @return The minimum attack level. + */ + public int getAttackLevel() { + return levels[Skill.ATTACK]; + } + + /** + * Gets the minimum defence level. + * + * @return The minimum defence level. + */ + public int getDefenceLevel() { + return levels[Skill.DEFENCE]; + } + /** * Gets the id. * @@ -87,56 +111,15 @@ public final class EquipmentDefinition { } /** - * Sets the required levels. + * Gets the level for a specific skill by its id. * - * @param attack The required attack level. - * @param strength The required strength level. - * @param defence The required defence level. - * @param ranged The required ranged level. - * @param magic The required magic level. + * @param skill The skill id. */ - public void setLevels(int attack, int strength, int defence, int ranged, int magic) { - this.attack = attack; - this.strength = strength; - this.defence = defence; - this.ranged = ranged; - this.magic = magic; - } - - /** - * Gets the minimum attack level. - * - * @return The minimum attack level. - */ - public int getAttackLevel() { - return attack; - } - - /** - * Gets the minimum strength level. - * - * @return The minimum strength level. - */ - public int getStrengthLevel() { - return strength; - } - - /** - * Gets the minimum defence level. - * - * @return The minimum defence level. - */ - public int getDefenceLevel() { - return defence; - } - - /** - * Gets the minimum ranged level. - * - * @return The minimum ranged level. - */ - public int getRangedLevel() { - return ranged; + public int getLevel(int skill) { + if (skill < Skill.ATTACK || skill > Skill.MAGIC) { + throw new IllegalArgumentException("Skill id out of bounds for an equipment definition."); + } + return levels[skill]; } /** @@ -145,16 +128,16 @@ public final class EquipmentDefinition { * @return The minimum magic level. */ public int getMagicLevel() { - return magic; + return levels[Skill.MAGIC]; } /** - * Sets the target slot. + * Gets the minimum ranged level. * - * @param slot The target slot. + * @return The minimum ranged level. */ - public void setSlot(int slot) { - this.slot = slot; + public int getRangedLevel() { + return levels[Skill.RANGED]; } /** @@ -167,12 +150,12 @@ public final class EquipmentDefinition { } /** - * Checks if this equipment is two-handed. + * Gets the minimum strength level. * - * @return {@code true} if so, {@code false} if not. + * @return The minimum strength level. */ - public boolean isTwoHanded() { - return twoHanded; + public int getStrengthLevel() { + return levels[Skill.STRENGTH]; } /** @@ -202,6 +185,15 @@ public final class EquipmentDefinition { return fullMask; } + /** + * Checks if this equipment is two-handed. + * + * @return {@code true} if so, {@code false} if not. + */ + public boolean isTwoHanded() { + return twoHanded; + } + /** * Sets the flags. * @@ -217,4 +209,30 @@ public final class EquipmentDefinition { this.fullMask = fullMask; } -} + /** + * Sets the required levels. + * + * @param attack The required attack level. + * @param strength The required strength level. + * @param defence The required defence level. + * @param ranged The required ranged level. + * @param magic The required magic level. + */ + public void setLevels(int attack, int strength, int defence, int ranged, int magic) { + levels[Skill.ATTACK] = attack; + levels[Skill.STRENGTH] = strength; + levels[Skill.DEFENCE] = defence; + levels[Skill.RANGED] = ranged; + levels[Skill.MAGIC] = magic; + } + + /** + * Sets the target slot. + * + * @param slot The target slot. + */ + public void setSlot(int slot) { + this.slot = slot; + } + +} \ No newline at end of file diff --git a/src/org/apollo/game/model/def/ItemDefinition.java b/src/org/apollo/game/model/def/ItemDefinition.java index 146b9537..7a3fc5de 100644 --- a/src/org/apollo/game/model/def/ItemDefinition.java +++ b/src/org/apollo/game/model/def/ItemDefinition.java @@ -59,7 +59,7 @@ public final class ItemDefinition { * Initialises the class with the specified set of definitions. * * @param definitions The definitions. - * @throws RuntimeException if there is an id mismatch. + * @throws RuntimeException If there is an id mismatch. */ public static void init(ItemDefinition[] definitions) { ItemDefinition.definitions = definitions; @@ -89,7 +89,7 @@ public final class ItemDefinition { * * @param id The id. * @return The definition. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ public static ItemDefinition forId(int id) { if (id < 0 || id >= definitions.length) { @@ -214,7 +214,7 @@ public final class ItemDefinition { /** * Converts this item to a note, if possible. * - * @throws IllegalStateException if {@link ItemDefinition#isNote()} returns {@code false}. + * @throws IllegalStateException If {@link ItemDefinition#isNote()} returns {@code false}. */ public void toNote() { if (isNote()) { @@ -336,7 +336,7 @@ public final class ItemDefinition { * * @param id The id. * @param action The action. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ public void setGroundAction(int id, String action) { if (id < 0 || id >= groundActions.length) { @@ -350,7 +350,7 @@ public final class ItemDefinition { * * @param id The id. * @return The action. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ public String getGroundAction(int id) { if (id < 0 || id >= groundActions.length) { @@ -364,7 +364,7 @@ public final class ItemDefinition { * * @param id The id. * @param action The action. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ public void setInventoryAction(int id, String action) { if (id < 0 || id >= inventoryActions.length) { @@ -378,7 +378,7 @@ public final class ItemDefinition { * * @param id The id. * @return The action. - * @throws IndexOutOfBoundsException if the id is out of bounds. + * @throws IndexOutOfBoundsException If the id is out of bounds. */ public String getInventoryAction(int id) { if (id < 0 || id >= inventoryActions.length) { diff --git a/src/org/apollo/game/scheduling/ScheduledTask.java b/src/org/apollo/game/scheduling/ScheduledTask.java index 7561a751..b8d0d0ae 100644 --- a/src/org/apollo/game/scheduling/ScheduledTask.java +++ b/src/org/apollo/game/scheduling/ScheduledTask.java @@ -28,7 +28,7 @@ public abstract class ScheduledTask { * @param delay The delay between executions of the task, in pulses. * @param immediate A flag indicating if this task should (for the first execution) be ran immediately, or after the * {@code delay}. - * @throws IllegalArgumentException if the delay is less than or equal to zero. + * @throws IllegalArgumentException If the delay is less than or equal to zero. */ public ScheduledTask(int delay, boolean immediate) { setDelay(delay); @@ -48,7 +48,7 @@ public abstract class ScheduledTask { * Sets the delay. * * @param delay The delay. - * @throws IllegalArgumentException if the delay is less than or equal to zero. + * @throws IllegalArgumentException If the delay is less than or equal to zero. */ public void setDelay(int delay) { if (delay < 0) { diff --git a/src/org/apollo/game/sync/seg/MovementSegment.java b/src/org/apollo/game/sync/seg/MovementSegment.java index 6295440d..82c28728 100644 --- a/src/org/apollo/game/sync/seg/MovementSegment.java +++ b/src/org/apollo/game/sync/seg/MovementSegment.java @@ -20,7 +20,7 @@ public final class MovementSegment extends SynchronizationSegment { * * @param blockSet The block set. * @param directions The directions array. - * @throws IllegalArgumentException if there are not 0, 1 or 2 directions. + * @throws IllegalArgumentException If there are not 0, 1 or 2 directions. */ public MovementSegment(SynchronizationBlockSet blockSet, Direction[] directions) { super(blockSet); diff --git a/src/org/apollo/io/EquipmentDefinitionParser.java b/src/org/apollo/io/EquipmentDefinitionParser.java index 68004e0d..5724f0d3 100644 --- a/src/org/apollo/io/EquipmentDefinitionParser.java +++ b/src/org/apollo/io/EquipmentDefinitionParser.java @@ -32,7 +32,7 @@ public final class EquipmentDefinitionParser { * Parses the input stream. * * @return The equipment definition array. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public EquipmentDefinition[] parse() throws IOException { DataInputStream dis = new DataInputStream(is); diff --git a/src/org/apollo/io/EventHandlerChainParser.java b/src/org/apollo/io/EventHandlerChainParser.java index 6b896d97..9837ce72 100644 --- a/src/org/apollo/io/EventHandlerChainParser.java +++ b/src/org/apollo/io/EventHandlerChainParser.java @@ -36,7 +36,7 @@ public final class EventHandlerChainParser { * Creates the event chain parser. * * @param is The source {@link InputStream}. - * @throws SAXException if a SAX error occurs. + * @throws SAXException If a SAX error occurs. */ public EventHandlerChainParser(InputStream is) throws SAXException { this.parser = new XmlParser(); @@ -46,11 +46,11 @@ public final class EventHandlerChainParser { /** * Parses the XML and produces a group of {@link EventHandlerChain}s. * - * @throws IOException if an I/O error occurs. - * @throws SAXException if a SAX error occurs. - * @throws ClassNotFoundException if a class was not found. - * @throws IllegalAccessException if a class was accessed illegally. - * @throws InstantiationException if a class could not be instantiated. + * @throws IOException If an I/O error occurs. + * @throws SAXException If a SAX error occurs. + * @throws ClassNotFoundException If a class was not found. + * @throws IllegalAccessException If a class was accessed illegally. + * @throws InstantiationException If a class could not be instantiated. * @return An {@link EventHandlerChainGroup}. */ @SuppressWarnings("unchecked") diff --git a/src/org/apollo/io/PluginMetaDataParser.java b/src/org/apollo/io/PluginMetaDataParser.java index dec9bb6e..df8c0937 100644 --- a/src/org/apollo/io/PluginMetaDataParser.java +++ b/src/org/apollo/io/PluginMetaDataParser.java @@ -34,7 +34,7 @@ public final class PluginMetaDataParser { * Creates the plugin meta data parser. * * @param is The input stream. - * @throws SAXException if a SAX error occurs. + * @throws SAXException If a SAX error occurs. */ public PluginMetaDataParser(InputStream is) throws SAXException { this.parser = new XmlParser(); @@ -45,8 +45,8 @@ public final class PluginMetaDataParser { * Parses the XML and creates a meta data object. * * @return The meta data object. - * @throws SAXException if a SAX error occurs. - * @throws IOException if an I/O error occurs. + * @throws SAXException If a SAX error occurs. + * @throws IOException If an I/O error occurs. */ public PluginMetaData parse() throws IOException, SAXException { XmlNode rootNode = parser.parse(is); @@ -109,7 +109,7 @@ public final class PluginMetaDataParser { * @param node The root node. * @param name The element name. * @return The node object. - * @throws IOException if the element does not exist. + * @throws IOException If the element does not exist. */ private XmlNode getElement(XmlNode node, String name) throws IOException { XmlNode child = node.getChild(name); diff --git a/src/org/apollo/io/player/PlayerLoader.java b/src/org/apollo/io/player/PlayerLoader.java index cd5425ec..4ef67c15 100644 --- a/src/org/apollo/io/player/PlayerLoader.java +++ b/src/org/apollo/io/player/PlayerLoader.java @@ -15,7 +15,7 @@ public interface PlayerLoader { * * @param credentials The player's credentials. * @return The {@link PlayerLoaderResponse}. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public PlayerLoaderResponse loadPlayer(PlayerCredentials credentials) throws Exception; diff --git a/src/org/apollo/io/player/PlayerLoaderResponse.java b/src/org/apollo/io/player/PlayerLoaderResponse.java index 65d89680..8e30620e 100644 --- a/src/org/apollo/io/player/PlayerLoaderResponse.java +++ b/src/org/apollo/io/player/PlayerLoaderResponse.java @@ -24,7 +24,7 @@ public final class PlayerLoaderResponse { * Creates a {@link PlayerLoaderResponse} with only a status code. * * @param status The status code. - * @throws IllegalArgumentException if the status code needs a {@link Player}. + * @throws IllegalArgumentException If the status code needs a {@link Player}. */ public PlayerLoaderResponse(int status) { if (status == LoginConstants.STATUS_OK || status == LoginConstants.STATUS_RECONNECTION_OK) { @@ -39,7 +39,7 @@ public final class PlayerLoaderResponse { * * @param status The status code. * @param player The player. - * @throws IllegalArgumentException if the status code does not need {@link Player}. + * @throws IllegalArgumentException If the status code does not need {@link Player}. */ public PlayerLoaderResponse(int status, Player player) { if (status != LoginConstants.STATUS_OK && status != LoginConstants.STATUS_RECONNECTION_OK) { diff --git a/src/org/apollo/io/player/PlayerSaver.java b/src/org/apollo/io/player/PlayerSaver.java index fbe7e011..b3942cab 100644 --- a/src/org/apollo/io/player/PlayerSaver.java +++ b/src/org/apollo/io/player/PlayerSaver.java @@ -14,7 +14,7 @@ public interface PlayerSaver { * Saves a player. * * @param player The player to save. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public void savePlayer(Player player) throws Exception; diff --git a/src/org/apollo/io/player/impl/BinaryPlayerLoader.java b/src/org/apollo/io/player/impl/BinaryPlayerLoader.java index 68155f16..890eb860 100644 --- a/src/org/apollo/io/player/impl/BinaryPlayerLoader.java +++ b/src/org/apollo/io/player/impl/BinaryPlayerLoader.java @@ -108,7 +108,7 @@ public final class BinaryPlayerLoader implements PlayerLoader { * * @param in The input stream. * @param inventory The inventory. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ private void readInventory(DataInputStream in, Inventory inventory) throws IOException { int capacity = in.readUnsignedShort(); diff --git a/src/org/apollo/io/player/impl/BinaryPlayerSaver.java b/src/org/apollo/io/player/impl/BinaryPlayerSaver.java index ee4fd8df..3d5ddc05 100644 --- a/src/org/apollo/io/player/impl/BinaryPlayerSaver.java +++ b/src/org/apollo/io/player/impl/BinaryPlayerSaver.java @@ -76,7 +76,7 @@ public final class BinaryPlayerSaver implements PlayerSaver { * * @param out The output stream. * @param inventory The inventory. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ private void writeInventory(DataOutputStream out, Inventory inventory) throws IOException { int capacity = inventory.capacity(); diff --git a/src/org/apollo/login/LoginService.java b/src/org/apollo/login/LoginService.java index 6f0a39b7..aeaf063e 100644 --- a/src/org/apollo/login/LoginService.java +++ b/src/org/apollo/login/LoginService.java @@ -44,7 +44,7 @@ public final class LoginService extends Service { /** * Creates the login service. * - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public LoginService() throws Exception { init(); @@ -53,7 +53,7 @@ public final class LoginService extends Service { /** * Initialises the login service. * - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ private void init() throws Exception { XmlParser parser = new XmlParser(); diff --git a/src/org/apollo/net/codec/game/GamePacketBuilder.java b/src/org/apollo/net/codec/game/GamePacketBuilder.java index a00eceba..034d5f90 100644 --- a/src/org/apollo/net/codec/game/GamePacketBuilder.java +++ b/src/org/apollo/net/codec/game/GamePacketBuilder.java @@ -69,7 +69,7 @@ public final class GamePacketBuilder { * Creates a {@link GamePacket} based on the current contents of this builder. * * @return The {@link GamePacket}. - * @throws IllegalStateException if the builder is not in byte access mode, or if the packet is raw. + * @throws IllegalStateException If the builder is not in byte access mode, or if the packet is raw. */ public GamePacket toGamePacket() { if (type == PacketType.RAW) { @@ -85,7 +85,7 @@ public final class GamePacketBuilder { * Gets the current length of the builder's buffer. * * @return The length of the buffer. - * @throws IllegalStateException if the builder is not in byte access mode. + * @throws IllegalStateException If the builder is not in byte access mode. */ public int getLength() { checkByteAccess(); @@ -95,7 +95,7 @@ public final class GamePacketBuilder { /** * Switches this builder's mode to the byte access mode. * - * @throws IllegalStateException if the builder is already in byte access mode. + * @throws IllegalStateException If the builder is already in byte access mode. */ public void switchToByteAccess() { if (mode == AccessMode.BYTE_ACCESS) { @@ -108,7 +108,7 @@ public final class GamePacketBuilder { /** * Switches this builder's mode to the bit access mode. * - * @throws IllegalStateException if the builder is already in bit access mode. + * @throws IllegalStateException If the builder is already in bit access mode. */ public void switchToBitAccess() { if (mode == AccessMode.BIT_ACCESS) { @@ -151,7 +151,7 @@ public final class GamePacketBuilder { * * @param type The data type. * @param value The value. - * @throws IllegalStateException if this reader is not in byte access mode. + * @throws IllegalStateException If this reader is not in byte access mode. */ public void put(DataType type, Number value) { put(type, DataOrder.BIG, DataTransformation.NONE, value); @@ -163,8 +163,8 @@ public final class GamePacketBuilder { * @param type The data type. * @param order The byte order. * @param value The value. - * @throws IllegalStateException if this reader is not in byte access mode. - * @throws IllegalArgumentException if the combination is invalid. + * @throws IllegalStateException If this reader is not in byte access mode. + * @throws IllegalArgumentException If the combination is invalid. */ public void put(DataType type, DataOrder order, Number value) { put(type, order, DataTransformation.NONE, value); @@ -176,8 +176,8 @@ public final class GamePacketBuilder { * @param type The type. * @param transformation The transformation. * @param value The value. - * @throws IllegalStateException if this reader is not in byte access mode. - * @throws IllegalArgumentException if the combination is invalid. + * @throws IllegalStateException If this reader is not in byte access mode. + * @throws IllegalArgumentException If the combination is invalid. */ public void put(DataType type, DataTransformation transformation, Number value) { put(type, DataOrder.BIG, transformation, value); @@ -190,8 +190,8 @@ public final class GamePacketBuilder { * @param order The byte order. * @param transformation The transformation. * @param value The value. - * @throws IllegalStateException if this reader is not in byte access mode. - * @throws IllegalArgumentException if the combination is invalid. + * @throws IllegalStateException If this reader is not in byte access mode. + * @throws IllegalArgumentException If the combination is invalid. */ public void put(DataType type, DataOrder order, DataTransformation transformation, Number value) { checkByteAccess(); @@ -288,7 +288,7 @@ public final class GamePacketBuilder { * Puts the bytes from the specified buffer into this packet's buffer. * * @param buffer The source {@link ChannelBuffer}. - * @throws IllegalStateException if the builder is not in byte access mode. + * @throws IllegalStateException If the builder is not in byte access mode. */ public void putBytes(ChannelBuffer buffer) { byte[] bytes = new byte[buffer.readableBytes()]; @@ -305,7 +305,7 @@ public final class GamePacketBuilder { * Puts the bytes from the specified buffer into this packet's buffer, in reverse. * * @param buffer The source {@link ChannelBuffer}. - * @throws IllegalStateException if the builder is not in byte access mode. + * @throws IllegalStateException If the builder is not in byte access mode. */ public void putBytesReverse(ChannelBuffer buffer) { byte[] bytes = new byte[buffer.readableBytes()]; @@ -322,7 +322,7 @@ public final class GamePacketBuilder { * Puts the specified byte array into the buffer. * * @param bytes The byte array. - * @throws IllegalStateException if the builder is not in bit access mode. + * @throws IllegalStateException If the builder is not in bit access mode. */ public void putBytes(byte[] bytes) { buffer.writeBytes(bytes); @@ -333,7 +333,7 @@ public final class GamePacketBuilder { * * @param transformation The transformation. * @param bytes The byte array. - * @throws IllegalStateException if the builder is not in byte access mode. + * @throws IllegalStateException If the builder is not in byte access mode. */ public void putBytes(DataTransformation transformation, byte[] bytes) { if (transformation == DataTransformation.NONE) { @@ -349,7 +349,7 @@ public final class GamePacketBuilder { * Puts the specified byte array into the buffer in reverse. * * @param bytes The byte array. - * @throws IllegalStateException if the builder is not in byte access mode. + * @throws IllegalStateException If the builder is not in byte access mode. */ public void putBytesReverse(byte[] bytes) { checkByteAccess(); @@ -363,7 +363,7 @@ public final class GamePacketBuilder { * * @param transformation The transformation. * @param bytes The byte array. - * @throws IllegalStateException if the builder is not in byte access mode. + * @throws IllegalStateException If the builder is not in byte access mode. */ public void putBytesReverse(DataTransformation transformation, byte[] bytes) { if (transformation == DataTransformation.NONE) { @@ -380,7 +380,7 @@ public final class GamePacketBuilder { * {@code flag} is {@code false}, the value of the bit is {@code 0}. * * @param flag The flag. - * @throws IllegalStateException if the builder is not in bit access mode. + * @throws IllegalStateException If the builder is not in bit access mode. */ public void putBit(boolean flag) { putBit(flag ? 1 : 0); @@ -390,7 +390,7 @@ public final class GamePacketBuilder { * Puts a single bit into the buffer with the value {@code value}. * * @param value The value. - * @throws IllegalStateException if the builder is not in bit access mode. + * @throws IllegalStateException If the builder is not in bit access mode. */ public void putBit(int value) { putBits(1, value); @@ -401,8 +401,8 @@ public final class GamePacketBuilder { * * @param numBits The number of bits to put into the buffer. * @param value The value. - * @throws IllegalStateException if the builder is not in bit access mode. - * @throws IllegalArgumentException if the number of bits is not between 1 and 31 inclusive. + * @throws IllegalStateException If the builder is not in bit access mode. + * @throws IllegalArgumentException If the number of bits is not between 1 and 31 inclusive. */ public void putBits(int numBits, int value) { if (numBits < 0 || numBits > 32) { @@ -442,7 +442,7 @@ public final class GamePacketBuilder { /** * Checks that this builder is in the byte access mode. * - * @throws IllegalStateException if the builder is not in byte access mode. + * @throws IllegalStateException If the builder is not in byte access mode. */ private void checkByteAccess() { if (mode != AccessMode.BYTE_ACCESS) { @@ -453,7 +453,7 @@ public final class GamePacketBuilder { /** * Checks that this builder is in the bit access mode. * - * @throws IllegalStateException if the builder is not in bit access mode. + * @throws IllegalStateException If the builder is not in bit access mode. */ private void checkBitAccess() { if (mode != AccessMode.BIT_ACCESS) { diff --git a/src/org/apollo/net/codec/game/GamePacketDecoder.java b/src/org/apollo/net/codec/game/GamePacketDecoder.java index 2dc6bbb6..9acd7b58 100644 --- a/src/org/apollo/net/codec/game/GamePacketDecoder.java +++ b/src/org/apollo/net/codec/game/GamePacketDecoder.java @@ -77,7 +77,7 @@ public final class GamePacketDecoder extends StatefulFrameDecoder= length) { @@ -149,14 +149,14 @@ public final class GamePacketDecoder extends StatefulFrameDecoder 32) { diff --git a/src/org/apollo/net/codec/login/LoginDecoder.java b/src/org/apollo/net/codec/login/LoginDecoder.java index 682852c1..83df23c3 100644 --- a/src/org/apollo/net/codec/login/LoginDecoder.java +++ b/src/org/apollo/net/codec/login/LoginDecoder.java @@ -75,7 +75,7 @@ public final class LoginDecoder extends StatefulFrameDecoder * @param channel The channel. * @param buffer The buffer. * @return The frame, or {@code null}. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ private Object decodeHandshake(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readable()) { @@ -100,7 +100,7 @@ public final class LoginDecoder extends StatefulFrameDecoder * @param channel The channel. * @param buffer The buffer. * @return The frame, or {@code null}. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ private Object decodeHeader(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() >= 2) { @@ -126,7 +126,7 @@ public final class LoginDecoder extends StatefulFrameDecoder * @param channel The channel. * @param buffer The buffer. * @return The frame, or {@code null}. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ private Object decodePayload(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() >= loginLength) { diff --git a/src/org/apollo/net/codec/update/OnDemandRequest.java b/src/org/apollo/net/codec/update/OnDemandRequest.java index 762c1098..bca29360 100644 --- a/src/org/apollo/net/codec/update/OnDemandRequest.java +++ b/src/org/apollo/net/codec/update/OnDemandRequest.java @@ -37,7 +37,7 @@ public final class OnDemandRequest implements Comparable { * * @param v The integer value. * @return The priority. - * @throws IllegalArgumentException if the value is outside of the range 1-3 inclusive. + * @throws IllegalArgumentException If the value is outside of the range 1-3 inclusive. */ public static Priority valueOf(int v) { switch (v) { diff --git a/src/org/apollo/net/meta/PacketMetaData.java b/src/org/apollo/net/meta/PacketMetaData.java index 8568cf65..5022b67c 100644 --- a/src/org/apollo/net/meta/PacketMetaData.java +++ b/src/org/apollo/net/meta/PacketMetaData.java @@ -12,7 +12,7 @@ public final class PacketMetaData { * * @param length The length of the packet. * @return The {@link PacketMetaData} object. - * @throws IllegalArgumentException if length is less than 0. + * @throws IllegalArgumentException If length is less than 0. */ public static PacketMetaData createFixed(int length) { if (length < 0) { @@ -74,7 +74,7 @@ public final class PacketMetaData { * Gets the length of this packet. * * @return The length of this packet. - * @throws IllegalStateException if the packet is not a fixed-size packet. + * @throws IllegalStateException If the packet is not a fixed-size packet. */ public int getLength() { if (type != PacketType.FIXED) { diff --git a/src/org/apollo/net/meta/PacketMetaDataGroup.java b/src/org/apollo/net/meta/PacketMetaDataGroup.java index 66a98d95..7db7dd40 100644 --- a/src/org/apollo/net/meta/PacketMetaDataGroup.java +++ b/src/org/apollo/net/meta/PacketMetaDataGroup.java @@ -12,7 +12,7 @@ public final class PacketMetaDataGroup { * * @param lengthArray The packet length array. * @return The {@link PacketMetaDataGroup} object. - * @throws IllegalArgumentException if the array length is not 256 or if there is an element in the array with a + * @throws IllegalArgumentException If the array length is not 256 or if there is an element in the array with a * value below -3. */ public static PacketMetaDataGroup createFromArray(int[] lengthArray) { @@ -54,7 +54,7 @@ public final class PacketMetaDataGroup { * * @param opcode The opcode of the packet. * @return The {@link PacketMetaData}, or {@code null} if the packet does not exist. - * @throws IllegalArgumentException if the opcoe is not in the range 0 to 255. + * @throws IllegalArgumentException If the opcoe is not in the range 0 to 255. */ public PacketMetaData getMetaData(int opcode) { if (opcode < 0 || opcode >= packets.length) { diff --git a/src/org/apollo/net/session/Session.java b/src/org/apollo/net/session/Session.java index 058073c7..5f2584fd 100644 --- a/src/org/apollo/net/session/Session.java +++ b/src/org/apollo/net/session/Session.java @@ -37,14 +37,14 @@ public abstract class Session { * Processes a message received from the channel. * * @param message The message. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public abstract void messageReceived(Object message) throws Exception; /** * Destroys this session. * - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public abstract void destroy() throws Exception; diff --git a/src/org/apollo/tools/EquipmentUpdater.java b/src/org/apollo/tools/EquipmentUpdater.java index 51568df6..6e92ed8b 100644 --- a/src/org/apollo/tools/EquipmentUpdater.java +++ b/src/org/apollo/tools/EquipmentUpdater.java @@ -21,7 +21,7 @@ public final class EquipmentUpdater { * The entry point of the application. * * @param args The command line arguments. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public static void main(String[] args) throws Exception { if (args.length != 1) { diff --git a/src/org/apollo/tools/NoteUpdater.java b/src/org/apollo/tools/NoteUpdater.java index 7ef76410..599d240d 100644 --- a/src/org/apollo/tools/NoteUpdater.java +++ b/src/org/apollo/tools/NoteUpdater.java @@ -22,7 +22,7 @@ public final class NoteUpdater { * The entry point of the application. * * @param args The command line arguments. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ public static void main(String[] args) throws Exception { if (args.length != 1) { diff --git a/src/org/apollo/update/RequestWorker.java b/src/org/apollo/update/RequestWorker.java index 7b7c00d1..c4c4ef1b 100644 --- a/src/org/apollo/update/RequestWorker.java +++ b/src/org/apollo/update/RequestWorker.java @@ -80,7 +80,7 @@ public abstract class RequestWorker implements Runnable { * * @param dispatcher The dispatcher. * @return The next request. - * @throws InterruptedException if the thread is interrupted. + * @throws InterruptedException If the thread is interrupted. */ protected abstract ChannelRequest nextRequest(UpdateDispatcher dispatcher) throws InterruptedException; @@ -90,7 +90,7 @@ public abstract class RequestWorker implements Runnable { * @param provider The resource provider. * @param channel The channel. * @param request The request to service. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ protected abstract void service(P provider, Channel channel, T request) throws IOException; diff --git a/src/org/apollo/update/UpdateDispatcher.java b/src/org/apollo/update/UpdateDispatcher.java index 45a32b08..77e95883 100644 --- a/src/org/apollo/update/UpdateDispatcher.java +++ b/src/org/apollo/update/UpdateDispatcher.java @@ -40,7 +40,7 @@ public final class UpdateDispatcher { * Gets the next 'on-demand' request from the queue, blocking if none are available. * * @return The 'on-demand' request. - * @throws InterruptedException if the thread is interrupted. + * @throws InterruptedException If the thread is interrupted. */ ChannelRequest nextOnDemandRequest() throws InterruptedException { return onDemandQueue.take(); @@ -50,7 +50,7 @@ public final class UpdateDispatcher { * Gets the next JAGGRAB request from the queue, blocking if none are available. * * @return The JAGGRAB request. - * @throws InterruptedException if the thread is interrupted. + * @throws InterruptedException If the thread is interrupted. */ ChannelRequest nextJagGrabRequest() throws InterruptedException { return jagGrabQueue.take(); @@ -60,7 +60,7 @@ public final class UpdateDispatcher { * Gets the next HTTP request from the queue, blocking if none are available. * * @return The HTTP request. - * @throws InterruptedException if the thread is interrupted. + * @throws InterruptedException If the thread is interrupted. */ ChannelRequest nextHttpRequest() throws InterruptedException { return httpQueue.take(); diff --git a/src/org/apollo/update/resource/ResourceProvider.java b/src/org/apollo/update/resource/ResourceProvider.java index 1452f273..ffed9834 100644 --- a/src/org/apollo/update/resource/ResourceProvider.java +++ b/src/org/apollo/update/resource/ResourceProvider.java @@ -15,7 +15,7 @@ public abstract class ResourceProvider { * * @param path The path to the resource, e.g. {@code /crc}. * @return {@code true} if the provider can fulfil a request to the resource, {@code false} otherwise. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public abstract boolean accept(String path) throws IOException; @@ -24,7 +24,7 @@ public abstract class ResourceProvider { * * @param path The path. * @return The resource, or {@code null} if it doesn't exist. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public abstract ByteBuffer get(String path) throws IOException; diff --git a/src/org/apollo/util/CompressionUtil.java b/src/org/apollo/util/CompressionUtil.java index 3b773261..e248f1e7 100644 --- a/src/org/apollo/util/CompressionUtil.java +++ b/src/org/apollo/util/CompressionUtil.java @@ -23,7 +23,7 @@ public final class CompressionUtil { * * @param compressed The compressed array. * @param uncompressed The uncompressed array. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public static void ungzip(byte[] compressed, byte[] uncompressed) throws IOException { DataInputStream is = new DataInputStream(new GZIPInputStream(new ByteArrayInputStream(compressed))); @@ -39,7 +39,7 @@ public final class CompressionUtil { * * @param compressed The compressed array. * @param uncompressed The uncompressed array. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public static void unbzip2(byte[] compressed, byte[] uncompressed) throws IOException { byte[] newCompressed = new byte[compressed.length + 4]; @@ -63,7 +63,7 @@ public final class CompressionUtil { * * @param bytes The uncompressed array. * @return The compressed array. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public static byte[] gzip(byte[] bytes) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); @@ -82,7 +82,7 @@ public final class CompressionUtil { * * @param bytes The uncompressed array. * @return The compressed array. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public static byte[] bzip2(byte[] bytes) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); diff --git a/src/org/apollo/util/StatefulFrameDecoder.java b/src/org/apollo/util/StatefulFrameDecoder.java index f80b2128..f214a2b6 100644 --- a/src/org/apollo/util/StatefulFrameDecoder.java +++ b/src/org/apollo/util/StatefulFrameDecoder.java @@ -36,7 +36,7 @@ public abstract class StatefulFrameDecoder> extends FrameDecod * Creates the stateful frame decoder with the specified initial state. * * @param state The initial state. - * @throws NullPointerException if the state is {@code null}. + * @throws NullPointerException If the state is {@code null}. */ public StatefulFrameDecoder(T state) { this(state, false); @@ -47,7 +47,7 @@ public abstract class StatefulFrameDecoder> extends FrameDecod * * @param state The initial state. * @param unwrap The unwrap flag. - * @throws NullPointerException if the state is {@code null}. + * @throws NullPointerException If the state is {@code null}. */ public StatefulFrameDecoder(T state, boolean unwrap) { super(unwrap); @@ -69,7 +69,7 @@ public abstract class StatefulFrameDecoder> extends FrameDecod * Sets a new state. * * @param state The new state. - * @throws NullPointerException if the state is {@code null}. + * @throws NullPointerException If the state is {@code null}. */ public final void setState(T state) { if (state == null) { @@ -86,7 +86,7 @@ public abstract class StatefulFrameDecoder> extends FrameDecod * @param buffer The cumulative buffer, which may contain zero or more bytes. * @param state The current state. The state may be changed by calling {@link #setState(Enum)}. * @return The decoded frame, or {@code null} if not enough data was received. - * @throws Exception if an error occurs during decoding. + * @throws Exception If an error occurs during decoding. */ protected abstract Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, T state) throws Exception; @@ -100,7 +100,7 @@ public abstract class StatefulFrameDecoder> extends FrameDecod * @param buffer The cumulative buffer, which may contain zero or more bytes. * @param state The current state. The state may be changed by calling {@link #setState(Enum)}. * @return The decoded frame, or {@code null} if not enough data was received. - * @throws Exception if an error occurs during decoding. + * @throws Exception If an error occurs during decoding. */ protected Object decodeLast(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, T state) throws Exception { diff --git a/src/org/apollo/util/StreamUtil.java b/src/org/apollo/util/StreamUtil.java index 0438b6e8..67db2168 100644 --- a/src/org/apollo/util/StreamUtil.java +++ b/src/org/apollo/util/StreamUtil.java @@ -16,7 +16,7 @@ public final class StreamUtil { * * @param os The output stream. * @param str The string. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public static void writeString(OutputStream os, String str) throws IOException { for (char c : str.toCharArray()) { @@ -30,7 +30,7 @@ public final class StreamUtil { * * @param is The input stream. * @return The string. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ public static String readString(InputStream is) throws IOException { StringBuilder builder = new StringBuilder(); diff --git a/src/org/apollo/util/plugin/PluginContext.java b/src/org/apollo/util/plugin/PluginContext.java index 706b122c..1e0d3b90 100644 --- a/src/org/apollo/util/plugin/PluginContext.java +++ b/src/org/apollo/util/plugin/PluginContext.java @@ -91,4 +91,4 @@ public final class PluginContext { chain.addLast(handler); } -} +} \ No newline at end of file diff --git a/src/org/apollo/util/plugin/PluginManager.java b/src/org/apollo/util/plugin/PluginManager.java index dab739a5..7497db68 100644 --- a/src/org/apollo/util/plugin/PluginManager.java +++ b/src/org/apollo/util/plugin/PluginManager.java @@ -75,9 +75,9 @@ public final class PluginManager { /** * Starts the plugin system by finding and loading all the plugins. * - * @throws SAXException if a SAX error occurs. - * @throws IOException if an I/O error occurs. - * @throws DependencyException if a dependency could not be resolved. + * @throws SAXException If a SAX error occurs. + * @throws IOException If an I/O error occurs. + * @throws DependencyException If a dependency could not be resolved. */ public void start() throws IOException, SAXException, DependencyException { Map plugins = createMap(findPlugins()); @@ -95,8 +95,8 @@ public final class PluginManager { * Finds plugins and loads their meta data. * * @return A collection of plugin meta data objects. - * @throws IOException if an I/O error occurs. - * @throws SAXException if a SAX error occurs. + * @throws IOException If an I/O error occurs. + * @throws SAXException If a SAX error occurs. */ private Collection findPlugins() throws IOException, SAXException { Collection plugins = new ArrayList(); @@ -129,8 +129,8 @@ public final class PluginManager { * @param plugin The plugin. * @param plugins The plugin map. * @param started A set of started plugins. - * @throws DependencyException if a dependency error occurs. - * @throws IOException if an I/O error occurs. + * @throws DependencyException If a dependency error occurs. + * @throws IOException If an I/O error occurs. */ private void start(PluginEnvironment env, PluginMetaData plugin, Map plugins, Set started) throws DependencyException, IOException { diff --git a/src/org/apollo/util/plugin/RubyPluginEnvironment.java b/src/org/apollo/util/plugin/RubyPluginEnvironment.java index 96d95058..42b26a44 100644 --- a/src/org/apollo/util/plugin/RubyPluginEnvironment.java +++ b/src/org/apollo/util/plugin/RubyPluginEnvironment.java @@ -22,7 +22,7 @@ public final class RubyPluginEnvironment implements PluginEnvironment { /** * Creates and bootstraps the Ruby plugin environment. * - * @throws IOException if an I/O error occurs during bootstrapping. + * @throws IOException If an I/O error occurs during bootstrapping. */ public RubyPluginEnvironment() throws IOException { parseBootstrapper(); @@ -31,7 +31,7 @@ public final class RubyPluginEnvironment implements PluginEnvironment { /** * Parses the bootstrapper. * - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ private void parseBootstrapper() throws IOException { File f = new File("./data/plugins/bootstrap.rb"); diff --git a/src/org/apollo/util/xml/XmlParser.java b/src/org/apollo/util/xml/XmlParser.java index b967d1a1..fe39e31b 100644 --- a/src/org/apollo/util/xml/XmlParser.java +++ b/src/org/apollo/util/xml/XmlParser.java @@ -89,7 +89,7 @@ public final class XmlParser { /** * Creates a new xml parser. * - * @throws SAXException if a SAX error occurs. + * @throws SAXException If a SAX error occurs. */ public XmlParser() throws SAXException { xmlReader = XMLReaderFactory.createXMLReader(); @@ -112,8 +112,8 @@ public final class XmlParser { * * @param is The {@link InputStream}. * @return The root {@link XmlNode}. - * @throws IOException if an I/O error occurs. - * @throws SAXException if a SAX error occurs. + * @throws IOException If an I/O error occurs. + * @throws SAXException If a SAX error occurs. */ public XmlNode parse(InputStream is) throws IOException, SAXException { synchronized (this) { @@ -126,8 +126,8 @@ public final class XmlParser { * * @param reader The {@link Reader}. * @return The root {@link XmlNode}. - * @throws IOException if an I/O error occurs. - * @throws SAXException if a SAX error occurs. + * @throws IOException If an I/O error occurs. + * @throws SAXException If a SAX error occurs. */ public XmlNode parse(Reader reader) throws IOException, SAXException { synchronized (this) { @@ -140,8 +140,8 @@ public final class XmlParser { * * @param source The {@link InputSource}. * @return The root {@link XmlNode}. - * @throws IOException if an I/O error occurs. - * @throws SAXException if a SAX error occurs. + * @throws IOException If an I/O error occurs. + * @throws SAXException If a SAX error occurs. */ private XmlNode parse(InputSource source) throws IOException, SAXException { rootNode = null; diff --git a/test/org/apollo/net/codec/game/TestGamePacketEncoder.java b/test/org/apollo/net/codec/game/TestGamePacketEncoder.java index 393c698f..03b3c37c 100644 --- a/test/org/apollo/net/codec/game/TestGamePacketEncoder.java +++ b/test/org/apollo/net/codec/game/TestGamePacketEncoder.java @@ -18,7 +18,7 @@ public class TestGamePacketEncoder { /** * Tests the {@link GamePacketEncoder#encode(org.jboss.netty.channel.ChannelHandlerContext, org.jboss.netty.channel.Channel, Object)} * method. - * @throws Exception if an error occurs. + * @throws Exception If an error occurs. */ @Test public void testEncode() throws Exception { diff --git a/test/org/apollo/util/TestCompressionUtil.java b/test/org/apollo/util/TestCompressionUtil.java index bd86f377..63bec4db 100644 --- a/test/org/apollo/util/TestCompressionUtil.java +++ b/test/org/apollo/util/TestCompressionUtil.java @@ -15,7 +15,7 @@ public class TestCompressionUtil { /** * Tests the {@link CompressionUtil#gzip(byte[])} and * {@link CompressionUtil#ungzip(byte[], byte[])} methods. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ @Test public void testGzip() throws IOException { @@ -29,7 +29,7 @@ public class TestCompressionUtil { /** * Tests the {@link CompressionUtil#bzip2(byte[])} and * {@link CompressionUtil#unbzip2(byte[], byte[])} methods. - * @throws IOException if an I/O error occurs. + * @throws IOException If an I/O error occurs. */ @Test public void testBzip2() throws IOException { diff --git a/test/org/apollo/util/xml/TestXmlParser.java b/test/org/apollo/util/xml/TestXmlParser.java index 9ac82d4c..46078c40 100644 --- a/test/org/apollo/util/xml/TestXmlParser.java +++ b/test/org/apollo/util/xml/TestXmlParser.java @@ -20,8 +20,8 @@ public final class TestXmlParser { /** * A test for the {@link XmlParser#parse(java.io.InputStream)} method. - * @throws SAXException if a SAX error occurs. - * @throws IOException if an I/O error occurs. + * @throws SAXException If a SAX error occurs. + * @throws IOException If an I/O error occurs. */ @Test public void testParseInputStream() throws SAXException, IOException { @@ -66,8 +66,8 @@ public final class TestXmlParser { /** * A test for the {@link XmlParser#parse(java.io.Reader)} method. - * @throws SAXException if a SAX error occurs. - * @throws IOException if an I/O error occurs. + * @throws SAXException If a SAX error occurs. + * @throws IOException If an I/O error occurs. */ @Test public void testParseReader() throws SAXException, IOException {