Format consistently; fix equipment removal.

This commit is contained in:
Major-
2013-11-02 15:33:09 +00:00
parent e0c7287af5
commit b920ab34a7
353 changed files with 1672 additions and 987 deletions
+12 -5
View File
@@ -1,9 +1,11 @@
package net.burtleburtle.bob.rand; package net.burtleburtle.bob.rand;
/** /**
* <p>An implementation of the * <p>
* <a href="http://www.burtleburtle.net/bob/rand/isaacafa.html">ISAAC</a> * An implementation of the <a href="http://www.burtleburtle.net/bob/rand/isaacafa.html">ISAAC</a> psuedorandom number
* psuedorandom number generator.</p> * generator.
* </p>
*
* <pre> * <pre>
* ------------------------------------------------------------------------------ * ------------------------------------------------------------------------------
* Rand.java: By Bob Jenkins. My random number generator, ISAAC. * Rand.java: By Bob Jenkins. My random number generator, ISAAC.
@@ -15,8 +17,10 @@ package net.burtleburtle.bob.rand;
* 980224: Translate to Java * 980224: Translate to Java
* ------------------------------------------------------------------------------ * ------------------------------------------------------------------------------
* </pre> * </pre>
* <p>This class has been changed to be more conformant to Java and javadoc * <p>
* conventions.</p> * This class has been changed to be more conformant to Java and javadoc conventions.
* </p>
*
* @author Bob Jenkins * @author Bob Jenkins
*/ */
public final class IsaacRandom { public final class IsaacRandom {
@@ -82,6 +86,7 @@ public final class IsaacRandom {
/** /**
* Creates the random number generator with the specified seed. * Creates the random number generator with the specified seed.
*
* @param seed The seed. * @param seed The seed.
*/ */
public IsaacRandom(int[] seed) { public IsaacRandom(int[] seed) {
@@ -155,6 +160,7 @@ public final class IsaacRandom {
/** /**
* Initialises this random number generator. * Initialises this random number generator.
*
* @param flag Set to {@code true} if a seed was passed to the constructor. * @param flag Set to {@code true} if a seed was passed to the constructor.
*/ */
private void init(boolean flag) { private void init(boolean flag) {
@@ -285,6 +291,7 @@ public final class IsaacRandom {
/** /**
* Gets the next random value. * Gets the next random value.
*
* @return The next random value. * @return The next random value.
*/ */
public int nextInt() { public int nextInt() {
@@ -2,3 +2,4 @@
* Contains a Java implementation of Bob Jenkins' ISAAC algorithm. * Contains a Java implementation of Bob Jenkins' ISAAC algorithm.
*/ */
package net.burtleburtle.bob.rand; package net.burtleburtle.bob.rand;
+13 -6
View File
@@ -28,6 +28,7 @@ import org.jboss.netty.util.Timer;
/** /**
* The core class of the Apollo server. * The core class of the Apollo server.
*
* @author Graham * @author Graham
*/ */
public final class Server { public final class Server {
@@ -39,6 +40,7 @@ public final class Server {
/** /**
* The entry point of the Apollo server application. * The entry point of the Apollo server application.
*
* @param args The command-line arguments passed to the application. * @param args The command-line arguments passed to the application.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
@@ -74,8 +76,8 @@ public final class Server {
private final ServerBootstrap jagGrabBootstrap = new ServerBootstrap(); private final ServerBootstrap jagGrabBootstrap = new ServerBootstrap();
/** /**
* The {@link ExecutorService} used for network events. The named thread * The {@link ExecutorService} used for network events. The named thread factory is unused as Netty names threads
* factory is unused as Netty names threads itself. * itself.
*/ */
private final ExecutorService networkExecutor = Executors.newCachedThreadPool(); private final ExecutorService networkExecutor = Executors.newCachedThreadPool();
@@ -96,6 +98,7 @@ public final class Server {
/** /**
* Creates the Apollo server. * Creates the Apollo server.
*
* @throws Exception if an error occurs whilst creating services. * @throws Exception if an error occurs whilst creating services.
*/ */
public Server() throws Exception { public Server() throws Exception {
@@ -105,13 +108,14 @@ public final class Server {
/** /**
* Initialises the server. * Initialises the server.
* @param releaseClassName The class name of the current active *
* {@link Release}. * @param releaseClassName The class name of the current active {@link Release}.
* @throws ClassNotFoundException if the release class could not be found. * @throws ClassNotFoundException if the release class could not be found.
* @throws IllegalAccessException if the release class could not be accessed. * @throws IllegalAccessException if the release class could not be accessed.
* @throws InstantiationException if the release class could not be instantiated. * @throws InstantiationException if the release class could not be instantiated.
*/ */
public void init(String releaseClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { public void init(String releaseClassName) throws ClassNotFoundException, InstantiationException,
IllegalAccessException {
Class<?> clazz = Class.forName(releaseClassName); Class<?> clazz = Class.forName(releaseClassName);
Release release = (Release) clazz.newInstance(); Release release = (Release) clazz.newInstance();
@@ -137,6 +141,7 @@ public final class Server {
/** /**
* Binds the server to the specified address. * Binds the server to the specified address.
*
* @param serviceAddress The service address to bind to. * @param serviceAddress The service address to bind to.
* @param httpAddress The HTTP address to bind to. * @param httpAddress The HTTP address to bind to.
* @param jagGrabAddress The JAGGRAB address to bind to. * @param jagGrabAddress The JAGGRAB address to bind to.
@@ -149,7 +154,8 @@ public final class Server {
try { try {
httpBootstrap.bind(httpAddress); httpBootstrap.bind(httpAddress);
} catch (Throwable t) { } catch (Throwable t) {
logger.log(Level.WARNING, "Binding to HTTP failed: client will use JAGGRAB as a fallback (not reccomended)!", t); logger.log(Level.WARNING,
"Binding to HTTP failed: client will use JAGGRAB as a fallback (not reccomended)!", t);
} }
logger.info("Binding JAGGRAB listener to address: " + jagGrabAddress + "..."); logger.info("Binding JAGGRAB listener to address: " + jagGrabAddress + "...");
@@ -160,6 +166,7 @@ public final class Server {
/** /**
* Starts the server. * Starts the server.
*
* @throws Exception if an error occurs. * @throws Exception if an error occurs.
*/ */
public void start() throws Exception { public void start() throws Exception {
+12 -8
View File
@@ -5,12 +5,12 @@ import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.DefaultChannelGroup; import org.jboss.netty.channel.group.DefaultChannelGroup;
/** /**
* A {@link ServerContext} is created along with the {@link Server} object. The * A {@link ServerContext} is created along with the {@link Server} object. The primary difference is that a reference
* primary difference is that a reference to the current context should be * to the current context should be passed around within the server. The {@link Server} should not be as it allows
* passed around within the server. The {@link Server} should not be as it * access to some methods such as
* allows access to some methods such as * {@link Server#bind(java.net.SocketAddress, java.net.SocketAddress, java.net.SocketAddress)} which user scripts/code
* {@link Server#bind(java.net.SocketAddress, java.net.SocketAddress, java.net.SocketAddress)} * should not be able to access.
* which user scripts/code should not be able to access. *
* @author Graham * @author Graham
*/ */
public final class ServerContext { public final class ServerContext {
@@ -32,6 +32,7 @@ public final class ServerContext {
/** /**
* Creates a new server context. * Creates a new server context.
*
* @param release The current release. * @param release The current release.
* @param serviceManager The service manager. * @param serviceManager The service manager.
*/ */
@@ -43,6 +44,7 @@ public final class ServerContext {
/** /**
* Gets the channel group. * Gets the channel group.
*
* @return The channel group. * @return The channel group.
*/ */
public ChannelGroup getChannelGroup() { public ChannelGroup getChannelGroup() {
@@ -51,6 +53,7 @@ public final class ServerContext {
/** /**
* Gets the current release. * Gets the current release.
*
* @return The current release. * @return The current release.
*/ */
public Release getRelease() { public Release getRelease() {
@@ -59,6 +62,7 @@ public final class ServerContext {
/** /**
* Gets the service manager. * Gets the service manager.
*
* @return The service manager. * @return The service manager.
*/ */
public ServiceManager getServiceManager() { public ServiceManager getServiceManager() {
@@ -66,8 +70,8 @@ public final class ServerContext {
} }
/** /**
* Gets a service. This method is shorthand for * Gets a service. This method is shorthand for {@code getServiceManager().getService(...)}.
* {@code getServiceManager().getService(...)}. *
* @param <S> The type of service. * @param <S> The type of service.
* @param clazz The service class. * @param clazz The service class.
* @return The service, or {@code null} if it could not be found. * @return The service, or {@code null} if it could not be found.
+3
View File
@@ -2,6 +2,7 @@ package org.apollo;
/** /**
* Represents a service that the server provides. * Represents a service that the server provides.
*
* @author Graham * @author Graham
*/ */
public abstract class Service { public abstract class Service {
@@ -13,6 +14,7 @@ public abstract class Service {
/** /**
* Gets the server context. * Gets the server context.
*
* @return The context. * @return The context.
*/ */
public final ServerContext getContext() { public final ServerContext getContext() {
@@ -21,6 +23,7 @@ public abstract class Service {
/** /**
* Sets the server context. * Sets the server context.
*
* @param ctx The context. * @param ctx The context.
*/ */
public final void setContext(ServerContext ctx) { public final void setContext(ServerContext ctx) {
+6
View File
@@ -11,6 +11,7 @@ import org.apollo.util.xml.XmlParser;
/** /**
* A class which manages {@link Service}s. * A class which manages {@link Service}s.
*
* @author Graham * @author Graham
*/ */
public final class ServiceManager { public final class ServiceManager {
@@ -27,6 +28,7 @@ public final class ServiceManager {
/** /**
* Creates and initializes the {@link ServiceManager}. * Creates and initializes the {@link ServiceManager}.
*
* @throws Exception if an error occurs. * @throws Exception if an error occurs.
*/ */
public ServiceManager() throws Exception { public ServiceManager() throws Exception {
@@ -35,6 +37,7 @@ public final class ServiceManager {
/** /**
* Initializes this service manager. * Initializes this service manager.
*
* @throws Exception if an error occurs. * @throws Exception if an error occurs.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -71,6 +74,7 @@ public final class ServiceManager {
/** /**
* Registers a service. * Registers a service.
*
* @param <S> The type of service. * @param <S> The type of service.
* @param clazz The service's class. * @param clazz The service's class.
* @param service The service. * @param service The service.
@@ -82,6 +86,7 @@ public final class ServiceManager {
/** /**
* Gets a service. * Gets a service.
*
* @param <S> The type of service. * @param <S> The type of service.
* @param clazz The service class. * @param clazz The service class.
* @return The service. * @return The service.
@@ -104,6 +109,7 @@ public final class ServiceManager {
/** /**
* Sets the context of all services. * Sets the context of all services.
*
* @param ctx The server context. * @param ctx The server context.
*/ */
public void setContext(ServerContext ctx) { public void setContext(ServerContext ctx) {
+4
View File
@@ -2,6 +2,7 @@ package org.apollo.fs;
/** /**
* A class which points to a file in the cache. * A class which points to a file in the cache.
*
* @author Graham * @author Graham
*/ */
public final class FileDescriptor { public final class FileDescriptor {
@@ -18,6 +19,7 @@ public final class FileDescriptor {
/** /**
* Creates the file descriptor. * Creates the file descriptor.
*
* @param type The file type. * @param type The file type.
* @param file The file id. * @param file The file id.
*/ */
@@ -28,6 +30,7 @@ public final class FileDescriptor {
/** /**
* Gets the file type. * Gets the file type.
*
* @return The file type. * @return The file type.
*/ */
public int getType() { public int getType() {
@@ -36,6 +39,7 @@ public final class FileDescriptor {
/** /**
* Gets the file id. * Gets the file id.
*
* @return The file id. * @return The file id.
*/ */
public int getFile() { public int getFile() {
@@ -2,6 +2,7 @@ package org.apollo.fs;
/** /**
* Holds file system related constants. * Holds file system related constants.
*
* @author Graham * @author Graham
*/ */
public final class FileSystemConstants { public final class FileSystemConstants {
+5
View File
@@ -2,12 +2,14 @@ package org.apollo.fs;
/** /**
* An {@link Index} points to a file in the {@code main_file_cache.dat} file. * An {@link Index} points to a file in the {@code main_file_cache.dat} file.
*
* @author Graham * @author Graham
*/ */
public final class Index { public final class Index {
/** /**
* Decodes a buffer into an index. * Decodes a buffer into an index.
*
* @param buffer The buffer. * @param buffer The buffer.
* @return The decoded {@link Index}. * @return The decoded {@link Index}.
* @throws IllegalArgumentException if the buffer length is invalid. * @throws IllegalArgumentException if the buffer length is invalid.
@@ -35,6 +37,7 @@ public final class Index {
/** /**
* Creates the index. * Creates the index.
*
* @param size The size of the file. * @param size The size of the file.
* @param block The first block of the file. * @param block The first block of the file.
*/ */
@@ -45,6 +48,7 @@ public final class Index {
/** /**
* Gets the size of the file. * Gets the size of the file.
*
* @return The size of the file. * @return The size of the file.
*/ */
public int getSize() { public int getSize() {
@@ -53,6 +57,7 @@ public final class Index {
/** /**
* Gets the first block of the file. * Gets the first block of the file.
*
* @return The first block of the file. * @return The first block of the file.
*/ */
public int getBlock() { public int getBlock() {
+11 -3
View File
@@ -9,9 +9,9 @@ import java.nio.ByteBuffer;
import java.util.zip.CRC32; import java.util.zip.CRC32;
/** /**
* A file system based on top of the operating system's file system. It * A file system based on top of the operating system's file system. It consists of a data file and index files. Index
* consists of a data file and index files. Index files point to blocks in the * files point to blocks in the data file, which contains the actual data.
* data file, which contains the actual data. *
* @author Graham * @author Graham
*/ */
public final class IndexedFileSystem implements Closeable { public final class IndexedFileSystem implements Closeable {
@@ -38,6 +38,7 @@ public final class IndexedFileSystem implements Closeable {
/** /**
* Creates the file system with the specified base directory. * Creates the file system with the specified base directory.
*
* @param base The base directory. * @param base The base directory.
* @param readOnly A flag indicating if the file system will be read only. * @param readOnly A flag indicating if the file system will be read only.
* @throws Exception if the file system is invalid. * @throws Exception if the file system is invalid.
@@ -49,6 +50,7 @@ public final class IndexedFileSystem implements Closeable {
/** /**
* Checks if this {@link IndexedFileSystem} is read only. * Checks if this {@link IndexedFileSystem} is read only.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean isReadOnly() { public boolean isReadOnly() {
@@ -57,6 +59,7 @@ public final class IndexedFileSystem implements Closeable {
/** /**
* Automatically detect the layout of the specified directory. * Automatically detect the layout of the specified directory.
*
* @param base The base directory. * @param base The base directory.
* @throws Exception if the file system is invalid. * @throws Exception if the file system is invalid.
*/ */
@@ -86,6 +89,7 @@ public final class IndexedFileSystem implements Closeable {
/** /**
* Gets the index of a file. * Gets the index of a file.
*
* @param fd The {@link FileDescriptor} which points to the file. * @param fd The {@link FileDescriptor} which points to the file.
* @return The {@link Index}. * @return The {@link Index}.
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
@@ -113,6 +117,7 @@ public final class IndexedFileSystem implements Closeable {
/** /**
* Gets the number of files with the specified type. * Gets the number of files with the specified type.
*
* @param type The type. * @param type The type.
* @return The number of files. * @return The number of files.
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
@@ -130,6 +135,7 @@ public final class IndexedFileSystem implements Closeable {
/** /**
* Gets the CRC table. * Gets the CRC table.
*
* @return The CRC table. * @return The CRC table.
* @throws IOException if an I/O erorr occurs. * @throws IOException if an I/O erorr occurs.
*/ */
@@ -185,6 +191,7 @@ public final class IndexedFileSystem implements Closeable {
/** /**
* Gets a file. * Gets a file.
*
* @param type The file type. * @param type The file type.
* @param file The file id. * @param file The file id.
* @return A {@link ByteBuffer} which contains the contents of the file. * @return A {@link ByteBuffer} which contains the contents of the file.
@@ -196,6 +203,7 @@ public final class IndexedFileSystem implements Closeable {
/** /**
* Gets a file. * Gets a file.
*
* @param fd The {@link FileDescriptor} which points to the file. * @param fd The {@link FileDescriptor} which points to the file.
* @return A {@link ByteBuffer} which contains the contents of the file. * @return A {@link ByteBuffer} which contains the contents of the file.
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
+5 -10
View File
@@ -17,11 +17,9 @@ public final class Archive {
/** /**
* Decodes the archive in the specified buffer. * Decodes the archive in the specified buffer.
* *
* @param buffer * @param buffer The buffer.
* The buffer.
* @return The archive. * @return The archive.
* @throws IOException * @throws IOException if an I/O error occurs.
* if an I/O error occurs.
*/ */
public static Archive decode(ByteBuffer buffer) throws IOException { public static Archive decode(ByteBuffer buffer) throws IOException {
int extractedSize = ByteBufferUtil.readUnsignedTriByte(buffer); int extractedSize = ByteBufferUtil.readUnsignedTriByte(buffer);
@@ -71,8 +69,7 @@ public final class Archive {
/** /**
* Creates a new archive. * Creates a new archive.
* *
* @param entries * @param entries The entries in this archive.
* The entries in this archive.
*/ */
public Archive(ArchiveEntry[] entries) { public Archive(ArchiveEntry[] entries) {
this.entries = entries; this.entries = entries;
@@ -81,11 +78,9 @@ public final class Archive {
/** /**
* Gets an entry by its name. * Gets an entry by its name.
* *
* @param name * @param name The name.
* The name.
* @return The entry. * @return The entry.
* @throws FileNotFoundException * @throws FileNotFoundException if the file could not be found.
* if the file could not be found.
*/ */
public ArchiveEntry getEntry(String name) throws FileNotFoundException { public ArchiveEntry getEntry(String name) throws FileNotFoundException {
int hash = 0; int hash = 0;
@@ -4,6 +4,7 @@ import java.nio.ByteBuffer;
/** /**
* Represents a single entry in an {@link Archive}. * Represents a single entry in an {@link Archive}.
*
* @author Graham * @author Graham
*/ */
public final class ArchiveEntry { public final class ArchiveEntry {
@@ -20,6 +21,7 @@ public final class ArchiveEntry {
/** /**
* Creates a new archive entry. * Creates a new archive entry.
*
* @param identifier The identifier. * @param identifier The identifier.
* @param buffer The buffer. * @param buffer The buffer.
*/ */
@@ -30,6 +32,7 @@ public final class ArchiveEntry {
/** /**
* Gets the identifier of this entry. * Gets the identifier of this entry.
*
* @return The identifier of this entry. * @return The identifier of this entry.
*/ */
public int getIdentifier() { public int getIdentifier() {
@@ -38,6 +41,7 @@ public final class ArchiveEntry {
/** /**
* Gets the buffer of this entry. * Gets the buffer of this entry.
*
* @return This buffer of this entry. * @return This buffer of this entry.
*/ */
public ByteBuffer getBuffer() { public ByteBuffer getBuffer() {
@@ -2,3 +2,4 @@
* Contains classes which deal with archives. * Contains classes which deal with archives.
*/ */
package org.apollo.fs.archive; package org.apollo.fs.archive;
+1
View File
@@ -3,3 +3,4 @@
* store game data files. * store game data files.
*/ */
package org.apollo.fs; package org.apollo.fs;
@@ -23,8 +23,7 @@ public final class ItemDefinitionParser {
/** /**
* Creates the item definition parser. * Creates the item definition parser.
* *
* @param fs * @param fs The indexed file system.
* The indexed file system.
*/ */
public ItemDefinitionParser(IndexedFileSystem fs) { public ItemDefinitionParser(IndexedFileSystem fs) {
this.fs = fs; this.fs = fs;
@@ -34,8 +33,7 @@ public final class ItemDefinitionParser {
* Parses the item definitions. * Parses the item definitions.
* *
* @return The item definitions. * @return The item definitions.
* @throws IOException * @throws IOException if an I/O error occurs.
* if an I/O error occurs.
*/ */
public ItemDefinition[] parse() throws IOException { public ItemDefinition[] parse() throws IOException {
Archive config = Archive.decode(fs.getFile(0, 2)); Archive config = Archive.decode(fs.getFile(0, 2));
@@ -62,10 +60,8 @@ public final class ItemDefinitionParser {
/** /**
* Parses a single definition. * Parses a single definition.
* *
* @param id * @param id The item's id.
* The item's id. * @param buffer The buffer.
* @param buffer
* The buffer.
* @return The definition. * @return The definition.
*/ */
private ItemDefinition parseDefinition(int id, ByteBuffer buffer) { private ItemDefinition parseDefinition(int id, ByteBuffer buffer) {
@@ -2,3 +2,4 @@
* Contains classes which parse files within the game's cache. * Contains classes which parse files within the game's cache.
*/ */
package org.apollo.fs.parser; package org.apollo.fs.parser;
+1
View File
@@ -2,6 +2,7 @@ package org.apollo.game;
/** /**
* Contains game-related constants. * Contains game-related constants.
*
* @author Graham * @author Graham
*/ */
public final class GameConstants { public final class GameConstants {
@@ -5,6 +5,7 @@ import java.util.logging.Logger;
/** /**
* A class which handles the logic for each pulse of the {@link GameService}. * A class which handles the logic for each pulse of the {@link GameService}.
*
* @author Graham * @author Graham
*/ */
public final class GamePulseHandler implements Runnable { public final class GamePulseHandler implements Runnable {
@@ -21,6 +22,7 @@ public final class GamePulseHandler implements Runnable {
/** /**
* Creates the game pulse handler object. * Creates the game pulse handler object.
*
* @param service The {@link GameService}. * @param service The {@link GameService}.
*/ */
GamePulseHandler(GameService service) { GamePulseHandler(GameService service) {
+15 -9
View File
@@ -22,23 +22,23 @@ import org.apollo.util.xml.XmlNode;
import org.apollo.util.xml.XmlParser; import org.apollo.util.xml.XmlParser;
/** /**
* The {@link GameService} class schedules and manages the execution of the * The {@link GameService} class schedules and manages the execution of the {@link GamePulseHandler} class.
* {@link GamePulseHandler} class. *
* @author Graham * @author Graham
*/ */
public final class GameService extends Service { public final class GameService extends Service {
/** /**
* The number of times to unregister players per cycle. This is to ensure * The number of times to unregister players per cycle. This is to ensure the saving threads don't get swamped with
* the saving threads don't get swamped with requests and slow everything * requests and slow everything down.
* down.
*/ */
private static final int UNREGISTERS_PER_CYCLE = 50; private static final int UNREGISTERS_PER_CYCLE = 50;
/** /**
* The scheduled executor service. * The scheduled executor service.
*/ */
private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("GameService")); private final ScheduledExecutorService scheduledExecutor = Executors
.newSingleThreadScheduledExecutor(new NamedThreadFactory("GameService"));
/** /**
* A queue of players to remove. * A queue of players to remove.
@@ -57,6 +57,7 @@ public final class GameService extends Service {
/** /**
* Creates the game service. * Creates the game service.
*
* @throws Exception if an error occurs during initialization. * @throws Exception if an error occurs during initialization.
*/ */
public GameService() throws Exception { public GameService() throws Exception {
@@ -65,6 +66,7 @@ public final class GameService extends Service {
/** /**
* Gets the event handler chains. * Gets the event handler chains.
*
* @return The event handler chains. * @return The event handler chains.
*/ */
public EventHandlerChainGroup getEventHandlerChains() { public EventHandlerChainGroup getEventHandlerChains() {
@@ -73,6 +75,7 @@ public final class GameService extends Service {
/** /**
* Initializes the game service. * Initializes the game service.
*
* @throws Exception if an error occurs. * @throws Exception if an error occurs.
*/ */
private void init() throws Exception { private void init() throws Exception {
@@ -110,7 +113,8 @@ public final class GameService extends Service {
*/ */
@Override @Override
public void start() { public void start() {
scheduledExecutor.scheduleAtFixedRate(new GamePulseHandler(this), GameConstants.PULSE_DELAY, GameConstants.PULSE_DELAY, TimeUnit.MILLISECONDS); scheduledExecutor.scheduleAtFixedRate(new GamePulseHandler(this), GameConstants.PULSE_DELAY,
GameConstants.PULSE_DELAY, TimeUnit.MILLISECONDS);
} }
/** /**
@@ -143,6 +147,7 @@ public final class GameService extends Service {
/** /**
* Registers a player (may block!). * Registers a player (may block!).
*
* @param player The player. * @param player The player.
* @return A {@link RegistrationStatus}. * @return A {@link RegistrationStatus}.
*/ */
@@ -153,8 +158,8 @@ public final class GameService extends Service {
} }
/** /**
* Unregisters a player. Returns immediately. The player is unregistered * Unregisters a player. Returns immediately. The player is unregistered at the start of the next cycle.
* at the start of the next cycle. *
* @param player The player. * @param player The player.
*/ */
public void unregisterPlayer(Player player) { public void unregisterPlayer(Player player) {
@@ -163,6 +168,7 @@ public final class GameService extends Service {
/** /**
* Finalizes the unregistration of a player. * Finalizes the unregistration of a player.
*
* @param player The player. * @param player The player.
*/ */
public void finalizePlayerUnregistration(Player player) { public void finalizePlayerUnregistration(Player player) {
+8 -9
View File
@@ -4,14 +4,12 @@ import org.apollo.game.model.Character;
import org.apollo.game.scheduling.ScheduledTask; import org.apollo.game.scheduling.ScheduledTask;
/** /**
* An action is a specialised {@link ScheduledTask} which is specific to a * An action is a specialised {@link ScheduledTask} which is specific to a character.
* character.
* <p> * <p>
* <strong>ALL</strong> actions <strong>MUST</strong> implement the * <strong>ALL</strong> actions <strong>MUST</strong> implement the {@link #equals(Object)} method. This is to check if
* {@link #equals(Object)} method. This is to check if two actions are * two actions are identical: if they are, then the new action does not replace the old one (so spam/accidental clicking
* identical: if they are, then the new action does not replace the old one (so * won't cancel your action, and start another from scratch).
* spam/accidental clicking won't cancel your action, and start another from *
* scratch).
* @author Graham * @author Graham
*/ */
public abstract class Action<T extends Character> extends ScheduledTask { public abstract class Action<T extends Character> extends ScheduledTask {
@@ -28,9 +26,9 @@ public abstract class Action<T extends Character> extends ScheduledTask {
/** /**
* Creates a new action. * Creates a new action.
*
* @param delay The delay in pulses. * @param delay The delay in pulses.
* @param immediate A flag indicating if the action should happen * @param immediate A flag indicating if the action should happen immediately.
* immediately.
* @param character The character performing the action. * @param character The character performing the action.
*/ */
public Action(int delay, boolean immediate, T character) { public Action(int delay, boolean immediate, T character) {
@@ -40,6 +38,7 @@ public abstract class Action<T extends Character> extends ScheduledTask {
/** /**
* Gets the character which performed the action. * Gets the character which performed the action.
*
* @return The character. * @return The character.
*/ */
public T getCharacter() { public T getCharacter() {
@@ -5,6 +5,7 @@ import org.apollo.game.model.Position;
/** /**
* An @{link Action} which fires when a distance requirement is met. * An @{link Action} which fires when a distance requirement is met.
*
* @author Blake * @author Blake
* @author Graham * @author Graham
*/ */
@@ -26,8 +27,7 @@ public abstract class DistancedAction<T extends Character> extends Action<T> {
private final int delay; private final int delay;
/** /**
* A flag indicating if this action fires immediately after the threshold * A flag indicating if this action fires immediately after the threshold is reached.
* is reached.
*/ */
private final boolean immediate; private final boolean immediate;
@@ -38,10 +38,9 @@ public abstract class DistancedAction<T extends Character> extends Action<T> {
/** /**
* Creates a new DistancedAction. * Creates a new DistancedAction.
* @param delay The delay between executions once the distance threshold is *
* reached. * @param delay The delay between executions once the distance threshold is reached.
* @param immediate Whether or not this action fires immediately after the * @param immediate Whether or not this action fires immediately after the distance threshold is reached.
* distance threshold is reached.
* @param character The character. * @param character The character.
* @param position The position. * @param position The position.
* @param distance The distance. * @param distance The distance.
@@ -60,7 +59,7 @@ public abstract class DistancedAction<T extends Character> extends Action<T> {
// some actions (e.g. agility) will cause the player to move away again // 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 // so we don't check once the player got close enough once
executeAction(); executeAction();
} else if (getCharacter().getPosition().getDistance(position) <= distance) { } else if (getCharacter().getPosition().getDistance(position) <= distance) {
reached = true; reached = true;
setDelay(delay); setDelay(delay);
if (immediate) { // TODO: required? if (immediate) { // TODO: required?
@@ -3,3 +3,4 @@
* characters perform. * characters perform.
*/ */
package org.apollo.game.action; package org.apollo.game.action;
+4
View File
@@ -2,6 +2,7 @@ package org.apollo.game.command;
/** /**
* Represents a command. * Represents a command.
*
* @author Graham * @author Graham
*/ */
public final class Command { public final class Command {
@@ -18,6 +19,7 @@ public final class Command {
/** /**
* Creates the command. * Creates the command.
*
* @param name The name of the command. * @param name The name of the command.
* @param arguments The command's arguments. * @param arguments The command's arguments.
*/ */
@@ -28,6 +30,7 @@ public final class Command {
/** /**
* Gets the name of the command. * Gets the name of the command.
*
* @return The name of the command. * @return The name of the command.
*/ */
public String getName() { public String getName() {
@@ -36,6 +39,7 @@ public final class Command {
/** /**
* Gets the command's arguments. * Gets the command's arguments.
*
* @return The command's arguments. * @return The command's arguments.
*/ */
public String[] getArguments() { public String[] getArguments() {
@@ -7,6 +7,7 @@ import org.apollo.game.model.Player;
/** /**
* A class which dispatches {@link Command}s to {@link CommandListener}s. * A class which dispatches {@link Command}s to {@link CommandListener}s.
*
* @author Graham * @author Graham
*/ */
public final class CommandDispatcher { public final class CommandDispatcher {
@@ -17,8 +18,7 @@ public final class CommandDispatcher {
private final Map<String, CommandListener> listeners = new HashMap<String, CommandListener>(); private final Map<String, CommandListener> listeners = new HashMap<String, CommandListener>();
/** /**
* Creates the command dispatcher and registers a listener for the credits * Creates the command dispatcher and registers a listener for the credits command.
* command.
*/ */
public CommandDispatcher() { public CommandDispatcher() {
// not in a plugin so it is harder for people to remove! // not in a plugin so it is harder for people to remove!
@@ -27,6 +27,7 @@ public final class CommandDispatcher {
/** /**
* Registers a listener with the * Registers a listener with the
*
* @param command The command's name. * @param command The command's name.
* @param listener The listener. * @param listener The listener.
*/ */
@@ -36,6 +37,7 @@ public final class CommandDispatcher {
/** /**
* Dispatches a command to the appropriate listener. * Dispatches a command to the appropriate listener.
*
* @param player The player. * @param player The player.
* @param command The command. * @param command The command.
*/ */
@@ -3,14 +3,15 @@ package org.apollo.game.command;
import org.apollo.game.model.Player; import org.apollo.game.model.Player;
/** /**
* An interface which should be implemented by classes to listen to * An interface which should be implemented by classes to listen to {@link Command}s.
* {@link Command}s. *
* @author Graham * @author Graham
*/ */
public interface CommandListener { public interface CommandListener {
/** /**
* Executes the action for this command. * Executes the action for this command.
*
* @param player The player. * @param player The player.
* @param command The command. * @param command The command.
*/ */
@@ -9,22 +9,19 @@ import org.apollo.game.model.inter.quest.QuestConstants;
import org.apollo.util.plugin.PluginManager; import org.apollo.util.plugin.PluginManager;
/** /**
* Implements a {@code ::credits} command that lists the authors of all plugins * Implements a {@code ::credits} command that lists the authors of all plugins used in the server.
* used in the server. *
* @author Graham * @author Graham
*/ */
public final class CreditsCommandListener implements CommandListener { public final class CreditsCommandListener implements CommandListener {
/* /*
* If you are considering removing this command, please bear in mind that * If you are considering removing this command, please bear in mind that Apollo took several people thousands of
* Apollo took several people thousands of hours to create. We released it * hours to create. We released it to the world for free and it isn't much to ask to leave this command in. It isn't
* to the world for free and it isn't much to ask to leave this command in. * very obtrusive and gives us some well-deserved recognition for the work we have done. Thank you!
* It isn't very obtrusive and gives us some well-deserved recognition for *
* the work we have done. Thank you! * The list of authors is generated from the plugin manager. If you create a custom plugin, make sure you add your
* * name to the plugin.xml file and it'll appear here automatically!
* The list of authors is generated from the plugin manager. If you create
* a custom plugin, make sure you add your name to the plugin.xml file and
* it'll appear here automatically!
*/ */
@Override @Override
@@ -36,13 +33,19 @@ public final class CreditsCommandListener implements CommandListener {
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "@dre@Apollo")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "@dre@Apollo"));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "@dre@Introduction")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "@dre@Introduction"));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], ""));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "This server is based on Apollo, a lightweight, fast, secure")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++],
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "and open-source RuneScape emulator. For more")); "This server is based on Apollo, a lightweight, fast, secure"));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "information about Apollo, visit the website at:")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++],
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "@dbl@https://github.com/apollo-rsps/apollo")); "and open-source RuneScape emulator. For more"));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++],
"information about Apollo, visit the website at:"));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++],
"@dbl@https://github.com/apollo-rsps/apollo"));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], ""));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "Apollo is released under the terms of the ISC")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++],
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "license, details can be found in the root folder of the ")); "Apollo is released under the terms of the ISC"));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++],
"license, details can be found in the root folder of the "));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "Apollo distribution.")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "Apollo distribution."));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], ""));
player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "@dre@Credits")); player.send(new SetInterfaceTextEvent(QuestConstants.QUEST_TEXT[pos++], "@dre@Credits"));
@@ -4,8 +4,8 @@ import org.apollo.game.model.Player;
import org.apollo.game.model.Player.PrivilegeLevel; import org.apollo.game.model.Player.PrivilegeLevel;
/** /**
* A {@link CommandListener} which checks the {@link PrivilegeLevel} of the * A {@link CommandListener} which checks the {@link PrivilegeLevel} of the {@link Player} executing the command.
* {@link Player} executing the command. *
* @author Graham * @author Graham
*/ */
public abstract class PrivilegedCommandListener implements CommandListener { public abstract class PrivilegedCommandListener implements CommandListener {
@@ -17,6 +17,7 @@ public abstract class PrivilegedCommandListener implements CommandListener {
/** /**
* Creates the privileged command listener with the specified minimum level. * Creates the privileged command listener with the specified minimum level.
*
* @param level The minimum privilege level. * @param level The minimum privilege level.
*/ */
public PrivilegedCommandListener(PrivilegeLevel level) { public PrivilegedCommandListener(PrivilegeLevel level) {
@@ -25,6 +26,7 @@ public abstract class PrivilegedCommandListener implements CommandListener {
/** /**
* Executes a privileged command. * Executes a privileged command.
*
* @param player The player. * @param player The player.
* @param command The command. * @param command The command.
*/ */
@@ -2,3 +2,4 @@
* Contains classes related to in-game commands. * Contains classes related to in-game commands.
*/ */
package org.apollo.game.command; package org.apollo.game.command;
+1
View File
@@ -2,6 +2,7 @@ package org.apollo.game.event;
/** /**
* Represents an event that can occur in the game world. * Represents an event that can occur in the game world.
*
* @author Graham * @author Graham
*/ */
public abstract class Event { public abstract class Event {
@@ -5,6 +5,7 @@ import org.apollo.game.model.Player;
/** /**
* A class which handles events. * A class which handles events.
*
* @author Graham * @author Graham
* @param <E> The type of event this class handles. * @param <E> The type of event this class handles.
*/ */
@@ -12,6 +13,7 @@ public abstract class EventHandler<E extends Event> {
/** /**
* Handles an event. * Handles an event.
*
* @param ctx The context. * @param ctx The context.
* @param player The player. * @param player The player.
* @param event The event. * @param event The event.
@@ -3,8 +3,8 @@ package org.apollo.game.event.handler;
import org.apollo.game.event.handler.chain.EventHandlerChain; import org.apollo.game.event.handler.chain.EventHandlerChain;
/** /**
* Provides operations specific to an {@link EventHandler} in an * Provides operations specific to an {@link EventHandler} in an {@link EventHandlerChain}.
* {@link EventHandlerChain}. *
* @author Graham * @author Graham
*/ */
public abstract class EventHandlerContext { public abstract class EventHandlerContext {
@@ -7,6 +7,7 @@ import org.apollo.game.model.Player;
/** /**
* A chain of event handlers. * A chain of event handlers.
*
* @author Graham * @author Graham
* @param <E> The type of event the handlers in this chain handle. * @param <E> The type of event the handlers in this chain handle.
*/ */
@@ -19,6 +20,7 @@ public final class EventHandlerChain<E extends Event> {
/** /**
* Creates the event handler chain. * Creates the event handler chain.
*
* @param handlers The handlers. * @param handlers The handlers.
*/ */
@SafeVarargs @SafeVarargs
@@ -28,6 +30,7 @@ public final class EventHandlerChain<E extends Event> {
/** /**
* Dynamically adds an event handler to the end of the chain. * Dynamically adds an event handler to the end of the chain.
*
* @param handler The handler. * @param handler The handler.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -39,8 +42,8 @@ public final class EventHandlerChain<E extends Event> {
} }
/** /**
* Handles the event, passing it down the chain until the chain is broken * Handles the event, passing it down the chain until the chain is broken or the event reaches the end of the chain.
* or the event reaches the end of the chain. *
* @param player The player. * @param player The player.
* @param event The event. * @param event The event.
*/ */
@@ -6,6 +6,7 @@ import org.apollo.game.event.Event;
/** /**
* A group of {@link EventHandlerChain}s classified by the {@link Event} type. * A group of {@link EventHandlerChain}s classified by the {@link Event} type.
*
* @author Graham * @author Graham
*/ */
public final class EventHandlerChainGroup { public final class EventHandlerChainGroup {
@@ -17,6 +18,7 @@ public final class EventHandlerChainGroup {
/** /**
* Creates the event handler chain group. * Creates the event handler chain group.
*
* @param chains The chains map. * @param chains The chains map.
*/ */
public EventHandlerChainGroup(Map<Class<? extends Event>, EventHandlerChain<?>> chains) { public EventHandlerChainGroup(Map<Class<? extends Event>, EventHandlerChain<?>> chains) {
@@ -25,10 +27,10 @@ public final class EventHandlerChainGroup {
/** /**
* Gets an {@link EventHandlerChain} from this group. * Gets an {@link EventHandlerChain} from this group.
*
* @param <E> The type of event. * @param <E> The type of event.
* @param clazz The event class. * @param clazz The event class.
* @return The {@link EventHandlerChain} if one was found, {@code null} * @return The {@link EventHandlerChain} if one was found, {@code null} otherwise.
* otherwise.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <E extends Event> EventHandlerChain<E> getChain(Class<E> clazz) { public <E extends Event> EventHandlerChain<E> getChain(Class<E> clazz) {
@@ -2,3 +2,4 @@
* Contains classes related to the chaining of event handlers. * Contains classes related to the chaining of event handlers.
*/ */
package org.apollo.game.event.handler.chain; package org.apollo.game.event.handler.chain;
@@ -6,8 +6,8 @@ import org.apollo.game.event.impl.ButtonEvent;
import org.apollo.game.model.Player; import org.apollo.game.model.Player;
/** /**
* An {@link EventHandler} which responds to {@link ButtonEvent}s for * An {@link EventHandler} which responds to {@link ButtonEvent}s for withdrawing items as notes.
* withdrawing items as notes. *
* @author Graham * @author Graham
*/ */
public final class BankButtonEventHandler extends EventHandler<ButtonEvent> { public final class BankButtonEventHandler extends EventHandler<ButtonEvent> {
@@ -10,14 +10,15 @@ import org.apollo.game.model.inter.bank.BankUtils;
import org.apollo.game.model.inter.bank.BankWithdrawEnterAmountListener; import org.apollo.game.model.inter.bank.BankWithdrawEnterAmountListener;
/** /**
* An event handler which handles withdrawing and depositing items from/to a * An event handler which handles withdrawing and depositing items from/to a player's bank.
* player's bank. *
* @author Graham * @author Graham
*/ */
public final class BankEventHandler extends EventHandler<ItemActionEvent> { public final class BankEventHandler extends EventHandler<ItemActionEvent> {
/** /**
* Converts an option to an amount. * Converts an option to an amount.
*
* @param option The option. * @param option The option.
* @return The amount. * @return The amount.
* @throws IllegalArgumentException if the option is not legal. * @throws IllegalArgumentException if the option is not legal.
@@ -53,6 +54,7 @@ public final class BankEventHandler extends EventHandler<ItemActionEvent> {
/** /**
* Handles a withdraw action. * Handles a withdraw action.
*
* @param ctx The event handler context. * @param ctx The event handler context.
* @param player The player. * @param player The player.
* @param event The event. * @param event The event.
@@ -60,7 +62,8 @@ public final class BankEventHandler extends EventHandler<ItemActionEvent> {
private void withdraw(EventHandlerContext ctx, Player player, ItemActionEvent event) { private void withdraw(EventHandlerContext ctx, Player player, ItemActionEvent event) {
int amount = optionToAmount(event.getOption()); int amount = optionToAmount(event.getOption());
if (amount == -1) { if (amount == -1) {
player.getInterfaceSet().openEnterAmountDialog(new BankWithdrawEnterAmountListener(player, event.getSlot(), event.getId())); player.getInterfaceSet().openEnterAmountDialog(
new BankWithdrawEnterAmountListener(player, event.getSlot(), event.getId()));
} else { } else {
if (!BankUtils.withdraw(player, event.getSlot(), event.getId(), amount)) { if (!BankUtils.withdraw(player, event.getSlot(), event.getId(), amount)) {
ctx.breakHandlerChain(); ctx.breakHandlerChain();
@@ -70,6 +73,7 @@ public final class BankEventHandler extends EventHandler<ItemActionEvent> {
/** /**
* Handles a deposit action. * Handles a deposit action.
*
* @param ctx The event handler context. * @param ctx The event handler context.
* @param player The player. * @param player The player.
* @param event The event. * @param event The event.
@@ -77,7 +81,8 @@ public final class BankEventHandler extends EventHandler<ItemActionEvent> {
private void deposit(EventHandlerContext ctx, Player player, ItemActionEvent event) { private void deposit(EventHandlerContext ctx, Player player, ItemActionEvent event) {
int amount = optionToAmount(event.getOption()); int amount = optionToAmount(event.getOption());
if (amount == -1) { if (amount == -1) {
player.getInterfaceSet().openEnterAmountDialog(new BankDepositEnterAmountListener(player, event.getSlot(), event.getId())); player.getInterfaceSet().openEnterAmountDialog(
new BankDepositEnterAmountListener(player, event.getSlot(), event.getId()));
} else { } else {
if (!BankUtils.deposit(player, event.getSlot(), event.getId(), amount)) { if (!BankUtils.deposit(player, event.getSlot(), event.getId(), amount)) {
ctx.breakHandlerChain(); ctx.breakHandlerChain();
@@ -8,6 +8,7 @@ import org.apollo.game.model.Player;
/** /**
* A handler which handles {@link CharacterDesignEvent}s. * A handler which handles {@link CharacterDesignEvent}s.
*
* @author Graham * @author Graham
*/ */
public final class CharacterDesignEventHandler extends EventHandler<CharacterDesignEvent> { public final class CharacterDesignEventHandler extends EventHandler<CharacterDesignEvent> {
@@ -9,6 +9,7 @@ import org.apollo.game.model.Player;
/** /**
* A handler which verifies {@link CharacterDesignEvent}s. * A handler which verifies {@link CharacterDesignEvent}s.
*
* @author Graham * @author Graham
*/ */
public final class CharacterDesignVerificationHandler extends EventHandler<CharacterDesignEvent> { public final class CharacterDesignVerificationHandler extends EventHandler<CharacterDesignEvent> {
@@ -22,6 +23,7 @@ public final class CharacterDesignVerificationHandler extends EventHandler<Chara
/** /**
* Checks if an appearance combination is valid. * Checks if an appearance combination is valid.
*
* @param appearance The appearance combination. * @param appearance The appearance combination.
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
@@ -46,6 +48,7 @@ public final class CharacterDesignVerificationHandler extends EventHandler<Chara
/** /**
* Checks if a {@link Gender#MALE} style combination is valid. * Checks if a {@link Gender#MALE} style combination is valid.
*
* @param appearance The appearance combination. * @param appearance The appearance combination.
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
@@ -63,6 +66,7 @@ public final class CharacterDesignVerificationHandler extends EventHandler<Chara
/** /**
* Checks if a {@link Gender#FEMALE} style combination is valid. * Checks if a {@link Gender#FEMALE} style combination is valid.
*
* @param appearance The appearance combination. * @param appearance The appearance combination.
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
@@ -8,6 +8,7 @@ import org.apollo.game.sync.block.SynchronizationBlock;
/** /**
* An event handler which broadcasts public chat messages. * An event handler which broadcasts public chat messages.
*
* @author Graham * @author Graham
*/ */
public final class ChatEventHandler extends EventHandler<ChatEvent> { public final class ChatEventHandler extends EventHandler<ChatEvent> {
@@ -7,6 +7,7 @@ import org.apollo.game.model.Player;
/** /**
* An event handler which verifies chat events. * An event handler which verifies chat events.
*
* @author Graham * @author Graham
*/ */
public final class ChatVerificationHandler extends EventHandler<ChatEvent> { public final class ChatVerificationHandler extends EventHandler<ChatEvent> {
@@ -7,6 +7,7 @@ import org.apollo.game.model.Player;
/** /**
* An {@link EventHandler} for the {@link ClosedInterfaceEvent}. * An {@link EventHandler} for the {@link ClosedInterfaceEvent}.
*
* @author Graham * @author Graham
*/ */
public final class ClosedInterfaceEventHandler extends EventHandler<ClosedInterfaceEvent> { public final class ClosedInterfaceEventHandler extends EventHandler<ClosedInterfaceEvent> {
@@ -9,6 +9,7 @@ import org.apollo.game.model.World;
/** /**
* An {@link EventHandler} which dispatches {@link CommandEvent}s. * An {@link EventHandler} which dispatches {@link CommandEvent}s.
*
* @author Graham * @author Graham
*/ */
public final class CommandEventHandler extends EventHandler<CommandEvent> { public final class CommandEventHandler extends EventHandler<CommandEvent> {
@@ -7,6 +7,7 @@ import org.apollo.game.model.Player;
/** /**
* An {@link EventHandler} for the {@link EnteredAmountEvent}. * An {@link EventHandler} for the {@link EnteredAmountEvent}.
*
* @author Graham * @author Graham
*/ */
public final class EnteredAmountEventHandler extends EventHandler<EnteredAmountEvent> { public final class EnteredAmountEventHandler extends EventHandler<EnteredAmountEvent> {
@@ -15,6 +15,7 @@ import org.apollo.game.model.inv.SynchronizationInventoryListener;
/** /**
* An event handler which equips items. * An event handler which equips items.
*
* @author Graham * @author Graham
*/ */
public final class EquipEventHandler extends EventHandler<EquipEvent> { public final class EquipEventHandler extends EventHandler<EquipEvent> {
@@ -48,7 +49,8 @@ public final class EquipEventHandler extends EventHandler<EquipEvent> {
return; return;
} }
if (skillSet.getSkill(Skill.STRENGTH).getMaximumLevel() < equipDef.getStrengthLevel()) { if (skillSet.getSkill(Skill.STRENGTH).getMaximumLevel() < equipDef.getStrengthLevel()) {
player.sendMessage("You need a Strength level of " + equipDef.getStrengthLevel() + " to equip this item."); player.sendMessage("You need a Strength level of " + equipDef.getStrengthLevel()
+ " to equip this item.");
ctx.breakHandlerChain(); ctx.breakHandlerChain();
return; return;
} }
@@ -77,12 +79,12 @@ public final class EquipEventHandler extends EventHandler<EquipEvent> {
// TODO: put all this into another method somewhere // TODO: put all this into another method somewhere
// check if there is enough space for a two handed weapon // check if there is enough space for a two handed weapon
if (equipDef.isTwoHanded()) { if (equipDef.isTwoHanded()) {
if(equipment.get(EquipmentConstants.SHIELD) != null){ if (equipment.get(EquipmentConstants.SHIELD) != null) {
Item shield = equipment.reset(EquipmentConstants.SHIELD); Item shield = equipment.reset(EquipmentConstants.SHIELD);
inventory.add(shield); inventory.add(shield);
} }
} }
// check if a shield is being added with a two handed weapon // check if a shield is being added with a two handed weapon
boolean removeWeapon = false; boolean removeWeapon = false;
@@ -5,42 +5,31 @@ import org.apollo.game.event.handler.EventHandlerContext;
import org.apollo.game.event.impl.ItemActionEvent; import org.apollo.game.event.impl.ItemActionEvent;
import org.apollo.game.model.Inventory; import org.apollo.game.model.Inventory;
import org.apollo.game.model.Item; import org.apollo.game.model.Item;
import org.apollo.game.model.Player; import org.apollo.game.model.def.ItemDefinition;
import org.apollo.game.model.inv.SynchronizationInventoryListener; import org.apollo.game.model.inv.SynchronizationInventoryListener;
import org.apollo.game.model.Player;
/** /**
* An event handler which removes equipped items. * An event handler which removes equipped items.
* *
* @author Graham * @author Graham
* @author Major
*/ */
public final class RemoveEventHandler extends EventHandler<ItemActionEvent> { public final class RemoveEventHandler extends EventHandler<ItemActionEvent> {
@Override @Override
public void handle(EventHandlerContext ctx, Player player, public void handle(EventHandlerContext ctx, Player player, ItemActionEvent event) {
ItemActionEvent event) {
if (event.getOption() == 1 if (event.getOption() == 1 && event.getInterfaceId() == SynchronizationInventoryListener.EQUIPMENT_ID) {
&& event.getInterfaceId() == SynchronizationInventoryListener.EQUIPMENT_ID) {
Inventory inventory = player.getInventory(); Inventory inventory = player.getInventory();
Inventory equipment = player.getEquipment(); Inventory equipment = player.getEquipment();
if (inventory.freeSlots() < 1) { // TODO what if the item is
// stackable and the player has
// the item in his inventory
// already.
inventory.forceCapacityExceeded();
ctx.breakHandlerChain();
return;
}
int slot = event.getSlot(); int slot = event.getSlot();
if (slot < 0 || slot >= equipment.capacity()) {
ctx.breakHandlerChain();
return;
}
Item item = equipment.get(slot); Item item = equipment.get(slot);
if (item == null || item.getId() != event.getId()) { int id = item.getId();
if (inventory.freeSlots() == 0 && !ItemDefinition.forId(id).isStackable()) {
inventory.forceCapacityExceeded();
ctx.breakHandlerChain(); ctx.breakHandlerChain();
return; return;
} }
@@ -51,22 +40,17 @@ public final class RemoveEventHandler extends EventHandler<ItemActionEvent> {
equipment.stopFiringEvents(); equipment.stopFiringEvents();
try { try {
equipment.set(slot, null); int remaining = inventory.add(id, item.getAmount());
Item copy = item; removed = remaining == 0;
inventory.add(item.getId(), item.getAmount()); equipment.set(slot, removed ? null : new Item(id, remaining));
if (copy != null) {
removed = false;
equipment.set(slot, copy);
}
} finally { } finally {
inventory.startFiringEvents(); inventory.startFiringEvents();
equipment.startFiringEvents(); equipment.startFiringEvents();
} }
if (removed) { if (removed) {
inventory.forceRefresh(); // TODO find out the specific slot inventory.forceRefresh();
// that got used? equipment.forceRefresh(slot);
equipment.forceRefresh();
} else { } else {
inventory.forceCapacityExceeded(); inventory.forceCapacityExceeded();
} }
@@ -9,8 +9,9 @@ import org.apollo.game.model.inter.bank.BankConstants;
import org.apollo.game.model.inv.SynchronizationInventoryListener; import org.apollo.game.model.inv.SynchronizationInventoryListener;
/** /**
* An {@link EventHandler} which updates an {@link Inventory} when the client * An {@link EventHandler} which updates an {@link Inventory} when the client sends a {@link SwitchItemEvent} to the
* sends a {@link SwitchItemEvent} to the server. * server.
*
* @author Graham * @author Graham
*/ */
public final class SwitchItemEventHandler extends EventHandler<SwitchItemEvent> { public final class SwitchItemEventHandler extends EventHandler<SwitchItemEvent> {
@@ -37,7 +38,8 @@ public final class SwitchItemEventHandler extends EventHandler<SwitchItemEvent>
return; // not a known inventory, ignore return; // not a known inventory, ignore
} }
if (event.getOldSlot() >= 0 && event.getNewSlot() >= 0 && event.getOldSlot() < inventory.capacity() && event.getNewSlot() < inventory.capacity()) { if (event.getOldSlot() >= 0 && event.getNewSlot() >= 0 && event.getOldSlot() < inventory.capacity()
&& event.getNewSlot() < inventory.capacity()) {
// events must be fired for it to work if a sidebar inv overlay is used // events must be fired for it to work if a sidebar inv overlay is used
inventory.swap(insertPermitted ? event.isInserting() : false, event.getOldSlot(), event.getNewSlot()); inventory.swap(insertPermitted ? event.isInserting() : false, event.getOldSlot(), event.getNewSlot());
} }
@@ -9,6 +9,7 @@ import org.apollo.game.model.WalkingQueue;
/** /**
* A handler for the {@link WalkEvent}. * A handler for the {@link WalkEvent}.
*
* @author Graham * @author Graham
*/ */
public final class WalkEventHandler extends EventHandler<WalkEvent> { public final class WalkEventHandler extends EventHandler<WalkEvent> {
@@ -2,3 +2,4 @@
* Contains event handler implementations. * Contains event handler implementations.
*/ */
package org.apollo.game.event.handler.impl; package org.apollo.game.event.handler.impl;
@@ -2,3 +2,4 @@
* Contains classes which define abstract event handlers. * Contains classes which define abstract event handlers.
*/ */
package org.apollo.game.event.handler; package org.apollo.game.event.handler;
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event sent when the client clicks a button. * An event sent when the client clicks a button.
*
* @author Graham * @author Graham
*/ */
public final class ButtonEvent extends Event { public final class ButtonEvent extends Event {
@@ -15,6 +16,7 @@ public final class ButtonEvent extends Event {
/** /**
* Creates the button event. * Creates the button event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
*/ */
public ButtonEvent(int interfaceId) { public ButtonEvent(int interfaceId) {
@@ -23,6 +25,7 @@ public final class ButtonEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -4,8 +4,8 @@ import org.apollo.game.event.Event;
import org.apollo.game.model.Appearance; import org.apollo.game.model.Appearance;
/** /**
* An event sent by the client when the player modifies their character's * An event sent by the client when the player modifies their character's design.
* design. *
* @author Graham * @author Graham
*/ */
public final class CharacterDesignEvent extends Event { public final class CharacterDesignEvent extends Event {
@@ -17,6 +17,7 @@ public final class CharacterDesignEvent extends Event {
/** /**
* Creates the character design event. * Creates the character design event.
*
* @param appearance The appearance. * @param appearance The appearance.
*/ */
public CharacterDesignEvent(Appearance appearance) { public CharacterDesignEvent(Appearance appearance) {
@@ -25,6 +26,7 @@ public final class CharacterDesignEvent extends Event {
/** /**
* Gets the appearance. * Gets the appearance.
*
* @return The appearance. * @return The appearance.
*/ */
public Appearance getAppearance() { public Appearance getAppearance() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event sent by the client to send a public chat message to other players. * An event sent by the client to send a public chat message to other players.
*
* @author Graham * @author Graham
*/ */
public final class ChatEvent extends Event { public final class ChatEvent extends Event {
@@ -30,6 +31,7 @@ public final class ChatEvent extends Event {
/** /**
* Creates a new chat event. * Creates a new chat event.
*
* @param message The message. * @param message The message.
* @param compressedMessage The compressed message. * @param compressedMessage The compressed message.
* @param color The text color. * @param color The text color.
@@ -44,6 +46,7 @@ public final class ChatEvent extends Event {
/** /**
* Gets the message. * Gets the message.
*
* @return The message. * @return The message.
*/ */
public String getMessage() { public String getMessage() {
@@ -52,6 +55,7 @@ public final class ChatEvent extends Event {
/** /**
* Gets the text color. * Gets the text color.
*
* @return The text color. * @return The text color.
*/ */
public int getTextColor() { public int getTextColor() {
@@ -60,6 +64,7 @@ public final class ChatEvent extends Event {
/** /**
* Gets the text effects. * Gets the text effects.
*
* @return The text effects. * @return The text effects.
*/ */
public int getTextEffects() { public int getTextEffects() {
@@ -68,6 +73,7 @@ public final class ChatEvent extends Event {
/** /**
* Gets the compressed message. * Gets the compressed message.
*
* @return The compressed message. * @return The compressed message.
*/ */
public byte[] getCompressedMessage() { public byte[] getCompressedMessage() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event which closes the open interface. * An event which closes the open interface.
*
* @author Graham * @author Graham
*/ */
public final class CloseInterfaceEvent extends Event { public final class CloseInterfaceEvent extends Event {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* Sent by the client when the current interface is closed. * Sent by the client when the current interface is closed.
*
* @author Graham * @author Graham
*/ */
public final class ClosedInterfaceEvent extends Event { public final class ClosedInterfaceEvent extends Event {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event issued by the client to send a {@code ::} command/ * An event issued by the client to send a {@code ::} command/
*
* @author Graham * @author Graham
*/ */
public final class CommandEvent extends Event { public final class CommandEvent extends Event {
@@ -15,6 +16,7 @@ public final class CommandEvent extends Event {
/** /**
* Creates the command event. * Creates the command event.
*
* @param command The command. * @param command The command.
*/ */
public CommandEvent(String command) { public CommandEvent(String command) {
@@ -23,6 +25,7 @@ public final class CommandEvent extends Event {
/** /**
* Gets the command. * Gets the command.
*
* @return The command. * @return The command.
*/ */
public String getCommand() { public String getCommand() {
@@ -3,8 +3,8 @@ package org.apollo.game.event.impl;
import org.apollo.game.event.Event; import org.apollo.game.event.Event;
/** /**
* An {@link Event} which is sent to the client to open up the enter amount * An {@link Event} which is sent to the client to open up the enter amount interface.
* interface. *
* @author Graham * @author Graham
*/ */
public final class EnterAmountEvent extends Event { public final class EnterAmountEvent extends Event {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event sent by the client when the player has entered an amount. * An event sent by the client when the player has entered an amount.
*
* @author Graham * @author Graham
*/ */
public final class EnteredAmountEvent extends Event { public final class EnteredAmountEvent extends Event {
@@ -15,6 +16,7 @@ public final class EnteredAmountEvent extends Event {
/** /**
* Creates the entered amount event. * Creates the entered amount event.
*
* @param amount The amount. * @param amount The amount.
*/ */
public EnteredAmountEvent(int amount) { public EnteredAmountEvent(int amount) {
@@ -23,6 +25,7 @@ public final class EnteredAmountEvent extends Event {
/** /**
* Gets the amount. * Gets the amount.
*
* @return The amount. * @return The amount.
*/ */
public int getAmount() { public int getAmount() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event sent by the client to request that an item is equipped. * An event sent by the client to request that an item is equipped.
*
* @author Graham * @author Graham
*/ */
public final class EquipEvent extends Event { public final class EquipEvent extends Event {
@@ -25,6 +26,7 @@ public final class EquipEvent extends Event {
/** /**
* Creates the equip event. * Creates the equip event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param id The id. * @param id The id.
* @param slot The slot. * @param slot The slot.
@@ -37,6 +39,7 @@ public final class EquipEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -45,6 +48,7 @@ public final class EquipEvent extends Event {
/** /**
* Gets the item id. * Gets the item id.
*
* @return The item id. * @return The item id.
*/ */
public int getId() { public int getId() {
@@ -53,6 +57,7 @@ public final class EquipEvent extends Event {
/** /**
* Gets the slot. * Gets the slot.
*
* @return The slot. * @return The slot.
*/ */
public int getSlot() { public int getSlot() {
@@ -2,12 +2,14 @@ package org.apollo.game.event.impl;
/** /**
* The fifth {@link ItemActionEvent}. * The fifth {@link ItemActionEvent}.
*
* @author Graham * @author Graham
*/ */
public final class FifthItemActionEvent extends ItemActionEvent { public final class FifthItemActionEvent extends ItemActionEvent {
/** /**
* Creates the fifth item action event. * Creates the fifth item action event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param id The item id. * @param id The item id.
* @param slot The item slot. * @param slot The item slot.
@@ -2,12 +2,14 @@ package org.apollo.game.event.impl;
/** /**
* The first {@link ItemActionEvent}. * The first {@link ItemActionEvent}.
*
* @author Graham * @author Graham
*/ */
public final class FirstItemActionEvent extends ItemActionEvent { public final class FirstItemActionEvent extends ItemActionEvent {
/** /**
* Creates the first item action event. * Creates the first item action event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param id The item id. * @param id The item id.
* @param slot The item slot. * @param slot The item slot.
@@ -4,12 +4,14 @@ import org.apollo.game.model.Position;
/** /**
* An event sent when the first option at an object is used. * An event sent when the first option at an object is used.
*
* @author Graham * @author Graham
*/ */
public final class FirstObjectActionEvent extends ObjectActionEvent { public final class FirstObjectActionEvent extends ObjectActionEvent {
/** /**
* Creates the first object action event. * Creates the first object action event.
*
* @param id The id. * @param id The id.
* @param position The position. * @param position The position.
*/ */
@@ -2,12 +2,14 @@ package org.apollo.game.event.impl;
/** /**
* The fourth {@link ItemActionEvent}. * The fourth {@link ItemActionEvent}.
*
* @author Graham * @author Graham
*/ */
public final class FourthItemActionEvent extends ItemActionEvent { public final class FourthItemActionEvent extends ItemActionEvent {
/** /**
* Creates the fourth item action event. * Creates the fourth item action event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param id The item id. * @param id The item id.
* @param slot The item slot. * @param slot The item slot.
@@ -3,8 +3,8 @@ package org.apollo.game.event.impl;
import org.apollo.game.event.Event; import org.apollo.game.event.Event;
/** /**
* An event which specifies the local id and membership status of the current * An event which specifies the local id and membership status of the current player.
* player. *
* @author Graham * @author Graham
*/ */
public final class IdAssignmentEvent extends Event { public final class IdAssignmentEvent extends Event {
@@ -21,6 +21,7 @@ public final class IdAssignmentEvent extends Event {
/** /**
* Creates the local id event. * Creates the local id event.
*
* @param id The id. * @param id The id.
* @param members The membership flag. * @param members The membership flag.
*/ */
@@ -31,6 +32,7 @@ public final class IdAssignmentEvent extends Event {
/** /**
* Gets the id. * Gets the id.
*
* @return The id. * @return The id.
*/ */
public int getId() { public int getId() {
@@ -39,6 +41,7 @@ public final class IdAssignmentEvent extends Event {
/** /**
* Gets the membership flag. * Gets the membership flag.
*
* @return The membership flag. * @return The membership flag.
*/ */
public boolean isMembers() { public boolean isMembers() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An {@link Event} which represents some sort of action on an item. * An {@link Event} which represents some sort of action on an item.
*
* @author Graham * @author Graham
*/ */
public abstract class ItemActionEvent extends Event { public abstract class ItemActionEvent extends Event {
@@ -30,6 +31,7 @@ public abstract class ItemActionEvent extends Event {
/** /**
* Creates the item action event. * Creates the item action event.
*
* @param option The option number. * @param option The option number.
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param id The id. * @param id The id.
@@ -44,6 +46,7 @@ public abstract class ItemActionEvent extends Event {
/** /**
* Gets the option number. * Gets the option number.
*
* @return The option number. * @return The option number.
*/ */
public int getOption() { public int getOption() {
@@ -52,6 +55,7 @@ public abstract class ItemActionEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -60,6 +64,7 @@ public abstract class ItemActionEvent extends Event {
/** /**
* Gets the item id. * Gets the item id.
*
* @return The item id. * @return The item id.
*/ */
public int getId() { public int getId() {
@@ -68,6 +73,7 @@ public abstract class ItemActionEvent extends Event {
/** /**
* Gets the slot. * Gets the slot.
*
* @return The slot. * @return The slot.
*/ */
public int getSlot() { public int getSlot() {
@@ -3,8 +3,8 @@ package org.apollo.game.event.impl;
import org.apollo.game.event.Event; import org.apollo.game.event.Event;
/** /**
* An event which is periodically sent by the client to keep a connection * An event which is periodically sent by the client to keep a connection alive.
* alive. *
* @author Graham * @author Graham
*/ */
public final class KeepAliveEvent extends Event { public final class KeepAliveEvent extends Event {
@@ -23,6 +23,7 @@ public final class KeepAliveEvent extends Event {
/** /**
* Gets the time when this event was created. * Gets the time when this event was created.
*
* @return The time when this event was created. * @return The time when this event was created.
*/ */
public long getCreatedAt() { public long getCreatedAt() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event sent to the client which logs it out cleanly. * An event sent to the client which logs it out cleanly.
*
* @author Graham * @author Graham
*/ */
public final class LogoutEvent extends Event { public final class LogoutEvent extends Event {
@@ -5,6 +5,7 @@ import org.apollo.game.model.Position;
/** /**
* An {@link Event} which represents some sort of action at an object. * An {@link Event} which represents some sort of action at an object.
*
* @author Graham * @author Graham
*/ */
public abstract class ObjectActionEvent extends Event { public abstract class ObjectActionEvent extends Event {
@@ -26,6 +27,7 @@ public abstract class ObjectActionEvent extends Event {
/** /**
* Creates a new object action event. * Creates a new object action event.
*
* @param option The option number. * @param option The option number.
* @param id The id of the object. * @param id The id of the object.
* @param position The position of the object. * @param position The position of the object.
@@ -38,6 +40,7 @@ public abstract class ObjectActionEvent extends Event {
/** /**
* Gets the option number. * Gets the option number.
*
* @return The option number. * @return The option number.
*/ */
public int getOption() { public int getOption() {
@@ -46,6 +49,7 @@ public abstract class ObjectActionEvent extends Event {
/** /**
* Gets the id of the object. * Gets the id of the object.
*
* @return The id of the object. * @return The id of the object.
*/ */
public int getId() { public int getId() {
@@ -54,6 +58,7 @@ public abstract class ObjectActionEvent extends Event {
/** /**
* Gets the position of the object. * Gets the position of the object.
*
* @return The position of the object. * @return The position of the object.
*/ */
public Position getPosition() { public Position getPosition() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event which opens an interface. * An event which opens an interface.
*
* @author Graham * @author Graham
*/ */
public final class OpenInterfaceEvent extends Event { public final class OpenInterfaceEvent extends Event {
@@ -15,6 +16,7 @@ public final class OpenInterfaceEvent extends Event {
/** /**
* Creates the event with the specified interface id. * Creates the event with the specified interface id.
*
* @param id The interface id. * @param id The interface id.
*/ */
public OpenInterfaceEvent(int id) { public OpenInterfaceEvent(int id) {
@@ -23,6 +25,7 @@ public final class OpenInterfaceEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getId() { public int getId() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An {@link Event} sent to open an interface and temporary sidebar overlay. * An {@link Event} sent to open an interface and temporary sidebar overlay.
*
* @author Graham * @author Graham
*/ */
public final class OpenInterfaceSidebarEvent extends Event { public final class OpenInterfaceSidebarEvent extends Event {
@@ -20,6 +21,7 @@ public final class OpenInterfaceSidebarEvent extends Event {
/** /**
* Creates the open interface sidebar event. * Creates the open interface sidebar event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param sidebarId The sidebar id. * @param sidebarId The sidebar id.
*/ */
@@ -30,6 +32,7 @@ public final class OpenInterfaceSidebarEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -38,6 +41,7 @@ public final class OpenInterfaceSidebarEvent extends Event {
/** /**
* Gets the sidebar id. * Gets the sidebar id.
*
* @return The sidebar id. * @return The sidebar id.
*/ */
public int getSidebarId() { public int getSidebarId() {
@@ -8,6 +8,7 @@ import org.apollo.game.sync.seg.SynchronizationSegment;
/** /**
* An event which is sent to synchronize the players. * An event which is sent to synchronize the players.
*
* @author Graham * @author Graham
*/ */
public final class PlayerSynchronizationEvent extends Event { public final class PlayerSynchronizationEvent extends Event {
@@ -44,6 +45,7 @@ public final class PlayerSynchronizationEvent extends Event {
/** /**
* Creates the player synchronization event. * Creates the player synchronization event.
*
* @param lastKnownRegion The last known region. * @param lastKnownRegion The last known region.
* @param position The player's current position. * @param position The player's current position.
* @param regionChanged A flag indicating if the region has changed. * @param regionChanged A flag indicating if the region has changed.
@@ -51,7 +53,8 @@ public final class PlayerSynchronizationEvent extends Event {
* @param localPlayers The number of local players. * @param localPlayers The number of local players.
* @param segments A list of segments. * @param segments A list of segments.
*/ */
public PlayerSynchronizationEvent(Position lastKnownRegion, Position position, boolean regionChanged, SynchronizationSegment segment, int localPlayers, List<SynchronizationSegment> segments) { public PlayerSynchronizationEvent(Position lastKnownRegion, Position position, boolean regionChanged,
SynchronizationSegment segment, int localPlayers, List<SynchronizationSegment> segments) {
this.lastKnownRegion = lastKnownRegion; this.lastKnownRegion = lastKnownRegion;
this.position = position; this.position = position;
this.regionChanged = regionChanged; this.regionChanged = regionChanged;
@@ -62,6 +65,7 @@ public final class PlayerSynchronizationEvent extends Event {
/** /**
* Gets the last known region. * Gets the last known region.
*
* @return The last known region. * @return The last known region.
*/ */
public Position getLastKnownRegion() { public Position getLastKnownRegion() {
@@ -70,6 +74,7 @@ public final class PlayerSynchronizationEvent extends Event {
/** /**
* Gets the player's position. * Gets the player's position.
*
* @return The player's position. * @return The player's position.
*/ */
public Position getPosition() { public Position getPosition() {
@@ -78,6 +83,7 @@ public final class PlayerSynchronizationEvent extends Event {
/** /**
* Checks if the region has changed. * Checks if the region has changed.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean hasRegionChanged() { public boolean hasRegionChanged() {
@@ -86,6 +92,7 @@ public final class PlayerSynchronizationEvent extends Event {
/** /**
* Gets the current player's segment. * Gets the current player's segment.
*
* @return The current player's segment. * @return The current player's segment.
*/ */
public SynchronizationSegment getSegment() { public SynchronizationSegment getSegment() {
@@ -94,6 +101,7 @@ public final class PlayerSynchronizationEvent extends Event {
/** /**
* Gets the number of local players. * Gets the number of local players.
*
* @return The number of local players. * @return The number of local players.
*/ */
public int getLocalPlayers() { public int getLocalPlayers() {
@@ -102,6 +110,7 @@ public final class PlayerSynchronizationEvent extends Event {
/** /**
* Gets the synchronization segments. * Gets the synchronization segments.
*
* @return The segments. * @return The segments.
*/ */
public List<SynchronizationSegment> getSegments() { public List<SynchronizationSegment> getSegments() {
@@ -5,6 +5,7 @@ import org.apollo.game.model.Position;
/** /**
* An event which indicates that the client should load the specified region. * An event which indicates that the client should load the specified region.
*
* @author Graham * @author Graham
*/ */
public final class RegionChangeEvent extends Event { public final class RegionChangeEvent extends Event {
@@ -16,6 +17,7 @@ public final class RegionChangeEvent extends Event {
/** /**
* Creates the region changed event. * Creates the region changed event.
*
* @param position The position of the region. * @param position The position of the region.
*/ */
public RegionChangeEvent(Position position) { public RegionChangeEvent(Position position) {
@@ -24,6 +26,7 @@ public final class RegionChangeEvent extends Event {
/** /**
* Gets the position of the region to load. * Gets the position of the region to load.
*
* @return The position of the region to load. * @return The position of the region to load.
*/ */
public Position getPosition() { public Position getPosition() {
@@ -2,12 +2,14 @@ package org.apollo.game.event.impl;
/** /**
* The second {@link ItemActionEvent}. * The second {@link ItemActionEvent}.
*
* @author Graham * @author Graham
*/ */
public final class SecondItemActionEvent extends ItemActionEvent { public final class SecondItemActionEvent extends ItemActionEvent {
/** /**
* Creates the second item action event. * Creates the second item action event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param id The item id. * @param id The item id.
* @param slot The item slot. * @param slot The item slot.
@@ -4,12 +4,14 @@ import org.apollo.game.model.Position;
/** /**
* An event sent when the second option at an object is used. * An event sent when the second option at an object is used.
*
* @author Graham * @author Graham
*/ */
public final class SecondObjectActionEvent extends ObjectActionEvent { public final class SecondObjectActionEvent extends ObjectActionEvent {
/** /**
* Creates the second object action event. * Creates the second object action event.
*
* @param id The id. * @param id The id.
* @param position The position. * @param position The position.
*/ */
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event which is sent to the client with a server-side message. * An event which is sent to the client with a server-side message.
*
* @author Graham * @author Graham
*/ */
public final class ServerMessageEvent extends Event { public final class ServerMessageEvent extends Event {
@@ -15,6 +16,7 @@ public final class ServerMessageEvent extends Event {
/** /**
* Creates the {@link ServerMessageEvent}. * Creates the {@link ServerMessageEvent}.
*
* @param message The message. * @param message The message.
*/ */
public ServerMessageEvent(String message) { public ServerMessageEvent(String message) {
@@ -23,6 +25,7 @@ public final class ServerMessageEvent extends Event {
/** /**
* Gets the message. * Gets the message.
*
* @return The message. * @return The message.
*/ */
public String getMessage() { public String getMessage() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event sent to the client to update an interface's text. * An event sent to the client to update an interface's text.
*
* @author Graham * @author Graham
*/ */
public final class SetInterfaceTextEvent extends Event { public final class SetInterfaceTextEvent extends Event {
@@ -20,6 +21,7 @@ public final class SetInterfaceTextEvent extends Event {
/** /**
* Creates the set interface text event. * Creates the set interface text event.
*
* @param interfaceId The interface's id. * @param interfaceId The interface's id.
* @param text The interface's text. * @param text The interface's text.
*/ */
@@ -30,6 +32,7 @@ public final class SetInterfaceTextEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -38,6 +41,7 @@ public final class SetInterfaceTextEvent extends Event {
/** /**
* Gets the interface's text. * Gets the interface's text.
*
* @return The interface's text. * @return The interface's text.
*/ */
public String getText() { public String getText() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event sent by the client when two items are switched. * An event sent by the client when two items are switched.
*
* @author Graham * @author Graham
*/ */
public final class SwitchItemEvent extends Event { public final class SwitchItemEvent extends Event {
@@ -30,9 +31,9 @@ public final class SwitchItemEvent extends Event {
/** /**
* Creates a new switch item event. * Creates a new switch item event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param inserting A flag indicating if the interface is in 'insert' mode * @param inserting A flag indicating if the interface is in 'insert' mode instead of swap mode.
* instead of swap mode.
* @param oldSlot The old slot. * @param oldSlot The old slot.
* @param newSlot The new slot. * @param newSlot The new slot.
*/ */
@@ -45,6 +46,7 @@ public final class SwitchItemEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -53,6 +55,7 @@ public final class SwitchItemEvent extends Event {
/** /**
* Checks if this event is in insertion mode. * Checks if this event is in insertion mode.
*
* @return The insertion flag. * @return The insertion flag.
*/ */
public boolean isInserting() { public boolean isInserting() {
@@ -61,6 +64,7 @@ public final class SwitchItemEvent extends Event {
/** /**
* Checks if this event is in swap mode. * Checks if this event is in swap mode.
*
* @return The swap flag. * @return The swap flag.
*/ */
public boolean isSwapping() { public boolean isSwapping() {
@@ -69,6 +73,7 @@ public final class SwitchItemEvent extends Event {
/** /**
* Gets the old slot. * Gets the old slot.
*
* @return The old slot. * @return The old slot.
*/ */
public int getOldSlot() { public int getOldSlot() {
@@ -77,6 +82,7 @@ public final class SwitchItemEvent extends Event {
/** /**
* Gets the new slot. * Gets the new slot.
*
* @return The new slot. * @return The new slot.
*/ */
public int getNewSlot() { public int getNewSlot() {
@@ -4,6 +4,7 @@ import org.apollo.game.event.Event;
/** /**
* An event sent to the client to change the interface of a tab. * An event sent to the client to change the interface of a tab.
*
* @author Graham * @author Graham
*/ */
public final class SwitchTabInterfaceEvent extends Event { public final class SwitchTabInterfaceEvent extends Event {
@@ -20,6 +21,7 @@ public final class SwitchTabInterfaceEvent extends Event {
/** /**
* Creates the switch interface event. * Creates the switch interface event.
*
* @param tab The tab id. * @param tab The tab id.
* @param interfaceId The interface id. * @param interfaceId The interface id.
*/ */
@@ -30,6 +32,7 @@ public final class SwitchTabInterfaceEvent extends Event {
/** /**
* Gets the tab id. * Gets the tab id.
*
* @return The tab id. * @return The tab id.
*/ */
public int getTabId() { public int getTabId() {
@@ -38,6 +41,7 @@ public final class SwitchTabInterfaceEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -2,12 +2,14 @@ package org.apollo.game.event.impl;
/** /**
* The third {@link ItemActionEvent}. * The third {@link ItemActionEvent}.
*
* @author Graham * @author Graham
*/ */
public final class ThirdItemActionEvent extends ItemActionEvent { public final class ThirdItemActionEvent extends ItemActionEvent {
/** /**
* Creates the third item action event. * Creates the third item action event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param id The item id. * @param id The item id.
* @param slot The item slot. * @param slot The item slot.
@@ -4,12 +4,14 @@ import org.apollo.game.model.Position;
/** /**
* An event sent when the third option at an object is used. * An event sent when the third option at an object is used.
*
* @author Graham * @author Graham
*/ */
public final class ThirdObjectActionEvent extends ObjectActionEvent { public final class ThirdObjectActionEvent extends ObjectActionEvent {
/** /**
* Creates the third object action event. * Creates the third object action event.
*
* @param id The id. * @param id The id.
* @param position The position. * @param position The position.
*/ */
@@ -5,6 +5,7 @@ import org.apollo.game.model.Item;
/** /**
* An event which updates all the items in an interface. * An event which updates all the items in an interface.
*
* @author Graham * @author Graham
*/ */
public final class UpdateItemsEvent extends Event { public final class UpdateItemsEvent extends Event {
@@ -21,6 +22,7 @@ public final class UpdateItemsEvent extends Event {
/** /**
* Creates the update inventory interface event. * Creates the update inventory interface event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param items The items. * @param items The items.
*/ */
@@ -31,6 +33,7 @@ public final class UpdateItemsEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -39,6 +42,7 @@ public final class UpdateItemsEvent extends Event {
/** /**
* Gets the items. * Gets the items.
*
* @return The items. * @return The items.
*/ */
public Item[] getItems() { public Item[] getItems() {
@@ -5,6 +5,7 @@ import org.apollo.game.model.Skill;
/** /**
* An {@link Event} sent to the client to update a player's skill level. * An {@link Event} sent to the client to update a player's skill level.
*
* @author Graham * @author Graham
*/ */
public final class UpdateSkillEvent extends Event { public final class UpdateSkillEvent extends Event {
@@ -21,6 +22,7 @@ public final class UpdateSkillEvent extends Event {
/** /**
* Creates an update skill event. * Creates an update skill event.
*
* @param id The id. * @param id The id.
* @param skill The skill. * @param skill The skill.
*/ */
@@ -31,6 +33,7 @@ public final class UpdateSkillEvent extends Event {
/** /**
* Gets the skill's id. * Gets the skill's id.
*
* @return The skill's id. * @return The skill's id.
*/ */
public int getId() { public int getId() {
@@ -39,6 +42,7 @@ public final class UpdateSkillEvent extends Event {
/** /**
* Gets the skill. * Gets the skill.
*
* @return The skill. * @return The skill.
*/ */
public Skill getSkill() { public Skill getSkill() {
@@ -5,6 +5,7 @@ import org.apollo.game.model.SlottedItem;
/** /**
* An event which updates a single item in an interface. * An event which updates a single item in an interface.
*
* @author Graham * @author Graham
*/ */
public final class UpdateSlottedItemsEvent extends Event { public final class UpdateSlottedItemsEvent extends Event {
@@ -21,6 +22,7 @@ public final class UpdateSlottedItemsEvent extends Event {
/** /**
* Creates the update item in interface event. * Creates the update item in interface event.
*
* @param interfaceId The interface id. * @param interfaceId The interface id.
* @param items The slotted items. * @param items The slotted items.
*/ */
@@ -31,6 +33,7 @@ public final class UpdateSlottedItemsEvent extends Event {
/** /**
* Gets the interface id. * Gets the interface id.
*
* @return The interface id. * @return The interface id.
*/ */
public int getInterfaceId() { public int getInterfaceId() {
@@ -39,6 +42,7 @@ public final class UpdateSlottedItemsEvent extends Event {
/** /**
* Gets an array of slotted items. * Gets an array of slotted items.
*
* @return The slotted items. * @return The slotted items.
*/ */
public SlottedItem[] getSlottedItems() { public SlottedItem[] getSlottedItems() {
@@ -5,6 +5,7 @@ import org.apollo.game.model.Position;
/** /**
* An event which the client sends to request that the player walks somewhere. * An event which the client sends to request that the player walks somewhere.
*
* @author Graham * @author Graham
*/ */
public final class WalkEvent extends Event { public final class WalkEvent extends Event {
@@ -21,6 +22,7 @@ public final class WalkEvent extends Event {
/** /**
* Creates the event. * Creates the event.
*
* @param steps The steps array. * @param steps The steps array.
* @param run The run flag. * @param run The run flag.
*/ */
@@ -34,6 +36,7 @@ public final class WalkEvent extends Event {
/** /**
* Gets the steps array. * Gets the steps array.
*
* @return An array of steps. * @return An array of steps.
*/ */
public Position[] getSteps() { public Position[] getSteps() {
@@ -42,6 +45,7 @@ public final class WalkEvent extends Event {
/** /**
* Checks if the steps should be ran (ctrl+click). * Checks if the steps should be ran (ctrl+click).
*
* @return {@code true} if so, {@code false} otherwise. * @return {@code true} if so, {@code false} otherwise.
*/ */
public boolean isRunning() { public boolean isRunning() {
@@ -2,3 +2,4 @@
* Contains event implementations. * Contains event implementations.
*/ */
package org.apollo.game.event.impl; package org.apollo.game.event.impl;
@@ -2,3 +2,4 @@
* Contains classes related to the event management in the game. * Contains classes related to the event management in the game.
*/ */
package org.apollo.game.event; package org.apollo.game.event;
+6 -1
View File
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Represents an animation. * Represents an animation.
*
* @author Graham * @author Graham
*/ */
public final class Animation { public final class Animation {
@@ -77,7 +78,7 @@ public final class Animation {
public static final Animation PANIC = new Animation(2105); public static final Animation PANIC = new Animation(2105);
/** /**
* The jig animation. * The jig animation.
*/ */
public static final Animation JIG = new Animation(2106); public static final Animation JIG = new Animation(2106);
@@ -163,6 +164,7 @@ public final class Animation {
/** /**
* Creates a new animation with no delay. * Creates a new animation with no delay.
*
* @param id The id. * @param id The id.
*/ */
public Animation(int id) { public Animation(int id) {
@@ -171,6 +173,7 @@ public final class Animation {
/** /**
* Creates a new animation. * Creates a new animation.
*
* @param id The id. * @param id The id.
* @param delay The delay. * @param delay The delay.
*/ */
@@ -181,6 +184,7 @@ public final class Animation {
/** /**
* Gets the animation's id. * Gets the animation's id.
*
* @return The animation's id. * @return The animation's id.
*/ */
public int getId() { public int getId() {
@@ -189,6 +193,7 @@ public final class Animation {
/** /**
* Gets the animation's delay. * Gets the animation's delay.
*
* @return The animation's delay. * @return The animation's delay.
*/ */
public int getDelay() { public int getDelay() {
+11 -9
View File
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Represents the appearance of a player. * Represents the appearance of a player.
*
* @author Graham * @author Graham
*/ */
public final class Appearance { public final class Appearance {
@@ -9,7 +10,8 @@ public final class Appearance {
/** /**
* The default appearance. * The default appearance.
*/ */
public static final Appearance DEFAULT_APPEARANCE = new Appearance(Gender.MALE, new int[] { 0, 10, 18, 26, 33, 36, 42 }, new int[5]); public static final Appearance DEFAULT_APPEARANCE = new Appearance(Gender.MALE, new int[] { 0, 10, 18, 26, 33, 36,
42 }, new int[5]);
/** /**
* The player's gender. * The player's gender.
@@ -28,6 +30,7 @@ public final class Appearance {
/** /**
* Creates the appearance with the specified gender, style and colors. * Creates the appearance with the specified gender, style and colors.
*
* @param gender The gender. * @param gender The gender.
* @param style The style. * @param style The style.
* @param colors The colors. * @param colors The colors.
@@ -49,6 +52,7 @@ public final class Appearance {
/** /**
* Gets the gender of the player. * Gets the gender of the player.
*
* @return The gender of the player. * @return The gender of the player.
*/ */
public Gender getGender() { public Gender getGender() {
@@ -57,6 +61,7 @@ public final class Appearance {
/** /**
* Checks if the player is male. * Checks if the player is male.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean isMale() { public boolean isMale() {
@@ -65,6 +70,7 @@ public final class Appearance {
/** /**
* Checks if the player is female. * Checks if the player is female.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean isFemale() { public boolean isFemale() {
@@ -73,25 +79,21 @@ public final class Appearance {
/** /**
* Gets the player's styles. * Gets the player's styles.
*
* @return The player's styles. * @return The player's styles.
*/ */
public int[] getStyle() { public int[] getStyle() {
/* /*
* Info on the elements of the array itself: * Info on the elements of the array itself:
* *
* 0 = head * 0 = head 1 = chin/beard 2 = chest 3 = arms 4 = hands 5 = legs 6 = feet
* 1 = chin/beard
* 2 = chest
* 3 = arms
* 4 = hands
* 5 = legs
* 6 = feet
*/ */
return style; return style;
} }
/** /**
* Gets the player's colors. * Gets the player's colors.
*
* @return The player's colors. * @return The player's colors.
*/ */
public int[] getColors() { public int[] getColors() {
+34 -12
View File
@@ -13,15 +13,14 @@ import org.apollo.game.sync.block.SynchronizationBlockSet;
import org.apollo.util.CharacterRepository; import org.apollo.util.CharacterRepository;
/** /**
* A {@link Character} is a living creature in the world, such as a player or * A {@link Character} is a living creature in the world, such as a player or NPC.
* NPC. *
* @author Graham * @author Graham
*/ */
public abstract class Character { public abstract class Character {
/** /**
* The index of this character in the {@link CharacterRepository} it * The index of this character in the {@link CharacterRepository} it belongs to.
* belongs to.
*/ */
private int index = -1; private int index = -1;
@@ -87,6 +86,7 @@ public abstract class Character {
/** /**
* Creates a new character with the specified initial position. * Creates a new character with the specified initial position.
*
* @param position The initial position of this character. * @param position The initial position of this character.
*/ */
public Character(Position position) { public Character(Position position) {
@@ -103,6 +103,7 @@ public abstract class Character {
/** /**
* Gets the character's inventory. * Gets the character's inventory.
*
* @return The character's inventory. * @return The character's inventory.
*/ */
public Inventory getInventory() { public Inventory getInventory() {
@@ -111,6 +112,7 @@ public abstract class Character {
/** /**
* Gets the character's equipment. * Gets the character's equipment.
*
* @return The character's equipment. * @return The character's equipment.
*/ */
public Inventory getEquipment() { public Inventory getEquipment() {
@@ -119,6 +121,7 @@ public abstract class Character {
/** /**
* Gets the character's bank. * Gets the character's bank.
*
* @return The character's bank. * @return The character's bank.
*/ */
public Inventory getBank() { public Inventory getBank() {
@@ -127,6 +130,7 @@ public abstract class Character {
/** /**
* Gets the local player list. * Gets the local player list.
*
* @return The local player list. * @return The local player list.
*/ */
public List<Player> getLocalPlayerList() { public List<Player> getLocalPlayerList() {
@@ -135,6 +139,7 @@ public abstract class Character {
/** /**
* Checks if this player is currently teleporting. * Checks if this player is currently teleporting.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean isTeleporting() { public boolean isTeleporting() {
@@ -143,8 +148,8 @@ public abstract class Character {
/** /**
* Sets the teleporting flag. * Sets the teleporting flag.
* @param teleporting {@code true} if the player is teleporting, *
* {@code false} if not. * @param teleporting {@code true} if the player is teleporting, {@code false} if not.
*/ */
public void setTeleporting(boolean teleporting) { public void setTeleporting(boolean teleporting) {
this.teleporting = teleporting; this.teleporting = teleporting;
@@ -152,6 +157,7 @@ public abstract class Character {
/** /**
* Gets the walking queue. * Gets the walking queue.
*
* @return The walking queue. * @return The walking queue.
*/ */
public WalkingQueue getWalkingQueue() { public WalkingQueue getWalkingQueue() {
@@ -160,6 +166,7 @@ public abstract class Character {
/** /**
* Sets the next directions for this character. * Sets the next directions for this character.
*
* @param first The first direction. * @param first The first direction.
* @param second The second direction. * @param second The second direction.
*/ */
@@ -170,6 +177,7 @@ public abstract class Character {
/** /**
* Gets the first direction. * Gets the first direction.
*
* @return The first direction. * @return The first direction.
*/ */
public Direction getFirstDirection() { public Direction getFirstDirection() {
@@ -178,6 +186,7 @@ public abstract class Character {
/** /**
* Gets the second direction. * Gets the second direction.
*
* @return The second direction. * @return The second direction.
*/ */
public Direction getSecondDirection() { public Direction getSecondDirection() {
@@ -186,8 +195,8 @@ public abstract class Character {
/** /**
* Gets the directions as an array. * Gets the directions as an array.
* @return A zero, one or two element array containing the directions (in *
* order). * @return A zero, one or two element array containing the directions (in order).
*/ */
public Direction[] getDirections() { public Direction[] getDirections() {
if (firstDirection != Direction.NONE) { if (firstDirection != Direction.NONE) {
@@ -203,6 +212,7 @@ public abstract class Character {
/** /**
* Gets the position of this character. * Gets the position of this character.
*
* @return The position of this character. * @return The position of this character.
*/ */
public Position getPosition() { public Position getPosition() {
@@ -211,6 +221,7 @@ public abstract class Character {
/** /**
* Sets the position of this character. * Sets the position of this character.
*
* @param position The position of this character. * @param position The position of this character.
*/ */
public void setPosition(Position position) { public void setPosition(Position position) {
@@ -219,6 +230,7 @@ public abstract class Character {
/** /**
* Checks if this character is active. * Checks if this character is active.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean isActive() { public boolean isActive() {
@@ -227,6 +239,7 @@ public abstract class Character {
/** /**
* Gets the index of this character. * Gets the index of this character.
*
* @return The index of this character. * @return The index of this character.
*/ */
public int getIndex() { public int getIndex() {
@@ -237,6 +250,7 @@ public abstract class Character {
/** /**
* Sets the index of this character. * Sets the index of this character.
*
* @param index The index of this character. * @param index The index of this character.
*/ */
public void setIndex(int index) { public void setIndex(int index) {
@@ -247,6 +261,7 @@ public abstract class Character {
/** /**
* Gets the {@link SynchronizationBlockSet}. * Gets the {@link SynchronizationBlockSet}.
*
* @return The block set. * @return The block set.
*/ */
public SynchronizationBlockSet getBlockSet() { public SynchronizationBlockSet getBlockSet() {
@@ -263,16 +278,17 @@ public abstract class Character {
/** /**
* Sends an {@link Event} to either: * Sends an {@link Event} to either:
* <ul> * <ul>
* <li>The client if this {@link Character} is a {@link Player}.</li> * <li>The client if this {@link Character} is a {@link Player}.</li>
* <li>The AI routines if this {@link Character} is an NPC</li> * <li>The AI routines if this {@link Character} is an NPC</li>
* </ul> * </ul>
*
* @param event The event. * @param event The event.
*/ */
public abstract void send(Event event); public abstract void send(Event event);
/** /**
* Teleports this character to the specified position, setting the * Teleports this character to the specified position, setting the appropriate flags and clearing the walking queue.
* appropriate flags and clearing the walking queue. *
* @param position The position. * @param position The position.
*/ */
public void teleport(Position position) { public void teleport(Position position) {
@@ -284,6 +300,7 @@ public abstract class Character {
/** /**
* Plays the specified animation. * Plays the specified animation.
*
* @param animation The animation. * @param animation The animation.
*/ */
public void playAnimation(Animation animation) { public void playAnimation(Animation animation) {
@@ -299,6 +316,7 @@ public abstract class Character {
/** /**
* Plays the specified graphic. * Plays the specified graphic.
*
* @param graphic The graphic. * @param graphic The graphic.
*/ */
public void playGraphic(Graphic graphic) { public void playGraphic(Graphic graphic) {
@@ -314,6 +332,7 @@ public abstract class Character {
/** /**
* Gets the character's skill set. * Gets the character's skill set.
*
* @return The character's skill set. * @return The character's skill set.
*/ */
public SkillSet getSkillSet() { public SkillSet getSkillSet() {
@@ -322,6 +341,7 @@ public abstract class Character {
/** /**
* Starts a new action, stopping the current one if it exists. * Starts a new action, stopping the current one if it exists.
*
* @param action The new action. * @param action The new action.
* @return A flag indicating if the action was started. * @return A flag indicating if the action was started.
*/ */
@@ -349,6 +369,7 @@ public abstract class Character {
/** /**
* Turns the character to face the specified position. * Turns the character to face the specified position.
*
* @param position The position to face. * @param position The position to face.
*/ */
public void turnTo(Position position) { public void turnTo(Position position) {
@@ -357,6 +378,7 @@ public abstract class Character {
/** /**
* Sends a message to the character. * Sends a message to the character.
*
* @param message The message. * @param message The message.
*/ */
public void sendMessage(String message) { public void sendMessage(String message) {
+7 -2
View File
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Represents a single movement direction. * Represents a single movement direction.
*
* @author Graham * @author Graham
*/ */
public enum Direction { public enum Direction {
@@ -57,8 +58,9 @@ public enum Direction {
public static final Direction[] EMPTY_DIRECTION_ARRAY = new Direction[0]; public static final Direction[] EMPTY_DIRECTION_ARRAY = new Direction[0];
/** /**
* Checks if the direction represented by the two delta values can connect * Checks if the direction represented by the two delta values can connect two points together in a single
* two points together in a single direction. * direction.
*
* @param deltaX The difference in X coordinates. * @param deltaX The difference in X coordinates.
* @param deltaY The difference in X coordinates. * @param deltaY The difference in X coordinates.
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
@@ -69,6 +71,7 @@ public enum Direction {
/** /**
* Creates a direction from the differences between X and Y. * Creates a direction from the differences between X and Y.
*
* @param deltaX The difference between two X coordinates. * @param deltaX The difference between two X coordinates.
* @param deltaY The difference between two Y coordinates. * @param deltaY The difference between two Y coordinates.
* @return The direction. * @return The direction.
@@ -107,6 +110,7 @@ public enum Direction {
/** /**
* Creates the direction. * Creates the direction.
*
* @param intValue The direction as an integer. * @param intValue The direction as an integer.
*/ */
private Direction(int intValue) { private Direction(int intValue) {
@@ -115,6 +119,7 @@ public enum Direction {
/** /**
* Gets the direction as an integer which the client can understand. * Gets the direction as an integer which the client can understand.
*
* @return The movement as an integer. * @return The movement as an integer.
*/ */
public int toInteger() { public int toInteger() {
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Contains equipment-related constants. * Contains equipment-related constants.
*
* @author Graham * @author Graham
*/ */
public final class EquipmentConstants { public final class EquipmentConstants {
+3
View File
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* An enumeration containing the two genders (male and female). * An enumeration containing the two genders (male and female).
*
* @author Graham * @author Graham
*/ */
public enum Gender { public enum Gender {
@@ -23,6 +24,7 @@ public enum Gender {
/** /**
* Creates the gender. * Creates the gender.
*
* @param intValue The integer representation. * @param intValue The integer representation.
*/ */
private Gender(int intValue) { private Gender(int intValue) {
@@ -31,6 +33,7 @@ public enum Gender {
/** /**
* Converts this gender to an integer. * Converts this gender to an integer.
*
* @return The integer representation used by the client. * @return The integer representation used by the client.
*/ */
public int toInteger() { public int toInteger() {
+7
View File
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Represents a 'still graphic'. * Represents a 'still graphic'.
*
* @author Graham * @author Graham
*/ */
public final class Graphic { public final class Graphic {
@@ -28,6 +29,7 @@ public final class Graphic {
/** /**
* Creates a new graphic with no delay and a height of zero. * Creates a new graphic with no delay and a height of zero.
*
* @param id The id. * @param id The id.
*/ */
public Graphic(int id) { public Graphic(int id) {
@@ -36,6 +38,7 @@ public final class Graphic {
/** /**
* Creates a new graphic with a height of zero. * Creates a new graphic with a height of zero.
*
* @param id The id. * @param id The id.
* @param delay The delay. * @param delay The delay.
*/ */
@@ -45,6 +48,7 @@ public final class Graphic {
/** /**
* Creates a new graphic. * Creates a new graphic.
*
* @param id The id. * @param id The id.
* @param delay The delay. * @param delay The delay.
* @param height The height. * @param height The height.
@@ -57,6 +61,7 @@ public final class Graphic {
/** /**
* Gets the graphic's id. * Gets the graphic's id.
*
* @return The graphic's id. * @return The graphic's id.
*/ */
public int getId() { public int getId() {
@@ -65,6 +70,7 @@ public final class Graphic {
/** /**
* Gets the graphic's delay. * Gets the graphic's delay.
*
* @return The graphic's delay. * @return The graphic's delay.
*/ */
public int getDelay() { public int getDelay() {
@@ -73,6 +79,7 @@ public final class Graphic {
/** /**
* Gets the graphic's height. * Gets the graphic's height.
*
* @return The graphic's height. * @return The graphic's height.
*/ */
public int getHeight() { public int getHeight() {
+21 -20
View File
@@ -13,25 +13,20 @@ import org.apollo.game.model.inter.InterfaceListener;
/** /**
* Represents the set of interfaces the player has open. * Represents the set of interfaces the player has open.
* <p> * <p>
* This class manages all six distinct types of interface (the last two are not * This class manages all six distinct types of interface (the last two are not present on 317 servers).
* present on 317 servers).
* <p> * <p>
* <ul> * <ul>
* <li><strong>Windows:</strong> the ones people mostly associate with the * <li><strong>Windows:</strong> the ones people mostly associate with the word interfaces. Things like your bank, the
* word interfaces. Things like your bank, the wildy warning screen, the * wildy warning screen, the trade screen, etc.</li>
* trade screen, etc.</li> * <li><strong>Overlays:</strong> display in the same place as windows, but don't prevent you from moving. For example,
* <li><strong>Overlays:</strong> display in the same place as windows, but * the wilderness level indicator.</li>
* don't prevent you from moving. For example, the wilderness level * <li><strong>Dialogues:</strong> interfaces which are displayed over the chat box.</li>
* indicator.</li> * <li><strong>Sidebars:</strong> an interface which displays over the inventory area.</li>
* <li><strong>Dialogues:</strong> interfaces which are displayed over the * <li><strong>Fullscreen windows:</strong> a window which displays over the whole screen e.g. the 377 welcome screen.</li>
* chat box.</li> * <li><strong>Fullscreen background:</strong> an interface displayed behind the fullscreen window, typically a blank,
* <li><strong>Sidebars:</strong> an interface which displays over the * black screen.</li>
* inventory area.</li>
* <li><strong>Fullscreen windows:</strong> a window which displays over the
* whole screen e.g. the 377 welcome screen.</li>
* <li><strong>Fullscreen background:</strong> an interface displayed behind
* the fullscreen window, typically a blank, black screen.</li>
* </ul> * </ul>
*
* @author Graham * @author Graham
*/ */
public final class InterfaceSet { public final class InterfaceSet {
@@ -59,6 +54,7 @@ public final class InterfaceSet {
/** /**
* Creates an interface set. * Creates an interface set.
*
* @param player The player. * @param player The player.
*/ */
public InterfaceSet(Player player) { public InterfaceSet(Player player) {
@@ -83,6 +79,7 @@ public final class InterfaceSet {
/** /**
* Opens the enter amount dialog. * Opens the enter amount dialog.
*
* @param listener The enter amount listener. * @param listener The enter amount listener.
*/ */
public void openEnterAmountDialog(EnterAmountListener listener) { public void openEnterAmountDialog(EnterAmountListener listener) {
@@ -93,6 +90,7 @@ public final class InterfaceSet {
/** /**
* Opens a window and inventory sidebar. * Opens a window and inventory sidebar.
*
* @param windowId The window's id. * @param windowId The window's id.
* @param sidebarId The sidebar's id. * @param sidebarId The sidebar's id.
*/ */
@@ -102,6 +100,7 @@ public final class InterfaceSet {
/** /**
* Opens a window and inventory sidebar with the specified listener. * Opens a window and inventory sidebar with the specified listener.
*
* @param listener The listener for this interface. * @param listener The listener for this interface.
* @param windowId The window's id. * @param windowId The window's id.
* @param sidebarId The sidebar's id. * @param sidebarId The sidebar's id.
@@ -118,6 +117,7 @@ public final class InterfaceSet {
/** /**
* Opens a window. * Opens a window.
*
* @param windowId The window's id. * @param windowId The window's id.
*/ */
public void openWindow(int windowId) { public void openWindow(int windowId) {
@@ -126,6 +126,7 @@ public final class InterfaceSet {
/** /**
* Opens a window with the specified listener. * Opens a window with the specified listener.
*
* @param listener The listener for this interface. * @param listener The listener for this interface.
* @param windowId The window's id. * @param windowId The window's id.
*/ */
@@ -140,6 +141,7 @@ public final class InterfaceSet {
/** /**
* Checks if this interface sets contains the specified interface. * Checks if this interface sets contains the specified interface.
*
* @param id The interface's id. * @param id The interface's id.
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
@@ -148,8 +150,7 @@ public final class InterfaceSet {
} }
/** /**
* An internal method for closing the interface, notifying the listener if * An internal method for closing the interface, notifying the listener if appropriate, but not sending any events.
* appropriate, but not sending any events.
*/ */
private void closeAndNotify() { private void closeAndNotify() {
amountListener = null; // TODO should we notify?? amountListener = null; // TODO should we notify??
@@ -162,8 +163,8 @@ public final class InterfaceSet {
} }
/** /**
* Called when the client has entered the specified amount. Notifies the * Called when the client has entered the specified amount. Notifies the current listener.
* current listener. *
* @param amount The amount. * @param amount The amount.
*/ */
public void enteredAmount(int amount) { public void enteredAmount(int amount) {
+3 -2
View File
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Represents the different types of interfaces. * Represents the different types of interfaces.
*
* @author Graham * @author Graham
*/ */
public enum InterfaceType { public enum InterfaceType {
@@ -12,8 +13,8 @@ public enum InterfaceType {
WINDOW, WINDOW,
/** /**
* An overlay is an interface which occupies the game screen like a window, * An overlay is an interface which occupies the game screen like a window, however, you can walk around and perform
* however, you can walk around and perform actions still. * actions still.
*/ */
OVERLAY, OVERLAY,
+46 -31
View File
@@ -8,32 +8,32 @@ import org.apollo.game.model.inv.InventoryListener;
/** /**
* Represents an inventory - a collection of {@link Item}s. * Represents an inventory - a collection of {@link Item}s.
*
* @author Graham * @author Graham
*/ */
public final class Inventory implements Cloneable { public final class Inventory implements Cloneable {
/** /**
* An enumeration containing the different 'stacking modes' of an * An enumeration containing the different 'stacking modes' of an {@link Inventory}.
* {@link Inventory}. *
* @author Graham * @author Graham
*/ */
public enum StackMode { public enum StackMode {
/** /**
* When in {@link #STACK_ALWAYS} mode, an {@link Inventory} will stack * When in {@link #STACK_ALWAYS} mode, an {@link Inventory} will stack every single item, regardless of the
* every single item, regardless of the settings of individual items. * settings of individual items.
*/ */
STACK_ALWAYS, STACK_ALWAYS,
/** /**
* When in {@link #STACK_STACKABLE_ITEMS} mode, an {@link Inventory} * When in {@link #STACK_STACKABLE_ITEMS} mode, an {@link Inventory} will stack items depending on their
* will stack items depending on their settings. * settings.
*/ */
STACK_STACKABLE_ITEMS, STACK_STACKABLE_ITEMS,
/** /**
* When in {@link #STACK_NEVER} mode, an {@link Inventory} will never * When in {@link #STACK_NEVER} mode, an {@link Inventory} will never stack items.
* stack items.
*/ */
STACK_NEVER; STACK_NEVER;
@@ -71,6 +71,7 @@ public final class Inventory implements Cloneable {
/** /**
* Creates an inventory. * Creates an inventory.
*
* @param capacity The capacity. * @param capacity The capacity.
* @throws IllegalArgumentException if the capacity is negative. * @throws IllegalArgumentException if the capacity is negative.
*/ */
@@ -80,6 +81,7 @@ public final class Inventory implements Cloneable {
/** /**
* Creates an inventory. * Creates an inventory.
*
* @param capacity The capacity. * @param capacity The capacity.
* @param mode The stacking mode. * @param mode The stacking mode.
* @throws IllegalArgumentException if the capacity is negative. * @throws IllegalArgumentException if the capacity is negative.
@@ -98,9 +100,8 @@ public final class Inventory implements Cloneable {
} }
/** /**
* Creates a copy of this inventory. Listeners are not copied, they must be * Creates a copy of this inventory. Listeners are not copied, they must be added again yourself! This is so cloned
* added again yourself! This is so cloned copies don't send updates to * copies don't send updates to their counterparts.
* their counterparts.
*/ */
@Override @Override
public Inventory clone() { public Inventory clone() {
@@ -112,6 +113,7 @@ public final class Inventory implements Cloneable {
/** /**
* Checks if this inventory contains an item with the specified id. * Checks if this inventory contains an item with the specified id.
*
* @param id The item's id. * @param id The item's id.
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
@@ -127,6 +129,7 @@ public final class Inventory implements Cloneable {
/** /**
* Gets the number of free slots. * Gets the number of free slots.
*
* @return The number of free slots. * @return The number of free slots.
*/ */
public int freeSlots() { public int freeSlots() {
@@ -144,6 +147,7 @@ public final class Inventory implements Cloneable {
/** /**
* Gets the capacity of this inventory. * Gets the capacity of this inventory.
*
* @return The capacity. * @return The capacity.
*/ */
public int capacity() { public int capacity() {
@@ -152,6 +156,7 @@ public final class Inventory implements Cloneable {
/** /**
* Gets the size of this inventory - the number of used slots. * Gets the size of this inventory - the number of used slots.
*
* @return The size. * @return The size.
*/ */
public int size() { public int size() {
@@ -160,6 +165,7 @@ public final class Inventory implements Cloneable {
/** /**
* Gets the item in the specified slot. * Gets the item in the specified slot.
*
* @param slot The slot. * @param slot The slot.
* @return The item, or {@code null} if the slot is empty. * @return The item, or {@code null} if the slot is empty.
* @throws IndexOutOfBoundsException if the slot is out of bounds. * @throws IndexOutOfBoundsException if the slot is out of bounds.
@@ -171,9 +177,9 @@ public final class Inventory implements Cloneable {
/** /**
* Sets the item that is in the specified slot. * Sets the item that is in the specified slot.
*
* @param slot The slot. * @param slot The slot.
* @param item The item, or {@code null} to remove the item that is in the * @param item The item, or {@code null} to remove the item that is in the slot.
* slot.
* @return The item that was in the slot. * @return The item that was in the slot.
* @throws IndexOutOfBoundsException if the slot is out of bounds. * @throws IndexOutOfBoundsException if the slot is out of bounds.
*/ */
@@ -194,6 +200,7 @@ public final class Inventory implements Cloneable {
/** /**
* Removes the item (if any) that is in the specified slot. * Removes the item (if any) that is in the specified slot.
*
* @param slot * @param slot
* @return The item that was in the slot. * @return The item that was in the slot.
* @throws IndexOutOfBoundsException if the slot is out of bounds. * @throws IndexOutOfBoundsException if the slot is out of bounds.
@@ -212,9 +219,9 @@ public final class Inventory implements Cloneable {
/** /**
* An alias for {@code add(id, 1)}. * An alias for {@code add(id, 1)}.
*
* @param id The id. * @param id The id.
* @return {@code true} if the item was added, {@code false} if there was * @return {@code true} if the item was added, {@code false} if there was not enough room.
* not enough room.
*/ */
public boolean add(int id) { public boolean add(int id) {
return add(id, 1) == 0; return add(id, 1) == 0;
@@ -222,6 +229,7 @@ public final class Inventory implements Cloneable {
/** /**
* An alias for {@code add(new Item(id, amount)}. * An alias for {@code add(new Item(id, amount)}.
*
* @param id The id. * @param id The id.
* @param amount The amount. * @param amount The amount.
* @return The amount that remains. * @return The amount that remains.
@@ -235,15 +243,13 @@ public final class Inventory implements Cloneable {
} }
/** /**
* Adds an item to this inventory. This will attempt to add as much of the * Adds an item to this inventory. This will attempt to add as much of the item that is possible. If the item
* item that is possible. If the item remains, it will be returned (in the * remains, it will be returned (in the case of stackable items, any quantity that remains in the stack is
* case of stackable items, any quantity that remains in the stack is * returned). If nothing remains, the method will return {@code null}. If something remains, the listener will also
* returned). If nothing remains, the method will return {@code null}. If * be notified which could be used, for example, to send a message to the player.
* something remains, the listener will also be notified which could be *
* used, for example, to send a message to the player.
* @param item The item to add to this inventory. * @param item The item to add to this inventory.
* @return The item that remains if there is not enough room in the * @return The item that remains if there is not enough room in the inventory. If nothing remains, {@code null}.
* inventory. If nothing remains, {@code null}.
*/ */
public Item add(Item item) { public Item add(Item item) {
int id = item.getId(); int id = item.getId();
@@ -264,7 +270,7 @@ public final class Inventory implements Cloneable {
remaining = 0; remaining = 0;
} }
set(slot, new Item(id, amount)); set(slot, new Item(id, amount));
return remaining > 0 ? new Item(id, remaining): null; return remaining > 0 ? new Item(id, remaining) : null;
} }
} }
for (int slot = 0; slot < capacity; slot++) { for (int slot = 0; slot < capacity; slot++) {
@@ -308,6 +314,7 @@ public final class Inventory implements Cloneable {
/** /**
* Removes one item with the specified id. * Removes one item with the specified id.
*
* @param id The id. * @param id The id.
* @return {@code true} if the item was removed, {@code false} otherwise. * @return {@code true} if the item was removed, {@code false} otherwise.
*/ */
@@ -317,6 +324,7 @@ public final class Inventory implements Cloneable {
/** /**
* An alias for {@code remove(item.getId(), item.getAmount())}. * An alias for {@code remove(item.getId(), item.getAmount())}.
*
* @param item The item to remove. * @param item The item to remove.
* @return The amount that was removed. * @return The amount that was removed.
*/ */
@@ -325,9 +333,9 @@ public final class Inventory implements Cloneable {
} }
/** /**
* Removes {@code amount} of the item with the specified {@code id}. If the * Removes {@code amount} of the item with the specified {@code id}. If the item is stackable, it will remove it
* item is stackable, it will remove it from the stack. If not, it'll * from the stack. If not, it'll remove {@code amount} items.
* remove {@code amount} items. *
* @param id The id. * @param id The id.
* @param amount The amount. * @param amount The amount.
* @return The amount that was removed. * @return The amount that was removed.
@@ -383,6 +391,7 @@ public final class Inventory implements Cloneable {
/** /**
* Swaps the two items at the specified slots. * Swaps the two items at the specified slots.
*
* @param oldSlot The old slot. * @param oldSlot The old slot.
* @param newSlot The new slot. * @param newSlot The new slot.
* @throws IndexOutOufBoundsException if the slot is out of bounds. * @throws IndexOutOufBoundsException if the slot is out of bounds.
@@ -393,6 +402,7 @@ public final class Inventory implements Cloneable {
/** /**
* Swaps the two items at the specified slots. * Swaps the two items at the specified slots.
*
* @param insert If the swap should be done in insertion mode. * @param insert If the swap should be done in insertion mode.
* @param oldSlot The old slot. * @param oldSlot The old slot.
* @param newSlot The new slot. * @param newSlot The new slot.
@@ -422,6 +432,7 @@ public final class Inventory implements Cloneable {
/** /**
* Adds a listener. * Adds a listener.
*
* @param listener The listener to add. * @param listener The listener to add.
*/ */
public void addListener(InventoryListener listener) { public void addListener(InventoryListener listener) {
@@ -430,6 +441,7 @@ public final class Inventory implements Cloneable {
/** /**
* Removes a listener. * Removes a listener.
*
* @param listener The listener to remove. * @param listener The listener to remove.
*/ */
public void removeListener(InventoryListener listener) { public void removeListener(InventoryListener listener) {
@@ -444,8 +456,7 @@ public final class Inventory implements Cloneable {
} }
/** /**
* Notifies listeners that the capacity of this inventory has been * Notifies listeners that the capacity of this inventory has been exceeded.
* exceeded.
*/ */
private void notifyCapacityExceeded() { private void notifyCapacityExceeded() {
if (firingEvents) { if (firingEvents) {
@@ -468,6 +479,7 @@ public final class Inventory implements Cloneable {
/** /**
* Notifies listeners that the specified slot has been updated. * Notifies listeners that the specified slot has been updated.
*
* @param slot The slot. * @param slot The slot.
*/ */
private void notifyItemUpdated(int slot) { private void notifyItemUpdated(int slot) {
@@ -481,6 +493,7 @@ public final class Inventory implements Cloneable {
/** /**
* Checks the bounds of the specified slot. * Checks the bounds of the specified slot.
*
* @param slot The slot. * @param slot The slot.
* @throws IndexOutOfBoundsException if the slot is out of bounds. * @throws IndexOutOfBoundsException if the slot is out of bounds.
*/ */
@@ -492,9 +505,9 @@ public final class Inventory implements Cloneable {
/** /**
* Checks if the item specified by the definition should be stacked. * Checks if the item specified by the definition should be stacked.
*
* @param def The definition. * @param def The definition.
* @return {@code true} if the item should be stacked, {@code false} * @return {@code true} if the item should be stacked, {@code false} otherwise.
* otherwise.
*/ */
private boolean isStackable(ItemDefinition def) { private boolean isStackable(ItemDefinition def) {
if (mode == StackMode.STACK_ALWAYS) { if (mode == StackMode.STACK_ALWAYS) {
@@ -508,6 +521,7 @@ public final class Inventory implements Cloneable {
/** /**
* Gets a clone of the items array. * Gets a clone of the items array.
*
* @return A clone of the items array. * @return A clone of the items array.
*/ */
public Item[] getItems() { public Item[] getItems() {
@@ -537,6 +551,7 @@ public final class Inventory implements Cloneable {
/** /**
* Forces a refresh of a specific slot. * Forces a refresh of a specific slot.
*
* @param slot The slot. * @param slot The slot.
*/ */
public void forceRefresh(int slot) { public void forceRefresh(int slot) {
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Holds {@link Inventory}-related constants. * Holds {@link Inventory}-related constants.
*
* @author Graham * @author Graham
*/ */
public final class InventoryConstants { public final class InventoryConstants {
+6
View File
@@ -4,6 +4,7 @@ import org.apollo.game.model.def.ItemDefinition;
/** /**
* Represents a single item. * Represents a single item.
*
* @author Graham * @author Graham
*/ */
public final class Item { public final class Item {
@@ -20,6 +21,7 @@ public final class Item {
/** /**
* Creates an item with an amount of {@code 1}. * Creates an item with an amount of {@code 1}.
*
* @param id The item's id. * @param id The item's id.
*/ */
public Item(int id) { public Item(int id) {
@@ -28,6 +30,7 @@ public final class Item {
/** /**
* Creates an item with the specified the amount. * Creates an item with the specified the amount.
*
* @param id The item's id. * @param id The item's id.
* @param amount The amount. * @param amount The amount.
* @throws IllegalArgumentException if the amount is negative. * @throws IllegalArgumentException if the amount is negative.
@@ -42,6 +45,7 @@ public final class Item {
/** /**
* Gets the id. * Gets the id.
*
* @return The id. * @return The id.
*/ */
public int getId() { public int getId() {
@@ -50,6 +54,7 @@ public final class Item {
/** /**
* Gets the amount. * Gets the amount.
*
* @return The amount. * @return The amount.
*/ */
public int getAmount() { public int getAmount() {
@@ -58,6 +63,7 @@ public final class Item {
/** /**
* Gets the {@link ItemDefinition} which describes this item. * Gets the {@link ItemDefinition} which describes this item.
*
* @return The definition. * @return The definition.
*/ */
public ItemDefinition getDefinition() { public ItemDefinition getDefinition() {
+46 -16
View File
@@ -21,12 +21,14 @@ import org.apollo.security.PlayerCredentials;
/** /**
* A {@link Player} is a {@link Character} that a user is controlling. * A {@link Player} is a {@link Character} that a user is controlling.
*
* @author Graham * @author Graham
*/ */
public final class Player extends Character { public final class Player extends Character {
/** /**
* An enumeration with the different privilege levels a player can have. * An enumeration with the different privilege levels a player can have.
*
* @author Graham * @author Graham
*/ */
public enum PrivilegeLevel { public enum PrivilegeLevel {
@@ -48,6 +50,7 @@ public final class Player extends Character {
/** /**
* Gets the privilege level for the specified numerical level. * Gets the privilege level for the specified numerical level.
*
* @param numericalLevel The numerical level. * @param numericalLevel The numerical level.
* @return The privilege level. * @return The privilege level.
* @throws IllegalArgumentException if the numerical level is invalid. * @throws IllegalArgumentException if the numerical level is invalid.
@@ -68,6 +71,7 @@ public final class Player extends Character {
/** /**
* Creates a privilege level. * Creates a privilege level.
*
* @param numericalLevel The numerical level. * @param numericalLevel The numerical level.
*/ */
private PrivilegeLevel(int numericalLevel) { private PrivilegeLevel(int numericalLevel) {
@@ -76,6 +80,7 @@ public final class Player extends Character {
/** /**
* Gets the numerical level. * Gets the numerical level.
*
* @return The numerical level used in the protocol. * @return The numerical level used in the protocol.
*/ */
public int toInteger() { public int toInteger() {
@@ -151,6 +156,7 @@ public final class Player extends Character {
/** /**
* Creates the {@link Player}. * Creates the {@link Player}.
*
* @param credentials The player's credentials. * @param credentials The player's credentials.
* @param position The initial position. * @param position The initial position.
*/ */
@@ -162,6 +168,7 @@ public final class Player extends Character {
/** /**
* Gets this player's interface set. * Gets this player's interface set.
*
* @return The interface set for this player. * @return The interface set for this player.
*/ */
public InterfaceSet getInterfaceSet() { public InterfaceSet getInterfaceSet() {
@@ -170,6 +177,7 @@ public final class Player extends Character {
/** /**
* Checks if there are excessive players. * Checks if there are excessive players.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean isExcessivePlayersSet() { public boolean isExcessivePlayersSet() {
@@ -199,6 +207,7 @@ public final class Player extends Character {
/** /**
* Gets this player's viewing distance. * Gets this player's viewing distance.
*
* @return The viewing distance. * @return The viewing distance.
*/ */
public int getViewingDistance() { public int getViewingDistance() {
@@ -206,8 +215,7 @@ public final class Player extends Character {
} }
/** /**
* Increments this player's viewing distance if it is less than the maximum * Increments this player's viewing distance if it is less than the maximum viewing distance.
* viewing distance.
*/ */
public void incrementViewingDistance() { public void incrementViewingDistance() {
if (viewingDistance < Position.MAX_DISTANCE) { if (viewingDistance < Position.MAX_DISTANCE) {
@@ -226,6 +234,7 @@ public final class Player extends Character {
/** /**
* Checks if this player has ever known a region. * Checks if this player has ever known a region.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean hasLastKnownRegion() { public boolean hasLastKnownRegion() {
@@ -234,8 +243,8 @@ public final class Player extends Character {
/** /**
* Gets the last known region. * Gets the last known region.
* @return The last known region, or {@code null} if the player has never *
* known a region. * @return The last known region, or {@code null} if the player has never known a region.
*/ */
public Position getLastKnownRegion() { public Position getLastKnownRegion() {
return lastKnownRegion; return lastKnownRegion;
@@ -243,6 +252,7 @@ public final class Player extends Character {
/** /**
* Sets the last known region. * Sets the last known region.
*
* @param lastKnownRegion The last known region. * @param lastKnownRegion The last known region.
*/ */
public void setLastKnownRegion(Position lastKnownRegion) { public void setLastKnownRegion(Position lastKnownRegion) {
@@ -251,6 +261,7 @@ public final class Player extends Character {
/** /**
* Gets the privilege level. * Gets the privilege level.
*
* @return The privilege level. * @return The privilege level.
*/ */
public PrivilegeLevel getPrivilegeLevel() { public PrivilegeLevel getPrivilegeLevel() {
@@ -259,6 +270,7 @@ public final class Player extends Character {
/** /**
* Sets the privilege level. * Sets the privilege level.
*
* @param privilegeLevel The privilege level. * @param privilegeLevel The privilege level.
*/ */
public void setPrivilegeLevel(PrivilegeLevel privilegeLevel) { public void setPrivilegeLevel(PrivilegeLevel privilegeLevel) {
@@ -267,6 +279,7 @@ public final class Player extends Character {
/** /**
* Checks if this player account has membership. * Checks if this player account has membership.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean isMembers() { public boolean isMembers() {
@@ -275,6 +288,7 @@ public final class Player extends Character {
/** /**
* Changes the membership status of this player. * Changes the membership status of this player.
*
* @param members The new membership flag. * @param members The new membership flag.
*/ */
public void setMembers(boolean members) { public void setMembers(boolean members) {
@@ -283,6 +297,7 @@ public final class Player extends Character {
/** /**
* Sets the player's {@link GameSession}. * Sets the player's {@link GameSession}.
*
* @param session The player's {@link GameSession}. * @param session The player's {@link GameSession}.
* @param reconnecting The reconnecting flag. * @param reconnecting The reconnecting flag.
*/ */
@@ -296,6 +311,7 @@ public final class Player extends Character {
/** /**
* Gets the player's credentials. * Gets the player's credentials.
*
* @return The player's credentials. * @return The player's credentials.
*/ */
public PlayerCredentials getCredentials() { public PlayerCredentials getCredentials() {
@@ -353,17 +369,21 @@ public final class Player extends Character {
// TODO only add bank listener when it is open? (like Hyperion) // TODO only add bank listener when it is open? (like Hyperion)
// inventory full listeners // inventory full listeners
InventoryListener fullInventoryListener = new FullInventoryListener(this, FullInventoryListener.FULL_INVENTORY_MESSAGE); InventoryListener fullInventoryListener = new FullInventoryListener(this,
FullInventoryListener.FULL_INVENTORY_MESSAGE);
InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE); InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE);
InventoryListener fullEquipmentListener = new FullInventoryListener(this, FullInventoryListener.FULL_EQUIPMENT_MESSAGE); InventoryListener fullEquipmentListener = new FullInventoryListener(this,
FullInventoryListener.FULL_EQUIPMENT_MESSAGE);
// equipment appearance listener // equipment appearance listener
InventoryListener appearanceListener = new AppearanceInventoryListener(this); InventoryListener appearanceListener = new AppearanceInventoryListener(this);
// synchronization listeners // synchronization listeners
InventoryListener syncInventoryListener = new SynchronizationInventoryListener(this, SynchronizationInventoryListener.INVENTORY_ID); InventoryListener syncInventoryListener = new SynchronizationInventoryListener(this,
SynchronizationInventoryListener.INVENTORY_ID);
InventoryListener syncBankListener = new SynchronizationInventoryListener(this, BankConstants.BANK_INVENTORY_ID); InventoryListener syncBankListener = new SynchronizationInventoryListener(this, BankConstants.BANK_INVENTORY_ID);
InventoryListener syncEquipmentListener = new SynchronizationInventoryListener(this, SynchronizationInventoryListener.EQUIPMENT_ID); InventoryListener syncEquipmentListener = new SynchronizationInventoryListener(this,
SynchronizationInventoryListener.EQUIPMENT_ID);
// add the listeners // add the listeners
inventory.addListener(syncInventoryListener); inventory.addListener(syncInventoryListener);
@@ -390,11 +410,10 @@ public final class Player extends Character {
// tabs TODO make a constant? look at player settings // tabs TODO make a constant? look at player settings
int[] tabs = { int[] tabs = {
// 6299 = music tab, music disabled // 6299 = music tab, music disabled
// 4445 = settings tab, music disabled // 4445 = settings tab, music disabled
// 12855 = ancients magic // 12855 = ancients magic
2423, 3917, 638, 3213, 1644, 5608, 1151, -1, 5065, 5715, 2449, 904, 147, 962, 2423, 3917, 638, 3213, 1644, 5608, 1151, -1, 5065, 5715, 2449, 904, 147, 962, };
};
for (int i = 0; i < tabs.length; i++) { for (int i = 0; i < tabs.length; i++) {
send(new SwitchTabInterfaceEvent(i, tabs[i])); send(new SwitchTabInterfaceEvent(i, tabs[i]));
} }
@@ -410,11 +429,13 @@ public final class Player extends Character {
@Override @Override
public String toString() { public String toString() {
return Player.class.getName() + " [username=" + credentials.getUsername() + ", privilegeLevel=" + privilegeLevel +"]"; return Player.class.getName() + " [username=" + credentials.getUsername() + ", privilegeLevel="
+ privilegeLevel + "]";
} }
/** /**
* Sets the region changed flag. * Sets the region changed flag.
*
* @param regionChanged A flag indicating if the region has changed. * @param regionChanged A flag indicating if the region has changed.
*/ */
public void setRegionChanged(boolean regionChanged) { public void setRegionChanged(boolean regionChanged) {
@@ -423,6 +444,7 @@ public final class Player extends Character {
/** /**
* Checks if the region has changed. * Checks if the region has changed.
*
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
*/ */
public boolean hasRegionChanged() { public boolean hasRegionChanged() {
@@ -431,6 +453,7 @@ public final class Player extends Character {
/** /**
* Gets the player's appearance. * Gets the player's appearance.
*
* @return The appearance. * @return The appearance.
*/ */
public Appearance getAppearance() { public Appearance getAppearance() {
@@ -439,6 +462,7 @@ public final class Player extends Character {
/** /**
* Sets the player's appearance. * Sets the player's appearance.
*
* @param appearance The new appearance. * @param appearance The new appearance.
*/ */
public void setAppearance(Appearance appearance) { public void setAppearance(Appearance appearance) {
@@ -448,6 +472,7 @@ public final class Player extends Character {
/** /**
* Gets the player's name. * Gets the player's name.
*
* @return The player's name. * @return The player's name.
*/ */
public String getName() { public String getName() {
@@ -456,6 +481,7 @@ public final class Player extends Character {
/** /**
* Gets the player's name, encoded as a long. * Gets the player's name, encoded as a long.
*
* @return The encoded player name. * @return The encoded player name.
*/ */
public long getEncodedName() { public long getEncodedName() {
@@ -471,6 +497,7 @@ public final class Player extends Character {
/** /**
* Gets the game session. * Gets the game session.
*
* @return The game session. * @return The game session.
*/ */
public GameSession getSession() { public GameSession getSession() {
@@ -479,8 +506,8 @@ public final class Player extends Character {
/** /**
* Sets the character design flag. * Sets the character design flag.
* @param designedCharacter A flag indicating if the character has been *
* designed. * @param designedCharacter A flag indicating if the character has been designed.
*/ */
public void setDesignedCharacter(boolean designedCharacter) { public void setDesignedCharacter(boolean designedCharacter) {
this.designedCharacter = designedCharacter; this.designedCharacter = designedCharacter;
@@ -488,6 +515,7 @@ public final class Player extends Character {
/** /**
* Checks if the player has designed their character. * Checks if the player has designed their character.
*
* @return A flag indicating if the player has designed their character. * @return A flag indicating if the player has designed their character.
*/ */
public boolean hasDesignedCharacter() { public boolean hasDesignedCharacter() {
@@ -496,6 +524,7 @@ public final class Player extends Character {
/** /**
* Gets the withdrawing notes flag. * Gets the withdrawing notes flag.
*
* @return The flag. * @return The flag.
*/ */
public boolean isWithdrawingNotes() { public boolean isWithdrawingNotes() {
@@ -504,6 +533,7 @@ public final class Player extends Character {
/** /**
* Sets the withdrawing notes flag. * Sets the withdrawing notes flag.
*
* @param withdrawingNotes The flag. * @param withdrawingNotes The flag.
*/ */
public void setWithdrawingNotes(boolean withdrawingNotes) { public void setWithdrawingNotes(boolean withdrawingNotes) {
+20 -6
View File
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Represents a position in the world. * Represents a position in the world.
*
* @author Graham * @author Graham
*/ */
public final class Position { public final class Position {
@@ -33,6 +34,7 @@ public final class Position {
/** /**
* Creates a position at the default height. * Creates a position at the default height.
*
* @param x The x coordinate. * @param x The x coordinate.
* @param y The y coordinate. * @param y The y coordinate.
*/ */
@@ -42,6 +44,7 @@ public final class Position {
/** /**
* Creates a position with the specified height. * Creates a position with the specified height.
*
* @param x The x coordinate. * @param x The x coordinate.
* @param y The y coordinate. * @param y The y coordinate.
* @param height The height. * @param height The height.
@@ -57,6 +60,7 @@ public final class Position {
/** /**
* Gets the x coordinate. * Gets the x coordinate.
*
* @return The x coordinate. * @return The x coordinate.
*/ */
public int getX() { public int getX() {
@@ -65,6 +69,7 @@ public final class Position {
/** /**
* Gets the y coordinate. * Gets the y coordinate.
*
* @return The y coordinate. * @return The y coordinate.
*/ */
public int getY() { public int getY() {
@@ -73,6 +78,7 @@ public final class Position {
/** /**
* Gets the height level. * Gets the height level.
*
* @return The height level. * @return The height level.
*/ */
public int getHeight() { public int getHeight() {
@@ -81,6 +87,7 @@ public final class Position {
/** /**
* Gets the x coordinate of the region. * Gets the x coordinate of the region.
*
* @return The region x coordinate. * @return The region x coordinate.
*/ */
public int getTopLeftRegionX() { public int getTopLeftRegionX() {
@@ -89,6 +96,7 @@ public final class Position {
/** /**
* Gets the y coordinate of the region. * Gets the y coordinate of the region.
*
* @return The region y coordinate. * @return The region y coordinate.
*/ */
public int getTopLeftRegionY() { public int getTopLeftRegionY() {
@@ -97,6 +105,7 @@ public final class Position {
/** /**
* Gets the x coordinate of the central region. * Gets the x coordinate of the central region.
*
* @return The x coordinate of the central region. * @return The x coordinate of the central region.
*/ */
public int getCentralRegionX() { public int getCentralRegionX() {
@@ -105,6 +114,7 @@ public final class Position {
/** /**
* Gets the y coordinate of the central region. * Gets the y coordinate of the central region.
*
* @return The y coordinate of the central region. * @return The y coordinate of the central region.
*/ */
public int getCentralRegionY() { public int getCentralRegionY() {
@@ -113,6 +123,7 @@ public final class Position {
/** /**
* Gets the x coordinate inside the region of this position. * Gets the x coordinate inside the region of this position.
*
* @return The local x coordinate. * @return The local x coordinate.
*/ */
public int getLocalX() { public int getLocalX() {
@@ -121,6 +132,7 @@ public final class Position {
/** /**
* Gets the y coordinate inside the region of this position. * Gets the y coordinate inside the region of this position.
*
* @return The local y coordinate. * @return The local y coordinate.
*/ */
public int getLocalY() { public int getLocalY() {
@@ -128,8 +140,8 @@ public final class Position {
} }
/** /**
* Gets the local x coordinate inside the region of the {@code base} * Gets the local x coordinate inside the region of the {@code base} position.
* position. *
* @param base The base position. * @param base The base position.
* @return The local x coordinate. * @return The local x coordinate.
*/ */
@@ -138,8 +150,8 @@ public final class Position {
} }
/** /**
* Gets the local y coordinate inside the region of the {@code base} * Gets the local y coordinate inside the region of the {@code base} position.
* position. *
* @param base The base position. * @param base The base position.
* @return The local y coordinate. * @return The local y coordinate.
*/ */
@@ -153,8 +165,8 @@ public final class Position {
} }
/** /**
* Gets the distance between this position and another position. Only X and * Gets the distance between this position and another position. Only X and Y are considered (i.e. 2 dimensions).
* Y are considered (i.e. 2 dimensions). *
* @param other The other position. * @param other The other position.
* @return The distance. * @return The distance.
*/ */
@@ -167,6 +179,7 @@ public final class Position {
/** /**
* Gets the longest horizontal or vertical delta between the two positions. * Gets the longest horizontal or vertical delta between the two positions.
*
* @param other The other position. * @param other The other position.
* @return The longest horizontal or vertical delta. * @return The longest horizontal or vertical delta.
*/ */
@@ -178,6 +191,7 @@ public final class Position {
/** /**
* Checks if the position is within distance of another. * Checks if the position is within distance of another.
*
* @param other The other position. * @param other The other position.
* @param distance The distance. * @param distance The distance.
* @return {@code true} if so, {@code false} if not. * @return {@code true} if so, {@code false} if not.
+8 -2
View File
@@ -2,6 +2,7 @@ package org.apollo.game.model;
/** /**
* Represents a single skill. * Represents a single skill.
*
* @author Graham * @author Graham
*/ */
public final class Skill { public final class Skill {
@@ -115,11 +116,12 @@ public final class Skill {
* The skill names. * The skill names.
*/ */
private static final String SKILL_NAMES[] = { "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", private static final String SKILL_NAMES[] = { "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer",
"Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining",
"Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft" }; "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft" };
/** /**
* Gets the name of a skill. * Gets the name of a skill.
*
* @param id The skill's id. * @param id The skill's id.
* @return The skill's name. * @return The skill's name.
*/ */
@@ -144,6 +146,7 @@ public final class Skill {
/** /**
* Creates a skill. * Creates a skill.
*
* @param experience The experience. * @param experience The experience.
* @param currentLevel The current level. * @param currentLevel The current level.
* @param maximumLevel The maximum level. * @param maximumLevel The maximum level.
@@ -156,6 +159,7 @@ public final class Skill {
/** /**
* Gets the experience. * Gets the experience.
*
* @return The experience. * @return The experience.
*/ */
public double getExperience() { public double getExperience() {
@@ -164,6 +168,7 @@ public final class Skill {
/** /**
* Gets the current level. * Gets the current level.
*
* @return The current level. * @return The current level.
*/ */
public int getCurrentLevel() { public int getCurrentLevel() {
@@ -172,6 +177,7 @@ public final class Skill {
/** /**
* Gets the maximum level. * Gets the maximum level.
*
* @return The maximum level. * @return The maximum level.
*/ */
public int getMaximumLevel() { public int getMaximumLevel() {

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