mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Format.
This commit is contained in:
@@ -112,7 +112,7 @@ public final class Server {
|
||||
|
||||
logger.fine("Binding HTTP listener to address: " + httpAddress + "...");
|
||||
try {
|
||||
httpBootstrap.bind(httpAddress);
|
||||
// httpBootstrap.bind(httpAddress);
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.WARNING,
|
||||
"Binding to HTTP failed: client will use JAGGRAB as a fallback (not recommended)!", t);
|
||||
|
||||
@@ -65,6 +65,7 @@ public final class NpcDefinitionDecoder {
|
||||
*/
|
||||
private NpcDefinition decode(int id, ByteBuffer buffer) {
|
||||
NpcDefinition definition = new NpcDefinition(id);
|
||||
|
||||
while (true) {
|
||||
int opcode = buffer.get() & 0xFF;
|
||||
|
||||
@@ -87,8 +88,7 @@ public final class NpcDefinitionDecoder {
|
||||
} else if (opcode == 14) {
|
||||
definition.setWalkAnimation(buffer.getShort());
|
||||
} else if (opcode == 17) {
|
||||
definition
|
||||
.setWalkAnimations(buffer.getShort(), buffer.getShort(), buffer.getShort(), buffer.getShort());
|
||||
definition.setWalkAnimations(buffer.getShort(), buffer.getShort(), buffer.getShort(), buffer.getShort());
|
||||
} else if (opcode >= 30 && opcode < 40) {
|
||||
String str = BufferUtil.readString(buffer);
|
||||
if (str.equals("hidden")) {
|
||||
|
||||
@@ -36,6 +36,7 @@ public final class GamePulseHandler implements Runnable {
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, "Exception during pulse.", t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,13 +4,14 @@ import org.apollo.game.model.entity.Mob;
|
||||
import org.apollo.game.scheduling.ScheduledTask;
|
||||
|
||||
/**
|
||||
* An action is a specialised {@link ScheduledTask} which is specific to a mob.
|
||||
* An action is a specialised {@link ScheduledTask} that is specific to a {@link Mob}.
|
||||
* <p>
|
||||
* <strong>ALL</strong> actions <strong>MUST</strong> implement the {@link #equals(Object)} method. This is to check if
|
||||
* two actions are identical: if they are, then the new action does not replace the old one (so spam/accidental clicking
|
||||
* won't cancel your action, and start another from scratch).
|
||||
*
|
||||
* @author Graham
|
||||
* @param <T> The type of mob.
|
||||
*/
|
||||
public abstract class Action<T extends Mob> extends ScheduledTask {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.apollo.game.model.entity.Mob;
|
||||
*
|
||||
* @author Blake
|
||||
* @author Graham
|
||||
* @param <T> The type of {@link Mob}.
|
||||
*/
|
||||
public abstract class DistancedAction<T extends Mob> extends Action<T> {
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@ package org.apollo.game.message.impl;
|
||||
import org.apollo.game.message.Message;
|
||||
import org.apollo.game.model.Item;
|
||||
|
||||
/**
|
||||
* A {@link Message} sent to the client to display an item on a tile for every player.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class AddGlobalTileItemMessage extends Message {
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,9 @@ public final class ArrowKeyMessage extends Message {
|
||||
|
||||
/**
|
||||
* Creates a new arrow key message.
|
||||
*
|
||||
* @param roll The camera roll.
|
||||
* @param yaw The camera yaw.
|
||||
*/
|
||||
public ArrowKeyMessage(int roll, int yaw) {
|
||||
this.roll = roll;
|
||||
|
||||
@@ -17,7 +17,7 @@ public final class FocusUpdateMessage extends Message {
|
||||
/**
|
||||
* Creates a new focus update message.
|
||||
*
|
||||
* @param update The data received.
|
||||
* @param focused The data received.
|
||||
*/
|
||||
public FocusUpdateMessage(boolean focused) {
|
||||
this.focused = focused;
|
||||
|
||||
@@ -28,7 +28,8 @@ public final class ForwardPrivateChatMessage extends Message {
|
||||
/**
|
||||
* Creates a new forward private message message.
|
||||
*
|
||||
* @param sender The player sending the 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) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public final class IgnoreListMessage extends Message {
|
||||
/**
|
||||
* Creates a new ignore list message.
|
||||
*
|
||||
* @param player The player.
|
||||
* @param usernames The {@link List} of usernames to send.
|
||||
*/
|
||||
public IgnoreListMessage(List<String> usernames) {
|
||||
this.usernames = usernames;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
/**
|
||||
* A {@link Message} sent by the client when a player uses one inventory item on another.
|
||||
* A {@link InventoryItemMessage} sent by the client when a player uses one inventory item on another.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
@@ -32,8 +32,7 @@ public final class ItemOnItemMessage extends InventoryItemMessage {
|
||||
* @param targetId The id of the target item.
|
||||
* @param targetSlot The slot of the target item.
|
||||
*/
|
||||
public ItemOnItemMessage(int usedInterface, int usedId, int usedSlot, int targetInterface, int targetId,
|
||||
int targetSlot) {
|
||||
public ItemOnItemMessage(int usedInterface, int usedId, int usedSlot, int targetInterface, int targetId, int targetSlot) {
|
||||
super(0, usedInterface, usedId, usedSlot);
|
||||
this.targetInterface = targetInterface;
|
||||
this.targetSlot = targetSlot;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
/**
|
||||
* A {@link Message} sent by the client when a player casts a spell on an inventory item.
|
||||
* A {@link InventoryItemMessage} sent by the client when a player casts a spell on an inventory item.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.apollo.game.message.Message;
|
||||
import org.apollo.game.model.Position;
|
||||
|
||||
/**
|
||||
* A {@link Message sent to the client instructing it to load the specified region.
|
||||
* A {@link Message} sent to the client instructing it to load the specified region.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class UpdateTileItemMessage extends Message {
|
||||
/**
|
||||
* Creates a new message that updates the previous amount of the item.
|
||||
*
|
||||
* @param id The item to be placed.
|
||||
* @param item The item to be placed.
|
||||
* @param previousAmount The previous amount of the item.
|
||||
*/
|
||||
public UpdateTileItemMessage(Item item, int previousAmount) {
|
||||
@@ -38,7 +38,7 @@ public final class UpdateTileItemMessage extends Message {
|
||||
/**
|
||||
* Creates a new set tile item message.
|
||||
*
|
||||
* @param id The item to be placed.
|
||||
* @param item The item to be placed.
|
||||
* @param previousAmount The previous amount of the item.
|
||||
* @param positionOffset The offset from the client's base position.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.apollo.game.model;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.MoreObjects;
|
||||
|
||||
/**
|
||||
* Represents a position in the world.
|
||||
@@ -219,7 +219,7 @@ public final class Position {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).add("x", x).add("y", y).add("height", height)
|
||||
return MoreObjects.toStringHelper(this).add("x", x).add("y", y).add("height", height)
|
||||
.add("sector x", getTopLeftSectorX()).add("sector y", getTopLeftSectorY()).toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.apollo.game.model;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -232,7 +231,7 @@ public final class World {
|
||||
* @param release The release number.
|
||||
* @param fs The file system.
|
||||
* @param manager The plugin manager. TODO move this.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
* @throws Exception If any definitions could not be loaded or there was a failure when loading plugins.
|
||||
*/
|
||||
public void init(int release, IndexedFileSystem fs, PluginManager manager) throws Exception {
|
||||
this.releaseNumber = release;
|
||||
@@ -345,6 +344,7 @@ public final class World {
|
||||
* Schedules a new task.
|
||||
*
|
||||
* @param task The {@link ScheduledTask}.
|
||||
* @return {@code true} if the task was added successfully.
|
||||
*/
|
||||
public boolean schedule(ScheduledTask task) {
|
||||
return scheduler.schedule(task);
|
||||
|
||||
@@ -51,14 +51,13 @@ public final class NpcDefinition {
|
||||
/**
|
||||
* Gets the NPC definition for the specified id.
|
||||
*
|
||||
* @param The id.
|
||||
* @param id The id.
|
||||
* @return The definition.
|
||||
* @throws IndexOutOfBoundsException If the id is out of bounds.
|
||||
*/
|
||||
public static NpcDefinition lookup(int id) {
|
||||
if (id < 0 || id >= definitions.length) {
|
||||
throw new IndexOutOfBoundsException(NpcDefinition.class.getName() + " lookup index " + id
|
||||
+ " out of bounds.");
|
||||
throw new IndexOutOfBoundsException(NpcDefinition.class.getName() + " lookup index " + id + " out of bounds.");
|
||||
}
|
||||
return definitions[id];
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public abstract class Mob extends Entity {
|
||||
/**
|
||||
* Gets this mob's {@link NpcDefinition}.
|
||||
*
|
||||
* @param definition The definition.
|
||||
* @return The npc definition.
|
||||
*/
|
||||
public final NpcDefinition getDefinition() {
|
||||
return definition;
|
||||
@@ -180,8 +180,8 @@ public abstract class Mob extends Entity {
|
||||
*/
|
||||
public final Direction[] getDirections() {
|
||||
if (firstDirection != Direction.NONE) {
|
||||
return secondDirection == Direction.NONE ? new Direction[] { firstDirection } : new Direction[] {
|
||||
firstDirection, secondDirection };
|
||||
return secondDirection == Direction.NONE ? new Direction[] { firstDirection } : new Direction[] { firstDirection,
|
||||
secondDirection };
|
||||
}
|
||||
return Direction.EMPTY_DIRECTION_ARRAY;
|
||||
}
|
||||
|
||||
@@ -221,8 +221,8 @@ public final class Player extends Mob {
|
||||
*
|
||||
* @param username The username.
|
||||
*/
|
||||
public boolean addFriend(String username) {
|
||||
return friends.add(username.toLowerCase());
|
||||
public void addFriend(String username) {
|
||||
friends.add(username.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,8 +230,8 @@ public final class Player extends Mob {
|
||||
*
|
||||
* @param username The username.
|
||||
*/
|
||||
public boolean addIgnore(String username) {
|
||||
return ignores.add(username.toLowerCase());
|
||||
public void addIgnore(String username) {
|
||||
ignores.add(username.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -606,6 +606,7 @@ public final class Player extends Mob {
|
||||
* Removes the specified username from this player's friend list.
|
||||
*
|
||||
* @param username The username.
|
||||
* @return {@code true} if the player's friend list contained the specified user, {@code false} if not.
|
||||
*/
|
||||
public boolean removeFriend(String username) {
|
||||
return friends.remove(username.toLowerCase());
|
||||
@@ -615,6 +616,7 @@ public final class Player extends Mob {
|
||||
* Removes the specified username from this player's ignore list.
|
||||
*
|
||||
* @param username The username.
|
||||
* @return {@code true} if the player's ignore list contained the specified user, {@code false} if not.
|
||||
*/
|
||||
public boolean removeIgnore(String username) {
|
||||
return ignores.remove(username.toLowerCase());
|
||||
@@ -666,6 +668,7 @@ public final class Player extends Mob {
|
||||
* Sends a message to the player.
|
||||
*
|
||||
* @param message The message.
|
||||
* @param filterable Whether or not the message can be filtered.
|
||||
*/
|
||||
public void sendMessage(String message, boolean filterable) {
|
||||
if (clientVersion > 0) {
|
||||
@@ -909,8 +912,8 @@ public final class Player extends Mob {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Player.class.getName() + " [username=" + getUsername() + ", privilege=" + privilegeLevel
|
||||
+ ", clientVersion=" + clientVersion + "]";
|
||||
return Player.class.getName() + " [username=" + getUsername() + ", privilege=" + privilegeLevel + ", clientVersion="
|
||||
+ clientVersion + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -925,8 +928,7 @@ public final class Player extends Mob {
|
||||
* Initialises the player's inventories.
|
||||
*/
|
||||
private void initInventories() {
|
||||
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 appearanceListener = new AppearanceInventoryListener(this);
|
||||
|
||||
|
||||
@@ -125,14 +125,12 @@ public final class SkillSet {
|
||||
*
|
||||
* @param listener The listener.
|
||||
*/
|
||||
public boolean addListener(SkillListener listener) {
|
||||
return listeners.add(listener);
|
||||
public void addListener(SkillListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the combat level for this skill set.
|
||||
*
|
||||
* @return The combat level.
|
||||
*/
|
||||
public void calculateCombatLevel() {
|
||||
int attack = skills[Skill.ATTACK].getMaximumLevel();
|
||||
@@ -249,8 +247,8 @@ public final class SkillSet {
|
||||
*
|
||||
* @param listener The listener to remove.
|
||||
*/
|
||||
public boolean removeListener(SkillListener listener) {
|
||||
return listeners.remove(listener);
|
||||
public void removeListener(SkillListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,77 +3,82 @@ package org.apollo.game.model.entity.attr;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A {@link Map} wrapper used to store {@link Attribute Attributes} and their {@link AttributeDefinition definitions}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class AttributeMap {
|
||||
|
||||
/**
|
||||
* The map of attribute names to definitions.
|
||||
*/
|
||||
private static Map<String, AttributeDefinition<?>> definitions = new HashMap<>(50);
|
||||
/**
|
||||
* The map of attribute names to definitions.
|
||||
*/
|
||||
private static Map<String, AttributeDefinition<?>> definitions = new HashMap<>(50);
|
||||
|
||||
/**
|
||||
* Registers an {@link AttributeDefinition}.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @param definition The definition.
|
||||
*/
|
||||
public static void addDefinition(String name, AttributeDefinition<?> definition) {
|
||||
definitions.put(name, definition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AttributeDefinition} with the specified name, or {@code null} if it is not defined.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @return The attribute definition.
|
||||
*/
|
||||
public static AttributeDefinition<?> getDefinition(String name) {
|
||||
return definitions.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AttributeDefinitions}, as a {@link Map}.
|
||||
*
|
||||
* @return The map of attribute names to definitions.
|
||||
*/
|
||||
public static Map<String, AttributeDefinition<?>> getDefinitions() {
|
||||
return new HashMap<>(definitions);
|
||||
}
|
||||
|
||||
/**
|
||||
* The map of attribute names to attributes.
|
||||
*/
|
||||
private Map<String, Attribute<?>> attributes = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Gets the {@link Attribute} with the specified name.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @return The attribute.
|
||||
*/
|
||||
public Attribute<?> getAttribute(String name) {
|
||||
return attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a shallow copy of the map of attributes.
|
||||
*
|
||||
* @return The attributes.
|
||||
*/
|
||||
public Map<String, Attribute<?>> getAttributes() {
|
||||
return new HashMap<>(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the {@link Attribute} with the specified name.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @param attribute The attribute.
|
||||
*/
|
||||
public void setAttribute(String name, Attribute<?> attribute) {
|
||||
if (getDefinition(name) == null) {
|
||||
throw new IllegalArgumentException("Attributes must be defined before their value can be set.");
|
||||
}
|
||||
attributes.put(name, attribute);
|
||||
/**
|
||||
* Registers an {@link AttributeDefinition}.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @param definition The definition.
|
||||
*/
|
||||
public static void addDefinition(String name, AttributeDefinition<?> definition) {
|
||||
definitions.put(name, definition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AttributeDefinition} with the specified name, or {@code null} if it is not defined.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @return The attribute definition.
|
||||
*/
|
||||
public static AttributeDefinition<?> getDefinition(String name) {
|
||||
return definitions.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AttributeDefinition}s, as a {@link Map}.
|
||||
*
|
||||
* @return The map of attribute names to definitions.
|
||||
*/
|
||||
public static Map<String, AttributeDefinition<?>> getDefinitions() {
|
||||
return new HashMap<>(definitions);
|
||||
}
|
||||
|
||||
/**
|
||||
* The map of attribute names to attributes.
|
||||
*/
|
||||
private Map<String, Attribute<?>> attributes = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Gets the {@link Attribute} with the specified name.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @return The attribute.
|
||||
*/
|
||||
public Attribute<?> getAttribute(String name) {
|
||||
return attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a shallow copy of the map of attributes.
|
||||
*
|
||||
* @return The attributes.
|
||||
*/
|
||||
public Map<String, Attribute<?>> getAttributes() {
|
||||
return new HashMap<>(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the {@link Attribute} with the specified name.
|
||||
*
|
||||
* @param name The name of the attribute.
|
||||
* @param attribute The attribute.
|
||||
*/
|
||||
public void setAttribute(String name, Attribute<?> attribute) {
|
||||
if (getDefinition(name) == null) {
|
||||
throw new IllegalArgumentException("Attributes must be defined before their value can be set.");
|
||||
}
|
||||
attributes.put(name, attribute);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package org.apollo.game.model.entity.attr;
|
||||
|
||||
/**
|
||||
* The type of attribute. The functionality of this enum (and other classes) is dependent on the ordering of the values
|
||||
* - the expected order is {@link #BOOLEAN}, {@link#DOUBLE}, {@link #LONG}, {@link #STRING}, {@link #SYMBOL}.
|
||||
* - the expected order is {@link #BOOLEAN}, {@link #DOUBLE}, {@link #LONG}, {@link #STRING}, {@link #SYMBOL}.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
|
||||
@@ -460,7 +460,6 @@ public final class Inventory implements Cloneable {
|
||||
* under no circumstances make any changes to other slots.
|
||||
*
|
||||
* @param slot The slot.
|
||||
* @param id The item id.
|
||||
* @param amount The amount to remove.
|
||||
* @return The amount that was removed (0 if nothing was removed).
|
||||
*/
|
||||
@@ -488,7 +487,7 @@ public final class Inventory implements Cloneable {
|
||||
/**
|
||||
* Removes the item (if any) that is in the specified slot.
|
||||
*
|
||||
* @param slot
|
||||
* @param slot The slot to reset.
|
||||
* @return The item that was in the slot.
|
||||
*/
|
||||
public Item reset(int slot) {
|
||||
|
||||
@@ -40,6 +40,7 @@ public enum PrivacyState {
|
||||
* Gets the privacy state for the specified numerical value.
|
||||
*
|
||||
* @param value The numerical value.
|
||||
* @param chat Whether or not the value is for public chat.
|
||||
* @return The privacy state.
|
||||
* @throws IllegalArgumentException If the specified value is out of bounds.
|
||||
*/
|
||||
@@ -77,6 +78,7 @@ public enum PrivacyState {
|
||||
/**
|
||||
* Converts this privacy state to an integer.
|
||||
*
|
||||
* @param chat Whether or not the value is for public chat.
|
||||
* @return The numerical value used by the client.
|
||||
*/
|
||||
public int toInteger(boolean chat) {
|
||||
|
||||
@@ -45,6 +45,7 @@ public final class Scheduler {
|
||||
* Schedules a new task.
|
||||
*
|
||||
* @param task The task to schedule.
|
||||
* @return {@code true} if the task was added successfully.
|
||||
*/
|
||||
public boolean schedule(ScheduledTask task) {
|
||||
return newTasks.add(task);
|
||||
|
||||
@@ -34,9 +34,9 @@ public abstract class SynchronizationBlock {
|
||||
* @return The appearance block.
|
||||
*/
|
||||
public static SynchronizationBlock createAppearanceBlock(Player player) {
|
||||
return new AppearanceBlock(player.getEncodedName(), player.getAppearance(), player.getSkillSet()
|
||||
.getCombatLevel(), 0, player.getEquipment(), player.getPrayerIcon(), player.isSkulled(),
|
||||
player.getDefinition() == null ? -1 : player.getDefinition().getId());
|
||||
return new AppearanceBlock(player.getEncodedName(), player.getAppearance(), player.getSkillSet().getCombatLevel(), 0,
|
||||
player.getEquipment(), player.getPrayerIcon(), player.isSkulled(), player.getDefinition() == null ? -1 : player
|
||||
.getDefinition().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ public abstract class SynchronizationBlock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link ForceMovement} block with the specified parameters.
|
||||
* Creates a {@link ForceMovementBlock} with the specified parameters.
|
||||
*
|
||||
* @param initialPosition The initial {@link Position} of the player.
|
||||
* @param finalPosition The final position of the player
|
||||
@@ -98,8 +98,8 @@ public abstract class SynchronizationBlock {
|
||||
*/
|
||||
public static SynchronizationBlock createHitUpdateBlock(int damage, int type, int currentHealth, int maximumHealth,
|
||||
boolean secondary) {
|
||||
return secondary ? new SecondaryHitUpdateBlock(damage, type, currentHealth, maximumHealth)
|
||||
: new HitUpdateBlock(damage, type, currentHealth, maximumHealth);
|
||||
return secondary ? new SecondaryHitUpdateBlock(damage, type, currentHealth, maximumHealth) : new HitUpdateBlock(damage,
|
||||
type, currentHealth, maximumHealth);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,6 +65,7 @@ public final class SynchronizationBlockSet implements Cloneable {
|
||||
* Removes a {@link SynchronizationBlock} from this set.
|
||||
*
|
||||
* @param clazz The block's class.
|
||||
* @return The removed block.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends SynchronizationBlock> T remove(Class<? extends SynchronizationBlock> clazz) {
|
||||
|
||||
@@ -95,8 +95,7 @@ public final class BinaryPlayerSaver implements PlayerSaver {
|
||||
}
|
||||
|
||||
Set<Entry<String, Attribute<?>>> attributes = player.getAttributes().entrySet();
|
||||
attributes
|
||||
.removeIf(e -> AttributeMap.getDefinition(e.getKey()).getPersistence() != AttributePersistence.SERIALIZED);
|
||||
attributes.removeIf(e -> AttributeMap.getDefinition(e.getKey()).getPersistence() != AttributePersistence.SERIALIZED);
|
||||
out.writeInt(attributes.size());
|
||||
|
||||
for (Entry<String, Attribute<?>> entry : attributes) {
|
||||
@@ -108,10 +107,10 @@ public final class BinaryPlayerSaver implements PlayerSaver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an attribute map entry to the specified output stream.
|
||||
* Writes an {@link Attribute} to the specified output stream.
|
||||
*
|
||||
* @param out The output stream.
|
||||
* @param entry The map entry.
|
||||
* @param attribute The attribute.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
private void saveAttribute(DataOutputStream out, Attribute<?> attribute) throws IOException {
|
||||
|
||||
@@ -4,11 +4,16 @@ import org.apollo.io.player.PlayerLoader;
|
||||
import org.apollo.io.player.PlayerLoaderResponse;
|
||||
import org.apollo.security.PlayerCredentials;
|
||||
|
||||
/**
|
||||
* A {@link PlayerLoader} that utilises {@code JDBC} to load player files.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class JdbcPlayerLoader implements PlayerLoader {
|
||||
|
||||
@Override
|
||||
public PlayerLoaderResponse loadPlayer(PlayerCredentials credentials) throws Exception {
|
||||
return null;
|
||||
throw new UnsupportedOperationException("JDBC loading is not supported at this time.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,16 @@ package org.apollo.io.player.impl;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
import org.apollo.io.player.PlayerSaver;
|
||||
|
||||
/**
|
||||
* A {@link PlayerSaver} that utilises {@code JDBC} to save the player.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public final class JdbcPlayerSaver implements PlayerSaver {
|
||||
|
||||
@Override
|
||||
public void savePlayer(Player player) throws Exception {
|
||||
|
||||
throw new UnsupportedOperationException("JDBC saving is not supported at this time.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.apollo.net.codec.game;
|
||||
|
||||
/**
|
||||
* Represents the order of bytes in a {@link DataType} when {@code {@link DataType#getBytes()} > 1}.
|
||||
* Represents the order of bytes in a {@link DataType} when {@link DataType#getBytes()} {@code > 1}.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.apollo.net.release.Release;
|
||||
import org.apollo.util.StatefulFrameDecoder;
|
||||
|
||||
/**
|
||||
* A {@link StatefulFrameDecoder} which decodes game packets.
|
||||
* A {@link StatefulFrameDecoder} that decodes {@link GamePacket}s.
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
@@ -59,17 +59,16 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, GameDecoderState state)
|
||||
throws IOException {
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, GameDecoderState state) throws IOException {
|
||||
switch (state) {
|
||||
case GAME_OPCODE:
|
||||
decodeOpcode(ctx, in, out);
|
||||
decodeOpcode(in, out);
|
||||
break;
|
||||
case GAME_LENGTH:
|
||||
decodeLength(ctx, in, out);
|
||||
decodeLength(in);
|
||||
break;
|
||||
case GAME_PAYLOAD:
|
||||
decodePayload(ctx, in, out);
|
||||
decodePayload(in, out);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Invalid game decoder state.");
|
||||
@@ -77,34 +76,27 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes in the length state.
|
||||
* Decodes the length state.
|
||||
*
|
||||
* @param ctx The channel handler context.
|
||||
* @param channel The channel.
|
||||
* @param buffer The buffer.
|
||||
* @return The frame, or {@code null}.
|
||||
* @throws Exception If an error occurs.
|
||||
*/
|
||||
private Object decodeLength(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) {
|
||||
private void decodeLength(ByteBuf buffer) {
|
||||
if (buffer.isReadable()) {
|
||||
length = buffer.readUnsignedByte();
|
||||
if (length != 0) {
|
||||
setState(GameDecoderState.GAME_PAYLOAD);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes in the opcode state.
|
||||
* Decodes the opcode state.
|
||||
*
|
||||
* @param ctx The channel handler context.
|
||||
* @param channel The channel.
|
||||
* @param buffer The buffer.
|
||||
* @return The frame, or {@code null}.
|
||||
* @param out The {@link List} of objects to be passed along the pipeline.
|
||||
* @throws IOException If a received opcode or packet type is illegal.
|
||||
*/
|
||||
private void decodeOpcode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws IOException {
|
||||
private void decodeOpcode(ByteBuf buffer, List<Object> out) throws IOException {
|
||||
if (buffer.isReadable()) {
|
||||
int encryptedOpcode = buffer.readUnsignedByte();
|
||||
opcode = encryptedOpcode - random.nextInt() & 0xFF;
|
||||
@@ -135,15 +127,12 @@ public final class GamePacketDecoder extends StatefulFrameDecoder<GameDecoderSta
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes in the payload state.
|
||||
* Decodes the payload state.
|
||||
*
|
||||
* @param ctx The channel handler context.
|
||||
* @param channel The channel.
|
||||
* @param buffer The buffer.
|
||||
* @return The frame, or {@code null}.
|
||||
* @throws Exception If an error occurs.
|
||||
* @param out The {@link List} of objects to be passed along the pipeline.
|
||||
*/
|
||||
private void decodePayload(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) {
|
||||
private void decodePayload(ByteBuf buffer, List<Object> out) {
|
||||
if (buffer.readableBytes() >= length) {
|
||||
ByteBuf payload = buffer.readBytes(length);
|
||||
setState(GameDecoderState.GAME_OPCODE);
|
||||
|
||||
@@ -58,8 +58,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, LoginDecoderState state)
|
||||
throws Exception {
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, LoginDecoderState state) throws Exception {
|
||||
switch (state) {
|
||||
case LOGIN_HANDSHAKE:
|
||||
decodeHandshake(ctx, in, out);
|
||||
@@ -79,10 +78,8 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
||||
* Decodes in the handshake state.
|
||||
*
|
||||
* @param ctx The channel handler context.
|
||||
* @param channel The channel.
|
||||
* @param buffer The buffer.
|
||||
* @return The frame, or {@code null}.
|
||||
* @throws Exception If an error occurs.
|
||||
* @param out The {@link List} of objects to pass forward through the pipeline.
|
||||
*/
|
||||
private void decodeHandshake(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) {
|
||||
if (buffer.isReadable()) {
|
||||
@@ -103,9 +100,8 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
||||
* Decodes in the header state.
|
||||
*
|
||||
* @param ctx The channel handler context.
|
||||
* @param channel The channel.
|
||||
* @param buffer The buffer.
|
||||
* @return The frame, or {@code null}.
|
||||
* @param out The {@link List} of objects to pass forward through the pipeline.
|
||||
* @throws IOException If the login type sent by the client is invalid.
|
||||
*/
|
||||
private void decodeHeader(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws IOException {
|
||||
@@ -127,9 +123,8 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
||||
* Decodes in the payload state.
|
||||
*
|
||||
* @param ctx The channel handler context.
|
||||
* @param channel The channel.
|
||||
* @param buffer The buffer.
|
||||
* @return The frame, or {@code null}.
|
||||
* @param out The {@link List} of objects to pass forward through the pipeline.
|
||||
* @throws Exception If an error occurs.
|
||||
*/
|
||||
private void decodePayload(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
|
||||
@@ -201,8 +196,8 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
||||
PlayerCredentials credentials = new PlayerCredentials(username, password, usernameHash, uid);
|
||||
IsaacRandomPair randomPair = new IsaacRandomPair(encodingRandom, decodingRandom);
|
||||
|
||||
LoginRequest request = new LoginRequest(credentials, randomPair, reconnecting, lowMemory, releaseNumber,
|
||||
archiveCrcs, clientVersion);
|
||||
LoginRequest request = new LoginRequest(credentials, randomPair, reconnecting, lowMemory, releaseNumber, archiveCrcs,
|
||||
clientVersion);
|
||||
|
||||
out.add(request);
|
||||
if (buffer.isReadable()) {
|
||||
|
||||
@@ -13,6 +13,9 @@ import java.util.List;
|
||||
*/
|
||||
public final class LoginEncoder extends MessageToMessageEncoder<LoginResponse> {
|
||||
|
||||
/**
|
||||
* Creates the login encoder.
|
||||
*/
|
||||
public LoginEncoder() {
|
||||
super(LoginResponse.class);
|
||||
}
|
||||
@@ -21,10 +24,12 @@ public final class LoginEncoder extends MessageToMessageEncoder<LoginResponse> {
|
||||
protected void encode(ChannelHandlerContext ctx, LoginResponse response, List<Object> out) {
|
||||
ByteBuf buffer = ctx.alloc().buffer(3);
|
||||
buffer.writeByte(response.getStatus());
|
||||
|
||||
if (response.getStatus() == LoginConstants.STATUS_OK) {
|
||||
buffer.writeByte(response.getRights());
|
||||
buffer.writeByte(response.isFlagged() ? 1 : 0);
|
||||
}
|
||||
|
||||
out.add(buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,9 +54,10 @@ public final class LoginRequest {
|
||||
* @param reconnecting The reconnecting flag.
|
||||
* @param releaseNumber The release number.
|
||||
* @param archiveCrcs The archive CRCs.
|
||||
* @param clientVersion The client version.
|
||||
*/
|
||||
public LoginRequest(PlayerCredentials credentials, IsaacRandomPair randomPair, boolean lowMemory,
|
||||
boolean reconnecting, int releaseNumber, int[] archiveCrcs, int clientVersion) {
|
||||
public LoginRequest(PlayerCredentials credentials, IsaacRandomPair randomPair, boolean lowMemory, boolean reconnecting,
|
||||
int releaseNumber, int[] archiveCrcs, int clientVersion) {
|
||||
this.credentials = credentials;
|
||||
this.randomPair = randomPair;
|
||||
this.lowMemory = lowMemory;
|
||||
|
||||
@@ -333,7 +333,7 @@ public final class PlayerSynchronizationMessageEncoder extends MessageEncoder<Pl
|
||||
/**
|
||||
* Puts a force movement block in the specified builder.
|
||||
*
|
||||
* @param forceMovementBlock The block.
|
||||
* @param block The block.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putForceMovementBlock(ForceMovementBlock block, GamePacketBuilder builder) {
|
||||
@@ -388,8 +388,7 @@ public final class PlayerSynchronizationMessageEncoder extends MessageEncoder<Pl
|
||||
* @param message The message.
|
||||
* @param builder The builder.
|
||||
*/
|
||||
private void putMovementUpdate(SynchronizationSegment seg, PlayerSynchronizationMessage message,
|
||||
GamePacketBuilder builder) {
|
||||
private void putMovementUpdate(SynchronizationSegment seg, PlayerSynchronizationMessage message, GamePacketBuilder builder) {
|
||||
boolean updateRequired = seg.getBlockSet().size() > 0;
|
||||
if (seg.getType() == SegmentType.TELEPORT) {
|
||||
Position position = ((TeleportSegment) seg).getDestination();
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.release.MessageEncoder;
|
||||
|
||||
/**
|
||||
* A {@link MessageEncoder} for the {@link SetWidgetComponentEvent}.
|
||||
* A {@link MessageEncoder} for the {@link SetWidgetVisibilityMessage}.
|
||||
*
|
||||
* @author Chris Fletcher
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,6 @@ public abstract class Session {
|
||||
* Processes a message received from the channel.
|
||||
*
|
||||
* @param message The message.
|
||||
* @throws Exception If an error occurs.
|
||||
*/
|
||||
public abstract void messageReceived(Object message);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.apollo.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
|
||||
@@ -11,11 +10,10 @@ import java.util.List;
|
||||
* A stateful implementation of a {@link ByteToMessageDecoder} which may be extended and used by other classes. The
|
||||
* current state is tracked by this class and is a user-specified enumeration.
|
||||
*
|
||||
* The state may be changed by calling the {@link StatefulFrameDecoder#setState(Enum)} method.
|
||||
* The state may be changed by calling the {@link StatefulFrameDecoder#setState} method.
|
||||
*
|
||||
* The current state is supplied as a parameter in the
|
||||
* {@link StatefulFrameDecoder#decode(ChannelHandlerContext, Channel, ByteBuf, Enum)} and
|
||||
* {@link StatefulFrameDecoder#decodeLast(ChannelHandlerContext, Channel, ByteBuf, Enum)} methods.
|
||||
* The current state is supplied as a parameter in the {@link StatefulFrameDecoder#decode} and
|
||||
* {@link StatefulFrameDecoder#decodeLast} methods.
|
||||
*
|
||||
* This class is not thread safe: it is recommended that the state is only set in the decode methods overriden.
|
||||
*
|
||||
@@ -61,8 +59,8 @@ public abstract class StatefulFrameDecoder<T extends Enum<T>> extends ByteToMess
|
||||
* Decodes the received packets into a frame.
|
||||
*
|
||||
* @param ctx The current context of this handler.
|
||||
* @param channel The channel.
|
||||
* @param buffer The cumulative buffer, which may contain zero or more bytes.
|
||||
* @param in The cumulative buffer, which may contain zero or more bytes.
|
||||
* @param out The {@link List} of objects to pass forward through the pipeline.
|
||||
* @param state The current state. The state may be changed by calling {@link #setState(Enum)}.
|
||||
*/
|
||||
protected abstract void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, T state) throws Exception;
|
||||
@@ -77,8 +75,8 @@ public abstract class StatefulFrameDecoder<T extends Enum<T>> extends ByteToMess
|
||||
* required. If you do not, remaining data will be discarded!
|
||||
*
|
||||
* @param ctx The current context of this handler.
|
||||
* @param channel The channel.
|
||||
* @param buffer The cumulative buffer, which may contain zero or more bytes.
|
||||
* @param in The cumulative buffer, which may contain zero or more bytes.
|
||||
* @param out The {@link List} of objects to pass forward through the pipeline.
|
||||
* @param state The current state. The state may be changed by calling {@link #setState(Enum)}.
|
||||
*/
|
||||
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out, T state) {
|
||||
|
||||
@@ -53,6 +53,7 @@ public final class PluginMetaData {
|
||||
* Creates the plugin meta data.
|
||||
*
|
||||
* @param id The plugin's id.
|
||||
* @param base The plugin's base folder.
|
||||
* @param name The plugin's name.
|
||||
* @param description The plugin's description.
|
||||
* @param authors The plugin's authors.
|
||||
|
||||
Reference in New Issue
Block a user