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