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

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