Fix issue #1; comment updates.

This commit is contained in:
Major-
2013-11-03 03:21:34 +00:00
parent b920ab34a7
commit 5f595c2746
50 changed files with 324 additions and 340 deletions
+7 -7
View File
@@ -99,7 +99,7 @@ public final class Server {
/** /**
* Creates the Apollo 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 { public Server() throws Exception {
logger.info("Starting Apollo..."); logger.info("Starting Apollo...");
@@ -110,9 +110,9 @@ public final class Server {
* Initialises the server. * Initialises the server.
* *
* @param releaseClassName The class name of the current active {@link Release}. * @param releaseClassName The class name of the current active {@link Release}.
* @throws ClassNotFoundException if the release class could not be found. * @throws ClassNotFoundException If the release class could not be found.
* @throws IllegalAccessException if the release class could not be accessed. * @throws IllegalAccessException If the release class could not be accessed.
* @throws InstantiationException if the release class could not be instantiated. * @throws InstantiationException If the release class could not be instantiated.
*/ */
public void init(String releaseClassName) throws ClassNotFoundException, InstantiationException, public void init(String releaseClassName) throws ClassNotFoundException, InstantiationException,
IllegalAccessException { IllegalAccessException {
@@ -155,7 +155,7 @@ public final class Server {
httpBootstrap.bind(httpAddress); httpBootstrap.bind(httpAddress);
} catch (Throwable t) { } catch (Throwable t) {
logger.log(Level.WARNING, 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 + "..."); logger.info("Binding JAGGRAB listener to address: " + jagGrabAddress + "...");
@@ -167,7 +167,7 @@ public final class Server {
/** /**
* Starts the server. * Starts the server.
* *
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
public void start() throws Exception { public void start() throws Exception {
PluginManager mgr = new PluginManager(new PluginContext(context)); PluginManager mgr = new PluginManager(new PluginContext(context));
@@ -181,4 +181,4 @@ public final class Server {
World.getWorld().init(releaseNo, fs, mgr); World.getWorld().init(releaseNo, fs, mgr);
} }
} }
+3 -3
View File
@@ -29,7 +29,7 @@ public final class ServiceManager {
/** /**
* Creates and initializes the {@link ServiceManager}. * Creates and initializes the {@link ServiceManager}.
* *
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
public ServiceManager() throws Exception { public ServiceManager() throws Exception {
init(); init();
@@ -38,7 +38,7 @@ public final class ServiceManager {
/** /**
* Initializes this service manager. * Initializes this service manager.
* *
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void init() throws Exception { private void init() throws Exception {
@@ -118,4 +118,4 @@ public final class ServiceManager {
} }
} }
} }
+1 -1
View File
@@ -12,7 +12,7 @@ public final class Index {
* *
* @param buffer The buffer. * @param buffer The buffer.
* @return The decoded {@link Index}. * @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) { public static Index decode(byte[] buffer) {
if (buffer.length != FileSystemConstants.INDEX_SIZE) { if (buffer.length != FileSystemConstants.INDEX_SIZE) {
+7 -7
View File
@@ -41,7 +41,7 @@ public final class IndexedFileSystem implements Closeable {
* *
* @param base The base directory. * @param base The base directory.
* @param readOnly A flag indicating if the file system will be read only. * @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 { public IndexedFileSystem(File base, boolean readOnly) throws Exception {
this.readOnly = readOnly; this.readOnly = readOnly;
@@ -61,7 +61,7 @@ public final class IndexedFileSystem implements Closeable {
* Automatically detect the layout of the specified directory. * Automatically detect the layout of the specified directory.
* *
* @param base The base 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 { private void detectLayout(File base) throws Exception {
int indexCount = 0; int indexCount = 0;
@@ -92,7 +92,7 @@ public final class IndexedFileSystem implements Closeable {
* *
* @param fd The {@link FileDescriptor} which points to the file. * @param fd The {@link FileDescriptor} which points to the file.
* @return The {@link Index}. * @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 { private Index getIndex(FileDescriptor fd) throws IOException {
int index = fd.getType(); int index = fd.getType();
@@ -120,7 +120,7 @@ public final class IndexedFileSystem implements Closeable {
* *
* @param type The type. * @param type The type.
* @return The number of files. * @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 { private int getFileCount(int type) throws IOException {
if (type < 0 || type >= indices.length) { if (type < 0 || type >= indices.length) {
@@ -137,7 +137,7 @@ public final class IndexedFileSystem implements Closeable {
* Gets the CRC table. * Gets the CRC table.
* *
* @return 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 { public ByteBuffer getCrcTable() throws IOException {
if (readOnly) { if (readOnly) {
@@ -195,7 +195,7 @@ public final class IndexedFileSystem implements Closeable {
* @param type The file type. * @param type The file type.
* @param file The file id. * @param file The file id.
* @return A {@link ByteBuffer} which contains the contents of 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(int type, int file) throws IOException { public ByteBuffer getFile(int type, int file) throws IOException {
return getFile(new FileDescriptor(type, file)); 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. * @param fd The {@link FileDescriptor} which points to the file.
* @return A {@link ByteBuffer} which contains the contents of 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 { public ByteBuffer getFile(FileDescriptor fd) throws IOException {
Index index = getIndex(fd); Index index = getIndex(fd);
+2 -2
View File
@@ -19,7 +19,7 @@ public final class Archive {
* *
* @param buffer The buffer. * @param buffer The buffer.
* @return The archive. * @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 { public static Archive decode(ByteBuffer buffer) throws IOException {
int extractedSize = ByteBufferUtil.readUnsignedTriByte(buffer); int extractedSize = ByteBufferUtil.readUnsignedTriByte(buffer);
@@ -80,7 +80,7 @@ public final class Archive {
* *
* @param name The name. * @param name The name.
* @return The entry. * @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 { public ArchiveEntry getEntry(String name) throws FileNotFoundException {
int hash = 0; int hash = 0;
@@ -33,7 +33,7 @@ public final class ItemDefinitionParser {
* Parses the item definitions. * Parses the item definitions.
* *
* @return 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 { public ItemDefinition[] parse() throws IOException {
Archive config = Archive.decode(fs.getFile(0, 2)); Archive config = Archive.decode(fs.getFile(0, 2));
+2 -2
View File
@@ -58,7 +58,7 @@ public final class GameService extends Service {
/** /**
* Creates the game 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 { public GameService() throws Exception {
init(); init();
@@ -76,7 +76,7 @@ public final class GameService extends Service {
/** /**
* Initializes the game service. * Initializes the game service.
* *
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
private void init() throws Exception { private void init() throws Exception {
InputStream is = new FileInputStream("data/events.xml"); InputStream is = new FileInputStream("data/events.xml");
@@ -21,7 +21,7 @@ public final class BankEventHandler extends EventHandler<ItemActionEvent> {
* *
* @param option The option. * @param option The option.
* @return The amount. * @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) { private static final int optionToAmount(int option) {
switch (option) { switch (option) {
@@ -12,6 +12,7 @@ import org.apollo.game.model.SkillSet;
import org.apollo.game.model.def.EquipmentDefinition; import org.apollo.game.model.def.EquipmentDefinition;
import org.apollo.game.model.def.ItemDefinition; import org.apollo.game.model.def.ItemDefinition;
import org.apollo.game.model.inv.SynchronizationInventoryListener; import org.apollo.game.model.inv.SynchronizationInventoryListener;
import org.apollo.util.LanguageUtil;
/** /**
* An event handler which equips items. * An event handler which equips items.
@@ -23,119 +24,84 @@ public final class EquipEventHandler extends EventHandler<EquipEvent> {
@Override @Override
public void handle(EventHandlerContext ctx, Player player, EquipEvent event) { public void handle(EventHandlerContext ctx, Player player, EquipEvent event) {
if (event.getInterfaceId() == SynchronizationInventoryListener.INVENTORY_ID) { if (event.getInterfaceId() == SynchronizationInventoryListener.INVENTORY_ID) {
int slot = event.getSlot(); int inventorySlot = event.getSlot();
if (slot < 0 || slot >= player.getInventory().capacity()) { Item equipping = player.getInventory().get(inventorySlot);
int equippingId = equipping.getId();
EquipmentDefinition equippingDef = EquipmentDefinition.forId(equippingId);
if (equippingDef == null) {
ctx.breakHandlerChain(); ctx.breakHandlerChain();
return; return;
} }
Item item = player.getInventory().get(slot); for (int id = 0; id < 5; id++) {
if (item == null || item.getId() != event.getId()) { int requirement = equippingDef.getLevel(id);
ctx.breakHandlerChain();
return;
}
ItemDefinition itemDef = item.getDefinition(); if (player.getSkillSet().getSkill(id).getMaximumLevel() < requirement) {
EquipmentDefinition equipDef = EquipmentDefinition.forId(item.getId()); String skillName = Skill.getName(id);
if (equipDef == null) { String article = LanguageUtil.getIndefiniteArticle(skillName);
ctx.breakHandlerChain();
return;
}
SkillSet skillSet = player.getSkillSet(); player.sendMessage("You need " + article + " " + skillName + " level of " + requirement
if (skillSet.getSkill(Skill.ATTACK).getMaximumLevel() < equipDef.getAttackLevel()) { + " to equip this item.");
player.sendMessage("You need an Attack level of " + equipDef.getAttackLevel() + " to equip this item."); ctx.breakHandlerChain();
ctx.breakHandlerChain(); return;
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;
} }
Inventory inventory = player.getInventory(); Inventory inventory = player.getInventory();
Inventory equipment = player.getEquipment(); Inventory equipment = player.getEquipment();
int equipmentSlot = equipDef.getSlot(); // start
// TODO: equip event decoder for 317, and remove event decoder for both int equipmentSlot = equippingDef.getSlot();
// TODO: put all this into another method somewhere Item currentlyEquipped = equipment.get(equipmentSlot);
// check if there is enough space for a two handed weapon if (equipping.getDefinition().isStackable()
if (equipDef.isTwoHanded()) { && (currentlyEquipped == null || currentlyEquipped.getId() == equippingId)) {
if (equipment.get(EquipmentConstants.SHIELD) != null) { equipment.set(equippingDef.getSlot(), equipping);
Item shield = equipment.reset(EquipmentConstants.SHIELD); 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); inventory.add(shield);
} }
} if (weapon != null) {
inventory.add(weapon);
// 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;
}
} }
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); Item previous = equipment.reset(equipmentSlot);
if (itemDef.isStackable() && previous != null && previous.getId() == item.getId()) { inventory.remove(equipping); // no need for fancy stuff here as we
// we know the item is there, so we can let the inventory class do its stacking magic // know the item isn't stackable.
inventory.remove(item); equipment.set(equipmentSlot, equipping);
Item tmp = equipment.add(item); if (previous != null) {
if (tmp != null) { inventory.add(previous);
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);
} }
ctx.breakHandlerChain(); ctx.breakHandlerChain();
} }
} }
} }
+9 -9
View File
@@ -73,7 +73,7 @@ public final class Inventory implements Cloneable {
* Creates an inventory. * Creates an inventory.
* *
* @param capacity The capacity. * @param capacity The capacity.
* @throws IllegalArgumentException if the capacity is negative. * @throws IllegalArgumentException If the capacity is negative.
*/ */
public Inventory(int capacity) { public Inventory(int capacity) {
this(capacity, StackMode.STACK_STACKABLE_ITEMS); this(capacity, StackMode.STACK_STACKABLE_ITEMS);
@@ -84,8 +84,8 @@ public final class Inventory implements Cloneable {
* *
* @param capacity The capacity. * @param capacity The capacity.
* @param mode The stacking mode. * @param mode The stacking mode.
* @throws IllegalArgumentException if the capacity is negative. * @throws IllegalArgumentException If the capacity is negative.
* @throws NullPointerException if the mode is {@code null}. * @throws NullPointerException If the mode is {@code null}.
*/ */
public Inventory(int capacity, StackMode mode) { public Inventory(int capacity, StackMode mode) {
if (capacity < 0) { if (capacity < 0) {
@@ -168,7 +168,7 @@ public final class Inventory implements Cloneable {
* *
* @param slot The slot. * @param slot The slot.
* @return The item, or {@code null} if the slot is empty. * @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) { public Item get(int slot) {
checkBounds(slot); checkBounds(slot);
@@ -181,7 +181,7 @@ public final class Inventory implements Cloneable {
* @param slot The slot. * @param slot The slot.
* @param item The item, or {@code null} to remove the item that is in 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. * @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) { public Item set(int slot, Item item) {
if (item == null) { if (item == null) {
@@ -203,7 +203,7 @@ public final class Inventory implements Cloneable {
* *
* @param slot * @param slot
* @return The item that was 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 reset(int slot) { public Item reset(int slot) {
checkBounds(slot); checkBounds(slot);
@@ -394,7 +394,7 @@ public final class Inventory implements Cloneable {
* *
* @param oldSlot The old slot. * @param oldSlot The old slot.
* @param newSlot The new 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) { public void swap(int oldSlot, int newSlot) {
swap(false, oldSlot, 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 insert If the swap should be done in insertion mode.
* @param oldSlot The old slot. * @param oldSlot The old slot.
* @param newSlot The new 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) { public void swap(boolean insert, int oldSlot, int newSlot) {
checkBounds(oldSlot); checkBounds(oldSlot);
@@ -495,7 +495,7 @@ public final class Inventory implements Cloneable {
* Checks the bounds of the specified slot. * Checks the bounds of the specified slot.
* *
* @param slot The 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) { private void checkBounds(int slot) {
if (slot < 0 || slot >= capacity) { if (slot < 0 || slot >= capacity) {
+1 -1
View File
@@ -33,7 +33,7 @@ public final class Item {
* *
* @param id The item's id. * @param id The item's id.
* @param amount The amount. * @param amount The amount.
* @throws IllegalArgumentException if the amount is negative. * @throws IllegalArgumentException If the amount is negative.
*/ */
public Item(int id, int amount) { public Item(int id, int amount) {
if (amount < 0) { if (amount < 0) {
+1 -1
View File
@@ -53,7 +53,7 @@ public final class Player extends Character {
* *
* @param numericalLevel The numerical level. * @param numericalLevel The numerical level.
* @return The privilege 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) { public static PrivilegeLevel valueOf(int numericalLevel) {
for (PrivilegeLevel level : values()) { for (PrivilegeLevel level : values()) {
+5 -5
View File
@@ -72,7 +72,7 @@ public final class SkillSet {
* *
* @param id The id. * @param id The id.
* @return The skill. * @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) { public Skill getSkill(int id) {
checkBounds(id); checkBounds(id);
@@ -219,7 +219,7 @@ public final class SkillSet {
* *
* @param id The id. * @param id The id.
* @param skill The skill. * @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) { public void setSkill(int id, Skill skill) {
checkBounds(id); checkBounds(id);
@@ -231,7 +231,7 @@ public final class SkillSet {
* Checks the bounds of the id. * Checks the bounds of the id.
* *
* @param id 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) { private void checkBounds(int id) {
if (id < 0 || id >= skills.length) { if (id < 0 || id >= skills.length) {
@@ -243,7 +243,7 @@ public final class SkillSet {
* Notifies listeners that a skill has been levelled up. * Notifies listeners that a skill has been levelled up.
* *
* @param id The skill's id. * @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) { private void notifyLevelledUp(int id) {
checkBounds(id); checkBounds(id);
@@ -258,7 +258,7 @@ public final class SkillSet {
* Notifies listeners that a skill has been updated. * Notifies listeners that a skill has been updated.
* *
* @param id The skill's id. * @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) { private void notifySkillUpdated(int id) {
checkBounds(id); checkBounds(id);
+1 -1
View File
@@ -103,7 +103,7 @@ public final class World {
* @param release The release number. * @param release The release number.
* @param fs The file system. * @param fs The file system.
* @param mgr The plugin manager. TODO move this. * @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 { public void init(int release, IndexedFileSystem fs, PluginManager mgr) throws IOException {
logger.info("Loading item definitions..."); logger.info("Loading item definitions...");
@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apollo.game.model.Item; import org.apollo.game.model.Item;
import org.apollo.game.model.Skill;
/** /**
* Represents a type of {@link Item} which may be equipped. * Represents a type of {@link Item} which may be equipped.
@@ -27,23 +28,33 @@ public final class EquipmentDefinition {
EquipmentDefinition def = definitions[id]; EquipmentDefinition def = definitions[id];
if (def != null) { if (def != null) {
if (def.getId() != id) { if (def.getId() != id) {
throw new RuntimeException("Item definition id mismatch!"); throw new RuntimeException("Equipment definition id mismatch!");
} }
EquipmentDefinition.definitions.put(def.getId(), def); 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. * Gets an equipment definition by its id.
* *
* @param id The id. * @param id The id.
* @return {@code null} if the item is not equipment, the definition otherwise. * @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) { public static EquipmentDefinition forId(int id) {
if (id < 0 || id >= ItemDefinition.count()) { 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); return definitions.get(id);
} }
@@ -58,11 +69,6 @@ public final class EquipmentDefinition {
*/ */
private int slot; private int slot;
/**
* The required levels.
*/
private int attack = 1, strength = 1, defence = 1, ranged = 1, magic = 1;
/** /**
* Various flags. * Various flags.
*/ */
@@ -77,6 +83,24 @@ public final class EquipmentDefinition {
this.id = id; 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. * 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 skill The skill id.
* @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) { public int getLevel(int skill) {
this.attack = attack; if (skill < Skill.ATTACK || skill > Skill.MAGIC) {
this.strength = strength; throw new IllegalArgumentException("Skill id out of bounds for an equipment definition.");
this.defence = defence; }
this.ranged = ranged; return levels[skill];
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;
} }
/** /**
@@ -145,16 +128,16 @@ public final class EquipmentDefinition {
* @return The minimum magic level. * @return The minimum magic level.
*/ */
public int getMagicLevel() { 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) { public int getRangedLevel() {
this.slot = slot; 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() { public int getStrengthLevel() {
return twoHanded; return levels[Skill.STRENGTH];
} }
/** /**
@@ -202,6 +185,15 @@ public final class EquipmentDefinition {
return fullMask; 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. * Sets the flags.
* *
@@ -217,4 +209,30 @@ public final class EquipmentDefinition {
this.fullMask = fullMask; 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;
}
}
@@ -59,7 +59,7 @@ public final class ItemDefinition {
* Initialises the class with the specified set of definitions. * Initialises the class with the specified set of definitions.
* *
* @param definitions The 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) { public static void init(ItemDefinition[] definitions) {
ItemDefinition.definitions = definitions; ItemDefinition.definitions = definitions;
@@ -89,7 +89,7 @@ public final class ItemDefinition {
* *
* @param id The id. * @param id The id.
* @return The definition. * @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) { public static ItemDefinition forId(int id) {
if (id < 0 || id >= definitions.length) { if (id < 0 || id >= definitions.length) {
@@ -214,7 +214,7 @@ public final class ItemDefinition {
/** /**
* Converts this item to a note, if possible. * 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() { public void toNote() {
if (isNote()) { if (isNote()) {
@@ -336,7 +336,7 @@ public final class ItemDefinition {
* *
* @param id The id. * @param id The id.
* @param action The action. * @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) { public void setGroundAction(int id, String action) {
if (id < 0 || id >= groundActions.length) { if (id < 0 || id >= groundActions.length) {
@@ -350,7 +350,7 @@ public final class ItemDefinition {
* *
* @param id The id. * @param id The id.
* @return The action. * @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) { public String getGroundAction(int id) {
if (id < 0 || id >= groundActions.length) { if (id < 0 || id >= groundActions.length) {
@@ -364,7 +364,7 @@ public final class ItemDefinition {
* *
* @param id The id. * @param id The id.
* @param action The action. * @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) { public void setInventoryAction(int id, String action) {
if (id < 0 || id >= inventoryActions.length) { if (id < 0 || id >= inventoryActions.length) {
@@ -378,7 +378,7 @@ public final class ItemDefinition {
* *
* @param id The id. * @param id The id.
* @return The action. * @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) { public String getInventoryAction(int id) {
if (id < 0 || id >= inventoryActions.length) { if (id < 0 || id >= inventoryActions.length) {
@@ -28,7 +28,7 @@ public abstract class ScheduledTask {
* @param delay The delay between executions of the task, in pulses. * @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 * @param immediate A flag indicating if this task should (for the first execution) be ran immediately, or after the
* {@code delay}. * {@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) { public ScheduledTask(int delay, boolean immediate) {
setDelay(delay); setDelay(delay);
@@ -48,7 +48,7 @@ public abstract class ScheduledTask {
* Sets the delay. * Sets the delay.
* *
* @param delay 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) { public void setDelay(int delay) {
if (delay < 0) { if (delay < 0) {
@@ -20,7 +20,7 @@ public final class MovementSegment extends SynchronizationSegment {
* *
* @param blockSet The block set. * @param blockSet The block set.
* @param directions The directions array. * @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) { public MovementSegment(SynchronizationBlockSet blockSet, Direction[] directions) {
super(blockSet); super(blockSet);
@@ -32,7 +32,7 @@ public final class EquipmentDefinitionParser {
* Parses the input stream. * Parses the input stream.
* *
* @return The equipment definition array. * @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 { public EquipmentDefinition[] parse() throws IOException {
DataInputStream dis = new DataInputStream(is); DataInputStream dis = new DataInputStream(is);
@@ -36,7 +36,7 @@ public final class EventHandlerChainParser {
* Creates the event chain parser. * Creates the event chain parser.
* *
* @param is The source {@link InputStream}. * @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 { public EventHandlerChainParser(InputStream is) throws SAXException {
this.parser = new XmlParser(); this.parser = new XmlParser();
@@ -46,11 +46,11 @@ public final class EventHandlerChainParser {
/** /**
* Parses the XML and produces a group of {@link EventHandlerChain}s. * Parses the XML and produces a group of {@link EventHandlerChain}s.
* *
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
* @throws ClassNotFoundException if a class was not found. * @throws ClassNotFoundException If a class was not found.
* @throws IllegalAccessException if a class was accessed illegally. * @throws IllegalAccessException If a class was accessed illegally.
* @throws InstantiationException if a class could not be instantiated. * @throws InstantiationException If a class could not be instantiated.
* @return An {@link EventHandlerChainGroup}. * @return An {@link EventHandlerChainGroup}.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
+4 -4
View File
@@ -34,7 +34,7 @@ public final class PluginMetaDataParser {
* Creates the plugin meta data parser. * Creates the plugin meta data parser.
* *
* @param is The input stream. * @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 { public PluginMetaDataParser(InputStream is) throws SAXException {
this.parser = new XmlParser(); this.parser = new XmlParser();
@@ -45,8 +45,8 @@ public final class PluginMetaDataParser {
* Parses the XML and creates a meta data object. * Parses the XML and creates a meta data object.
* *
* @return The meta data object. * @return The meta data object.
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
public PluginMetaData parse() throws IOException, SAXException { public PluginMetaData parse() throws IOException, SAXException {
XmlNode rootNode = parser.parse(is); XmlNode rootNode = parser.parse(is);
@@ -109,7 +109,7 @@ public final class PluginMetaDataParser {
* @param node The root node. * @param node The root node.
* @param name The element name. * @param name The element name.
* @return The node object. * @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 { private XmlNode getElement(XmlNode node, String name) throws IOException {
XmlNode child = node.getChild(name); XmlNode child = node.getChild(name);
+1 -1
View File
@@ -15,7 +15,7 @@ public interface PlayerLoader {
* *
* @param credentials The player's credentials. * @param credentials The player's credentials.
* @return The {@link PlayerLoaderResponse}. * @return The {@link PlayerLoaderResponse}.
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
public PlayerLoaderResponse loadPlayer(PlayerCredentials credentials) throws Exception; public PlayerLoaderResponse loadPlayer(PlayerCredentials credentials) throws Exception;
@@ -24,7 +24,7 @@ public final class PlayerLoaderResponse {
* Creates a {@link PlayerLoaderResponse} with only a status code. * Creates a {@link PlayerLoaderResponse} with only a status code.
* *
* @param status The 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) { public PlayerLoaderResponse(int status) {
if (status == LoginConstants.STATUS_OK || status == LoginConstants.STATUS_RECONNECTION_OK) { if (status == LoginConstants.STATUS_OK || status == LoginConstants.STATUS_RECONNECTION_OK) {
@@ -39,7 +39,7 @@ public final class PlayerLoaderResponse {
* *
* @param status The status code. * @param status The status code.
* @param player The player. * @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) { public PlayerLoaderResponse(int status, Player player) {
if (status != LoginConstants.STATUS_OK && status != LoginConstants.STATUS_RECONNECTION_OK) { if (status != LoginConstants.STATUS_OK && status != LoginConstants.STATUS_RECONNECTION_OK) {
+1 -1
View File
@@ -14,7 +14,7 @@ public interface PlayerSaver {
* Saves a player. * Saves a player.
* *
* @param player The player to save. * @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; public void savePlayer(Player player) throws Exception;
@@ -108,7 +108,7 @@ public final class BinaryPlayerLoader implements PlayerLoader {
* *
* @param in The input stream. * @param in The input stream.
* @param inventory The inventory. * @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 { private void readInventory(DataInputStream in, Inventory inventory) throws IOException {
int capacity = in.readUnsignedShort(); int capacity = in.readUnsignedShort();
@@ -76,7 +76,7 @@ public final class BinaryPlayerSaver implements PlayerSaver {
* *
* @param out The output stream. * @param out The output stream.
* @param inventory The inventory. * @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 { private void writeInventory(DataOutputStream out, Inventory inventory) throws IOException {
int capacity = inventory.capacity(); int capacity = inventory.capacity();
+2 -2
View File
@@ -44,7 +44,7 @@ public final class LoginService extends Service {
/** /**
* Creates the login service. * Creates the login service.
* *
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
public LoginService() throws Exception { public LoginService() throws Exception {
init(); init();
@@ -53,7 +53,7 @@ public final class LoginService extends Service {
/** /**
* Initialises the login service. * Initialises the login service.
* *
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
private void init() throws Exception { private void init() throws Exception {
XmlParser parser = new XmlParser(); XmlParser parser = new XmlParser();
@@ -69,7 +69,7 @@ public final class GamePacketBuilder {
* Creates a {@link GamePacket} based on the current contents of this builder. * Creates a {@link GamePacket} based on the current contents of this builder.
* *
* @return The {@link GamePacket}. * @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() { public GamePacket toGamePacket() {
if (type == PacketType.RAW) { if (type == PacketType.RAW) {
@@ -85,7 +85,7 @@ public final class GamePacketBuilder {
* Gets the current length of the builder's buffer. * Gets the current length of the builder's buffer.
* *
* @return The length of the 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() { public int getLength() {
checkByteAccess(); checkByteAccess();
@@ -95,7 +95,7 @@ public final class GamePacketBuilder {
/** /**
* Switches this builder's mode to the byte access mode. * 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() { public void switchToByteAccess() {
if (mode == AccessMode.BYTE_ACCESS) { if (mode == AccessMode.BYTE_ACCESS) {
@@ -108,7 +108,7 @@ public final class GamePacketBuilder {
/** /**
* Switches this builder's mode to the bit access mode. * 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() { public void switchToBitAccess() {
if (mode == AccessMode.BIT_ACCESS) { if (mode == AccessMode.BIT_ACCESS) {
@@ -151,7 +151,7 @@ public final class GamePacketBuilder {
* *
* @param type The data type. * @param type The data type.
* @param value The value. * @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) { public void put(DataType type, Number value) {
put(type, DataOrder.BIG, DataTransformation.NONE, value); put(type, DataOrder.BIG, DataTransformation.NONE, value);
@@ -163,8 +163,8 @@ public final class GamePacketBuilder {
* @param type The data type. * @param type The data type.
* @param order The byte order. * @param order The byte order.
* @param value The value. * @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.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public void put(DataType type, DataOrder order, Number value) { public void put(DataType type, DataOrder order, Number value) {
put(type, order, DataTransformation.NONE, value); put(type, order, DataTransformation.NONE, value);
@@ -176,8 +176,8 @@ public final class GamePacketBuilder {
* @param type The type. * @param type The type.
* @param transformation The transformation. * @param transformation The transformation.
* @param value The value. * @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.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public void put(DataType type, DataTransformation transformation, Number value) { public void put(DataType type, DataTransformation transformation, Number value) {
put(type, DataOrder.BIG, transformation, value); put(type, DataOrder.BIG, transformation, value);
@@ -190,8 +190,8 @@ public final class GamePacketBuilder {
* @param order The byte order. * @param order The byte order.
* @param transformation The transformation. * @param transformation The transformation.
* @param value The value. * @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.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public void put(DataType type, DataOrder order, DataTransformation transformation, Number value) { public void put(DataType type, DataOrder order, DataTransformation transformation, Number value) {
checkByteAccess(); checkByteAccess();
@@ -288,7 +288,7 @@ public final class GamePacketBuilder {
* Puts the bytes from the specified buffer into this packet's buffer. * Puts the bytes from the specified buffer into this packet's buffer.
* *
* @param buffer The source {@link ChannelBuffer}. * @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) { public void putBytes(ChannelBuffer buffer) {
byte[] bytes = new byte[buffer.readableBytes()]; 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. * Puts the bytes from the specified buffer into this packet's buffer, in reverse.
* *
* @param buffer The source {@link ChannelBuffer}. * @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) { public void putBytesReverse(ChannelBuffer buffer) {
byte[] bytes = new byte[buffer.readableBytes()]; byte[] bytes = new byte[buffer.readableBytes()];
@@ -322,7 +322,7 @@ public final class GamePacketBuilder {
* Puts the specified byte array into the buffer. * Puts the specified byte array into the buffer.
* *
* @param bytes The byte array. * @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) { public void putBytes(byte[] bytes) {
buffer.writeBytes(bytes); buffer.writeBytes(bytes);
@@ -333,7 +333,7 @@ public final class GamePacketBuilder {
* *
* @param transformation The transformation. * @param transformation The transformation.
* @param bytes The byte array. * @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) { public void putBytes(DataTransformation transformation, byte[] bytes) {
if (transformation == DataTransformation.NONE) { if (transformation == DataTransformation.NONE) {
@@ -349,7 +349,7 @@ public final class GamePacketBuilder {
* Puts the specified byte array into the buffer in reverse. * Puts the specified byte array into the buffer in reverse.
* *
* @param bytes The byte array. * @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) { public void putBytesReverse(byte[] bytes) {
checkByteAccess(); checkByteAccess();
@@ -363,7 +363,7 @@ public final class GamePacketBuilder {
* *
* @param transformation The transformation. * @param transformation The transformation.
* @param bytes The byte array. * @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) { public void putBytesReverse(DataTransformation transformation, byte[] bytes) {
if (transformation == DataTransformation.NONE) { 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}. * {@code flag} is {@code false}, the value of the bit is {@code 0}.
* *
* @param flag The flag. * @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) { public void putBit(boolean flag) {
putBit(flag ? 1 : 0); putBit(flag ? 1 : 0);
@@ -390,7 +390,7 @@ public final class GamePacketBuilder {
* Puts a single bit into the buffer with the value {@code value}. * Puts a single bit into the buffer with the value {@code value}.
* *
* @param value The 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) { public void putBit(int value) {
putBits(1, value); putBits(1, value);
@@ -401,8 +401,8 @@ public final class GamePacketBuilder {
* *
* @param numBits The number of bits to put into the buffer. * @param numBits The number of bits to put into the buffer.
* @param value The 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.
* @throws IllegalArgumentException if the number of bits is not between 1 and 31 inclusive. * @throws IllegalArgumentException If the number of bits is not between 1 and 31 inclusive.
*/ */
public void putBits(int numBits, int value) { public void putBits(int numBits, int value) {
if (numBits < 0 || numBits > 32) { if (numBits < 0 || numBits > 32) {
@@ -442,7 +442,7 @@ public final class GamePacketBuilder {
/** /**
* Checks that this builder is in the byte access mode. * 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() { private void checkByteAccess() {
if (mode != AccessMode.BYTE_ACCESS) { if (mode != AccessMode.BYTE_ACCESS) {
@@ -453,7 +453,7 @@ public final class GamePacketBuilder {
/** /**
* Checks that this builder is in the bit access mode. * 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() { private void checkBitAccess() {
if (mode != AccessMode.BIT_ACCESS) { if (mode != AccessMode.BIT_ACCESS) {
@@ -77,7 +77,7 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
* @param channel The channel. * @param channel The channel.
* @param buffer The buffer. * @param buffer The buffer.
* @return The frame, or {@code null}. * @return The frame, or {@code null}.
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
private Object decodeOpcode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { private Object decodeOpcode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
if (buffer.readable()) { if (buffer.readable()) {
@@ -116,7 +116,7 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
* @param channel The channel. * @param channel The channel.
* @param buffer The buffer. * @param buffer The buffer.
* @return The frame, or {@code null}. * @return The frame, or {@code null}.
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
private Object decodeLength(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { private Object decodeLength(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
if (buffer.readable()) { if (buffer.readable()) {
@@ -137,7 +137,7 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
* @param channel The channel. * @param channel The channel.
* @param buffer The buffer. * @param buffer The buffer.
* @return The frame, or {@code null}. * @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 { private Object decodePayload(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
if (buffer.readableBytes() >= length) { if (buffer.readableBytes() >= length) {
@@ -149,14 +149,14 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
} }
/** /**
* Decodes a zero length packet. This hackery is required as Netty will throw an exception if we return a frame but * Decodes a zero length packet. This hackery is required as Netty will throw an Exception If we return a frame but
* have read nothing! * have read nothing!
* *
* @param ctx The channel handler context. * @param ctx The channel handler context.
* @param channel The channel. * @param channel The channel.
* @param buffer The buffer. * @param buffer The buffer.
* @return The frame, or {@code null}. * @return The frame, or {@code null}.
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
private Object decodeZeroLengthPacket(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) private Object decodeZeroLengthPacket(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer)
throws Exception { throws Exception {
@@ -47,7 +47,7 @@ public final class GamePacketReader {
/** /**
* Switches this builder's mode to the byte access mode. * 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() { public void switchToByteAccess() {
if (mode == AccessMode.BYTE_ACCESS) { if (mode == AccessMode.BYTE_ACCESS) {
@@ -60,7 +60,7 @@ public final class GamePacketReader {
/** /**
* Switches this builder's mode to the bit access mode. * 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() { public void switchToBitAccess() {
if (mode == AccessMode.BIT_ACCESS) { if (mode == AccessMode.BIT_ACCESS) {
@@ -74,7 +74,7 @@ public final class GamePacketReader {
* Gets a string from the buffer. * Gets a string from the buffer.
* *
* @return The string. * @return The string.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
*/ */
public String getString() { public String getString() {
checkByteAccess(); checkByteAccess();
@@ -85,7 +85,7 @@ public final class GamePacketReader {
* Gets a signed smart from the buffer. * Gets a signed smart from the buffer.
* *
* @return The smart. * @return The smart.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
*/ */
public int getSignedSmart() { public int getSignedSmart() {
checkByteAccess(); checkByteAccess();
@@ -101,7 +101,7 @@ public final class GamePacketReader {
* Gets an unsigned smart from the buffer. * Gets an unsigned smart from the buffer.
* *
* @return The smart. * @return The smart.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
*/ */
public int getUnsignedSmart() { public int getUnsignedSmart() {
checkByteAccess(); checkByteAccess();
@@ -118,7 +118,7 @@ public final class GamePacketReader {
* *
* @param type The data type. * @param type The data type.
* @return The value. * @return 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 long getSigned(DataType type) { public long getSigned(DataType type) {
return getSigned(type, DataOrder.BIG, DataTransformation.NONE); return getSigned(type, DataOrder.BIG, DataTransformation.NONE);
@@ -130,8 +130,8 @@ public final class GamePacketReader {
* @param type The data type. * @param type The data type.
* @param order The byte order. * @param order The byte order.
* @return The value. * @return The value.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public long getSigned(DataType type, DataOrder order) { public long getSigned(DataType type, DataOrder order) {
return getSigned(type, order, DataTransformation.NONE); return getSigned(type, order, DataTransformation.NONE);
@@ -143,8 +143,8 @@ public final class GamePacketReader {
* @param type The data type. * @param type The data type.
* @param transformation The data transformation. * @param transformation The data transformation.
* @return The value. * @return The value.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public long getSigned(DataType type, DataTransformation transformation) { public long getSigned(DataType type, DataTransformation transformation) {
return getSigned(type, DataOrder.BIG, transformation); return getSigned(type, DataOrder.BIG, transformation);
@@ -157,8 +157,8 @@ public final class GamePacketReader {
* @param order The byte order. * @param order The byte order.
* @param transformation The data transformation. * @param transformation The data transformation.
* @return The value. * @return The value.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public long getSigned(DataType type, DataOrder order, DataTransformation transformation) { public long getSigned(DataType type, DataOrder order, DataTransformation transformation) {
long longValue = get(type, order, transformation); long longValue = get(type, order, transformation);
@@ -176,7 +176,7 @@ public final class GamePacketReader {
* *
* @param type The data type. * @param type The data type.
* @return The value. * @return 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 long getUnsigned(DataType type) { public long getUnsigned(DataType type) {
return getUnsigned(type, DataOrder.BIG, DataTransformation.NONE); return getUnsigned(type, DataOrder.BIG, DataTransformation.NONE);
@@ -188,8 +188,8 @@ public final class GamePacketReader {
* @param type The data type. * @param type The data type.
* @param order The byte order. * @param order The byte order.
* @return The value. * @return The value.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public long getUnsigned(DataType type, DataOrder order) { public long getUnsigned(DataType type, DataOrder order) {
return getUnsigned(type, order, DataTransformation.NONE); return getUnsigned(type, order, DataTransformation.NONE);
@@ -201,8 +201,8 @@ public final class GamePacketReader {
* @param type The data type. * @param type The data type.
* @param transformation The data transformation. * @param transformation The data transformation.
* @return The value. * @return The value.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public long getUnsigned(DataType type, DataTransformation transformation) { public long getUnsigned(DataType type, DataTransformation transformation) {
return getUnsigned(type, DataOrder.BIG, transformation); return getUnsigned(type, DataOrder.BIG, transformation);
@@ -215,8 +215,8 @@ public final class GamePacketReader {
* @param order The byte order. * @param order The byte order.
* @param transformation The data transformation. * @param transformation The data transformation.
* @return The value. * @return The value.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
public long getUnsigned(DataType type, DataOrder order, DataTransformation transformation) { public long getUnsigned(DataType type, DataOrder order, DataTransformation transformation) {
long longValue = get(type, order, transformation); long longValue = get(type, order, transformation);
@@ -233,8 +233,8 @@ public final class GamePacketReader {
* @param order The data order. * @param order The data order.
* @param transformation The data transformation. * @param transformation The data transformation.
* @return The value. * @return The value.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
* @throws IllegalArgumentException if the combination is invalid. * @throws IllegalArgumentException If the combination is invalid.
*/ */
private long get(DataType type, DataOrder order, DataTransformation transformation) { private long get(DataType type, DataOrder order, DataTransformation transformation) {
checkByteAccess(); checkByteAccess();
@@ -304,7 +304,7 @@ public final class GamePacketReader {
* Gets bytes. * Gets bytes.
* *
* @param bytes The target byte array. * @param bytes The target byte array.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
*/ */
public void getBytes(byte[] bytes) { public void getBytes(byte[] bytes) {
checkByteAccess(); checkByteAccess();
@@ -318,7 +318,7 @@ public final class GamePacketReader {
* *
* @param transformation The transformation. * @param transformation The transformation.
* @param bytes The target byte array. * @param bytes The target byte array.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
*/ */
public void getBytes(DataTransformation transformation, byte[] bytes) { public void getBytes(DataTransformation transformation, byte[] bytes) {
if (transformation == DataTransformation.NONE) { if (transformation == DataTransformation.NONE) {
@@ -334,7 +334,7 @@ public final class GamePacketReader {
* Gets bytes in reverse. * Gets bytes in reverse.
* *
* @param bytes The target byte array. * @param bytes The target byte array.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
*/ */
public void getBytesReverse(byte[] bytes) { public void getBytesReverse(byte[] bytes) {
checkByteAccess(); checkByteAccess();
@@ -348,7 +348,7 @@ public final class GamePacketReader {
* *
* @param transformation The transformation. * @param transformation The transformation.
* @param bytes The target byte array. * @param bytes The target byte array.
* @throws IllegalStateException if this reader is not in byte access mode. * @throws IllegalStateException If this reader is not in byte access mode.
*/ */
public void getBytesReverse(DataTransformation transformation, byte[] bytes) { public void getBytesReverse(DataTransformation transformation, byte[] bytes) {
if (transformation == DataTransformation.NONE) { if (transformation == DataTransformation.NONE) {
@@ -363,7 +363,7 @@ public final class GamePacketReader {
/** /**
* Checks that this reader is in the byte access mode. * Checks that this reader is in the byte access mode.
* *
* @throws IllegalStateException if the reader is not in byte access mode. * @throws IllegalStateException If the reader is not in byte access mode.
*/ */
private void checkByteAccess() { private void checkByteAccess() {
if (mode != AccessMode.BYTE_ACCESS) { if (mode != AccessMode.BYTE_ACCESS) {
@@ -374,7 +374,7 @@ public final class GamePacketReader {
/** /**
* Checks that this reader is in the bit access mode. * Checks that this reader is in the bit access mode.
* *
* @throws IllegalStateException if the reader is not in bit access mode. * @throws IllegalStateException If the reader is not in bit access mode.
*/ */
private void checkBitAccess() { private void checkBitAccess() {
if (mode != AccessMode.BIT_ACCESS) { if (mode != AccessMode.BIT_ACCESS) {
@@ -386,7 +386,7 @@ public final class GamePacketReader {
* Gets a bit from the buffer. * Gets a bit from the buffer.
* *
* @return The value. * @return The value.
* @throws IllegalStateException if the reader is not in bit access mode. * @throws IllegalStateException If the reader is not in bit access mode.
*/ */
public int getBit() { public int getBit() {
return getBits(1); return getBits(1);
@@ -397,8 +397,8 @@ public final class GamePacketReader {
* *
* @param numBits The number of bits. * @param numBits The number of bits.
* @return The value. * @return The value.
* @throws IllegalStateException if the reader is not in bit access mode. * @throws IllegalStateException If the reader is not in bit access mode.
* @throws IllegalArgumentException if the number of bits is not between 1 and 31 inclusive. * @throws IllegalArgumentException If the number of bits is not between 1 and 31 inclusive.
*/ */
public int getBits(int numBits) { public int getBits(int numBits) {
if (numBits < 0 || numBits > 32) { if (numBits < 0 || numBits > 32) {
@@ -75,7 +75,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
* @param channel The channel. * @param channel The channel.
* @param buffer The buffer. * @param buffer The buffer.
* @return The frame, or {@code null}. * @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 { private Object decodeHandshake(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
if (buffer.readable()) { if (buffer.readable()) {
@@ -100,7 +100,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
* @param channel The channel. * @param channel The channel.
* @param buffer The buffer. * @param buffer The buffer.
* @return The frame, or {@code null}. * @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 { private Object decodeHeader(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
if (buffer.readableBytes() >= 2) { if (buffer.readableBytes() >= 2) {
@@ -126,7 +126,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
* @param channel The channel. * @param channel The channel.
* @param buffer The buffer. * @param buffer The buffer.
* @return The frame, or {@code null}. * @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 { private Object decodePayload(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
if (buffer.readableBytes() >= loginLength) { if (buffer.readableBytes() >= loginLength) {
@@ -37,7 +37,7 @@ public final class OnDemandRequest implements Comparable<OnDemandRequest> {
* *
* @param v The integer value. * @param v The integer value.
* @return The priority. * @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) { public static Priority valueOf(int v) {
switch (v) { switch (v) {
+2 -2
View File
@@ -12,7 +12,7 @@ public final class PacketMetaData {
* *
* @param length The length of the packet. * @param length The length of the packet.
* @return The {@link PacketMetaData} object. * @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) { public static PacketMetaData createFixed(int length) {
if (length < 0) { if (length < 0) {
@@ -74,7 +74,7 @@ public final class PacketMetaData {
* Gets the length of this packet. * Gets the length of this packet.
* *
* @return 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() { public int getLength() {
if (type != PacketType.FIXED) { if (type != PacketType.FIXED) {
@@ -12,7 +12,7 @@ public final class PacketMetaDataGroup {
* *
* @param lengthArray The packet length array. * @param lengthArray The packet length array.
* @return The {@link PacketMetaDataGroup} object. * @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. * value below -3.
*/ */
public static PacketMetaDataGroup createFromArray(int[] lengthArray) { public static PacketMetaDataGroup createFromArray(int[] lengthArray) {
@@ -54,7 +54,7 @@ public final class PacketMetaDataGroup {
* *
* @param opcode The opcode of the packet. * @param opcode The opcode of the packet.
* @return The {@link PacketMetaData}, or {@code null} if the packet does not exist. * @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) { public PacketMetaData getMetaData(int opcode) {
if (opcode < 0 || opcode >= packets.length) { if (opcode < 0 || opcode >= packets.length) {
+2 -2
View File
@@ -37,14 +37,14 @@ public abstract class Session {
* Processes a message received from the channel. * Processes a message received from the channel.
* *
* @param message The message. * @param message The message.
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
public abstract void messageReceived(Object message) throws Exception; public abstract void messageReceived(Object message) throws Exception;
/** /**
* Destroys this session. * Destroys this session.
* *
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
public abstract void destroy() throws Exception; public abstract void destroy() throws Exception;
+1 -1
View File
@@ -21,7 +21,7 @@ public final class EquipmentUpdater {
* The entry point of the application. * The entry point of the application.
* *
* @param args The command line arguments. * @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 { public static void main(String[] args) throws Exception {
if (args.length != 1) { if (args.length != 1) {
+1 -1
View File
@@ -22,7 +22,7 @@ public final class NoteUpdater {
* The entry point of the application. * The entry point of the application.
* *
* @param args The command line arguments. * @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 { public static void main(String[] args) throws Exception {
if (args.length != 1) { if (args.length != 1) {
+2 -2
View File
@@ -80,7 +80,7 @@ public abstract class RequestWorker<T, P> implements Runnable {
* *
* @param dispatcher The dispatcher. * @param dispatcher The dispatcher.
* @return The next request. * @return The next request.
* @throws InterruptedException if the thread is interrupted. * @throws InterruptedException If the thread is interrupted.
*/ */
protected abstract ChannelRequest<T> nextRequest(UpdateDispatcher dispatcher) throws InterruptedException; protected abstract ChannelRequest<T> nextRequest(UpdateDispatcher dispatcher) throws InterruptedException;
@@ -90,7 +90,7 @@ public abstract class RequestWorker<T, P> implements Runnable {
* @param provider The resource provider. * @param provider The resource provider.
* @param channel The channel. * @param channel The channel.
* @param request The request to service. * @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; protected abstract void service(P provider, Channel channel, T request) throws IOException;
+3 -3
View File
@@ -40,7 +40,7 @@ public final class UpdateDispatcher {
* Gets the next 'on-demand' request from the queue, blocking if none are available. * Gets the next 'on-demand' request from the queue, blocking if none are available.
* *
* @return The 'on-demand' request. * @return The 'on-demand' request.
* @throws InterruptedException if the thread is interrupted. * @throws InterruptedException If the thread is interrupted.
*/ */
ChannelRequest<OnDemandRequest> nextOnDemandRequest() throws InterruptedException { ChannelRequest<OnDemandRequest> nextOnDemandRequest() throws InterruptedException {
return onDemandQueue.take(); return onDemandQueue.take();
@@ -50,7 +50,7 @@ public final class UpdateDispatcher {
* Gets the next JAGGRAB request from the queue, blocking if none are available. * Gets the next JAGGRAB request from the queue, blocking if none are available.
* *
* @return The JAGGRAB request. * @return The JAGGRAB request.
* @throws InterruptedException if the thread is interrupted. * @throws InterruptedException If the thread is interrupted.
*/ */
ChannelRequest<JagGrabRequest> nextJagGrabRequest() throws InterruptedException { ChannelRequest<JagGrabRequest> nextJagGrabRequest() throws InterruptedException {
return jagGrabQueue.take(); return jagGrabQueue.take();
@@ -60,7 +60,7 @@ public final class UpdateDispatcher {
* Gets the next HTTP request from the queue, blocking if none are available. * Gets the next HTTP request from the queue, blocking if none are available.
* *
* @return The HTTP request. * @return The HTTP request.
* @throws InterruptedException if the thread is interrupted. * @throws InterruptedException If the thread is interrupted.
*/ */
ChannelRequest<HttpRequest> nextHttpRequest() throws InterruptedException { ChannelRequest<HttpRequest> nextHttpRequest() throws InterruptedException {
return httpQueue.take(); return httpQueue.take();
@@ -15,7 +15,7 @@ public abstract class ResourceProvider {
* *
* @param path The path to the resource, e.g. {@code /crc}. * @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. * @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; public abstract boolean accept(String path) throws IOException;
@@ -24,7 +24,7 @@ public abstract class ResourceProvider {
* *
* @param path The path. * @param path The path.
* @return The resource, or {@code null} if it doesn't exist. * @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; public abstract ByteBuffer get(String path) throws IOException;
+4 -4
View File
@@ -23,7 +23,7 @@ public final class CompressionUtil {
* *
* @param compressed The compressed array. * @param compressed The compressed array.
* @param uncompressed The uncompressed 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 { public static void ungzip(byte[] compressed, byte[] uncompressed) throws IOException {
DataInputStream is = new DataInputStream(new GZIPInputStream(new ByteArrayInputStream(compressed))); DataInputStream is = new DataInputStream(new GZIPInputStream(new ByteArrayInputStream(compressed)));
@@ -39,7 +39,7 @@ public final class CompressionUtil {
* *
* @param compressed The compressed array. * @param compressed The compressed array.
* @param uncompressed The uncompressed 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 { public static void unbzip2(byte[] compressed, byte[] uncompressed) throws IOException {
byte[] newCompressed = new byte[compressed.length + 4]; byte[] newCompressed = new byte[compressed.length + 4];
@@ -63,7 +63,7 @@ public final class CompressionUtil {
* *
* @param bytes The uncompressed array. * @param bytes The uncompressed array.
* @return The compressed 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 { public static byte[] gzip(byte[] bytes) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
@@ -82,7 +82,7 @@ public final class CompressionUtil {
* *
* @param bytes The uncompressed array. * @param bytes The uncompressed array.
* @return The compressed 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 { public static byte[] bzip2(byte[] bytes) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
@@ -36,7 +36,7 @@ public abstract class StatefulFrameDecoder<T extends Enum<T>> extends FrameDecod
* Creates the stateful frame decoder with the specified initial state. * Creates the stateful frame decoder with the specified initial state.
* *
* @param state The 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) { public StatefulFrameDecoder(T state) {
this(state, false); this(state, false);
@@ -47,7 +47,7 @@ public abstract class StatefulFrameDecoder<T extends Enum<T>> extends FrameDecod
* *
* @param state The initial state. * @param state The initial state.
* @param unwrap The unwrap flag. * @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) { public StatefulFrameDecoder(T state, boolean unwrap) {
super(unwrap); super(unwrap);
@@ -69,7 +69,7 @@ public abstract class StatefulFrameDecoder<T extends Enum<T>> extends FrameDecod
* Sets a new state. * Sets a new state.
* *
* @param state The 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) { public final void setState(T state) {
if (state == null) { if (state == null) {
@@ -86,7 +86,7 @@ public abstract class StatefulFrameDecoder<T extends Enum<T>> extends FrameDecod
* @param buffer The cumulative buffer, which may contain zero or more bytes. * @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)}. * @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. * @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) protected abstract Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, T state)
throws Exception; throws Exception;
@@ -100,7 +100,7 @@ public abstract class StatefulFrameDecoder<T extends Enum<T>> extends FrameDecod
* @param buffer The cumulative buffer, which may contain zero or more bytes. * @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)}. * @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. * @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) protected Object decodeLast(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, T state)
throws Exception { throws Exception {
+2 -2
View File
@@ -16,7 +16,7 @@ public final class StreamUtil {
* *
* @param os The output stream. * @param os The output stream.
* @param str The string. * @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 { public static void writeString(OutputStream os, String str) throws IOException {
for (char c : str.toCharArray()) { for (char c : str.toCharArray()) {
@@ -30,7 +30,7 @@ public final class StreamUtil {
* *
* @param is The input stream. * @param is The input stream.
* @return The string. * @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 { public static String readString(InputStream is) throws IOException {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@@ -91,4 +91,4 @@ public final class PluginContext {
chain.addLast(handler); chain.addLast(handler);
} }
} }
@@ -75,9 +75,9 @@ public final class PluginManager {
/** /**
* Starts the plugin system by finding and loading all the plugins. * Starts the plugin system by finding and loading all the plugins.
* *
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
* @throws DependencyException if a dependency could not be resolved. * @throws DependencyException If a dependency could not be resolved.
*/ */
public void start() throws IOException, SAXException, DependencyException { public void start() throws IOException, SAXException, DependencyException {
Map<String, PluginMetaData> plugins = createMap(findPlugins()); Map<String, PluginMetaData> plugins = createMap(findPlugins());
@@ -95,8 +95,8 @@ public final class PluginManager {
* Finds plugins and loads their meta data. * Finds plugins and loads their meta data.
* *
* @return A collection of plugin meta data objects. * @return A collection of plugin meta data objects.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
*/ */
private Collection<PluginMetaData> findPlugins() throws IOException, SAXException { private Collection<PluginMetaData> findPlugins() throws IOException, SAXException {
Collection<PluginMetaData> plugins = new ArrayList<PluginMetaData>(); Collection<PluginMetaData> plugins = new ArrayList<PluginMetaData>();
@@ -129,8 +129,8 @@ public final class PluginManager {
* @param plugin The plugin. * @param plugin The plugin.
* @param plugins The plugin map. * @param plugins The plugin map.
* @param started A set of started plugins. * @param started A set of started plugins.
* @throws DependencyException if a dependency error occurs. * @throws DependencyException If a dependency error occurs.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
private void start(PluginEnvironment env, PluginMetaData plugin, Map<String, PluginMetaData> plugins, private void start(PluginEnvironment env, PluginMetaData plugin, Map<String, PluginMetaData> plugins,
Set<PluginMetaData> started) throws DependencyException, IOException { Set<PluginMetaData> started) throws DependencyException, IOException {
@@ -22,7 +22,7 @@ public final class RubyPluginEnvironment implements PluginEnvironment {
/** /**
* Creates and bootstraps the Ruby plugin environment. * 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 { public RubyPluginEnvironment() throws IOException {
parseBootstrapper(); parseBootstrapper();
@@ -31,7 +31,7 @@ public final class RubyPluginEnvironment implements PluginEnvironment {
/** /**
* Parses the bootstrapper. * Parses the bootstrapper.
* *
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
private void parseBootstrapper() throws IOException { private void parseBootstrapper() throws IOException {
File f = new File("./data/plugins/bootstrap.rb"); File f = new File("./data/plugins/bootstrap.rb");
+7 -7
View File
@@ -89,7 +89,7 @@ public final class XmlParser {
/** /**
* Creates a new xml parser. * Creates a new xml parser.
* *
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
*/ */
public XmlParser() throws SAXException { public XmlParser() throws SAXException {
xmlReader = XMLReaderFactory.createXMLReader(); xmlReader = XMLReaderFactory.createXMLReader();
@@ -112,8 +112,8 @@ public final class XmlParser {
* *
* @param is The {@link InputStream}. * @param is The {@link InputStream}.
* @return The root {@link XmlNode}. * @return The root {@link XmlNode}.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
*/ */
public XmlNode parse(InputStream is) throws IOException, SAXException { public XmlNode parse(InputStream is) throws IOException, SAXException {
synchronized (this) { synchronized (this) {
@@ -126,8 +126,8 @@ public final class XmlParser {
* *
* @param reader The {@link Reader}. * @param reader The {@link Reader}.
* @return The root {@link XmlNode}. * @return The root {@link XmlNode}.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
*/ */
public XmlNode parse(Reader reader) throws IOException, SAXException { public XmlNode parse(Reader reader) throws IOException, SAXException {
synchronized (this) { synchronized (this) {
@@ -140,8 +140,8 @@ public final class XmlParser {
* *
* @param source The {@link InputSource}. * @param source The {@link InputSource}.
* @return The root {@link XmlNode}. * @return The root {@link XmlNode}.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
*/ */
private XmlNode parse(InputSource source) throws IOException, SAXException { private XmlNode parse(InputSource source) throws IOException, SAXException {
rootNode = null; rootNode = null;
@@ -18,7 +18,7 @@ public class TestGamePacketEncoder {
/** /**
* Tests the {@link GamePacketEncoder#encode(org.jboss.netty.channel.ChannelHandlerContext, org.jboss.netty.channel.Channel, Object)} * Tests the {@link GamePacketEncoder#encode(org.jboss.netty.channel.ChannelHandlerContext, org.jboss.netty.channel.Channel, Object)}
* method. * method.
* @throws Exception if an error occurs. * @throws Exception If an error occurs.
*/ */
@Test @Test
public void testEncode() throws Exception { public void testEncode() throws Exception {
@@ -15,7 +15,7 @@ public class TestCompressionUtil {
/** /**
* Tests the {@link CompressionUtil#gzip(byte[])} and * Tests the {@link CompressionUtil#gzip(byte[])} and
* {@link CompressionUtil#ungzip(byte[], byte[])} methods. * {@link CompressionUtil#ungzip(byte[], byte[])} methods.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
@Test @Test
public void testGzip() throws IOException { public void testGzip() throws IOException {
@@ -29,7 +29,7 @@ public class TestCompressionUtil {
/** /**
* Tests the {@link CompressionUtil#bzip2(byte[])} and * Tests the {@link CompressionUtil#bzip2(byte[])} and
* {@link CompressionUtil#unbzip2(byte[], byte[])} methods. * {@link CompressionUtil#unbzip2(byte[], byte[])} methods.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
@Test @Test
public void testBzip2() throws IOException { public void testBzip2() throws IOException {
+4 -4
View File
@@ -20,8 +20,8 @@ public final class TestXmlParser {
/** /**
* A test for the {@link XmlParser#parse(java.io.InputStream)} method. * A test for the {@link XmlParser#parse(java.io.InputStream)} method.
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
@Test @Test
public void testParseInputStream() throws SAXException, IOException { 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. * A test for the {@link XmlParser#parse(java.io.Reader)} method.
* @throws SAXException if a SAX error occurs. * @throws SAXException If a SAX error occurs.
* @throws IOException if an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
@Test @Test
public void testParseReader() throws SAXException, IOException { public void testParseReader() throws SAXException, IOException {