Format and cleanup.

This commit is contained in:
Major-
2013-11-24 01:29:04 +00:00
parent ea115562c0
commit a66a901dd4
296 changed files with 1224 additions and 1266 deletions
+3 -3
View File
@@ -4,10 +4,10 @@
<chain />
</event>
<event>
<type>org.apollo.game.event.impl.CharacterDesignEvent</type>
<type>org.apollo.game.event.impl.PlayerDesignEvent</type>
<chain>
<handler>org.apollo.game.event.handler.impl.CharacterDesignVerificationHandler</handler>
<handler>org.apollo.game.event.handler.impl.CharacterDesignEventHandler</handler>
<handler>org.apollo.game.event.handler.impl.PlayerDesignVerificationHandler</handler>
<handler>org.apollo.game.event.handler.impl.PlayerDesignEventHandler</handler>
</chain>
</event>
<event>
+1 -1
View File
@@ -80,4 +80,4 @@ public final class ServerContext {
return serviceManager;
}
}
}
+1 -1
View File
@@ -46,4 +46,4 @@ public final class FileDescriptor {
return type;
}
}
}
+1 -1
View File
@@ -64,4 +64,4 @@ public final class Index {
return size;
}
}
}
+22 -24
View File
@@ -91,7 +91,7 @@ public final class IndexedFileSystem implements Closeable {
} else if (newEngineData.exists() && !oldEngineData.isDirectory()) {
data = new RandomAccessFile(newEngineData, readOnly ? "r" : "rw");
} else {
throw new FileNotFoundException("No data file present");
throw new FileNotFoundException("no data file present");
}
}
@@ -123,27 +123,27 @@ public final class IndexedFileSystem implements Closeable {
for (int i = 1; i < crcs.length; i++) {
crc32.reset();
ByteBuffer bb = getFile(0, i);
byte[] bytes = new byte[bb.remaining()];
bb.get(bytes, 0, bytes.length);
ByteBuffer buffer = getFile(0, i);
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes, 0, bytes.length);
crc32.update(bytes, 0, bytes.length);
crcs[i] = (int) crc32.getValue();
}
// hash the CRCs and place them in the buffer
ByteBuffer buf = ByteBuffer.allocate(crcs.length * 4 + 4);
ByteBuffer buffer = ByteBuffer.allocate(crcs.length * 4 + 4);
for (int crc : crcs) {
hash = (hash << 1) + crc;
buf.putInt(crc);
buffer.putInt(crc);
}
// place the hash into the buffer
buf.putInt(hash);
buf.flip();
buffer.putInt(hash);
buffer.flip();
synchronized (this) {
crcTable = buf.asReadOnlyBuffer();
crcTable = buffer.asReadOnlyBuffer();
return crcTable.duplicate();
}
}
@@ -153,16 +153,16 @@ public final class IndexedFileSystem implements Closeable {
/**
* Gets a file.
*
* @param fd The {@link FileDescriptor} which points to the file.
* @param descriptor 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.
*/
public ByteBuffer getFile(FileDescriptor fd) throws IOException {
Index index = getIndex(fd);
public ByteBuffer getFile(FileDescriptor descriptor) throws IOException {
Index index = getIndex(descriptor);
ByteBuffer buffer = ByteBuffer.allocate(index.getSize());
// calculate some initial values
long ptr = (long) index.getBlock() * (long) FileSystemConstants.BLOCK_SIZE;
long ptr = index.getBlock() * FileSystemConstants.BLOCK_SIZE;
int read = 0;
int size = index.getSize();
int blocks = size / FileSystemConstants.CHUNK_SIZE;
@@ -171,7 +171,6 @@ public final class IndexedFileSystem implements Closeable {
}
for (int i = 0; i < blocks; i++) {
// read header
byte[] header = new byte[FileSystemConstants.HEADER_SIZE];
synchronized (data) {
@@ -211,15 +210,14 @@ public final class IndexedFileSystem implements Closeable {
read += chunkSize;
ptr = (long) nextBlock * (long) FileSystemConstants.BLOCK_SIZE;
// if we still have more data to read, check the validity of the
// header
// if we still have more data to read, check the validity of the header
if (size > read) {
if (nextType != fd.getType() + 1) {
throw new IOException("File type mismatch.");
if (nextType != descriptor.getType() + 1) {
throw new IOException("file type mismatch.");
}
if (nextFile != fd.getFile()) {
throw new IOException("File id mismatch.");
if (nextFile != descriptor.getFile()) {
throw new IOException("file id mismatch.");
}
}
}
@@ -261,12 +259,12 @@ public final class IndexedFileSystem implements Closeable {
/**
* Gets the index of a file.
*
* @param fd The {@link FileDescriptor} which points to the file.
* @param descriptor The {@link FileDescriptor} which points to the file.
* @return The {@link Index}.
* @throws IOException If an I/O error occurs.
*/
private Index getIndex(FileDescriptor fd) throws IOException {
int index = fd.getType();
private Index getIndex(FileDescriptor descriptor) throws IOException {
int index = descriptor.getType();
if (index < 0 || index >= indices.length) {
throw new IndexOutOfBoundsException("file descriptor type out of bounds");
}
@@ -274,7 +272,7 @@ public final class IndexedFileSystem implements Closeable {
byte[] buffer = new byte[FileSystemConstants.INDEX_SIZE];
RandomAccessFile indexFile = indices[index];
synchronized (indexFile) {
long ptr = (long) fd.getFile() * (long) FileSystemConstants.INDEX_SIZE;
long ptr = descriptor.getFile() * FileSystemConstants.INDEX_SIZE;
if (ptr >= 0 && indexFile.length() >= ptr + FileSystemConstants.INDEX_SIZE) {
indexFile.seek(ptr);
indexFile.readFully(buffer);
+1 -1
View File
@@ -48,4 +48,4 @@ public final class ArchiveEntry {
return identifier;
}
}
}
+1 -2
View File
@@ -1,5 +1,4 @@
/**
* Contains classes which deal with archives.
*/
package org.apollo.fs.archive;
package org.apollo.fs.archive;
+1 -2
View File
@@ -1,5 +1,4 @@
/**
* Contains classes which parse files within the game's cache.
*/
package org.apollo.fs.decoder;
package org.apollo.fs.decoder;
+1 -2
View File
@@ -2,5 +2,4 @@
* Contains classes which deal with the file system that the client uses to
* store game data files.
*/
package org.apollo.fs;
package org.apollo.fs;
+1 -1
View File
@@ -24,4 +24,4 @@ public final class GameConstants {
}
}
}
+1 -1
View File
@@ -38,4 +38,4 @@ public final class GamePulseHandler implements Runnable {
}
}
}
}
+12 -12
View File
@@ -4,7 +4,7 @@ import org.apollo.game.model.Mob;
import org.apollo.game.scheduling.ScheduledTask;
/**
* An action is a specialised {@link ScheduledTask} which is specific to a character.
* An action is a specialised {@link ScheduledTask} which is specific to a mob.
* <p>
* <strong>ALL</strong> actions <strong>MUST</strong> implement the {@link #equals(Object)} method. This is to check if
* two actions are identical: if they are, then the new action does not replace the old one (so spam/accidental clicking
@@ -15,9 +15,9 @@ import org.apollo.game.scheduling.ScheduledTask;
public abstract class Action<T extends Mob> extends ScheduledTask {
/**
* The character performing the action.
* The mob performing the action.
*/
private final T character;
protected final T mob;
/**
* A flag indicating if this action is stopping.
@@ -29,20 +29,20 @@ public abstract class Action<T extends Mob> extends ScheduledTask {
*
* @param delay The delay in pulses.
* @param immediate A flag indicating if the action should happen immediately.
* @param character The character performing the action.
* @param mob The mob performing the action.
*/
public Action(int delay, boolean immediate, T character) {
public Action(int delay, boolean immediate, T mob) {
super(delay, immediate);
this.character = character;
this.mob = mob;
}
/**
* Gets the character which performed the action.
* Gets the mob which performed the action.
*
* @return The character.
* @return The mob.
*/
public T getCharacter() {
return character;
public T getMob() {
return mob;
}
@Override
@@ -50,8 +50,8 @@ public abstract class Action<T extends Mob> extends ScheduledTask {
super.stop();
if (!stopping) {
stopping = true;
character.stopAction();
mob.stopAction();
}
}
}
}
@@ -41,12 +41,12 @@ public abstract class DistancedAction<T extends Mob> extends Action<T> {
*
* @param delay The delay between executions once the distance threshold is reached.
* @param immediate Whether or not this action fires immediately after the distance threshold is reached.
* @param character The character.
* @param mob The mob.
* @param position The position.
* @param distance The distance.
*/
public DistancedAction(int delay, boolean immediate, T character, Position position, int distance) {
super(0, true, character);
public DistancedAction(int delay, boolean immediate, T mob, Position position, int distance) {
super(0, true, mob);
this.position = position;
this.distance = distance;
this.delay = delay;
@@ -59,7 +59,7 @@ public abstract class DistancedAction<T extends Mob> extends Action<T> {
// some actions (e.g. agility) will cause the player to move away again
// so we don't check once the player got close enough once
executeAction();
} else if (getCharacter().getPosition().getDistance(position) <= distance) {
} else if (mob.getPosition().getDistance(position) <= distance) {
reached = true;
setDelay(delay);
if (immediate) { // TODO: required?
@@ -73,4 +73,4 @@ public abstract class DistancedAction<T extends Mob> extends Action<T> {
*/
public abstract void executeAction();
}
}
+2 -3
View File
@@ -1,6 +1,5 @@
/**
* Contains classes related to actions, specialised scheduled tasks which
* characters perform.
* mobs perform.
*/
package org.apollo.game.action;
package org.apollo.game.action;
@@ -1,5 +1,4 @@
/**
* Contains classes related to in-game commands.
*/
package org.apollo.game.command;
package org.apollo.game.command;
@@ -20,4 +20,4 @@ public abstract class EventHandler<E extends Event> {
*/
public abstract void handle(EventHandlerContext ctx, Player player, E event);
}
}
@@ -14,4 +14,4 @@ public abstract class EventHandlerContext {
*/
public abstract void breakHandlerChain();
}
}
@@ -37,4 +37,4 @@ public final class EventHandlerChainGroup {
return (EventHandlerChain<E>) chains.get(clazz);
}
}
}
@@ -1,5 +1,4 @@
/**
* Contains classes related to the chaining of event handlers.
*/
package org.apollo.game.event.handler.chain;
package org.apollo.game.event.handler.chain;
@@ -31,4 +31,4 @@ public final class BankButtonEventHandler extends EventHandler<ButtonEvent> {
}
}
}
}
@@ -18,4 +18,4 @@ public final class ChatEventHandler extends EventHandler<ChatEvent> {
player.getBlockSet().add(SynchronizationBlock.createChatBlock(player, event));
}
}
}
@@ -21,4 +21,4 @@ public final class ChatVerificationHandler extends EventHandler<ChatEvent> {
}
}
}
}
@@ -17,4 +17,4 @@ public final class ClosedInterfaceEventHandler extends EventHandler<ClosedInterf
player.getInterfaceSet().interfaceClosed();
}
}
}
@@ -23,10 +23,9 @@ public final class CommandEventHandler extends EventHandler<CommandEvent> {
String[] arguments = new String[components.length - 1];
System.arraycopy(components, 1, arguments, 0, arguments.length);
Command command = new Command(name, arguments);
World.getWorld().getCommandDispatcher().dispatch(player, command);
}
}
}
@@ -17,4 +17,4 @@ public final class EnteredAmountEventHandler extends EventHandler<EnteredAmountE
player.getInterfaceSet().enteredAmount(event.getAmount());
}
}
}
@@ -27,7 +27,6 @@ public final class ItemOnItemVerificationHandler extends EventHandler<ItemOnItem
Item item = inventory.get(slot);
if (item == null || item.getId() != event.getTargetId()) {
ctx.breakHandlerChain();
return;
}
}
@@ -2,22 +2,22 @@ package org.apollo.game.event.handler.impl;
import org.apollo.game.event.handler.EventHandler;
import org.apollo.game.event.handler.EventHandlerContext;
import org.apollo.game.event.impl.CharacterDesignEvent;
import org.apollo.game.event.impl.PlayerDesignEvent;
import org.apollo.game.event.impl.CloseInterfaceEvent;
import org.apollo.game.model.Player;
/**
* A handler which handles {@link CharacterDesignEvent}s.
* A handler which handles {@link PlayerDesignEvent}s.
*
* @author Graham
*/
public final class CharacterDesignEventHandler extends EventHandler<CharacterDesignEvent> {
public final class PlayerDesignEventHandler extends EventHandler<PlayerDesignEvent> {
@Override
public void handle(EventHandlerContext ctx, Player player, CharacterDesignEvent event) {
public void handle(EventHandlerContext ctx, Player player, PlayerDesignEvent event) {
player.setAppearance(event.getAppearance());
player.setDesignedCharacter(true);
player.setDesigned(true);
player.send(new CloseInterfaceEvent());
}
}
}
@@ -2,21 +2,21 @@ package org.apollo.game.event.handler.impl;
import org.apollo.game.event.handler.EventHandler;
import org.apollo.game.event.handler.EventHandlerContext;
import org.apollo.game.event.impl.CharacterDesignEvent;
import org.apollo.game.event.impl.PlayerDesignEvent;
import org.apollo.game.model.Appearance;
import org.apollo.game.model.Gender;
import org.apollo.game.model.Player;
/**
* A handler which verifies {@link CharacterDesignEvent}s.
* A handler which verifies {@link PlayerDesignEvent}s.
*
* @author Graham
*/
public final class CharacterDesignVerificationHandler extends EventHandler<CharacterDesignEvent> {
public final class PlayerDesignVerificationHandler extends EventHandler<PlayerDesignEvent> {
@Override
public void handle(EventHandlerContext ctx, Player player, CharacterDesignEvent event) {
if (!valid(event.getAppearance()) || player.hasDesignedCharacter()) {
public void handle(EventHandlerContext ctx, Player player, PlayerDesignEvent event) {
if (!valid(event.getAppearance()) || player.hasDesignedAvatar()) {
ctx.breakHandlerChain();
}
}
@@ -42,7 +42,7 @@ public final class CharacterDesignVerificationHandler extends EventHandler<Chara
} else if (gender == Gender.FEMALE) {
return validFemaleStyle(appearance);
} else {
return false; // maybe null?
throw new IllegalArgumentException("player can only be either male or female");
}
}
@@ -82,4 +82,4 @@ public final class CharacterDesignVerificationHandler extends EventHandler<Chara
return true;
}
}
}
@@ -21,7 +21,6 @@ public final class SwitchItemEventHandler extends EventHandler<SwitchItemEvent>
Inventory inventory;
boolean insertPermitted = false;
// TODO is there a better way of doing this??
switch (event.getInterfaceId()) {
case SynchronizationInventoryListener.INVENTORY_ID:
case BankConstants.SIDEBAR_INVENTORY_ID:
@@ -45,4 +44,4 @@ public final class SwitchItemEventHandler extends EventHandler<SwitchItemEvent>
}
}
}
}
@@ -23,7 +23,7 @@ public final class WalkEventHandler extends EventHandler<WalkEvent> {
Position step = steps[i];
if (i == 0) {
if (!queue.addFirstStep(step)) {
return; /* ignore packet */
return; // ignore packet
}
} else {
queue.addStep(step);
@@ -1,5 +1,4 @@
/**
* Contains event handler implementations.
*/
package org.apollo.game.event.handler.impl;
package org.apollo.game.event.handler.impl;
@@ -1,5 +1,4 @@
/**
* Contains classes which define abstract event handlers.
*/
package org.apollo.game.event.handler;
package org.apollo.game.event.handler;
@@ -1,12 +0,0 @@
package org.apollo.game.event.impl;
import org.apollo.game.event.Event;
/**
* An outgoing event sent to reset the animations of every character.
*
* @author Major
*/
public class CharacterAnimationResetEvent extends Event {
}
@@ -80,4 +80,4 @@ public final class ChatEvent extends Event {
return effects;
}
}
}
@@ -9,4 +9,4 @@ import org.apollo.game.event.Event;
*/
public final class CloseInterfaceEvent extends Event {
}
}
@@ -9,4 +9,4 @@ import org.apollo.game.event.Event;
*/
public final class ClosedInterfaceEvent extends Event {
}
}
@@ -32,4 +32,4 @@ public final class CommandEvent extends Event {
return command;
}
}
}
@@ -9,4 +9,4 @@ import org.apollo.game.event.Event;
*/
public final class EnterAmountEvent extends Event {
}
}
@@ -32,4 +32,4 @@ public final class EnteredAmountEvent extends Event {
return amount;
}
}
}
@@ -18,4 +18,4 @@ public final class FifthItemActionEvent extends ItemActionEvent {
super(5, interfaceId, id, slot);
}
}
}
@@ -18,4 +18,4 @@ public final class FifthItemOptionEvent extends ItemOptionEvent {
super(5, interfaceId, id, slot);
}
}
}
@@ -18,4 +18,4 @@ public final class FirstItemActionEvent extends ItemActionEvent {
super(1, interfaceId, id, slot);
}
}
}
@@ -18,4 +18,4 @@ public final class FirstItemOptionEvent extends ItemOptionEvent {
super(1, interfaceId, id, slot);
}
}
}
@@ -19,4 +19,4 @@ public final class FirstObjectActionEvent extends ObjectActionEvent {
super(1, id, position);
}
}
}
@@ -18,4 +18,4 @@ public final class FourthItemActionEvent extends ItemActionEvent {
super(4, interfaceId, id, slot);
}
}
}
@@ -18,4 +18,4 @@ public final class FourthItemOptionEvent extends ItemOptionEvent {
super(4, interfaceId, id, slot);
}
}
}
@@ -48,4 +48,4 @@ public final class IdAssignmentEvent extends Event {
return members;
}
}
}
@@ -30,4 +30,4 @@ public final class KeepAliveEvent extends Event {
return createdAt;
}
}
}
@@ -9,4 +9,4 @@ import org.apollo.game.event.Event;
*/
public final class LogoutEvent extends Event {
}
}
@@ -0,0 +1,12 @@
package org.apollo.game.event.impl;
import org.apollo.game.event.Event;
/**
* An outgoing event sent to reset the animations of every mob.
*
* @author Major
*/
public class MobAnimationResetEvent extends Event {
}
@@ -65,4 +65,4 @@ public abstract class ObjectActionEvent extends Event {
return position;
}
}
}
@@ -32,4 +32,4 @@ public final class OpenInterfaceEvent extends Event {
return id;
}
}
}
@@ -48,4 +48,4 @@ public final class OpenInterfaceSidebarEvent extends Event {
return sidebarId;
}
}
}
@@ -4,11 +4,11 @@ import org.apollo.game.event.Event;
import org.apollo.game.model.Appearance;
/**
* An event sent by the client when the player modifies their character's design.
* An event sent by the client when the player modifies their design.
*
* @author Graham
*/
public final class CharacterDesignEvent extends Event {
public final class PlayerDesignEvent extends Event {
/**
* The appearance.
@@ -16,11 +16,11 @@ public final class CharacterDesignEvent extends Event {
private final Appearance appearance;
/**
* Creates the character design event.
* Creates the player design event.
*
* @param appearance The appearance.
*/
public CharacterDesignEvent(Appearance appearance) {
public PlayerDesignEvent(Appearance appearance) {
this.appearance = appearance;
}
@@ -33,4 +33,4 @@ public final class CharacterDesignEvent extends Event {
return appearance;
}
}
}
@@ -117,4 +117,4 @@ public final class PlayerSynchronizationEvent extends Event {
return regionChanged;
}
}
}
@@ -18,4 +18,4 @@ public final class SecondItemActionEvent extends ItemActionEvent {
super(2, interfaceId, id, slot);
}
}
}
@@ -18,4 +18,4 @@ public final class SecondItemOptionEvent extends ItemOptionEvent {
super(2, interfaceId, id, slot);
}
}
}
@@ -19,4 +19,4 @@ public final class SecondObjectActionEvent extends ObjectActionEvent {
super(2, id, position);
}
}
}
@@ -32,4 +32,4 @@ public final class ServerMessageEvent extends Event {
return message;
}
}
}
@@ -64,4 +64,4 @@ public final class SetWidgetItemModelEvent extends Event {
return zoom;
}
}
}
@@ -3,14 +3,14 @@ package org.apollo.game.event.impl;
import org.apollo.game.event.Event;
/**
* An event which is sent to the client to make a character model on an interface play a certain animation.
* An event which is sent to the client to make a mob model on an interface play a certain animation.
*
* @author Chris Fletcher
*/
public final class SetWidgetModelAnimationEvent extends Event {
/**
* The model's mood id.
* The model's animation id.
*/
private final int animation;
@@ -48,4 +48,4 @@ public final class SetWidgetNpcModelEvent extends Event {
return modelId;
}
}
}
@@ -32,4 +32,4 @@ public final class SetWidgetPlayerModelEvent extends Event {
return interfaceId;
}
}
}
@@ -48,4 +48,4 @@ public final class SetWidgetTextEvent extends Event {
return text;
}
}
}
@@ -49,4 +49,4 @@ public final class SetWidgetVisibilityEvent extends Event {
return visible;
}
}
}
@@ -31,17 +31,5 @@ public class SpamPacketEvent extends Event {
public byte[] getData() {
return data;
}
// 0
// random * 256
// 101
// 233
// 45092 (short)
// 35784 if random * 2= 0
// random * 256
// 64
// 38
// Math.random() * 65536
// Math.random() * 65536
// offset - start offset (exc. the first 0 sent) - size byte.
}
@@ -89,4 +89,4 @@ public final class SwitchItemEvent extends Event {
return !inserting;
}
}
}
@@ -48,4 +48,4 @@ public final class SwitchTabInterfaceEvent extends Event {
return tab;
}
}
}
@@ -18,4 +18,4 @@ public final class ThirdItemActionEvent extends ItemActionEvent {
super(3, interfaceId, id, slot);
}
}
}
@@ -18,4 +18,4 @@ public final class ThirdItemOptionEvent extends ItemOptionEvent {
super(3, interfaceId, id, slot);
}
}
}
@@ -19,4 +19,4 @@ public final class ThirdObjectActionEvent extends ObjectActionEvent {
super(3, id, position);
}
}
}
@@ -49,4 +49,4 @@ public final class UpdateItemsEvent extends Event {
return items;
}
}
}
@@ -49,4 +49,4 @@ public final class UpdateSkillEvent extends Event {
return skill;
}
}
}
@@ -49,4 +49,4 @@ public final class UpdateSlottedItemsEvent extends Event {
return items;
}
}
}
@@ -52,4 +52,4 @@ public final class WalkEvent extends Event {
return run;
}
}
}
@@ -1,5 +1,4 @@
/**
* Contains event implementations.
*/
package org.apollo.game.event.impl;
package org.apollo.game.event.impl;
+1 -2
View File
@@ -1,5 +1,4 @@
/**
* Contains classes related to the event management in the game.
*/
package org.apollo.game.event;
package org.apollo.game.event;
+19 -19
View File
@@ -7,16 +7,16 @@ package org.apollo.game.model;
*/
public enum Direction {
/**
* East movement.
*/
EAST(4),
/**
* No movement.
*/
NONE(-1),
/**
* North west movement.
*/
NORTH_WEST(0),
/**
* North movement.
*/
@@ -28,9 +28,19 @@ public enum Direction {
NORTH_EAST(2),
/**
* North west movement.
* West movement.
*/
NORTH_WEST(0),
WEST(3),
/**
* East movement.
*/
EAST(4),
/**
* South west movement.
*/
SOUTH_WEST(5),
/**
* South movement.
@@ -40,17 +50,7 @@ public enum Direction {
/**
* South east movement.
*/
SOUTH_EAST(7),
/**
* South west movement.
*/
SOUTH_WEST(5),
/**
* West movement.
*/
WEST(3);
SOUTH_EAST(7);
/**
* An empty direction array.
@@ -126,4 +126,4 @@ public enum Direction {
return intValue;
}
}
}
+3 -3
View File
@@ -1,14 +1,14 @@
package org.apollo.game.model;
/**
* Represents an in-game entity, such as a character, object, projectile etc.
* Represents an in-game entity, such as a mob, object, projectile etc.
*
* @author Major
*/
public abstract class Entity {
/**
* The position of the entity.
* The position of this entity.
*/
protected Position position;
@@ -20,7 +20,7 @@ public abstract class Entity {
public abstract EntityType getEntityType();
/**
* Gets the position of this entity.
* Gets the {@link Position} of this entity.
*
* @return The position.
*/
+1 -1
View File
@@ -33,7 +33,7 @@ public enum EntityType {
PROJECTILE,
/**
* A permanent object appearing on the map.
* A permanent object appearing on the map, loaded from the cache.
*/
STATIC_OBJECT;
@@ -8,59 +8,59 @@ package org.apollo.game.model;
public final class EquipmentConstants {
/**
* The amulet slot.
* The hat slot.
*/
public static final int AMULET = 2;
/**
* The arrows slot.
*/
public static final int ARROWS = 13;
public static final int HAT = 0;
/**
* The cape slot.
*/
public static final int CAPE = 1;
/**
* The amulet slot.
*/
public static final int AMULET = 2;
/**
* The weapon slot.
*/
public static final int WEAPON = 3;
/**
* The chest slot.
*/
public static final int CHEST = 4;
/**
* The feet slot.
*/
public static final int FEET = 10;
/**
* The hands slot.
*/
public static final int HANDS = 9;
/**
* The hat slot.
*/
public static final int HAT = 0;
/**
* The legs slot.
*/
public static final int LEGS = 7;
/**
* The ring slot.
*/
public static final int RING = 12;
/**
* The shield slot.
*/
public static final int SHIELD = 5;
/**
* The weapon slot.
* The legs slot.
*/
public static final int WEAPON = 3;
public static final int LEGS = 7;
/**
* The hands slot.
*/
public static final int HANDS = 9;
/**
* The feet slot.
*/
public static final int FEET = 10;
/**
* The ring slot.
*/
public static final int RING = 12;
/**
* The arrows slot.
*/
public static final int ARROWS = 13;
/**
* Default private constructor to prevent instantiation;
+6 -6
View File
@@ -7,15 +7,15 @@ package org.apollo.game.model;
*/
public enum Gender {
/**
* The female gender.
*/
FEMALE(1),
/**
* The male gender.
*/
MALE(0);
MALE(0),
/**
* The female gender.
*/
FEMALE(1);
/**
* An integer representation used by the client.
+10 -15
View File
@@ -73,7 +73,6 @@ public final class Inventory implements Cloneable {
* Creates an inventory.
*
* @param capacity The capacity.
* @throws IllegalArgumentException If the capacity is negative.
*/
public Inventory(int capacity) {
this(capacity, StackMode.STACK_STACKABLE_ITEMS);
@@ -83,7 +82,7 @@ public final class Inventory implements Cloneable {
* Creates an inventory.
*
* @param capacity The capacity.
* @param mode The stacking mode.
* @param mode The {@link StackMode}.
* @throws IllegalArgumentException If the capacity is negative.
* @throws NullPointerException If the mode is {@code null}.
*/
@@ -92,7 +91,7 @@ public final class Inventory implements Cloneable {
throw new IllegalArgumentException("capacity cannot be negative");
}
if (mode == null) {
throw new NullPointerException("mode");
throw new NullPointerException("stacking mode cannot be null");
}
this.capacity = capacity;
items = new Item[capacity];
@@ -195,9 +194,9 @@ public final class Inventory implements Cloneable {
}
/**
* Adds a listener.
* Adds an {@link InventoryListener}.
*
* @param listener The listener to add.
* @param listener The listener.
*/
public void addListener(InventoryListener listener) {
listeners.add(listener);
@@ -298,7 +297,6 @@ 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.
*/
public Item get(int slot) {
checkBounds(slot);
@@ -447,7 +445,6 @@ 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.
*/
public Item reset(int slot) {
checkBounds(slot);
@@ -467,7 +464,6 @@ 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.
*/
public Item set(int slot, Item item) {
if (item == null) {
@@ -529,7 +525,6 @@ 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.
*/
public void swap(boolean insert, int oldSlot, int newSlot) {
checkBounds(oldSlot);
@@ -543,13 +538,14 @@ public final class Inventory implements Cloneable {
for (int slot = oldSlot; slot > newSlot; slot--) {
swap(slot, slot - 1);
}
} // else no change is required - aren't we lucky?
}
forceRefresh();
} else {
Item temp = items[oldSlot];
Item tmp = items[oldSlot];
items[oldSlot] = items[newSlot];
items[newSlot] = temp;
notifyItemsUpdated(); // TODO can we just fire for the two slots?
items[newSlot] = tmp;
notifyItemUpdated(oldSlot);
notifyItemUpdated(newSlot);
}
}
@@ -558,10 +554,9 @@ 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.
*/
public void swap(int oldSlot, int newSlot) {
swap(false, oldSlot, newSlot);
}
}
}
+1 -1
View File
@@ -75,4 +75,4 @@ public final class Item {
return Item.class.getName() + " [id=" + id + ", amount=" + amount + "]";
}
}
}
+83 -90
View File
@@ -4,13 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import org.apollo.game.action.Action;
import org.apollo.game.event.Event;
import org.apollo.game.model.Inventory.StackMode;
import org.apollo.game.model.def.NpcDefinition;
import org.apollo.game.scheduling.impl.SkillNormalizationTask;
import org.apollo.game.sync.block.SynchronizationBlock;
import org.apollo.game.sync.block.SynchronizationBlockSet;
import org.apollo.util.CharacterRepository;
import org.apollo.util.MobRepository;
/**
* A {@link Mob} is a living entity in the world, such as a player or NPC.
@@ -20,95 +19,80 @@ import org.apollo.util.CharacterRepository;
public abstract class Mob extends Entity {
/**
* The character's current action.
* This mob's current action.
*/
private Action<?> action;
/**
* The character's bank.
* This mob's set of {@link SynchronizationBlock}s.
*/
private final Inventory bank = new Inventory(InventoryConstants.BANK_CAPACITY, StackMode.STACK_ALWAYS);
protected SynchronizationBlockSet blockSet = new SynchronizationBlockSet();
/**
* A set of {@link SynchronizationBlock}s.
* This mob's {@link NpcDefinition). A {@link Player} only uses this if they are appearing as an npc in-game.
*/
private SynchronizationBlockSet blockSet = new SynchronizationBlockSet();
protected NpcDefinition definition;
/**
* The character's {@link NpcDefinition). This is only used by an instance of the {@link Player} class if they are
* appearing as an npc in-game.
*/
private NpcDefinition definition;
/**
* The character's equipment.
* This mob's equipment.
*/
private final Inventory equipment = new Inventory(InventoryConstants.EQUIPMENT_CAPACITY, StackMode.STACK_ALWAYS);
/**
* The first direction.
* This mob's first movement {@link Direction}.
*/
private Direction firstDirection = Direction.NONE;
/**
* The index of this character in the {@link CharacterRepository} it belongs to.
* The index of this mob in the {@link MobRepository} it belongs to.
*/
private int index = -1;
/**
* The character's inventory.
* This mob's inventory.
*/
private final Inventory inventory = new Inventory(InventoryConstants.INVENTORY_CAPACITY);
/**
* The list of local npcs.
* This mob's {@link List} of local npcs.
*/
private final List<Npc> localNpcs = new ArrayList<Npc>();
/**
* A list of local players.
* This mob's {@link List} of local players.
*/
private final List<Player> localPlayers = new ArrayList<Player>();
/**
* The second direction.
* This mob's second movement direction.
*/
private Direction secondDirection = Direction.NONE;
/**
* The character's skill set.
* This mob's skill set.
*/
private final SkillSet skillSet = new SkillSet();
/**
* Teleportation flag.
* Indicates whether this mob is currently teleporting or not.
*/
private boolean teleporting = false;
/**
* The walking queue.
* This mob's walking queue.
*/
private final WalkingQueue walkingQueue = new WalkingQueue(this);
/**
* Creates a new character with the specified initial position.
* Creates a new mob with the specified initial {@link Position}.
*
* @param position The initial position of this character.
* @param position The initial position.
*/
public Mob(Position position) {
this.position = position;
init();
}
/**
* Gets the character's bank.
*
* @return The character's bank.
*/
public Inventory getBank() {
return bank;
}
/**
* Gets the {@link SynchronizationBlockSet}.
*
@@ -118,6 +102,19 @@ public abstract class Mob extends Entity {
return blockSet;
}
/**
* Deals damage to this mob.
*
* @param damage The damage dealt.
* @param type The type of damage.
* @param secondary Whether this should be dealt as a secondary hit or not.
*/
public void damage(int damage, int type, boolean secondary) {
Skill hitpoints = skillSet.getSkill(Skill.HITPOINTS);
blockSet.add(SynchronizationBlock.createHitUpdateBlock(damage, type, hitpoints.getCurrentLevel(),
hitpoints.getMaximumLevel(), secondary));
}
/**
* Gets the directions as an array.
*
@@ -132,27 +129,27 @@ public abstract class Mob extends Entity {
}
/**
* Gets the character's equipment.
* Gets the mob's equipment.
*
* @return The character's equipment.
* @return The mob's equipment.
*/
public Inventory getEquipment() {
return equipment;
}
/**
* Gets the first direction.
* Gets the first {@link Direction}.
*
* @return The first direction.
* @return The direction.
*/
public Direction getFirstDirection() {
return firstDirection;
}
/**
* Gets the index of this character.
* Gets the index of this mob.
*
* @return The index of this character.
* @return The index.
*/
public int getIndex() {
synchronized (this) {
@@ -161,34 +158,34 @@ public abstract class Mob extends Entity {
}
/**
* Gets the character's inventory.
* Gets the mob's inventory.
*
* @return The character's inventory.
* @return The inventory.
*/
public Inventory getInventory() {
return inventory;
}
/**
* Gets the local npc list.
* Gets the local npc {@link List}.
*
* @return The local npc list.
* @return The list.
*/
public List<Npc> getLocalNpcList() {
return localNpcs;
}
/**
* Gets the local player list.
* Gets the local player {@link List}.
*
* @return The local player list.
* @return The list.
*/
public List<Player> getLocalPlayerList() {
return localPlayers;
}
/**
* Gets this character's {@link NpcDefinition}.
* Gets this mob's {@link NpcDefinition}.
*
* @param definition The definition.
*/
@@ -196,31 +193,26 @@ public abstract class Mob extends Entity {
return definition;
}
@Override
public Position getPosition() {
return position;
}
/**
* Gets the second direction.
* Gets the second {@link Direction}.
*
* @return The second direction.
* @return The direction.
*/
public Direction getSecondDirection() {
return secondDirection;
}
/**
* Gets the character's skill set.
* Gets this mob's {@link SkillSet}.
*
* @return The character's skill set.
* @return The skill set.
*/
public SkillSet getSkillSet() {
return skillSet;
}
/**
* Gets the walking queue.
* Gets the {@link WalkingQueue}.
*
* @return The walking queue.
*/
@@ -229,14 +221,14 @@ public abstract class Mob extends Entity {
}
/**
* Initialises this character.
* Initialises this mob.
*/
private void init() {
World.getWorld().schedule(new SkillNormalizationTask(this));
}
/**
* Checks if this character is active.
* Checks if this mob is active.
*
* @return {@code true} if so, {@code false} if not.
*/
@@ -245,7 +237,7 @@ public abstract class Mob extends Entity {
}
/**
* Checks if this player is currently teleporting.
* Checks if this mob is currently teleporting.
*
* @return {@code true} if so, {@code false} if not.
*/
@@ -254,7 +246,7 @@ public abstract class Mob extends Entity {
}
/**
* Plays the specified animation.
* Plays the specified {@link Animation}.
*
* @param animation The animation.
*/
@@ -263,7 +255,7 @@ public abstract class Mob extends Entity {
}
/**
* Plays the specified graphic.
* Plays the specified {@link Graphic}.
*
* @param graphic The graphic.
*/
@@ -279,18 +271,7 @@ public abstract class Mob extends Entity {
}
/**
* Sends an {@link Event} to either:
* <ul>
* <li>The client if this {@link Mob} is a {@link Player}.</li>
* <li>The AI routines if this {@link Mob} is an NPC</li>
* </ul>
*
* @param event The event.
*/
public abstract void send(Event event);
/**
* Sets this character's {@link NpcDefinition}.
* Sets this mob's {@link NpcDefinition}.
*
* @param definition The definition.
*/
@@ -299,7 +280,7 @@ public abstract class Mob extends Entity {
}
/**
* Sets the next directions for this character.
* Sets the next directions for this mob.
*
* @param first The first direction.
* @param second The second direction.
@@ -310,9 +291,9 @@ public abstract class Mob extends Entity {
}
/**
* Sets the index of this character.
* Sets the index of this mob.
*
* @param index The index of this character.
* @param index The index.
*/
public void setIndex(int index) {
synchronized (this) {
@@ -321,18 +302,29 @@ public abstract class Mob extends Entity {
}
/**
* Sets the position of this character.
* Sets the position of this mob.
*
* @param position The position of this character.
* @param position The position.
*/
public void setPosition(Position position) {
this.position = position;
}
/**
* Sets the teleporting flag.
* Forces this mob to shout a message. Note that messages can only be shown in the chat box if they are said by a
* player.
*
* @param teleporting {@code true} if the player is teleporting, {@code false} if not.
* @param message The message.
* @param chatBox If the message should be shown in the player's chat box.
*/
public void shout(String message, boolean chatBox) {
blockSet.add(SynchronizationBlock.createForceChatBlock(message));
}
/**
* Sets whether this mob is teleporting or not.
*
* @param teleporting {@code true} if the mob is teleporting, {@code false} if not.
*/
public void setTeleporting(boolean teleporting) {
this.teleporting = teleporting;
@@ -366,21 +358,22 @@ public abstract class Mob extends Entity {
}
/**
* Stops the current animation.
* Stops the current {@link Animation}.
*/
public void stopAnimation() {
playAnimation(Animation.STOP_ANIMATION);
}
/**
* Stops the current graphic.
* Stops the current {@link Graphic}.
*/
public void stopGraphic() {
playGraphic(Graphic.STOP_GRAPHIC);
}
/**
* Teleports this character to the specified position, setting the appropriate flags and clearing the walking queue.
* Teleports this mob to the specified {@link Position}, setting the appropriate flags and clearing the walking
* queue.
*
* @param position The position.
*/
@@ -388,11 +381,11 @@ public abstract class Mob extends Entity {
teleporting = true;
this.position = position;
walkingQueue.clear();
stopAction(); // TODO do it on any movement is a must.. walking queue perhaps?
stopAction(); // TODO do it on any movement is a must... walking queue perhaps?
}
/**
* Turns the character to face the specified position.
* Turns the mob to face the specified {@link Position}.
*
* @param position The position to face.
*/
@@ -401,12 +394,12 @@ public abstract class Mob extends Entity {
}
/**
* Updates the character's interacting character.
* Updates this mob's interacting mob.
*
* @param index The index of the interacting character.
* @param index The index of the interacting mob.
*/
public void updateInteractingCharacter(int index) {
blockSet.add(SynchronizationBlock.createInteractingCharacterBlock(index));
public void updateInteractingMob(int index) {
blockSet.add(SynchronizationBlock.createInteractingMobBlock(index));
}
}
+24 -21
View File
@@ -1,19 +1,14 @@
package org.apollo.game.model;
import org.apollo.game.event.Event;
import org.apollo.game.model.def.NpcDefinition;
import org.apollo.game.sync.block.SynchronizationBlock;
/**
* An {@link Npc} is a {@link Mob} that is not being controlled by a player.
*
* @author Major
*/
public class Npc extends Mob {
/**
* This npc's definition.
*/
private final NpcDefinition definition;
public final class Npc extends Mob {
/**
* Creates a new npc with the specified id and {@link Position}.
@@ -36,23 +31,31 @@ public class Npc extends Mob {
this.definition = definition;
}
/**
* Gets the id of this npc. Shorthand for {@link #getDefinition().getId()}.
*
* @return The id.
*/
public int getId() {
return definition.getId();
}
/**
* Transforms this npc into the npc with the specified id.
*
* @param id The id.
*/
public void transform(int id) {
if (id < 0 || id > NpcDefinition.count()) {
throw new IllegalArgumentException("id to transform to is out of bounds");
}
definition = NpcDefinition.lookup(id);
blockSet.add(SynchronizationBlock.createTransformBlock(id));
}
@Override
public EntityType getEntityType() {
return EntityType.NPC;
}
/**
* Gets this npc's {@link NpcDefinition}
*
* @return The definition.
*/
@Override
public NpcDefinition getNpcDefinition() {
return definition;
}
@Override
public void send(Event event) {
}
}
+41 -20
View File
@@ -12,6 +12,7 @@ import org.apollo.game.event.impl.ServerMessageEvent;
import org.apollo.game.event.impl.SetWidgetTextEvent;
import org.apollo.game.event.impl.SwitchTabInterfaceEvent;
import org.apollo.game.event.impl.UpdateRunEnergyEvent;
import org.apollo.game.model.Inventory.StackMode;
import org.apollo.game.model.inter.InterfaceConstants;
import org.apollo.game.model.inter.InterfaceSet;
import org.apollo.game.model.inter.bank.BankConstants;
@@ -102,20 +103,25 @@ public final class Player extends Mob {
*/
private Appearance appearance = Appearance.DEFAULT_APPEARANCE;
/**
* This player's bank.
*/
private final Inventory bank = new Inventory(InventoryConstants.BANK_CAPACITY, StackMode.STACK_ALWAYS);
/**
* A {@link List} of this player's mouse clicks.
*/
private Deque<Point> clicks = new ArrayDeque<Point>();
/**
* The player's credentials.
* This player's credentials.
*/
private PlayerCredentials credentials;
/**
* A flag indicating if the player has designed their character.
* A flag indicating if the player has designed their avatar.
*/
private boolean designedCharacter = false;
private boolean designedAvatar = false;
/**
* A flag which indicates there are npcs that couldn't be added.
@@ -150,7 +156,7 @@ public final class Player extends Mob {
/**
* This player's prayer icon.
*/
private int prayerIcon = -1;
private int prayerIcon = 0;
/**
* The privilege level.
@@ -246,6 +252,15 @@ public final class Player extends Mob {
return appearance;
}
/**
* Gets the mob's bank.
*
* @return The bank.
*/
public Inventory getBank() {
return bank;
}
/**
* Gets the {@link Deque} of clicks.
*
@@ -369,12 +384,12 @@ public final class Player extends Mob {
}
/**
* Checks if the player has designed their character.
* Checks if the player has designed their avatar.
*
* @return A flag indicating if the player has designed their character.
* @return A flag indicating if the player has designed their avatar.
*/
public boolean hasDesignedCharacter() {
return designedCharacter;
public boolean hasDesignedAvatar() {
return designedAvatar;
}
/**
@@ -424,8 +439,6 @@ public final class Player extends Mob {
InventoryListener fullInventoryListener = new FullInventoryListener(this,
FullInventoryListener.FULL_INVENTORY_MESSAGE);
InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE);
InventoryListener fullEquipmentListener = new FullInventoryListener(this,
FullInventoryListener.FULL_EQUIPMENT_MESSAGE);
// equipment appearance listener
InventoryListener appearanceListener = new AppearanceInventoryListener(this);
@@ -444,7 +457,6 @@ public final class Player extends Mob {
bank.addListener(fullBankListener);
equipment.addListener(syncEquipmentListener);
equipment.addListener(appearanceListener);
equipment.addListener(fullEquipmentListener);
}
/**
@@ -530,7 +542,11 @@ public final class Player extends Mob {
viewingDistance = 1;
}
@Override
/**
* Sends an {@link Event} to this player.
*
* @param event The event.
*/
public void send(Event event) {
if (isActive()) {
if (!queuedEvents.isEmpty()) {
@@ -552,8 +568,8 @@ public final class Player extends Mob {
send(new IdAssignmentEvent(getIndex(), members)); // TODO should this be sent when we reconnect?
sendMessage("Welcome to RuneScape.");
if (!designedCharacter) {
interfaceSet.openWindow(InterfaceConstants.CHARACTER_DESIGN);
if (!designedAvatar) {
interfaceSet.openWindow(InterfaceConstants.AVATAR_DESIGN);
}
int[] tabs = InterfaceConstants.DEFAULT_INVENTORY_TABS;
@@ -569,7 +585,7 @@ public final class Player extends Mob {
}
/**
* Sends a message to the character.
* Sends a message to the player.
*
* @param message The message.
*/
@@ -605,12 +621,12 @@ public final class Player extends Mob {
}
/**
* Sets the character design flag.
* Sets the design flag.
*
* @param designedCharacter A flag indicating if the character has been designed.
* @param designed A flag indicating if the player has been designed.
*/
public void setDesignedCharacter(boolean designedCharacter) {
this.designedCharacter = designedCharacter;
public void setDesigned(boolean designed) {
this.designedAvatar = designed;
}
/**
@@ -700,9 +716,14 @@ public final class Player extends Mob {
this.withdrawingNotes = withdrawingNotes;
}
@Override
public void shout(String message, boolean chatBox) {
blockSet.add(SynchronizationBlock.createForceChatBlock(chatBox ? '~' + message : message));
}
@Override
public void teleport(Position position) {
super.teleport(position); // TODO put this in the same place as Character#teleport and WalkEventHandler!!
super.teleport(position);
if (interfaceSet.size() > 0) {
interfaceSet.close();
}
+16 -23
View File
@@ -48,8 +48,8 @@ public final class SkillSet {
* @return The minimum level.
*/
public static int getLevelForExperience(double experience) {
int points = 0;
int output = 0;
int points = 0, output = 0;
for (int lvl = 1; lvl <= 99; lvl++) {
points += Math.floor(lvl + 300.0 * Math.pow(2.0, lvl / 7.0));
output = (int) Math.floor(points / 4);
@@ -110,22 +110,21 @@ public final class SkillSet {
setSkill(id, new Skill(newExperience, newCurrentLevel, newMaximumLevel));
if (delta > 0) {
// here so it notifies using the updated skill
notifyLevelledUp(id);
notifyLevelledUp(id); // here so it notifies using the updated skill
}
}
/**
* Adds a listener.
* Adds a {@link SkillListener} to this set.
*
* @param listener The listener to add.
* @param listener The listener.
*/
public boolean addListener(SkillListener listener) {
return listeners.add(listener);
}
/**
* Gets the combat level for this skill set.
* Calculates the combat level for this skill set.
*
* @return The combat level.
*/
@@ -138,15 +137,12 @@ public final class SkillSet {
int ranged = skills[Skill.RANGED].getMaximumLevel();
int magic = skills[Skill.MAGIC].getMaximumLevel();
double combatLevel = (defence + hitpoints + Math.floor(prayer / 2)) * 0.25;
double base = (defence + hitpoints + Math.floor(prayer / 2)) * 0.25;
double melee = (attack + strength) * 0.325;
double range = ranged * 0.4875;
double mage = magic * 0.4875;
this.combatLevel = (int) (combatLevel + Math.max(melee, Math.max(range, mage)));
this.combatLevel = (int) (base + Math.max(melee, Math.max(range, mage)));
}
/**
@@ -169,7 +165,7 @@ public final class SkillSet {
}
/**
* Gets the combat level for this skill set.
* Gets the combat level of this skill set.
*
* @return The combat level.
*/
@@ -218,13 +214,10 @@ public final class SkillSet {
int cur = skills[id].getCurrentLevel();
int max = skills[id].getMaximumLevel();
if (cur > max) {
cur--;
} else if (max > cur) {
cur++;
} else {
if (cur == max) {
continue;
}
cur += cur < max ? 1 : -1;
setSkill(id, new Skill(skills[id].getExperience(), cur, max));
}
@@ -270,14 +263,14 @@ public final class SkillSet {
}
/**
* Removes all the listeners.
* Removes all the {@link SkillListener}s.
*/
public void removeAllListeners() {
listeners.clear();
}
/**
* Removes a listener.
* Removes a {@link SkillListener}.
*
* @param listener The listener to remove.
*/
@@ -286,7 +279,7 @@ public final class SkillSet {
}
/**
* Sets a skill.
* Sets a {@link Skill}.
*
* @param id The id.
* @param skill The skill.
@@ -298,7 +291,7 @@ public final class SkillSet {
}
/**
* Gets the number of skills.
* Gets the number of {@link Skill}s in this set.
*
* @return The number of skills.
*/
@@ -307,7 +300,7 @@ public final class SkillSet {
}
/**
* Re-enables the firing of events.
* Starts the firing of events.
*/
public void startFiringEvents() {
firingEvents = true;
+20 -19
View File
@@ -51,9 +51,9 @@ public final class WalkingQueue {
private static final int MAXIMUM_SIZE = 128;
/**
* The character whose walking queue this is.
* The mob whose walking queue this is.
*/
private final Mob character;
private final Mob mob;
/**
* The old queue of directions.
@@ -71,32 +71,32 @@ public final class WalkingQueue {
private boolean runningQueue;
/**
* Creates a walking queue for the specified character.
* Creates a walking queue for the specified mob.
*
* @param character The character.
* @param mob The mob.
*/
public WalkingQueue(Mob character) {
this.character = character;
public WalkingQueue(Mob mob) {
this.mob = mob;
}
/**
* Adds the first step to the queue, attempting to connect the server and client position by looking at the previous
* queue.
*
* @param clientConnectionPosition The first step.
* @param clientPosition The first step.
* @return {@code true} if the queues could be connected correctly, {@code false} if not.
*/
public boolean addFirstStep(Position clientConnectionPosition) {
Position serverPosition = character.getPosition();
public boolean addFirstStep(Position clientPosition) {
Position serverPosition = mob.getPosition();
int deltaX = clientConnectionPosition.getX() - serverPosition.getX();
int deltaY = clientConnectionPosition.getY() - serverPosition.getY();
int deltaX = clientPosition.getX() - serverPosition.getX();
int deltaY = clientPosition.getY() - serverPosition.getY();
if (Direction.isConnectable(deltaX, deltaY)) {
points.clear();
oldPoints.clear();
addStep(clientConnectionPosition);
addStep(clientPosition);
return true;
}
@@ -119,7 +119,7 @@ public final class WalkingQueue {
addStep(travelBackPosition);
}
addStep(clientConnectionPosition);
addStep(clientPosition);
return true;
}
}
@@ -147,7 +147,7 @@ public final class WalkingQueue {
Direction direction = Direction.fromDeltas(deltaX, deltaY);
if (direction != Direction.NONE) {
Point p = new Point(new Position(x, y, character.getPosition().getHeight()), direction);
Point p = new Point(new Position(x, y, mob.getPosition().getHeight()), direction);
points.add(p);
oldPoints.add(p);
}
@@ -202,7 +202,7 @@ public final class WalkingQueue {
private Point getLast() {
Point last = points.peekLast();
if (last == null) {
return new Point(character.getPosition(), Direction.NONE);
return new Point(mob.getPosition(), Direction.NONE);
}
return last;
}
@@ -211,17 +211,18 @@ public final class WalkingQueue {
* Called every pulse, updates the queue.
*/
public void pulse() {
Position position = character.getPosition();
Position position = mob.getPosition();
Direction first = Direction.NONE;
Direction second = Direction.NONE;
Point next = points.poll();
if (next != null) {
mob.stopAction();
first = next.direction;
position = next.position;
if (runningQueue /* or run toggled AND enough energy */) {
if (runningQueue /* and enough energy */) {
next = points.poll();
if (next != null) {
second = next.direction;
@@ -230,8 +231,8 @@ public final class WalkingQueue {
}
}
character.setDirections(first, second);
character.setPosition(position);
mob.setDirections(first, second);
mob.setPosition(position);
}
/**
+27 -28
View File
@@ -26,13 +26,13 @@ import org.apollo.game.model.sector.SectorRepository;
import org.apollo.game.scheduling.ScheduledTask;
import org.apollo.game.scheduling.Scheduler;
import org.apollo.io.EquipmentDefinitionParser;
import org.apollo.util.CharacterRepository;
import org.apollo.util.MobRepository;
import org.apollo.util.plugin.PluginManager;
/**
* The world class is a singleton which contains objects like the {@link CharacterRepository} for players and NPCs. It
* should only contain things relevant to the in-game world and not classes which deal with I/O and such (these may be
* better off inside some custom {@link Service} or other code, however, the circumstances are rare).
* The world class is a singleton which contains objects like the {@link MobRepository} for players and NPCs. It should
* only contain things relevant to the in-game world and not classes which deal with I/O and such (these may be better
* off inside some custom {@link Service} or other code, however, the circumstances are rare).
*
* @author Graham
*/
@@ -86,20 +86,14 @@ public final class World {
private final CommandDispatcher dispatcher = new CommandDispatcher();
/**
* The {@link CharacterRepository} of {@link Npc}s.
* The {@link MobRepository} of {@link Npc}s.
*/
private final CharacterRepository<Npc> npcRepository = new CharacterRepository<Npc>(WorldConstants.MAXIMUM_NPCS);
private final MobRepository<Npc> npcRepository = new MobRepository<Npc>(WorldConstants.MAXIMUM_NPCS);
/**
* The {@link CharacterRepository} of {@link Player}s.
* The {@link MobRepository} of {@link Player}s.
*/
private final CharacterRepository<Player> playerRepository = new CharacterRepository<Player>(
WorldConstants.MAXIMUM_PLAYERS);
/**
* The release number (i.e. version) of this world.
*/
private int releaseNumber;
private final MobRepository<Player> playerRepository = new MobRepository<Player>(WorldConstants.MAXIMUM_PLAYERS);
/**
* A {@link Map} of player usernames and the player objects.
@@ -111,6 +105,11 @@ public final class World {
*/
private PluginManager pluginManager;
/**
* The release number (i.e. version) of this world.
*/
private int releaseNumber;
/**
* This world's {@link SectorRepository}.
*/
@@ -128,7 +127,7 @@ public final class World {
}
/**
* Gets the command dispatcher. TODO should this be here?
* Gets the command dispatcher.
*
* @return The command dispatcher.
*/
@@ -141,7 +140,7 @@ public final class World {
*
* @return The npc repository.
*/
public CharacterRepository<Npc> getNpcRepository() {
public MobRepository<Npc> getNpcRepository() {
return npcRepository;
}
@@ -156,14 +155,14 @@ public final class World {
}
/**
* Gets the character repository.
* Gets the player repository.
* <p>
* Note: players should be registered and unregistered using {@link World#register(Player)} and
* {@link World#unregister(Player)} respectively, not by adding to or removing from this repository directly.
*
* @return The character repository.
* @return The player repository.
*/
public CharacterRepository<Player> getPlayerRepository() {
public MobRepository<Player> getPlayerRepository() {
return playerRepository;
}
@@ -176,6 +175,15 @@ public final class World {
return pluginManager;
}
/**
* Gets the release number of this world.
*
* @return The release number.
*/
public int getReleaseNumber() {
return releaseNumber;
}
/**
* Initialises the world by loading definitions from the specified file system.
*
@@ -288,15 +296,6 @@ public final class World {
return RegistrationStatus.WORLD_FULL;
}
/**
* Gets the release number of this world.
*
* @return The release number.
*/
public int getReleaseNumber() {
return releaseNumber;
}
/**
* Schedules a new task.
*
@@ -2,5 +2,4 @@
* Contains definition classes which contain information about types of items,
* NPCs, etc.
*/
package org.apollo.game.model.def;
package org.apollo.game.model.def;
@@ -14,4 +14,4 @@ public interface EnterAmountListener {
*/
public void amountEntered(int amount);
}
}
@@ -8,9 +8,9 @@ package org.apollo.game.model.inter;
public class InterfaceConstants {
/**
* The character design interface id.
* The avatar design interface id.
*/
public static final int CHARACTER_DESIGN = 3559;
public static final int AVATAR_DESIGN = 3559;
/**
* The default inventory tab ids.
@@ -12,4 +12,4 @@ public interface InterfaceListener {
*/
public void interfaceClosed();
}
}
@@ -63,7 +63,6 @@ public final class InterfaceSet {
*/
public void close() {
closeAndNotify();
player.send(new CloseInterfaceEvent());
}
@@ -34,4 +34,4 @@ public final class BankConstants {
}
}
}
@@ -45,4 +45,4 @@ public final class BankDepositEnterAmountListener implements EnterAmountListener
}
}
}
}
@@ -45,4 +45,4 @@ public final class BankInterfaceListener implements InterfaceListener {
player.getBank().removeListener(bankListener);
}
}
}
@@ -33,7 +33,6 @@ public final class BankUtils {
Inventory bank = player.getBank();
Item item = inventory.get(slot);
int newId = ItemDefinition.noteToItem(item.getId());
if (bank.freeSlots() == 0 && !bank.contains(item.getId())) {
@@ -126,10 +125,10 @@ public final class BankUtils {
}
/**
* Default private constructor to prevent insantiation.
* Default private constructor to prevent instantiation.
*/
private BankUtils() {
}
}
}
@@ -45,4 +45,4 @@ public final class BankWithdrawEnterAmountListener implements EnterAmountListene
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More