Resolve merge conflict.

This commit is contained in:
Major-
2015-04-15 18:36:00 +01:00
546 changed files with 2638 additions and 2465 deletions
+1 -1
View File
@@ -179,7 +179,7 @@ def on_message(args, proc)
numbers.each_index do |index|
number = numbers[index]
if message.to_s.start_with?(number)
option = index + 1
message = message[number.length + 1, message.length].to_sym
+4 -3
View File
@@ -13,12 +13,12 @@ class OpenDoorAction < DistancedAction
def executeAction
mob.turn_to(@door.position)
DoorUtil::toggle(@door, mob)
DoorUtil::toggle(@door)
stop
end
def equals(other)
return (get_class == other.get_class && @door_object == other.door_object)
return (get_class == other.get_class && @door == other.door)
end
end
@@ -28,6 +28,7 @@ on :message, :first_object_action do |player, message|
if DoorUtil::is_door?(message.id)
puts "Player: #{player.position}, door: #{message.position}"
door = DoorUtil::get_door_object(message.position, message.id)
player.start_action(OpenDoorAction.new(player, door)) unless door.nil?
DoorUtil::toggle(door) unless door.nil?
# player.start_action(OpenDoorAction.new(player, door)) unless door.nil?
end
end
+2 -2
View File
@@ -46,7 +46,7 @@ module DoorUtil
end
# Toggles the given door.
def self.toggle(door, player)
def self.toggle(door)
position = door.position
region = $world.region_repository.from_position(position)
region.remove_entity(door)
@@ -59,7 +59,7 @@ module DoorUtil
else
toggled_position = translate_door_position(door)
toggled_orientation = translate_door_orientation(door)
toggled_door = DynamicGameObject.createPublic(door.id, toggled_position, door.type, toggled_orientation)
toggled_door = DynamicGameObject.createPublic($world, door.id, toggled_position, door.type, toggled_orientation)
toggled_region = $world.region_repository.from_position(toggled_position)
toggled_region.add_entity(toggled_door)
+66 -67
View File
@@ -1,78 +1,77 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>org.apollo</artifactId>
<version>1.0</version>
<groupId>apollo</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.apollo</artifactId>
<version>1.0</version>
<groupId>apollo</groupId>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<mainClass>org.apollo.Server</mainClass>
<arguments>
<argument>-server</argument>
<argument>-Xmx750M</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<mainClass>org.apollo.Server</mainClass>
<arguments>
<argument>-server</argument>
<argument>-Xmx750M</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.9</version>
</dependency>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>1.7.19</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>1.7.19</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.26.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.27.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.lambdaworks</groupId>
<artifactId>scrypt</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.lambdaworks</groupId>
<artifactId>scrypt</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5</version>
</dependency>
</dependencies>
</dependencies>
</project>
+149 -167
View File
@@ -5,7 +5,7 @@ package net.burtleburtle.bob.rand;
* 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.
@@ -20,7 +20,7 @@ package net.burtleburtle.bob.rand;
* <p>
* This class has been changed to be more conformant to Java and javadoc conventions.
* </p>
*
*
* @author Bob Jenkins
*/
public final class IsaacRandom {
@@ -31,79 +31,125 @@ public final class IsaacRandom {
private static final int GOLDEN_RATIO = 0x9e3779b9;
/**
* The log of the size of the result and memory arrays.
* The log of the size of the result and state arrays.
*/
private static final int LOG_SIZE = 8;
private static final int LOG_SIZE = Long.BYTES;
/**
* The size of the result and memory arrays.
* The size of the result and states arrays.
*/
private static final int SIZE = 1 << LOG_SIZE;
/**
* A mask for pseudorandom lookup.
* A mask for pseudo-random lookup.
*/
private static int MASK = SIZE - 1 << 2;
/**
* The accumulator.
* The results given to the user.
*/
private int a;
/**
* The last result.
*/
private int b;
/**
* The counter.
*/
private int c;
/**
* The count through the results in the results array.
*/
private int count;
private final int[] results = new int[SIZE];
/**
* The internal state.
*/
private int[] mem;
private final int[] state = new int[SIZE];
/**
* The results given to the user.
* The count through the results in the results array.
*/
private int[] rsl;
private int count = SIZE;
/**
* Creates the random number generator without an initial seed.
* The accumulator.
*/
public IsaacRandom() {
mem = new int[SIZE];
rsl = new int[SIZE];
init(false);
}
private int accumulator;
/**
* The last result.
*/
private int last;
/**
* The counter.
*/
private int counter;
/**
* Creates the random number generator with the specified seed.
*
*
* @param seed The seed.
*/
public IsaacRandom(int[] seed) {
mem = new int[SIZE];
rsl = new int[SIZE];
for (int i = 0; i < seed.length; ++i) {
rsl[i] = seed[i];
}
init(true);
int length = Math.min(seed.length, results.length);
System.arraycopy(seed, 0, results, 0, length);
init();
}
/**
* Initialises this random number generator.
*
* @param hasSeed Set to {@code true} if a seed was passed to the constructor.
* Generates 256 results.
*/
private void init(boolean hasSeed) {
private void isaac() {
int i, j, x, y;
last += ++counter;
for (i = 0, j = SIZE / 2; i < SIZE / 2;) {
x = state[i];
accumulator ^= accumulator << 13;
accumulator += state[j++];
state[i] = y = state[(x & MASK) >> 2] + accumulator + last;
results[i++] = last = state[(y >> LOG_SIZE & MASK) >> 2] + x;
x = state[i];
accumulator ^= accumulator >>> 6;
accumulator += state[j++];
state[i] = y = state[(x & MASK) >> 2] + accumulator + last;
results[i++] = last = state[(y >> LOG_SIZE & MASK) >> 2] + x;
x = state[i];
accumulator ^= accumulator << 2;
accumulator += state[j++];
state[i] = y = state[(x & MASK) >> 2] + accumulator + last;
results[i++] = last = state[(y >> LOG_SIZE & MASK) >> 2] + x;
x = state[i];
accumulator ^= accumulator >>> 16;
accumulator += state[j++];
state[i] = y = state[(x & MASK) >> 2] + accumulator + last;
results[i++] = last = state[(y >> LOG_SIZE & MASK) >> 2] + x;
}
for (j = 0; j < SIZE / 2;) {
x = state[i];
accumulator ^= accumulator << 13;
accumulator += state[j++];
state[i] = y = state[(x & MASK) >> 2] + accumulator + last;
results[i++] = last = state[(y >> LOG_SIZE & MASK) >> 2] + x;
x = state[i];
accumulator ^= accumulator >>> 6;
accumulator += state[j++];
state[i] = y = state[(x & MASK) >> 2] + accumulator + last;
results[i++] = last = state[(y >> LOG_SIZE & MASK) >> 2] + x;
x = state[i];
accumulator ^= accumulator << 2;
accumulator += state[j++];
state[i] = y = state[(x & MASK) >> 2] + accumulator + last;
results[i++] = last = state[(y >> LOG_SIZE & MASK) >> 2] + x;
x = state[i];
accumulator ^= accumulator >>> 16;
accumulator += state[j++];
state[i] = y = state[(x & MASK) >> 2] + accumulator + last;
results[i++] = last = state[(y >> LOG_SIZE & MASK) >> 2] + x;
}
}
/**
* Initializes this random number generator.
*/
private void init() {
int i;
int a, b, c, d, e, f, g, h;
a = b = c = d = e = f = g = h = GOLDEN_RATIO;
@@ -136,16 +182,15 @@ public final class IsaacRandom {
}
for (i = 0; i < SIZE; i += 8) { /* fill in mem[] with messy stuff */
if (hasSeed) {
a += rsl[i];
b += rsl[i + 1];
c += rsl[i + 2];
d += rsl[i + 3];
e += rsl[i + 4];
f += rsl[i + 5];
g += rsl[i + 6];
h += rsl[i + 7];
}
a += results[i];
b += results[i + 1];
c += results[i + 2];
d += results[i + 3];
e += results[i + 4];
f += results[i + 5];
g += results[i + 6];
h += results[i + 7];
a ^= b << 11;
d += a;
b += c;
@@ -170,128 +215,65 @@ public final class IsaacRandom {
h ^= a >>> 9;
c += h;
a += b;
mem[i] = a;
mem[i + 1] = b;
mem[i + 2] = c;
mem[i + 3] = d;
mem[i + 4] = e;
mem[i + 5] = f;
mem[i + 6] = g;
mem[i + 7] = h;
state[i] = a;
state[i + 1] = b;
state[i + 2] = c;
state[i + 3] = d;
state[i + 4] = e;
state[i + 5] = f;
state[i + 6] = g;
state[i + 7] = h;
}
if (hasSeed) { /* second pass makes all of seed affect all of mem */
for (i = 0; i < SIZE; i += 8) {
a += mem[i];
b += mem[i + 1];
c += mem[i + 2];
d += mem[i + 3];
e += mem[i + 4];
f += mem[i + 5];
g += mem[i + 6];
h += mem[i + 7];
a ^= b << 11;
d += a;
b += c;
b ^= c >>> 2;
e += b;
c += d;
c ^= d << 8;
f += c;
d += e;
d ^= e >>> 16;
g += d;
e += f;
e ^= f << 10;
h += e;
f += g;
f ^= g >>> 4;
a += f;
g += h;
g ^= h << 8;
b += g;
h += a;
h ^= a >>> 9;
c += h;
a += b;
mem[i] = a;
mem[i + 1] = b;
mem[i + 2] = c;
mem[i + 3] = d;
mem[i + 4] = e;
mem[i + 5] = f;
mem[i + 6] = g;
mem[i + 7] = h;
}
for (i = 0; i < SIZE; i += 8) {
a += state[i];
b += state[i + 1];
c += state[i + 2];
d += state[i + 3];
e += state[i + 4];
f += state[i + 5];
g += state[i + 6];
h += state[i + 7];
a ^= b << 11;
d += a;
b += c;
b ^= c >>> 2;
e += b;
c += d;
c ^= d << 8;
f += c;
d += e;
d ^= e >>> 16;
g += d;
e += f;
e ^= f << 10;
h += e;
f += g;
f ^= g >>> 4;
a += f;
g += h;
g ^= h << 8;
b += g;
h += a;
h ^= a >>> 9;
c += h;
a += b;
state[i] = a;
state[i + 1] = b;
state[i + 2] = c;
state[i + 3] = d;
state[i + 4] = e;
state[i + 5] = f;
state[i + 6] = g;
state[i + 7] = h;
}
isaac();
count = SIZE;
}
/**
* Generates 256 results.
*/
private void isaac() {
int i, j, x, y;
b += ++c;
for (i = 0, j = SIZE / 2; i < SIZE / 2;) {
x = mem[i];
a ^= a << 13;
a += mem[j++];
mem[i] = y = mem[(x & MASK) >> 2] + a + b;
rsl[i++] = b = mem[(y >> LOG_SIZE & MASK) >> 2] + x;
x = mem[i];
a ^= a >>> 6;
a += mem[j++];
mem[i] = y = mem[(x & MASK) >> 2] + a + b;
rsl[i++] = b = mem[(y >> LOG_SIZE & MASK) >> 2] + x;
x = mem[i];
a ^= a << 2;
a += mem[j++];
mem[i] = y = mem[(x & MASK) >> 2] + a + b;
rsl[i++] = b = mem[(y >> LOG_SIZE & MASK) >> 2] + x;
x = mem[i];
a ^= a >>> 16;
a += mem[j++];
mem[i] = y = mem[(x & MASK) >> 2] + a + b;
rsl[i++] = b = mem[(y >> LOG_SIZE & MASK) >> 2] + x;
}
for (j = 0; j < SIZE / 2;) {
x = mem[i];
a ^= a << 13;
a += mem[j++];
mem[i] = y = mem[(x & MASK) >> 2] + a + b;
rsl[i++] = b = mem[(y >> LOG_SIZE & MASK) >> 2] + x;
x = mem[i];
a ^= a >>> 6;
a += mem[j++];
mem[i] = y = mem[(x & MASK) >> 2] + a + b;
rsl[i++] = b = mem[(y >> LOG_SIZE & MASK) >> 2] + x;
x = mem[i];
a ^= a << 2;
a += mem[j++];
mem[i] = y = mem[(x & MASK) >> 2] + a + b;
rsl[i++] = b = mem[(y >> LOG_SIZE & MASK) >> 2] + x;
x = mem[i];
a ^= a >>> 16;
a += mem[j++];
mem[i] = y = mem[(x & MASK) >> 2] + a + b;
rsl[i++] = b = mem[(y >> LOG_SIZE & MASK) >> 2] + x;
}
}
/**
* Gets the next random value.
*
*
* @return The next random value.
*/
public int nextInt() {
@@ -299,7 +281,7 @@ public final class IsaacRandom {
isaac();
count = SIZE - 1;
}
return rsl[count];
return results[count];
}
}
+20 -17
View File
@@ -10,6 +10,7 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -25,9 +26,11 @@ import org.apollo.net.release.r317.Release317;
import org.apollo.util.plugin.PluginContext;
import org.apollo.util.plugin.PluginManager;
import com.google.common.base.Stopwatch;
/**
* The core class of the Apollo server.
*
*
* @author Graham
*/
public final class Server {
@@ -39,12 +42,13 @@ 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) {
Stopwatch stopwatch = Stopwatch.createStarted();
try {
long start = System.currentTimeMillis();
Server server = new Server();
server.init(args.length == 1 ? args[0] : Release317.class.getName());
@@ -53,10 +57,11 @@ public final class Server {
SocketAddress jaggrab = new InetSocketAddress(NetworkConstants.JAGGRAB_PORT);
server.bind(service, http, jaggrab);
logger.fine("Starting apollo took " + (System.currentTimeMillis() - start) + " ms.");
} catch (Throwable t) {
logger.log(Level.SEVERE, "Error whilst starting server.", t);
}
logger.fine("Starting apollo took " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms.");
}
/**
@@ -81,16 +86,14 @@ public final class Server {
/**
* Creates the Apollo server.
*
* @throws Exception If an error occurs whilst creating services.
*/
public Server() throws Exception {
public Server() {
logger.info("Starting Apollo...");
}
/**
* 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.
@@ -98,14 +101,14 @@ public final class Server {
public void bind(SocketAddress serviceAddress, SocketAddress httpAddress, SocketAddress jagGrabAddress) {
try {
logger.fine("Binding service listener to address: " + serviceAddress + "...");
serviceBootstrap.bind(serviceAddress).syncUninterruptibly();
serviceBootstrap.bind(serviceAddress).sync();
logger.fine("Binding HTTP listener to address: " + httpAddress + "...");
httpBootstrap.bind(httpAddress).syncUninterruptibly();
httpBootstrap.bind(httpAddress).sync();
logger.fine("Binding JAGGRAB listener to address: " + jagGrabAddress + "...");
jagGrabBootstrap.bind(jagGrabAddress).syncUninterruptibly();
} catch (Exception e) {
jagGrabBootstrap.bind(jagGrabAddress).sync();
} catch (InterruptedException e) {
logger.log(Level.SEVERE, "Binding to a port failed: ensure apollo isn't already running.", e);
System.exit(1);
}
@@ -115,15 +118,16 @@ public final class Server {
/**
* Initialises the server.
*
*
* @param releaseClassName The class name of the current active {@link Release}.
* @throws Exception If an error occurs.
*/
public void init(String releaseClassName) throws Exception {
Class<?> clazz = Class.forName(releaseClassName);
Release release = (Release) clazz.newInstance();
int releaseNo = release.getReleaseNumber();
logger.info("Initialized release #" + release.getReleaseNumber() + ".");
logger.info("Initialized release #" + releaseNo + ".");
serviceBootstrap.group(loopGroup);
httpBootstrap.group(loopGroup);
@@ -131,7 +135,8 @@ public final class Server {
World world = new World();
ServiceManager serviceManager = new ServiceManager(world);
ServerContext context = new ServerContext(release, serviceManager);
IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs", Integer.toString(releaseNo)), true);
ServerContext context = new ServerContext(release, serviceManager, fs);
ApolloHandler handler = new ApolloHandler(context);
ChannelInitializer<SocketChannel> serviceInitializer = new ServiceChannelInitializer(handler);
@@ -149,8 +154,6 @@ public final class Server {
PluginManager manager = new PluginManager(world, new PluginContext(context));
serviceManager.startAll();
int releaseNo = release.getReleaseNumber();
IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs", Integer.toString(releaseNo)), true);
world.init(releaseNo, fs, manager);
}
+27 -8
View File
@@ -1,12 +1,15 @@
package org.apollo;
import java.util.Objects;
import org.apollo.fs.IndexedFileSystem;
import org.apollo.net.release.Release;
/**
* 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} which user scripts/code should not be able to access.
*
*
* @author Graham
*/
public final class ServerContext {
@@ -21,30 +24,46 @@ public final class ServerContext {
*/
private final ServiceManager serviceManager;
/**
* The IndexedFileSystem.
*/
private final IndexedFileSystem fileSystem;
/**
* Creates a new server context.
*
*
* @param release The current release.
* @param serviceManager The service manager.
* @param fileSystem The indexed file system.
*/
ServerContext(Release release, ServiceManager serviceManager) {
this.release = release;
this.serviceManager = serviceManager;
protected ServerContext(Release release, ServiceManager serviceManager, IndexedFileSystem fileSystem) {
this.release = Objects.requireNonNull(release);
this.serviceManager = Objects.requireNonNull(serviceManager);
this.serviceManager.setContext(this);
this.fileSystem = Objects.requireNonNull(fileSystem);
}
/**
* Gets the current release.
*
*
* @return The current release.
*/
public Release getRelease() {
return release;
}
/**
* Gets the IndexeFileSystem
*
* @return The IndexedFileSystem.
*/
public IndexedFileSystem getFileSystem() {
return fileSystem;
}
/**
* Gets a service. This method is shorthand for {@code getServiceManager().getService(...)}.
*
*
* @param clazz The service class.
* @return The service, or {@code null} if it could not be found.
*/
@@ -54,7 +73,7 @@ public final class ServerContext {
/**
* Gets the service manager.
*
*
* @return The service manager.
*/
public ServiceManager getServiceManager() {
+3 -3
View File
@@ -4,7 +4,7 @@ import org.apollo.game.model.World;
/**
* Represents a service that the server provides for a {@link World}.
*
*
* @author Graham
*/
public abstract class Service {
@@ -30,7 +30,7 @@ public abstract class Service {
/**
* Gets the {@link ServerContext}.
*
*
* @return The context.
*/
public final ServerContext getContext() {
@@ -39,7 +39,7 @@ public abstract class Service {
/**
* Sets the {@link ServerContext}.
*
*
* @param context The context.
*/
public final void setContext(ServerContext context) {
+7 -7
View File
@@ -14,7 +14,7 @@ import org.xml.sax.SAXException;
/**
* A class which manages {@link Service}s.
*
*
* @author Graham
*/
public final class ServiceManager {
@@ -27,11 +27,11 @@ public final class ServiceManager {
/**
* The service map.
*/
private Map<Class<? extends Service>, Service> services = new HashMap<>();
private final Map<Class<? extends Service>, Service> services = new HashMap<>();
/**
* Creates and initializes the {@link ServiceManager}.
*
*
* @param world The {@link World} to create the {@link Service}s for.
* @throws IOException If there is an error reading from the xml file.
* @throws SAXException If there is an error parsing the xml file.
@@ -43,7 +43,7 @@ public final class ServiceManager {
/**
* Gets a service.
*
*
* @param clazz The service class.
* @return The service.
*/
@@ -54,7 +54,7 @@ public final class ServiceManager {
/**
* Initializes this service manager.
*
*
* @param world The {@link World} to create the {@link Service}s for.
* @throws SAXException If the service XML file could not be parsed.
* @throws IOException If the file could not be accessed.
@@ -91,7 +91,7 @@ public final class ServiceManager {
/**
* Registers a service.
*
*
* @param clazz The service's class.
* @param service The service.
*/
@@ -102,7 +102,7 @@ public final class ServiceManager {
/**
* Sets the context of all services.
*
*
* @param ctx The server context.
*/
public void setContext(ServerContext ctx) {
+4 -4
View File
@@ -2,7 +2,7 @@ package org.apollo.fs;
/**
* A class which points to a file in the cache.
*
*
* @author Graham
*/
public final class FileDescriptor {
@@ -19,7 +19,7 @@ public final class FileDescriptor {
/**
* Creates the file descriptor.
*
*
* @param type The file type.
* @param file The file id.
*/
@@ -30,7 +30,7 @@ public final class FileDescriptor {
/**
* Gets the file id.
*
*
* @return The file id.
*/
public int getFile() {
@@ -39,7 +39,7 @@ public final class FileDescriptor {
/**
* Gets the file type.
*
*
* @return The file type.
*/
public int getType() {
+1 -1
View File
@@ -2,7 +2,7 @@ package org.apollo.fs;
/**
* Holds file system related constants.
*
*
* @author Graham
*/
public final class FileSystemConstants {
+5 -5
View File
@@ -4,14 +4,14 @@ import com.google.common.base.Preconditions;
/**
* 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.
@@ -37,7 +37,7 @@ public final class Index {
/**
* Creates the index.
*
*
* @param size The size of the file.
* @param block The first block of the file.
*/
@@ -48,7 +48,7 @@ public final class Index {
/**
* Gets the first block of the file.
*
*
* @return The first block of the file.
*/
public int getBlock() {
@@ -57,7 +57,7 @@ public final class Index {
/**
* Gets the size of the file.
*
*
* @return The size of the file.
*/
public int getSize() {
+33 -10
View File
@@ -7,6 +7,7 @@ import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.zip.CRC32;
import com.google.common.base.Preconditions;
@@ -14,7 +15,7 @@ import com.google.common.base.Preconditions;
/**
* 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 {
@@ -24,6 +25,11 @@ public final class IndexedFileSystem implements Closeable {
*/
private ByteBuffer crcTable;
/**
* The {@link #crcTable} represented as an {@code int} array.
*/
private int[] crcs;
/**
* The data file.
*/
@@ -32,7 +38,7 @@ public final class IndexedFileSystem implements Closeable {
/**
* The index files.
*/
private RandomAccessFile[] indices = new RandomAccessFile[256];
private final RandomAccessFile[] indices = new RandomAccessFile[256];
/**
* Read only flag.
@@ -41,7 +47,7 @@ public final class IndexedFileSystem implements Closeable {
/**
* Creates the file system with the specified base directory.
*
*
* @param base The base directory.
* @param readOnly Indicates whether the file system will be read only or not.
* @throws FileNotFoundException If the data files could not be found.
@@ -70,7 +76,7 @@ public final class IndexedFileSystem implements Closeable {
/**
* Automatically detect the layout of the specified directory.
*
*
* @param base The base directory.
* @throws FileNotFoundException If the data files could not be found.
*/
@@ -97,7 +103,7 @@ public final class IndexedFileSystem implements Closeable {
/**
* Gets the CRC table.
*
*
* @return The CRC table.
* @throws IOException If there is an error accessing files to create the table.
* @throws IllegalStateException If this file system is not read-only.
@@ -143,9 +149,26 @@ public final class IndexedFileSystem implements Closeable {
throw new IllegalStateException("Cannot get CRC table from a writable file system.");
}
/**
* Gets the CRC table as an {@code int} array.
*
* @return The CRC table as an {@code int} array.
* @throws IOException If there is an error accessing files to create the table.
*/
public int[] getCrcs() throws IOException {
if (crcs != null) {
return crcs;
}
ByteBuffer buffer = getCrcTable();
crcs = new int[(buffer.remaining() / Integer.BYTES) - 1];
Arrays.setAll(crcs, crc -> buffer.getInt());
return crcs;
}
/**
* Gets a file.
*
*
* @param descriptor The {@link FileDescriptor} pointing to the file.
* @return A {@link ByteBuffer} containing the contents of the file.
* @throws IOException If there is an error decoding the file.
@@ -211,7 +234,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.
@@ -223,7 +246,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 there is an error getting the length of the specified index file.
@@ -241,7 +264,7 @@ public final class IndexedFileSystem implements Closeable {
/**
* Gets the index of a file.
*
*
* @param descriptor The {@link FileDescriptor} which points to the file.
* @return The {@link Index}.
* @throws IOException If there is an error reading from the index file.
@@ -269,7 +292,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() {
+5 -5
View File
@@ -9,14 +9,14 @@ import org.apollo.util.CompressionUtil;
/**
* Represents an archive.
*
*
* @author Graham
*/
public final class Archive {
/**
* Decodes the archive in the specified buffer.
*
*
* @param buffer The buffer.
* @return The archive.
* @throws IOException If there is an error decompressing the archive.
@@ -72,7 +72,7 @@ public final class Archive {
/**
* Creates a new archive.
*
*
* @param entries The entries in this archive.
*/
public Archive(ArchiveEntry[] entries) {
@@ -81,7 +81,7 @@ public final class Archive {
/**
* Gets an {@link ArchiveEntry} by its name.
*
*
* @param name The name.
* @return The entry.
* @throws FileNotFoundException If the entry could not be found.
@@ -99,7 +99,7 @@ public final class Archive {
/**
* Hashes the specified string into an integer used to identify an {@link ArchiveEntry}.
*
*
* @param name The name of the entry.
* @return The hash.
*/
+4 -4
View File
@@ -4,7 +4,7 @@ import java.nio.ByteBuffer;
/**
* Represents a single entry in an {@link Archive}.
*
*
* @author Graham
*/
public final class ArchiveEntry {
@@ -21,7 +21,7 @@ public final class ArchiveEntry {
/**
* Creates a new archive entry.
*
*
* @param identifier The identifier.
* @param buffer The buffer.
*/
@@ -32,7 +32,7 @@ public final class ArchiveEntry {
/**
* Gets the buffer of this entry.
*
*
* @return This buffer of this entry.
*/
public ByteBuffer getBuffer() {
@@ -41,7 +41,7 @@ public final class ArchiveEntry {
/**
* Gets the identifier of this entry.
*
*
* @return The identifier of this entry.
*/
public int getIdentifier() {
@@ -26,7 +26,7 @@ import com.google.common.collect.Iterables;
/**
* Parses static object definitions, which include map tiles and landscapes.
*
*
* @author Ryley
* @author Major
*/
@@ -59,7 +59,7 @@ public final class GameObjectDecoder {
/**
* Creates the GameObjectDecoder.
*
*
* @param fs The {@link IndexedFileSystem}.
* @param regions The {@link RegionRepository}.
*/
@@ -70,7 +70,7 @@ public final class GameObjectDecoder {
/**
* Decodes the GameObjects from their MapDefinitions.
*
*
* @param world The {@link World} containing the StaticGameObjects.
* @return The decoded objects.
* @throws IOException If there is an error decoding the {@link MapDefinition}s.
@@ -99,7 +99,7 @@ public final class GameObjectDecoder {
/**
* Blocks tiles covered by a GameObject, if applicable.
*
*
* @param object The {@link GameObject}.
* @param position The position of the GameObject.
*/
@@ -133,7 +133,7 @@ public final class GameObjectDecoder {
if (block) {
for (int dx = 0; dx < definition.getWidth(); dx++) {
for (int dy = 0; dy < definition.getLength(); dy++) {
int localX = (x % Region.SIZE) + dx, localY = (y % Region.SIZE) + dy;
int localX = x % Region.SIZE + dx, localY = y % Region.SIZE + dy;
if (localX > 7 || localY > 7) {
int nextLocalX = localX > 7 ? x + localX - 7 : x + localX;
@@ -141,11 +141,13 @@ public final class GameObjectDecoder {
Position nextPosition = new Position(nextLocalX, nextLocalY);
Region next = regions.fromPosition(nextPosition);
int nextX = (nextPosition.getX() % Region.SIZE) + dx, nextY = (nextPosition.getY() % Region.SIZE) + dy;
if (nextX > 7)
int nextX = nextPosition.getX() % Region.SIZE + dx, nextY = nextPosition.getY() % Region.SIZE + dy;
if (nextX > 7) {
nextX -= 7;
if (nextY > 7)
}
if (nextY > 7) {
nextY -= 7;
}
next.getMatrix(height).block(nextX, nextY);
continue;
@@ -159,7 +161,7 @@ public final class GameObjectDecoder {
/**
* Decodes the attributes of a terrain file, blocking the tile if necessary.
*
*
* @param attributes The terrain attributes.
* @param position The {@link Position} of the tile whose attributes are being decoded.
*/
@@ -181,14 +183,14 @@ public final class GameObjectDecoder {
}
if (block) {
int localX = (x % Region.SIZE), localY = (y % Region.SIZE);
int localX = x % Region.SIZE, localY = y % Region.SIZE;
current.block(localX, localY);
}
}
/**
* Decodes object data stored in the specified {@link ByteBuffer}.
*
*
* @param world The {@link World} containing the StaticGameObjects.
* @param buffer The ByteBuffer.
* @param x The x coordinate of the top left tile of the map file.
@@ -209,7 +211,7 @@ public final class GameObjectDecoder {
int localY = packed & 0x3F;
int localX = packed >> 6 & 0x3F;
int height = (packed >> 12) & 0x3;
int height = packed >> 12 & 0x3;
int attributes = buffer.get() & 0xFF;
int type = attributes >> 2;
@@ -229,7 +231,7 @@ public final class GameObjectDecoder {
/**
* Decodes terrain data stored in the specified {@link ByteBuffer}.
*
*
* @param buffer The ByteBuffer.
* @param x The x coordinate of the top left tile of the map file.
* @param y The y coordinate of the top left tile of the map file.
@@ -10,7 +10,7 @@ import org.apollo.util.BufferUtil;
/**
* Decodes item data from the {@code obj.dat} file into {@link ItemDefinition}s.
*
*
* @author Graham
*/
public final class ItemDefinitionDecoder {
@@ -22,7 +22,7 @@ public final class ItemDefinitionDecoder {
/**
* Creates the item definition decoder.
*
*
* @param fs The indexed file system.
*/
public ItemDefinitionDecoder(IndexedFileSystem fs) {
@@ -31,7 +31,7 @@ public final class ItemDefinitionDecoder {
/**
* Decodes the item definitions.
*
*
* @return The item definitions.
* @throws IOException If an I/O error occurs.
*/
@@ -58,7 +58,7 @@ public final class ItemDefinitionDecoder {
/**
* Decodes a single definition.
*
*
* @param id The item's id.
* @param buffer The buffer.
* @return The {@link ItemDefinition}.
@@ -12,7 +12,7 @@ import org.apollo.game.model.area.Region;
/**
* Decodes {@link MapDefinition}s from the {@link IndexedFileSystem}.
*
*
* @author Ryley
* @author Major
*/
@@ -82,7 +82,7 @@ public final class MapFileDecoder {
/**
* Creates the {@link MapDefinition}.
*
*
* @param packedCoordinates The packed coordinates.
* @param terrain The terrain file id.
* @param objects The object file id.
@@ -97,7 +97,7 @@ public final class MapFileDecoder {
/**
* Gets the packed coordinates.
*
*
* @return The packed coordinates.
*/
public int getPackedCoordinates() {
@@ -106,7 +106,7 @@ public final class MapFileDecoder {
/**
* Gets the id of the file containing the terrain data.
*
*
* @return The file id.
*/
public int getTerrainFile() {
@@ -115,7 +115,7 @@ public final class MapFileDecoder {
/**
* Gets the id of the file containing the object data.
*
*
* @return The file id.
*/
public int getObjectFile() {
@@ -124,7 +124,7 @@ public final class MapFileDecoder {
/**
* Returns whether or not this MapDefinition is for a members-only area of the world.
*
*
* @return {@code true} if this MapDefinition is for a members-only area, {@code false} if not.
*/
public boolean isMembersOnly() {
@@ -11,7 +11,7 @@ import org.apollo.util.BufferUtil;
/**
* Decodes npc data from the {@code npc.dat} file into {@link NpcDefinition}s.
*
*
* @author Major
*/
public final class NpcDefinitionDecoder {
@@ -23,7 +23,7 @@ public final class NpcDefinitionDecoder {
/**
* Creates the npc definition decoder.
*
*
* @param fs The indexed file system.
*/
public NpcDefinitionDecoder(IndexedFileSystem fs) {
@@ -32,7 +32,7 @@ public final class NpcDefinitionDecoder {
/**
* Decodes the npc definitions.
*
*
* @return An array of all parsed npc definitions.
* @throws IOException If an I/O error occurs.
*/
@@ -59,7 +59,7 @@ public final class NpcDefinitionDecoder {
/**
* Decodes a single definition.
*
*
* @param id The npc's id.
* @param buffer The buffer.
* @return The {@link NpcDefinition}.
@@ -121,24 +121,20 @@ public final class NpcDefinitionDecoder {
} else if (opcode == 102 || opcode == 103) {
buffer.getShort();
} else if (opcode == 106) {
@SuppressWarnings("unused")
int morphVariableBitsIndex = wrap(buffer.getShort());
@SuppressWarnings("unused")
int morphismCount = wrap(buffer.getShort());
wrap(buffer.getShort());
wrap(buffer.getShort());
int count = buffer.get() & 0xFF;
int[] morphisms = new int[count + 1];
Arrays.setAll(morphisms, index -> wrap(buffer.getShort()));
} else if (opcode == 107) {
@SuppressWarnings("unused")
boolean clickable = false;
}
}
}
/**
* Wraps a morphism value around, returning -1 if the specified value is 65,535.
*
*
* @param value The value.
* @return -1 if {@code value} is 65,535, otherwise {@code value}.
*/
@@ -10,7 +10,7 @@ import org.apollo.util.BufferUtil;
/**
* Decodes object data from the {@code loc.dat} file into {@link ObjectDefinition}s.
*
*
* @author Major
*/
public final class ObjectDefinitionDecoder {
@@ -22,7 +22,7 @@ public final class ObjectDefinitionDecoder {
/**
* Creates the decoder.
*
*
* @param fs The {@link IndexedFileSystem}.
*/
public ObjectDefinitionDecoder(IndexedFileSystem fs) {
@@ -31,7 +31,7 @@ public final class ObjectDefinitionDecoder {
/**
* Decodes all of the data into {@link ObjectDefinition}s.
*
*
* @return The definitions.
* @throws IOException If an error occurs when decoding the archive or finding an entry.
*/
@@ -57,7 +57,7 @@ public final class ObjectDefinitionDecoder {
/**
* Decodes data from the cache into an {@link ObjectDefinition}.
*
*
* @param id The id of the object.
* @param data The {@link ByteBuffer} containing the data.
* @return The object definition.
+1 -1
View File
@@ -2,7 +2,7 @@ package org.apollo.game;
/**
* Contains game-related constants.
*
*
* @author Graham
*/
public final class GameConstants {
+2 -2
View File
@@ -5,7 +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 {
@@ -22,7 +22,7 @@ public final class GamePulseHandler implements Runnable {
/**
* Creates the game pulse handler object.
*
*
* @param service The {@link GameService}.
*/
protected GamePulseHandler(GameService service) {
+10 -11
View File
@@ -20,15 +20,14 @@ import org.apollo.io.MessageHandlerChainSetParser;
import org.apollo.login.LoginService;
import org.apollo.net.session.GameSession;
import org.apollo.util.MobRepository;
import org.apollo.util.ThreadUtil;
import org.apollo.util.xml.XmlNode;
import org.apollo.util.xml.XmlParser;
import org.xml.sax.SAXException;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
/**
* The {@link GameService} class schedules and manages the execution of the {@link GamePulseHandler} class.
*
*
* @author Graham
*/
public final class GameService extends Service {
@@ -52,7 +51,7 @@ public final class GameService extends Service {
/**
* The scheduled executor service.
*/
private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat("GameService").build());
private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(ThreadUtil.build("GameService"));
/**
* The {@link ClientSynchronizer}.
@@ -61,7 +60,7 @@ public final class GameService extends Service {
/**
* Creates the GameService.
*
*
* @param world The {@link World} the GameService is for.
* @throws Exception If an error occurs during initialization.
*/
@@ -72,7 +71,7 @@ public final class GameService extends Service {
/**
* Finalizes the unregistration of a player.
*
*
* @param player The player.
*/
public void finalizePlayerUnregistration(Player player) {
@@ -83,7 +82,7 @@ public final class GameService extends Service {
/**
* Gets the MessageHandlerChainSet
*
*
* @return The set of MessageHandlerChain's.
*/
public MessageHandlerChainSet getMessageHandlerChainSet() {
@@ -112,7 +111,7 @@ public final class GameService extends Service {
/**
* Registers a {@link Player} (may block!).
*
*
* @param player The Player.
* @param session The {@link GameSession} of the Player.
* @return A {@link RegistrationStatus}.
@@ -133,7 +132,7 @@ public final class GameService extends Service {
/**
* Shuts down this game service.
*
*
* @param natural Whether or not the shutdown was expected.
*/
public void shutdown(boolean natural) {
@@ -148,7 +147,7 @@ public final class GameService extends Service {
/**
* 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) {
@@ -173,7 +172,7 @@ public final class GameService extends Service {
/**
* Initializes the game service.
*
*
* @throws IOException If there is an error accessing the file.
* @throws SAXException If there is an error parsing the file.
* @throws ReflectiveOperationException If a MessageHandler could not be created.
+3 -3
View File
@@ -9,7 +9,7 @@ import org.apollo.game.scheduling.ScheduledTask;
* <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
* @param <T> The type of mob.
*/
@@ -27,7 +27,7 @@ public abstract class Action<T extends Mob> extends ScheduledTask {
/**
* Creates a new action.
*
*
* @param delay The delay in pulses.
* @param immediate A flag indicating if the action should happen immediately.
* @param mob The mob performing the action.
@@ -39,7 +39,7 @@ public abstract class Action<T extends Mob> extends ScheduledTask {
/**
* Gets the mob which performed the action.
*
*
* @return The mob.
*/
public final T getMob() {
@@ -5,7 +5,7 @@ import org.apollo.game.model.entity.Mob;
/**
* An @{link Action} which fires when a distance requirement is met.
*
*
* @author Blake
* @author Graham
* @param <T> The type of {@link Mob}.
@@ -39,7 +39,7 @@ public abstract class DistancedAction<T extends Mob> 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 mob The mob.
+4 -4
View File
@@ -2,7 +2,7 @@ package org.apollo.game.command;
/**
* Represents a command.
*
*
* @author Graham
*/
public final class Command {
@@ -19,7 +19,7 @@ public final class Command {
/**
* Creates the command.
*
*
* @param name The name of the command.
* @param arguments The command's arguments.
*/
@@ -30,7 +30,7 @@ public final class Command {
/**
* Gets the command's arguments.
*
*
* @return The command's arguments.
*/
public String[] getArguments() {
@@ -39,7 +39,7 @@ public final class Command {
/**
* Gets the name of the command.
*
*
* @return The name of the command.
*/
public String getName() {
@@ -8,7 +8,7 @@ import org.apollo.game.model.entity.Player;
/**
* A class that dispatches {@link Command}s to {@link CommandListener}s.
*
*
* @author Graham
*/
public final class CommandDispatcher {
@@ -20,7 +20,7 @@ public final class CommandDispatcher {
/**
* Initialises this CommandDispatcher.
*
*
* @param authors The {@link Set} of plugin authors.
*/
public void init(Set<String> authors) {
@@ -29,7 +29,7 @@ public final class CommandDispatcher {
/**
* Dispatches a command to the appropriate listener.
*
*
* @param player The player.
* @param command The command.
*/
@@ -42,7 +42,7 @@ public final class CommandDispatcher {
/**
* Registers a listener with the dispatcher.
*
*
* @param command The command's name.
* @param listener The listener.
*/
@@ -5,7 +5,7 @@ import org.apollo.game.model.entity.setting.PrivilegeLevel;
/**
* An interface which should be implemented to listen to {@link Command}s.
*
*
* @author Graham
* @author Major
*/
@@ -25,7 +25,7 @@ public abstract class CommandListener {
/**
* Creates a new command listener.
*
*
* @param level The required {@link PrivilegeLevel}.
*/
public CommandListener(PrivilegeLevel level) {
@@ -34,7 +34,7 @@ public abstract class CommandListener {
/**
* Executes the action for this command.
*
*
* @param player The player.
* @param command The command.
*/
@@ -42,7 +42,7 @@ public abstract class CommandListener {
/**
* Executes a privileged command.
*
*
* @param player The player.
* @param command The command.
*/
@@ -10,16 +10,16 @@ import com.google.common.collect.ImmutableSet;
/**
* Implements a {@code ::credits} command that lists the authors of all plugins used in the server.
*
*
* @author Graham
*/
public final class CreditsCommandListener extends CommandListener {
/**
* The Set of authors.
*/
private final Set<String> authors;
/**
* Creates the CreditsCommandListener.
*
+2 -2
View File
@@ -2,7 +2,7 @@ package org.apollo.game.message;
/**
* A message sent by the client that can be intercepted.
*
*
* @author Graham
* @author Major
*/
@@ -22,7 +22,7 @@ public abstract class Message {
/**
* Returns whether or not the Message chain has been terminated.
*
*
* @return {@code true} if the Message chain has been terminated, otherwise {@code false}.
*/
public final boolean terminated() {
@@ -5,7 +5,7 @@ import org.apollo.game.model.entity.Player;
/**
* Listens for {@link Message}s received from the client.
*
*
* @author Graham
* @author Ryley
* @param <M> The type of Message this class is listening for.
@@ -28,7 +28,7 @@ public abstract class MessageHandler<M extends Message> {
/**
* Handles the Message that was received.
*
*
* @param player The player to handle the Message for.
* @param message The Message.
*/
@@ -9,7 +9,7 @@ import com.google.common.base.MoreObjects;
/**
* A chain of {@link MessageHandler}s
*
*
* @author Graham
* @author Ryley
* @param <M> The Message type this chain represents.
@@ -28,7 +28,7 @@ public final class MessageHandlerChain<M extends Message> {
/**
* Constructs a new {@link MessageHandlerChain}.
*
*
* @param type The Class type of this chain.
*/
public MessageHandlerChain(Class<M> type) {
@@ -37,7 +37,7 @@ public final class MessageHandlerChain<M extends Message> {
/**
* Adds the specified {@link MessageHandler} to this chain.
*
*
* @param handler The MessageHandler.
*/
public void addHandler(MessageHandler<M> handler) {
@@ -46,7 +46,7 @@ public final class MessageHandlerChain<M extends Message> {
/**
* Notifies each {@link MessageHandler} in this chain that a {@link Message} has been received.
*
*
* @param player The Player to handle this message for.
* @param message The Message.
* @return {@code true} if and only if the Message propagated down the chain without being terminated, otherwise
@@ -7,7 +7,7 @@ import org.apollo.game.model.entity.Player;
/**
* A group of {@link MessageHandlerChain}s classified by the {@link Message} type.
*
*
* @author Graham
* @author Ryley
* @author Major
@@ -30,12 +30,12 @@ public final class MessageHandlerChainSet {
public <M extends Message> boolean notify(Player player, M message) {
@SuppressWarnings("unchecked")
MessageHandlerChain<M> chain = (MessageHandlerChain<M>) chains.get(message.getClass());
return (chain == null) || chain.notify(player, message);
return chain == null || chain.notify(player, message);
}
/**
* Places the {@link MessageHandlerChain} into this set.
*
*
* @param clazz The {@link Class} to associate the MessageHandlerChain with.
* @param handler The MessageHandlerChain.
*/
@@ -7,7 +7,7 @@ import org.apollo.game.model.entity.Player;
/**
* A {@link MessageHandler} that responds to {@link ButtonMessage}s for withdrawing items as notes.
*
*
* @author Graham
*/
public final class BankButtonMessageHandler extends MessageHandler<ButtonMessage> {
@@ -12,14 +12,14 @@ import org.apollo.game.model.inter.bank.BankWithdrawEnterAmountListener;
/**
* A {@link MessageHandler} that handles withdrawing and depositing items from/to a player's bank.
*
*
* @author Graham
*/
public final class BankMessageHandler extends MessageHandler<ItemActionMessage> {
/**
* Converts an option to an amount.
*
*
* @param option The option.
* @return The amount.
* @throws IllegalArgumentException If the option is invalid.
@@ -63,7 +63,7 @@ public final class BankMessageHandler extends MessageHandler<ItemActionMessage>
/**
* Handles a deposit action.
*
*
* @param player The player.
* @param message The message.
*/
@@ -80,7 +80,7 @@ public final class BankMessageHandler extends MessageHandler<ItemActionMessage>
/**
* Handles a withdraw action.
*
*
* @param player The player.
* @param message The message.
*/
@@ -8,7 +8,7 @@ import org.apollo.game.sync.block.SynchronizationBlock;
/**
* A {@link MessageHandler} that broadcasts public chat messages.
*
*
* @author Graham
*/
public final class ChatMessageHandler extends MessageHandler<ChatMessage> {
@@ -7,7 +7,7 @@ import org.apollo.game.model.entity.Player;
/**
* A {@link MessageHandler} that verifies {@link ChatMessage}s.
*
*
* @author Graham
*/
public final class ChatVerificationHandler extends MessageHandler<ChatMessage> {
@@ -7,7 +7,7 @@ import org.apollo.game.model.entity.Player;
/**
* A {@link MessageHandler} for the {@link ClosedInterfaceMessage}.
*
*
* @author Graham
*/
public final class ClosedInterfaceMessageHandler extends MessageHandler<ClosedInterfaceMessage> {
@@ -9,7 +9,7 @@ import org.apollo.game.model.entity.Player;
/**
* A {@link MessageHandler} that dispatches {@link CommandMessage}s.
*
*
* @author Graham
*/
public final class CommandMessageHandler extends MessageHandler<CommandMessage> {
@@ -9,7 +9,7 @@ import org.apollo.game.model.inter.InterfaceType;
/**
* A {@link MessageHandler} which intercepts button clicks on dialogues, and forwards the message to the current
* listener.
*
*
* @author Chris Fletcher
*/
public final class DialogueButtonHandler extends MessageHandler<ButtonMessage> {
@@ -8,7 +8,7 @@ import org.apollo.game.model.inter.InterfaceType;
/**
* A {@link MessageHandler} for the {@link DialogueContinueMessage}.
*
*
* @author Chris Fletcher
*/
public final class DialogueContinueMessageHandler extends MessageHandler<DialogueContinueMessage> {
@@ -7,7 +7,7 @@ import org.apollo.game.model.entity.Player;
/**
* A {@link MessageHandler} for the {@link EnteredAmountMessage}.
*
*
* @author Graham
*/
public final class EnteredAmountMessageHandler extends MessageHandler<EnteredAmountMessage> {
@@ -14,13 +14,13 @@ import org.apollo.util.LanguageUtil;
/**
* A {@link MessageHandler} that equips items.
*
*
* @author Major
* @author Graham
* @author Ryley
*/
public final class EquipItemHandler extends MessageHandler<ItemOptionMessage> {
/**
* The option used when equipping an item.
*/
@@ -98,8 +98,7 @@ public final class EquipItemHandler extends MessageHandler<ItemOptionMessage> {
return;
}
if (definition.getSlot() == EquipmentConstants.SHIELD && weapon != null
&& EquipmentDefinition.lookup(weapon.getId()).isTwoHanded()) {
if (definition.getSlot() == EquipmentConstants.SHIELD && weapon != null && EquipmentDefinition.lookup(weapon.getId()).isTwoHanded()) {
equipment.set(EquipmentConstants.SHIELD, inventory.reset(inventorySlot));
inventory.add(equipment.reset(EquipmentConstants.WEAPON));
return;
@@ -11,7 +11,7 @@ import org.apollo.game.model.inv.SynchronizationInventoryListener;
/**
* A {@link MessageHandler} that verifies the target item in {@link ItemOnItemMessage}s.
*
*
* @author Chris Fletcher
*/
public final class ItemOnItemVerificationHandler extends MessageHandler<ItemOnItemMessage> {
@@ -11,7 +11,7 @@ import org.apollo.game.model.inv.SynchronizationInventoryListener;
/**
* A {@link MessageHandler} that verifies {@link ItemOnObjectMessage}s.
*
*
* @author Major
*/
public final class ItemOnObjectVerificationHandler extends MessageHandler<ItemOnObjectMessage> {
@@ -27,8 +27,7 @@ public final class ItemOnObjectVerificationHandler extends MessageHandler<ItemOn
@Override
public void handle(Player player, ItemOnObjectMessage message) {
if (message.getInterfaceId() != SynchronizationInventoryListener.INVENTORY_ID
&& message.getInterfaceId() != BankConstants.SIDEBAR_INVENTORY_ID) {
if (message.getInterfaceId() != SynchronizationInventoryListener.INVENTORY_ID && message.getInterfaceId() != BankConstants.SIDEBAR_INVENTORY_ID) {
message.terminate();
return;
}
@@ -14,7 +14,7 @@ import org.apollo.game.model.inv.SynchronizationInventoryListener;
/**
* A {@link MessageHandler} that verifies {@link InventoryItemMessage}s.
*
*
* @author Chris Fletcher
* @author Major
*/
@@ -31,7 +31,7 @@ public final class ItemVerificationHandler extends MessageHandler<InventoryItemM
/**
* A supplier for an {@link Inventory}.
*
*
* @author Major
*/
@FunctionalInterface
@@ -39,7 +39,7 @@ public final class ItemVerificationHandler extends MessageHandler<InventoryItemM
/**
* Gets the appropriate {@link Inventory}.
*
*
* @param player The {@link Player} who prompted the verification call.
* @return The inventory. Must not be {@code null}.
*/
@@ -62,7 +62,7 @@ public final class ItemVerificationHandler extends MessageHandler<InventoryItemM
/**
* Adds an {@link Inventory} with the specified interface id to the {@link Map} of supported ones,
* <strong>iff</strong> the specified id does <strong>not</strong> already have a mapping.
*
*
* @param id The id of the interface.
* @param supplier The {@link InventorySupplier}.
*/
@@ -15,14 +15,14 @@ import org.apollo.game.model.entity.obj.GameObject;
/**
* A verification {@link MessageHandler} for the {@link ObjectActionMessage}.
*
*
* @author Major
*/
public final class ObjectActionVerificationHandler extends MessageHandler<ObjectActionMessage> {
/**
* Indicates whether or not the {@link List} of {@link GameObject}s contains the object with the specified id.
*
*
* @param id The id of the object.
* @param objects The list of objects.
* @return {@code true} if the list does contain the object with the specified id, otherwise {@code false}.
@@ -8,7 +8,7 @@ import org.apollo.util.MobRepository;
/**
* A verification {@link MessageHandler} for the {@link PlayerActionMessage}.
*
*
* @author Major
*/
public final class PlayerActionVerificationHandler extends MessageHandler<PlayerActionMessage> {
@@ -8,7 +8,7 @@ import org.apollo.game.model.entity.Player;
/**
* A {@link MessageHandler} that handles {@link PlayerDesignMessage}s.
*
*
* @author Graham
*/
public final class PlayerDesignMessageHandler extends MessageHandler<PlayerDesignMessage> {
@@ -9,7 +9,7 @@ import org.apollo.game.model.entity.setting.Gender;
/**
* A {@link MessageHandler} that verifies {@link PlayerDesignMessage}s.
*
*
* @author Graham
*/
public final class PlayerDesignVerificationHandler extends MessageHandler<PlayerDesignMessage> {
@@ -32,7 +32,7 @@ public final class PlayerDesignVerificationHandler extends MessageHandler<Player
/**
* Checks if an appearance combination is valid.
*
*
* @param appearance The appearance combination.
* @return {@code true} if so, {@code false} if not.
*/
@@ -58,7 +58,7 @@ public final class PlayerDesignVerificationHandler extends MessageHandler<Player
/**
* Checks if a {@link Gender#FEMALE} style combination is valid.
*
*
* @param appearance The appearance combination.
* @return {@code true} if so, {@code false} if not.
*/
@@ -78,7 +78,7 @@ public final class PlayerDesignVerificationHandler extends MessageHandler<Player
/**
* Checks if a {@link Gender#MALE} style combination is valid.
*
*
* @param appearance The appearance combination.
* @return {@code true} if so, {@code false} if not.
*/
@@ -10,7 +10,7 @@ import org.apollo.game.model.inv.SynchronizationInventoryListener;
/**
* A {@link MessageHandler} that removes equipped items.
*
*
* @author Graham
* @author Major
*/
@@ -11,7 +11,7 @@ import org.apollo.game.model.inv.SynchronizationInventoryListener;
/**
* A {@link MessageHandler} which updates an {@link Inventory} when the client sends a {@link SwitchItemMessage} to the
* server.
*
*
* @author Graham
*/
public final class SwitchItemMessageHandler extends MessageHandler<SwitchItemMessage> {
@@ -9,7 +9,7 @@ import org.apollo.game.model.entity.WalkingQueue;
/**
* A {@link MessageHandler} that handles {@link WalkMessage}s.
*
*
* @author Graham
*/
public final class WalkMessageHandler extends MessageHandler<WalkMessage> {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client when a player adds someone to their friends list.
*
*
* @author Major
*/
public final class AddFriendMessage extends Message {
@@ -16,7 +16,7 @@ public final class AddFriendMessage extends Message {
/**
* Creates a new befriend user message.
*
*
* @param username The befriended player's username.
*/
public AddFriendMessage(String username) {
@@ -25,7 +25,7 @@ public final class AddFriendMessage extends Message {
/**
* Gets the username of the befriended player.
*
*
* @return The username.
*/
public String getUsername() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client when a player adds someone to their ignore list.
*
*
* @author Major
*/
public final class AddIgnoreMessage extends Message {
@@ -16,7 +16,7 @@ public final class AddIgnoreMessage extends Message {
/**
* Creates a new ignore player message.
*
*
* @param username The ignored player's username.
*/
public AddIgnoreMessage(String username) {
@@ -25,7 +25,7 @@ public final class AddIgnoreMessage extends Message {
/**
* Gets the username of the ignored player.
*
*
* @return The username.
*/
public String getUsername() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client when the user has pressed an arrow key.
*
*
* @author Major
*/
public final class ArrowKeyMessage extends Message {
@@ -21,7 +21,7 @@ public final class ArrowKeyMessage extends Message {
/**
* Creates a new arrow key message.
*
*
* @param roll The camera roll.
* @param yaw The camera yaw.
*/
@@ -32,7 +32,7 @@ public final class ArrowKeyMessage extends Message {
/**
* Gets the roll of the camera.
*
*
* @return The roll.
*/
public int getRoll() {
@@ -41,7 +41,7 @@ public final class ArrowKeyMessage extends Message {
/**
* Gets the yaw of the camera.
*
*
* @return The yaw.
*/
public int getYaw() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client when a player clicks a button.
*
*
* @author Graham
*/
public final class ButtonMessage extends Message {
@@ -16,7 +16,7 @@ public final class ButtonMessage extends Message {
/**
* Creates the button message.
*
*
* @param widgetId The widget id.
*/
public ButtonMessage(int widgetId) {
@@ -25,7 +25,7 @@ public final class ButtonMessage extends Message {
/**
* Gets the widget id.
*
*
* @return The widget id.
*/
public int getWidgetId() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client to send a public chat message to other players.
*
*
* @author Graham
*/
public final class ChatMessage extends Message {
@@ -31,7 +31,7 @@ public final class ChatMessage extends Message {
/**
* Creates a new chat message.
*
*
* @param message The message.
* @param compressedMessage The compressed message.
* @param color The text color.
@@ -46,7 +46,7 @@ public final class ChatMessage extends Message {
/**
* Gets the compressed message.
*
*
* @return The compressed message.
*/
public byte[] getCompressedMessage() {
@@ -55,7 +55,7 @@ public final class ChatMessage extends Message {
/**
* Gets the message.
*
*
* @return The message.
*/
public String getMessage() {
@@ -64,7 +64,7 @@ public final class ChatMessage extends Message {
/**
* Gets the text color.
*
*
* @return The text color.
*/
public int getTextColor() {
@@ -73,7 +73,7 @@ public final class ChatMessage extends Message {
/**
* Gets the text effects.
*
*
* @return The text effects.
*/
public int getTextEffects() {
@@ -23,7 +23,7 @@ public final class ClearRegionMessage extends Message {
/**
* Creates the ClearRegionMessage.
*
*
* @param player The {@link Position} of the Player this {@link Message} is being sent to.
* @param region The {@link RegionCoordinates} of the Region being cleared.
*/
@@ -34,7 +34,7 @@ public final class ClearRegionMessage extends Message {
/**
* Gets the {@link Position} of the Player this {@link Message} is being sent to..
*
*
* @return The Position.
*/
public Position getPlayerPosition() {
@@ -43,7 +43,7 @@ public final class ClearRegionMessage extends Message {
/**
* Gets the {@link Position} of the Region being cleared.
*
*
* @return The Position.
*/
public Position getRegionPosition() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent to the client that closes the open interface.
*
*
* @author Graham
*/
public final class CloseInterfaceMessage extends Message {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client when the current interface is closed.
*
*
* @author Graham
*/
public final class ClosedInterfaceMessage extends Message {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client to send a {@code ::} command.
*
*
* @author Graham
*/
public final class CommandMessage extends Message {
@@ -16,7 +16,7 @@ public final class CommandMessage extends Message {
/**
* Creates the command message.
*
*
* @param command The command.
*/
public CommandMessage(String command) {
@@ -25,7 +25,7 @@ public final class CommandMessage extends Message {
/**
* Gets the command.
*
*
* @return The command.
*/
public String getCommand() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent to the client to adjust a certain config or attribute setting.
*
*
* @author Chris Fletcher
*/
public final class ConfigMessage extends Message {
@@ -21,7 +21,7 @@ public final class ConfigMessage extends Message {
/**
* Creates a new config message.
*
*
* @param id The config's identifier.
* @param value The value.
*/
@@ -32,7 +32,7 @@ public final class ConfigMessage extends Message {
/**
* Gets the config's identifier.
*
*
* @return The config id.
*/
public int getId() {
@@ -41,7 +41,7 @@ public final class ConfigMessage extends Message {
/**
* Gets the config's value.
*
*
* @return The config value.
*/
public int getValue() {
@@ -5,7 +5,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client when the player clicks the "Click here to continue" button on a dialogue
* interface.
*
*
* @author Chris Fletcher
*/
public final class DialogueContinueMessage extends Message {
@@ -17,7 +17,7 @@ public final class DialogueContinueMessage extends Message {
/**
* Creates a new dialogue continue message.
*
*
* @param interfaceId The interface id.
*/
public DialogueContinueMessage(int interfaceId) {
@@ -26,7 +26,7 @@ public final class DialogueContinueMessage extends Message {
/**
* Gets the interface id of the button.
*
*
* @return The interface id.
*/
public int getInterfaceId() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent to the client to display crossbones when the player enters a multi-combat zone.
*
*
* @author Major
*/
public final class DisplayCrossbonesMessage extends Message {
@@ -16,7 +16,7 @@ public final class DisplayCrossbonesMessage extends Message {
/**
* Creates a display crossbones message.
*
*
* @param display Whether or not the crossbones should be displayed.
*/
public DisplayCrossbonesMessage(boolean display) {
@@ -25,7 +25,7 @@ public final class DisplayCrossbonesMessage extends Message {
/**
* Indicates whether the crossbones will be displayed.
*
*
* @return {@code true} if the crossbones will be displayed, otherwise {@code false}.
*/
public boolean isDisplayed() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent to the client to change the currently displayed tab interface.
*
*
* @author Chris Fletcher
*/
public final class DisplayTabInterfaceMessage extends Message {
@@ -16,7 +16,7 @@ public final class DisplayTabInterfaceMessage extends Message {
/**
* Creates a new display tab interface message.
*
*
* @param tab The index of the tab to display.
*/
public DisplayTabInterfaceMessage(int tab) {
@@ -25,7 +25,7 @@ public final class DisplayTabInterfaceMessage extends Message {
/**
* Gets the index of the tab to display.
*
*
* @return The tab index.
*/
public int getTab() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent to the client to open up the enter amount interface.
*
*
* @author Graham
*/
public final class EnterAmountMessage extends Message {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client when the player has entered an amount.
*
*
* @author Graham
*/
public final class EnteredAmountMessage extends Message {
@@ -16,7 +16,7 @@ public final class EnteredAmountMessage extends Message {
/**
* Creates the entered amount message.
*
*
* @param amount The amount.
*/
public EnteredAmountMessage(int amount) {
@@ -25,7 +25,7 @@ public final class EnteredAmountMessage extends Message {
/**
* Gets the amount.
*
*
* @return The amount.
*/
public int getAmount() {
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The fifth {@link ItemActionMessage}.
*
*
* @author Graham
*/
public final class FifthItemActionMessage extends ItemActionMessage {
/**
* Creates the fifth item action message.
*
*
* @param interfaceId The interface id.
* @param id The item id.
* @param slot The item slot.
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The fifth {@link ItemOptionMessage}.
*
*
* @author Chris Fletcher
*/
public final class FifthItemOptionMessage extends ItemOptionMessage {
/**
* Creates the fifth item option message.
*
*
* @param interfaceId The interface id.
* @param id The id.
* @param slot The slot.
@@ -2,7 +2,7 @@ package org.apollo.game.message.impl;
/**
* The fifth {@link NpcActionMessage}.
*
*
* @author Major
* @author Stuart
*/
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The fifth {@link PlayerActionMessage}.
*
*
* @author Major
*/
public final class FifthPlayerActionMessage extends PlayerActionMessage {
/**
* Creates a fifth player action message.
*
*
* @param playerIndex The index of the clicked player.
*/
public FifthPlayerActionMessage(int playerIndex) {
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The first {@link ItemActionMessage}.
*
*
* @author Graham
*/
public final class FirstItemActionMessage extends ItemActionMessage {
/**
* Creates the first item action message.
*
*
* @param interfaceId The interface id.
* @param id The item id.
* @param slot The item slot.
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The first {@link ItemOptionMessage}.
*
*
* @author Chris Fletcher
*/
public final class FirstItemOptionMessage extends ItemOptionMessage {
/**
* Creates the first item option message.
*
*
* @param interfaceId The interface id.
* @param id The id.
* @param slot The slot.
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The first {@link NpcActionMessage}.
*
*
* @author Major
*/
public final class FirstNpcActionMessage extends NpcActionMessage {
/**
* Creates a new first npc action message.
*
*
* @param index The index of the npc.
*/
public FirstNpcActionMessage(int index) {
@@ -4,14 +4,14 @@ import org.apollo.game.model.Position;
/**
* The first {@link ObjectActionMessage}.
*
*
* @author Graham
*/
public final class FirstObjectActionMessage extends ObjectActionMessage {
/**
* Creates the first object action message.
*
*
* @param id The id.
* @param position The position.
*/
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The first {@link PlayerActionMessage}.
*
*
* @author Major
*/
public final class FirstPlayerActionMessage extends PlayerActionMessage {
/**
* Creates a first player action message.
*
*
* @param playerIndex The index of the clicked player.
*/
public FirstPlayerActionMessage(int playerIndex) {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client when the player clicks with their mouse (or mousekeys etc).
*
*
* @author Major
*/
public final class FlaggedMouseEventMessage extends Message {
@@ -32,7 +32,7 @@ public final class FlaggedMouseEventMessage extends Message {
/**
* Creates a new mouse click message.
*
*
* @param clickCount The number of clicks on this point.
* @param x The x coordinate of the mouse click.
* @param y The y coordinate of the mouse click.
@@ -47,7 +47,7 @@ public final class FlaggedMouseEventMessage extends Message {
/**
* Gets the number of clicks on this point - maximum value of 2047.
*
*
* @return The number of clicks.
*/
public int getClickCount() {
@@ -56,7 +56,7 @@ public final class FlaggedMouseEventMessage extends Message {
/**
* The x coordinate of the click.
*
*
* @return The x coordinate.
*/
public int getX() {
@@ -65,7 +65,7 @@ public final class FlaggedMouseEventMessage extends Message {
/**
* The y coordinate of the click.
*
*
* @return The y coordinate.
*/
public int getY() {
@@ -75,7 +75,7 @@ public final class FlaggedMouseEventMessage extends Message {
/**
* Gets the value indicating whether the {@link #x} and {@link #y} values represent the deviation from the last
* click or an actual point.
*
*
* @return The value.
*/
public boolean getDelta() {
@@ -25,7 +25,7 @@ public final class FlashTabInterfaceMessage extends Message {
/**
* Gets the id of the tab to flash.
*
*
* @return The id.
*/
public int getTab() {
@@ -25,7 +25,7 @@ public final class FlashingTabClickedMessage extends Message {
/**
* Gets the index of the tab that was clicked.
*
*
* @return The tab index.
*/
public int getTab() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent by the client to indicate a change in the client's focus (i.e. if it is the active window).
*
*
* @author Major
*/
public final class FocusUpdateMessage extends Message {
@@ -16,7 +16,7 @@ public final class FocusUpdateMessage extends Message {
/**
* Creates a new focus update message.
*
*
* @param focused The data received.
*/
public FocusUpdateMessage(boolean focused) {
@@ -25,7 +25,7 @@ public final class FocusUpdateMessage extends Message {
/**
* Indicates whether or not the client is focused.
*
*
* @return {@code true} if the client is focused, otherwise {@code false}.
*/
public boolean isFocused() {
@@ -5,7 +5,7 @@ import org.apollo.game.model.entity.setting.PrivilegeLevel;
/**
* A {@link Message} sent to the client that forwards a private chat.
*
*
* @author Major
*/
public final class ForwardPrivateChatMessage extends Message {
@@ -27,20 +27,20 @@ public final class ForwardPrivateChatMessage extends Message {
/**
* Creates a new forward private message message.
*
*
* @param username The username of the player sending the message.
* @param level The {@link PrivilegeLevel} of the player sending the message.
* @param message The compressed message.
*/
public ForwardPrivateChatMessage(String username, PrivilegeLevel level, byte[] message) {
this.username = username;
this.privilege = level;
privilege = level;
this.message = message;
}
/**
* Gets the username of the sender.
*
*
* @return The username.
*/
public String getSenderUsername() {
@@ -49,7 +49,7 @@ public final class ForwardPrivateChatMessage extends Message {
/**
* Gets the {@link PrivilegeLevel} of the sender.
*
*
* @return The privilege level.
*/
public PrivilegeLevel getSenderPrivilege() {
@@ -58,7 +58,7 @@ public final class ForwardPrivateChatMessage extends Message {
/**
* Gets the compressed message.
*
*
* @return The message.
*/
public byte[] getCompressedMessage() {
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The fourth {@link ItemActionMessage}.
*
*
* @author Graham
*/
public final class FourthItemActionMessage extends ItemActionMessage {
/**
* Creates the fourth item action message.
*
*
* @param interfaceId The interface id.
* @param id The item id.
* @param slot The item slot.
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The fourth {@link ItemOptionMessage}.
*
*
* @author Chris Fletcher
*/
public final class FourthItemOptionMessage extends ItemOptionMessage {
/**
* Creates the fourth item option message.
*
*
* @param interfaceId The interface id.
* @param id The id.
* @param slot The slot.
@@ -2,7 +2,7 @@ package org.apollo.game.message.impl;
/**
* The fourth {@link NpcActionMessage}.
*
*
* @author Major
* @author Stuart
*/
@@ -10,7 +10,7 @@ public final class FourthNpcActionMessage extends NpcActionMessage {
/**
* Creates the FourthNpcActionMessage.
*
*
* @param index The index of the Npc.
*/
public FourthNpcActionMessage(int index) {
@@ -2,14 +2,14 @@ package org.apollo.game.message.impl;
/**
* The fourth {@link PlayerActionMessage}.
*
*
* @author Major
*/
public final class FourthPlayerActionMessage extends PlayerActionMessage {
/**
* Creates a fourth player action message.
*
*
* @param playerIndex The index of the clicked player.
*/
public FourthPlayerActionMessage(int playerIndex) {
@@ -5,7 +5,7 @@ import org.apollo.game.model.entity.setting.ServerStatus;
/**
* A {@link Message} sent to the client to update the friend server status.
*
*
* @author Major
*/
public final class FriendServerStatusMessage extends Message {
@@ -17,7 +17,7 @@ public final class FriendServerStatusMessage extends Message {
/**
* Creates a new friend server status message.
*
*
* @param status The status.
*/
public FriendServerStatusMessage(ServerStatus status) {
@@ -26,7 +26,7 @@ public final class FriendServerStatusMessage extends Message {
/**
* Gets the status code of the friend server.
*
*
* @return The status code.
*/
public int getStatusCode() {
@@ -14,9 +14,9 @@ import org.apollo.game.model.area.RegionCoordinates;
public final class GroupedRegionUpdateMessage extends Message {
/**
* The Position of the Player.
* The last known region Position of the Player.
*/
private final Position player;
private final Position lastKnownRegion;
/**
* The Position of the Region being updated.
@@ -30,29 +30,29 @@ public final class GroupedRegionUpdateMessage extends Message {
/**
* Creates the GroupedRegionUpdateMessage.
*
* @param player The {@link Position} of the Player.
*
* @param lastKnownRegion The last known region {@link Position} of the Player.
* @param coordinates The {@link RegionCoordinates} of the Region being updated.
* @param messages The {@link List} of {@link RegionUpdateMessage}s.
*/
public GroupedRegionUpdateMessage(Position player, RegionCoordinates coordinates, List<RegionUpdateMessage> messages) {
this.player = player;
this.region = new Position(coordinates.getAbsoluteX(), coordinates.getAbsoluteY());
public GroupedRegionUpdateMessage(Position lastKnownRegion, RegionCoordinates coordinates, List<RegionUpdateMessage> messages) {
this.lastKnownRegion = lastKnownRegion;
region = new Position(coordinates.getAbsoluteX(), coordinates.getAbsoluteY());
this.messages = messages;
}
/**
* Gets the {@link Position} of the Player.
*
*
* @return The Position.
*/
public Position getPlayerPosition() {
return player;
public Position getLastKnownRegion() {
return lastKnownRegion;
}
/**
* Gets the {@link List} of {@link RegionUpdateMessage}s.
*
*
* @return The Collection.
*/
public List<RegionUpdateMessage> getMessages() {
@@ -61,7 +61,7 @@ public final class GroupedRegionUpdateMessage extends Message {
/**
* Gets the {@link Position} of the Region these updates affect.
*
*
* @return The Position.
*/
public Position getRegionPosition() {
@@ -47,7 +47,7 @@ public final class HintIconMessage extends Message {
/**
* Gets the value of this type.
*
*
* @return The value.
*/
public int getValue() {
@@ -58,7 +58,7 @@ public final class HintIconMessage extends Message {
/**
* Creates a HintIconMessage for the Npc with the specified index.
*
*
* @param index The index of the Npc.
* @return The HintIconMessage.
*/
@@ -68,7 +68,7 @@ public final class HintIconMessage extends Message {
/**
* Creates a HintIconMessage for the Player with the specified index.
*
*
* @param index The index of the Player.
* @return The HintIconMessage.
*/
@@ -78,7 +78,7 @@ public final class HintIconMessage extends Message {
/**
* Creates a HintIconMessage that removes the current Npc hint icon.
*
*
* @return The HintIconMessage.
*/
public static HintIconMessage resetNpc() {
@@ -87,7 +87,7 @@ public final class HintIconMessage extends Message {
/**
* Creates a HintIconMessage that removes the current Player hint icon.
*
*
* @return The HintIconMessage.
*/
public static HintIconMessage resetPlayer() {
@@ -5,7 +5,7 @@ import org.apollo.game.model.entity.setting.MembershipStatus;
/**
* A {@link Message} sent to the client that specifies the local id and membership status of the current player.
*
*
* @author Graham
*/
public final class IdAssignmentMessage extends Message {
@@ -22,7 +22,7 @@ public final class IdAssignmentMessage extends Message {
/**
* Creates the local id message.
*
*
* @param id The id.
* @param members The MembershipStatus.
*/
@@ -33,7 +33,7 @@ public final class IdAssignmentMessage extends Message {
/**
* Gets the id.
*
*
* @return The id.
*/
public int getId() {
@@ -42,7 +42,7 @@ public final class IdAssignmentMessage extends Message {
/**
* Gets whether or not the Player is a {@link MembershipStatus#PAID paying member}.
*
*
* @return {@code true} if the Player is a paying member, {@code false} if not.
*/
public boolean isMembers() {
@@ -6,7 +6,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent to the client that updates the ignored user list.
*
*
* @author Major
*/
public final class IgnoreListMessage extends Message {
@@ -18,7 +18,7 @@ public final class IgnoreListMessage extends Message {
/**
* Creates a new ignore list message.
*
*
* @param usernames The {@link List} of usernames to send.
*/
public IgnoreListMessage(List<String> usernames) {
@@ -27,7 +27,7 @@ public final class IgnoreListMessage extends Message {
/**
* Gets the list of ignored usernames.
*
*
* @return The usernames.
*/
public List<String> getUsernames() {
@@ -5,7 +5,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} that represents some sort of action on an item in an inventory. Note that this is the parent of
* both item option and item action message, and so cannot be used to determine when one of those messages is fired.
*
*
* @author Chris Fletcher
*/
public abstract class InventoryItemMessage extends Message {
@@ -32,7 +32,7 @@ public abstract class InventoryItemMessage extends Message {
/**
* Creates the item action message.
*
*
* @param option The option number.
* @param interfaceId The interface id.
* @param id The id.
@@ -47,7 +47,7 @@ public abstract class InventoryItemMessage extends Message {
/**
* Gets the item id.
*
*
* @return The item id.
*/
public final int getId() {
@@ -56,7 +56,7 @@ public abstract class InventoryItemMessage extends Message {
/**
* Gets the interface id.
*
*
* @return The interface id.
*/
public final int getInterfaceId() {
@@ -65,7 +65,7 @@ public abstract class InventoryItemMessage extends Message {
/**
* Gets the option number.
*
*
* @return The option number.
*/
public final int getOption() {
@@ -74,7 +74,7 @@ public abstract class InventoryItemMessage extends Message {
/**
* Gets the slot.
*
*
* @return The slot.
*/
public final int getSlot() {
@@ -6,14 +6,14 @@ import org.apollo.game.message.Message;
* A {@link Message} sent by the client that represents some sort of action on an item. Note that the actual message
* sent by the client is one of the five item action messages, but this is the message that should be intercepted (and
* the option verified).
*
*
* @author Chris Fletcher
*/
public abstract class ItemActionMessage extends InventoryItemMessage {
/**
* Creates the item action message.
*
*
* @param option The option number.
* @param interfaceId The interface id.
* @param id The id.
@@ -2,7 +2,7 @@ package org.apollo.game.message.impl;
/**
* A {@link InventoryItemMessage} sent by the client when a player uses one inventory item on another.
*
*
* @author Chris Fletcher
*/
public final class ItemOnItemMessage extends InventoryItemMessage {
@@ -24,7 +24,7 @@ public final class ItemOnItemMessage extends InventoryItemMessage {
/**
* Creates a new item-on-item message.
*
*
* @param usedInterface The interface id of the used item.
* @param usedId The id of the used item.
* @param usedSlot The slot of the target item.
@@ -41,7 +41,7 @@ public final class ItemOnItemMessage extends InventoryItemMessage {
/**
* Gets the id of the target item.
*
*
* @return The target item's interface id.
*/
public int getTargetId() {
@@ -50,7 +50,7 @@ public final class ItemOnItemMessage extends InventoryItemMessage {
/**
* Gets the interface id of the target item.
*
*
* @return The target item's interface id.
*/
public int getTargetInterfaceId() {
@@ -59,7 +59,7 @@ public final class ItemOnItemMessage extends InventoryItemMessage {
/**
* Gets the slot of the target item.
*
*
* @return The slot of the target item.
*/
public int getTargetSlot() {
@@ -5,7 +5,7 @@ import org.apollo.game.model.Position;
/**
* A {@link Message} sent by the client when an item is used on an object.
*
*
* @author Major
*/
public final class ItemOnObjectMessage extends InventoryItemMessage {
@@ -22,7 +22,7 @@ public final class ItemOnObjectMessage extends InventoryItemMessage {
/**
* Creates an item on object message.
*
*
* @param interfaceId The interface id.
* @param itemId The item id.
* @param itemSlot The slot the item is in.
@@ -33,12 +33,12 @@ public final class ItemOnObjectMessage extends InventoryItemMessage {
public ItemOnObjectMessage(int interfaceId, int itemId, int itemSlot, int objectId, int x, int y) {
super(0, interfaceId, itemId, itemSlot);
this.objectId = objectId;
this.position = new Position(x, y);
position = new Position(x, y);
}
/**
* Gets the object id.
*
*
* @return The object id.
*/
public int getObjectId() {
@@ -47,7 +47,7 @@ public final class ItemOnObjectMessage extends InventoryItemMessage {
/**
* Gets the position of the object.
*
*
* @return The position.
*/
public Position getPosition() {
@@ -4,14 +4,14 @@ package org.apollo.game.message.impl;
* An {@link InventoryItemMessage} sent by the client when an item's option is clicked (e.g. equip, eat, drink, etc).
* Note that the actual message sent by the client is one of the five item option messages, but this is the message that
* should be intercepted (and the option verified).
*
*
* @author Chris Fletcher
*/
public abstract class ItemOptionMessage extends InventoryItemMessage {
/**
* Creates the item option message.
*
*
* @param option The option number.
* @param interfaceId The interface id.
* @param id The id.
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} periodically sent by the client to keep a connection alive.
*
*
* @author Graham
*/
public final class KeepAliveMessage extends Message {
@@ -23,7 +23,7 @@ public final class KeepAliveMessage extends Message {
/**
* Gets the time when this message was created.
*
*
* @return The time when this message was created.
*/
public long getCreatedAt() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent to the client that cleanly logs it out.
*
*
* @author Graham
*/
public final class LogoutMessage extends Message {
@@ -2,7 +2,7 @@ package org.apollo.game.message.impl;
/**
* A {@link InventoryItemMessage} sent by the client when a player casts a spell on an inventory item.
*
*
* @author Chris Fletcher
*/
public final class MagicOnItemMessage extends InventoryItemMessage {
@@ -14,7 +14,7 @@ public final class MagicOnItemMessage extends InventoryItemMessage {
/**
* Creates a new magic on item message.
*
*
* @param interfaceId The interface id.
* @param id The item id.
* @param slot The item slot.
@@ -27,7 +27,7 @@ public final class MagicOnItemMessage extends InventoryItemMessage {
/**
* Gets the spell id.
*
*
* @return The spell id.
*/
public int getSpellId() {
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
/**
* A {@link Message} sent to the client to reset the animations of every mob.
*
*
* @author Major
*/
public final class MobAnimationResetMessage extends Message {

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