mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 00:38:11 +00:00
Cleanup and improve comments.
This commit is contained in:
@@ -248,9 +248,8 @@ POISON_IVY_BERRIES = Ingredient.new(6018)
|
||||
YEW_ROOTS = Ingredient.new(6049)
|
||||
MAGIC_ROOTS = Ingredient.new(6051)
|
||||
|
||||
# Grinded ingredients
|
||||
# Ground ingredients
|
||||
UNICORN_HORN_DUST = append_ground(235, 237)
|
||||
DRAGON_SCALE_DUST = append_ground(241, 243)
|
||||
CHOCOLATE_DUST = append_ground(1975, 1973)
|
||||
CRUSHED_NEST = append_ground(6693, 5075)
|
||||
GROUND_MUD_RUNE = append_ground(9594, 4698)
|
||||
# CRUSHED_NEST = append_ground(6693, 5075)
|
||||
@@ -83,4 +83,4 @@ def append_convert(button, level, elements, experience, reward)
|
||||
end
|
||||
|
||||
append_convert 1159, 15, { EARTH => 2, WATER => 2, NATURE => 1 }, 25, 1963 # Bones to bananas
|
||||
append_convert 15877, 60, { NATURE => 2, WATER => 4, EARTH => 4 }, 35.5, 6883 # Bones to peaches
|
||||
#append_convert 15877, 60, { NATURE => 2, WATER => 4, EARTH => 4 }, 35.5, 6883 # Bones to peaches
|
||||
@@ -49,7 +49,7 @@ public final class BankEventHandler extends EventHandler<ItemActionEvent> {
|
||||
private void deposit(EventHandlerContext ctx, Player player, ItemActionEvent event) {
|
||||
int amount = optionToAmount(event.getOption());
|
||||
if (amount == -1) {
|
||||
player.getInterfaceSet().openEnterAmountDialog(
|
||||
player.getInterfaceSet().openEnterAmountDialogue(
|
||||
new BankDepositEnterAmountListener(player, event.getSlot(), event.getId()));
|
||||
} else if (!BankUtils.deposit(player, event.getSlot(), event.getId(), amount)) {
|
||||
ctx.breakHandlerChain();
|
||||
@@ -58,14 +58,12 @@ public final class BankEventHandler extends EventHandler<ItemActionEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, ItemActionEvent event) {
|
||||
if (!player.getInterfaceSet().contains(BankConstants.BANK_WINDOW_ID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getInterfaceId() == BankConstants.SIDEBAR_INVENTORY_ID) {
|
||||
deposit(ctx, player, event);
|
||||
} else if (event.getInterfaceId() == BankConstants.BANK_INVENTORY_ID) {
|
||||
withdraw(ctx, player, event);
|
||||
if (player.getInterfaceSet().contains(BankConstants.BANK_WINDOW_ID)) {
|
||||
if (event.getInterfaceId() == BankConstants.SIDEBAR_INVENTORY_ID) {
|
||||
deposit(ctx, player, event);
|
||||
} else if (event.getInterfaceId() == BankConstants.BANK_INVENTORY_ID) {
|
||||
withdraw(ctx, player, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +77,7 @@ public final class BankEventHandler extends EventHandler<ItemActionEvent> {
|
||||
private void withdraw(EventHandlerContext ctx, Player player, ItemActionEvent event) {
|
||||
int amount = optionToAmount(event.getOption());
|
||||
if (amount == -1) {
|
||||
player.getInterfaceSet().openEnterAmountDialog(
|
||||
player.getInterfaceSet().openEnterAmountDialogue(
|
||||
new BankWithdrawEnterAmountListener(player, event.getSlot(), event.getId()));
|
||||
} else if (!BankUtils.withdraw(player, event.getSlot(), event.getId(), amount)) {
|
||||
ctx.breakHandlerChain();
|
||||
|
||||
@@ -16,15 +16,13 @@ public final class CommandEventHandler extends EventHandler<CommandEvent> {
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, CommandEvent event) {
|
||||
String str = event.getCommand();
|
||||
String[] components = str.split(" ");
|
||||
|
||||
String[] components = event.getCommand().split(" ");
|
||||
String name = components[0];
|
||||
|
||||
String[] arguments = new String[components.length - 1];
|
||||
|
||||
System.arraycopy(components, 1, arguments, 0, arguments.length);
|
||||
Command command = new Command(name, arguments);
|
||||
|
||||
Command command = new Command(name, arguments);
|
||||
World.getWorld().getCommandDispatcher().dispatch(player, command);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public final class PlayerDesignEventHandler extends EventHandler<PlayerDesignEve
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, PlayerDesignEvent event) {
|
||||
player.setAppearance(event.getAppearance());
|
||||
player.setDesigned(true);
|
||||
player.setNew(true);
|
||||
player.send(new CloseInterfaceEvent());
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public final class PlayerDesignVerificationHandler extends EventHandler<PlayerDe
|
||||
|
||||
@Override
|
||||
public void handle(EventHandlerContext ctx, Player player, PlayerDesignEvent event) {
|
||||
if (!valid(event.getAppearance()) || player.hasDesignedAvatar()) {
|
||||
if (!valid(event.getAppearance()) || player.isNewPlayer()) {
|
||||
ctx.breakHandlerChain();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.apollo.game.event.impl.ItemActionEvent;
|
||||
import org.apollo.game.model.Inventory;
|
||||
import org.apollo.game.model.Item;
|
||||
import org.apollo.game.model.Player;
|
||||
import org.apollo.game.model.def.ItemDefinition;
|
||||
import org.apollo.game.model.inv.SynchronizationInventoryListener;
|
||||
|
||||
/**
|
||||
@@ -27,7 +26,7 @@ public final class RemoveEventHandler extends EventHandler<ItemActionEvent> {
|
||||
Item item = equipment.get(slot);
|
||||
int id = item.getId();
|
||||
|
||||
if (inventory.freeSlots() == 0 && !ItemDefinition.lookup(id).isStackable()) {
|
||||
if (inventory.freeSlots() == 0 && !item.getDefinition().isStackable()) {
|
||||
inventory.forceCapacityExceeded();
|
||||
ctx.breakHandlerChain();
|
||||
return;
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class SwitchItemEventHandler extends EventHandler<SwitchItemEvent>
|
||||
|
||||
if (event.getOldSlot() >= 0 && event.getNewSlot() >= 0 && event.getOldSlot() < inventory.capacity()
|
||||
&& event.getNewSlot() < inventory.capacity()) {
|
||||
// events must be fired for it to work if a sidebar inv overlay is used
|
||||
// events must be fired for it to work if a sidebar inventory overlay is used
|
||||
inventory.swap(insertPermitted ? event.isInserting() : false, event.getOldSlot(), event.getNewSlot());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,17 @@ import org.apollo.game.event.Event;
|
||||
public abstract class NpcActionEvent extends Event {
|
||||
|
||||
/**
|
||||
* The option number .
|
||||
* The option number.
|
||||
*/
|
||||
private final int option;
|
||||
|
||||
/**
|
||||
* The npc index.
|
||||
* The index of the clicked npc.
|
||||
*/
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* Creates a new npc action event.
|
||||
* Creates an npc action event.
|
||||
*
|
||||
* @param option The option number.
|
||||
* @param index The index of the npc.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Contains login listeners.
|
||||
* Contains login and logout listeners.
|
||||
*/
|
||||
package org.apollo.game.login;
|
||||
@@ -40,11 +40,9 @@ public final class Appearance {
|
||||
public Appearance(Gender gender, int[] style, int[] colors) {
|
||||
if (gender == null || style == null || colors == null) {
|
||||
throw new NullPointerException("No arguments can be null.");
|
||||
}
|
||||
if (style.length != 7) {
|
||||
} else if (style.length != 7) {
|
||||
throw new IllegalArgumentException("The style array must have 7 elements.");
|
||||
}
|
||||
if (colors.length != 5) {
|
||||
} else if (colors.length != 5) {
|
||||
throw new IllegalArgumentException("The colors array must have 5 elements.");
|
||||
}
|
||||
this.gender = gender;
|
||||
|
||||
@@ -7,16 +7,16 @@ package org.apollo.game.model;
|
||||
*/
|
||||
public enum Direction {
|
||||
|
||||
/**
|
||||
* East movement.
|
||||
*/
|
||||
EAST(4),
|
||||
|
||||
/**
|
||||
* No movement.
|
||||
*/
|
||||
NONE(-1),
|
||||
|
||||
/**
|
||||
* North west movement.
|
||||
*/
|
||||
NORTH_WEST(0),
|
||||
|
||||
/**
|
||||
* North movement.
|
||||
*/
|
||||
@@ -28,9 +28,19 @@ public enum Direction {
|
||||
NORTH_EAST(2),
|
||||
|
||||
/**
|
||||
* North west movement.
|
||||
* West movement.
|
||||
*/
|
||||
NORTH_WEST(0),
|
||||
WEST(3),
|
||||
|
||||
/**
|
||||
* East movement.
|
||||
*/
|
||||
EAST(4),
|
||||
|
||||
/**
|
||||
* South west movement.
|
||||
*/
|
||||
SOUTH_WEST(5),
|
||||
|
||||
/**
|
||||
* South movement.
|
||||
@@ -40,17 +50,7 @@ public enum Direction {
|
||||
/**
|
||||
* South east movement.
|
||||
*/
|
||||
SOUTH_EAST(7),
|
||||
|
||||
/**
|
||||
* South west movement.
|
||||
*/
|
||||
SOUTH_WEST(5),
|
||||
|
||||
/**
|
||||
* West movement.
|
||||
*/
|
||||
WEST(3);
|
||||
SOUTH_EAST(7);
|
||||
|
||||
/**
|
||||
* An empty direction array.
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package org.apollo.game.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents an in-game entity, such as a mob, object, projectile etc.
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
public abstract class Entity implements Serializable {
|
||||
public abstract class Entity {
|
||||
|
||||
/**
|
||||
* Represents a type of {@link Entity}.
|
||||
@@ -40,12 +38,8 @@ public abstract class Entity implements Serializable {
|
||||
* A projectile (e.g. an arrow).
|
||||
*/
|
||||
PROJECTILE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The generated serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 5968243763380631014L;
|
||||
}
|
||||
|
||||
/**
|
||||
* The position of this entity.
|
||||
@@ -64,7 +58,7 @@ public abstract class Entity implements Serializable {
|
||||
/**
|
||||
* Gets the {@link EntityType} of this entity.
|
||||
*
|
||||
* @return The type.
|
||||
* @return The entity type.
|
||||
*/
|
||||
public abstract EntityType getEntityType();
|
||||
|
||||
|
||||
@@ -8,59 +8,59 @@ package org.apollo.game.model;
|
||||
public final class EquipmentConstants {
|
||||
|
||||
/**
|
||||
* The amulet slot.
|
||||
* The hat slot.
|
||||
*/
|
||||
public static final int AMULET = 2;
|
||||
|
||||
/**
|
||||
* The arrows slot.
|
||||
*/
|
||||
public static final int ARROWS = 13;
|
||||
public static final int HAT = 0;
|
||||
|
||||
/**
|
||||
* The cape slot.
|
||||
*/
|
||||
public static final int CAPE = 1;
|
||||
|
||||
/**
|
||||
* The amulet slot.
|
||||
*/
|
||||
public static final int AMULET = 2;
|
||||
|
||||
/**
|
||||
* The weapon slot.
|
||||
*/
|
||||
public static final int WEAPON = 3;
|
||||
|
||||
/**
|
||||
* The chest slot.
|
||||
*/
|
||||
public static final int CHEST = 4;
|
||||
|
||||
/**
|
||||
* The feet slot.
|
||||
*/
|
||||
public static final int FEET = 10;
|
||||
|
||||
/**
|
||||
* The hands slot.
|
||||
*/
|
||||
public static final int HANDS = 9;
|
||||
|
||||
/**
|
||||
* The hat slot.
|
||||
*/
|
||||
public static final int HAT = 0;
|
||||
|
||||
/**
|
||||
* The legs slot.
|
||||
*/
|
||||
public static final int LEGS = 7;
|
||||
|
||||
/**
|
||||
* The ring slot.
|
||||
*/
|
||||
public static final int RING = 12;
|
||||
|
||||
/**
|
||||
* The shield slot.
|
||||
*/
|
||||
public static final int SHIELD = 5;
|
||||
|
||||
/**
|
||||
* The weapon slot.
|
||||
* The legs slot.
|
||||
*/
|
||||
public static final int WEAPON = 3;
|
||||
public static final int LEGS = 7;
|
||||
|
||||
/**
|
||||
* The hands slot.
|
||||
*/
|
||||
public static final int HANDS = 9;
|
||||
|
||||
/**
|
||||
* The feet slot.
|
||||
*/
|
||||
public static final int FEET = 10;
|
||||
|
||||
/**
|
||||
* The ring slot.
|
||||
*/
|
||||
public static final int RING = 12;
|
||||
|
||||
/**
|
||||
* The arrows slot.
|
||||
*/
|
||||
public static final int ARROWS = 13;
|
||||
|
||||
/**
|
||||
* Default private constructor to prevent instantiation;
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class Graphic {
|
||||
/**
|
||||
* Gets the graphic's delay.
|
||||
*
|
||||
* @return The graphic's delay.
|
||||
* @return The delay.
|
||||
*/
|
||||
public int getDelay() {
|
||||
return delay;
|
||||
@@ -71,7 +71,7 @@ public final class Graphic {
|
||||
/**
|
||||
* Gets the graphic's height.
|
||||
*
|
||||
* @return The graphic's height.
|
||||
* @return The height.
|
||||
*/
|
||||
public int getHeight() {
|
||||
return height;
|
||||
@@ -80,7 +80,7 @@ public final class Graphic {
|
||||
/**
|
||||
* Gets the graphic's id.
|
||||
*
|
||||
* @return The graphic's id.
|
||||
* @return The id.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
|
||||
@@ -89,12 +89,10 @@ public final class Inventory implements Cloneable {
|
||||
public Inventory(int capacity, StackMode mode) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("Capacity cannot be negative.");
|
||||
}
|
||||
if (mode == null) {
|
||||
} else if (mode == null) {
|
||||
throw new NullPointerException("Stacking mode cannot be null.");
|
||||
}
|
||||
this.capacity = capacity;
|
||||
items = new Item[capacity];
|
||||
items = new Item[this.capacity = capacity];
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
@@ -117,10 +115,7 @@ public final class Inventory implements Cloneable {
|
||||
*/
|
||||
public int add(int id, int amount) {
|
||||
Item item = add(new Item(id, amount));
|
||||
if (item != null) {
|
||||
return item.getAmount();
|
||||
}
|
||||
return 0;
|
||||
return item != null ? item.getAmount() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,8 +135,7 @@ public final class Inventory implements Cloneable {
|
||||
Item other = items[slot];
|
||||
if (other != null && other.getId() == id) {
|
||||
long total = item.getAmount() + other.getAmount();
|
||||
int amount;
|
||||
int remaining;
|
||||
int amount, remaining;
|
||||
if (total > Integer.MAX_VALUE) {
|
||||
amount = (int) (total - Integer.MAX_VALUE);
|
||||
remaining = (int) (total - amount);
|
||||
@@ -335,18 +329,18 @@ public final class Inventory implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item specified by the definition should be stacked.
|
||||
* Checks if the item with the specified {@link ItemDefinition} should be stacked.
|
||||
*
|
||||
* @param def The definition.
|
||||
* @param definition The item definition.
|
||||
* @return {@code true} if the item should be stacked, {@code false} otherwise.
|
||||
*/
|
||||
private boolean isStackable(ItemDefinition def) {
|
||||
private boolean isStackable(ItemDefinition definition) {
|
||||
if (mode == StackMode.STACK_ALWAYS) {
|
||||
return true;
|
||||
} else if (mode == StackMode.STACK_STACKABLE_ITEMS) {
|
||||
return def.isStackable();
|
||||
return definition.isStackable();
|
||||
}
|
||||
return false; // will be STACK_NEVER
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,9 +372,8 @@ public final class Inventory implements Cloneable {
|
||||
*/
|
||||
private void notifyItemUpdated(int slot) {
|
||||
if (firingEvents) {
|
||||
Item item = items[slot];
|
||||
for (InventoryListener listener : listeners) {
|
||||
listener.itemUpdated(this, slot, item);
|
||||
listener.itemUpdated(this, slot, items[slot]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,11 +532,12 @@ public final class Inventory implements Cloneable {
|
||||
public void shift() {
|
||||
Item[] old = items;
|
||||
items = new Item[capacity];
|
||||
for (int i = 0, pos = 0; i < items.length; i++) {
|
||||
if (old[i] != null) {
|
||||
items[pos++] = old[i];
|
||||
for (int slot = 0, pos = 0; slot < items.length; slot++) {
|
||||
if (old[slot] != null) {
|
||||
items[pos++] = old[slot];
|
||||
}
|
||||
}
|
||||
|
||||
if (firingEvents) {
|
||||
notifyItemsUpdated();
|
||||
}
|
||||
@@ -602,6 +596,7 @@ public final class Inventory implements Cloneable {
|
||||
public void swap(boolean insert, int oldSlot, int newSlot) {
|
||||
checkBounds(oldSlot);
|
||||
checkBounds(newSlot);
|
||||
|
||||
if (insert) {
|
||||
if (newSlot > oldSlot) {
|
||||
for (int slot = oldSlot; slot < newSlot; slot++) {
|
||||
@@ -614,9 +609,9 @@ public final class Inventory implements Cloneable {
|
||||
}
|
||||
forceRefresh();
|
||||
} else {
|
||||
Item tmp = items[oldSlot];
|
||||
Item item = items[oldSlot];
|
||||
items[oldSlot] = items[newSlot];
|
||||
items[newSlot] = tmp;
|
||||
items[newSlot] = item;
|
||||
notifyItemUpdated(oldSlot);
|
||||
notifyItemUpdated(newSlot);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ public final class Item {
|
||||
*/
|
||||
private final int amount;
|
||||
|
||||
/**
|
||||
* The item definition.
|
||||
*/
|
||||
private final ItemDefinition definition;
|
||||
|
||||
/**
|
||||
* The item's id.
|
||||
*/
|
||||
@@ -41,6 +46,7 @@ public final class Item {
|
||||
}
|
||||
this.id = id;
|
||||
this.amount = amount;
|
||||
this.definition = ItemDefinition.lookup(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,12 +59,12 @@ public final class Item {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link ItemDefinition} which describes this item.
|
||||
* Gets the {@link ItemDefinition} that describes this item.
|
||||
*
|
||||
* @return The definition.
|
||||
*/
|
||||
public ItemDefinition getDefinition() {
|
||||
return ItemDefinition.lookup(id);
|
||||
return definition;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,11 +17,6 @@ import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||
*/
|
||||
public abstract class Mob extends Entity {
|
||||
|
||||
/**
|
||||
* The generated serial uid.
|
||||
*/
|
||||
private static final long serialVersionUID = 8342608309450355638L;
|
||||
|
||||
/**
|
||||
* This mob's current action.
|
||||
*/
|
||||
@@ -33,7 +28,7 @@ public abstract class Mob extends Entity {
|
||||
protected transient SynchronizationBlockSet blockSet = new SynchronizationBlockSet();
|
||||
|
||||
/**
|
||||
* This mob's npc definition. A player only uses this if they are appearing as an npc in-game.
|
||||
* This mob's npc definition. A player only uses this if they are appearing as an npc.
|
||||
*/
|
||||
protected NpcDefinition definition;
|
||||
|
||||
@@ -424,7 +419,7 @@ public abstract class Mob extends Entity {
|
||||
this.position = position;
|
||||
teleporting = true;
|
||||
walkingQueue.clear();
|
||||
stopAction(); // TODO do it on any movement is a must... walking queue perhaps?
|
||||
stopAction();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,8 +428,7 @@ public abstract class Mob extends Entity {
|
||||
* @param position The position to face.
|
||||
*/
|
||||
public final void turnTo(Position position) {
|
||||
blockSet.add(SynchronizationBlock.createTurnToPositionBlock(position));
|
||||
this.facingPosition = position;
|
||||
blockSet.add(SynchronizationBlock.createTurnToPositionBlock(this.facingPosition = position));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import org.apollo.game.sync.block.SynchronizationBlock;
|
||||
*
|
||||
* @author Major
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public final class Npc extends Mob {
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,10 @@ import org.apollo.game.event.impl.SwitchTabInterfaceEvent;
|
||||
import org.apollo.game.event.impl.UpdateRunEnergyEvent;
|
||||
import org.apollo.game.model.Inventory.StackMode;
|
||||
import org.apollo.game.model.inter.InterfaceConstants;
|
||||
import org.apollo.game.model.inter.InterfaceListener;
|
||||
import org.apollo.game.model.inter.InterfaceSet;
|
||||
import org.apollo.game.model.inter.bank.BankConstants;
|
||||
import org.apollo.game.model.inter.bank.BankInterfaceListener;
|
||||
import org.apollo.game.model.inv.AppearanceInventoryListener;
|
||||
import org.apollo.game.model.inv.FullInventoryListener;
|
||||
import org.apollo.game.model.inv.InventoryListener;
|
||||
@@ -27,7 +29,6 @@ import org.apollo.game.model.settings.PrivacyState;
|
||||
import org.apollo.game.model.settings.PrivilegeLevel;
|
||||
import org.apollo.game.model.settings.ScreenBrightness;
|
||||
import org.apollo.game.model.skill.LevelUpSkillListener;
|
||||
import org.apollo.game.model.skill.SkillListener;
|
||||
import org.apollo.game.model.skill.SynchronizationSkillListener;
|
||||
import org.apollo.game.sync.block.SynchronizationBlock;
|
||||
import org.apollo.net.session.GameSession;
|
||||
@@ -41,11 +42,6 @@ import org.apollo.util.Point;
|
||||
*/
|
||||
public final class Player extends Mob {
|
||||
|
||||
/**
|
||||
* The generated serial uid.
|
||||
*/
|
||||
private static final long serialVersionUID = -5865532568677077237L;
|
||||
|
||||
/**
|
||||
* The player's appearance.
|
||||
*/
|
||||
@@ -64,7 +60,7 @@ public final class Player extends Mob {
|
||||
/**
|
||||
* A deque of this player's mouse clicks.
|
||||
*/
|
||||
private transient Deque<Point> clicks = new ArrayDeque<Point>();
|
||||
private transient Deque<Point> clicks = new ArrayDeque<>();
|
||||
|
||||
/**
|
||||
* The version of the client this player is using. This is not the same as the release number, instead denoting the
|
||||
@@ -77,11 +73,6 @@ public final class Player extends Mob {
|
||||
*/
|
||||
private PlayerCredentials credentials;
|
||||
|
||||
/**
|
||||
* A flag indicating if the player has designed their avatar.
|
||||
*/
|
||||
private boolean designedAvatar = false;
|
||||
|
||||
/**
|
||||
* A flag which indicates there are npcs that couldn't be added.
|
||||
*/
|
||||
@@ -132,6 +123,11 @@ public final class Player extends Mob {
|
||||
*/
|
||||
private transient boolean members = false;
|
||||
|
||||
/**
|
||||
* A flag indicating if the player is new.
|
||||
*/
|
||||
private boolean newPlayer = false;
|
||||
|
||||
/**
|
||||
* This player's prayer icon.
|
||||
*/
|
||||
@@ -200,8 +196,8 @@ public final class Player extends Mob {
|
||||
*/
|
||||
public Player(PlayerCredentials credentials, Position position) {
|
||||
super(position);
|
||||
init();
|
||||
this.credentials = credentials;
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -477,15 +473,6 @@ public final class Player extends Mob {
|
||||
return worldId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has designed their avatar.
|
||||
*
|
||||
* @return A flag indicating if the player has designed their avatar.
|
||||
*/
|
||||
public boolean hasDesignedAvatar() {
|
||||
return designedAvatar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether or not the player with the specified username is on this player's ignore list.
|
||||
*
|
||||
@@ -535,22 +522,17 @@ public final class Player extends Mob {
|
||||
* Initialises the player's inventories.
|
||||
*/
|
||||
private void initInventories() {
|
||||
// inventory full listeners
|
||||
InventoryListener fullInventoryListener = new FullInventoryListener(this,
|
||||
FullInventoryListener.FULL_INVENTORY_MESSAGE);
|
||||
InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE);
|
||||
|
||||
// equipment appearance listener
|
||||
InventoryListener appearanceListener = new AppearanceInventoryListener(this);
|
||||
|
||||
// synchronization listeners
|
||||
InventoryListener syncInventoryListener = new SynchronizationInventoryListener(this,
|
||||
SynchronizationInventoryListener.INVENTORY_ID);
|
||||
InventoryListener syncBankListener = new SynchronizationInventoryListener(this, BankConstants.BANK_INVENTORY_ID);
|
||||
InventoryListener syncEquipmentListener = new SynchronizationInventoryListener(this,
|
||||
SynchronizationInventoryListener.EQUIPMENT_ID);
|
||||
|
||||
// add the listeners
|
||||
inventory.addListener(syncInventoryListener);
|
||||
inventory.addListener(fullInventoryListener);
|
||||
bank.addListener(syncBankListener);
|
||||
@@ -563,17 +545,8 @@ public final class Player extends Mob {
|
||||
* Initialises the player's skills.
|
||||
*/
|
||||
private void initSkills() {
|
||||
SkillSet skills = getSkillSet();
|
||||
|
||||
// synchronization listener
|
||||
SkillListener syncListener = new SynchronizationSkillListener(this);
|
||||
|
||||
// level up listener
|
||||
SkillListener levelUpListener = new LevelUpSkillListener(this);
|
||||
|
||||
// add the listeners
|
||||
skills.addListener(syncListener);
|
||||
skills.addListener(levelUpListener);
|
||||
skillSet.addListener(new SynchronizationSkillListener(this));
|
||||
skillSet.addListener(new LevelUpSkillListener(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -603,6 +576,15 @@ public final class Player extends Mob {
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this player has logged in before.
|
||||
*
|
||||
* @return A flag indicating if the player is new.
|
||||
*/
|
||||
public boolean isNewPlayer() {
|
||||
return newPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the player is running or not.
|
||||
*
|
||||
@@ -637,6 +619,22 @@ public final class Player extends Mob {
|
||||
return filteringMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens this player's bank.
|
||||
*/
|
||||
public void openBank() {
|
||||
InventoryListener invListener = new SynchronizationInventoryListener(this, BankConstants.SIDEBAR_INVENTORY_ID);
|
||||
InventoryListener bankListener = new SynchronizationInventoryListener(this, BankConstants.BANK_INVENTORY_ID);
|
||||
|
||||
inventory.addListener(invListener);
|
||||
bank.addListener(bankListener);
|
||||
inventory.forceRefresh();
|
||||
bank.forceRefresh();
|
||||
|
||||
InterfaceListener interListener = new BankInterfaceListener(this, invListener, bankListener);
|
||||
interfaceSet.openWindowWithSidebar(interListener, BankConstants.BANK_WINDOW_ID, BankConstants.SIDEBAR_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified username from this player's friend list.
|
||||
*
|
||||
@@ -694,8 +692,7 @@ public final class Player extends Mob {
|
||||
private void sendInitialEvents() {
|
||||
send(new IdAssignmentEvent(index, members)); // TODO should this be sent when we reconnect?
|
||||
sendMessage("Welcome to RuneScape.");
|
||||
|
||||
if (!designedAvatar) {
|
||||
if (!newPlayer) {
|
||||
interfaceSet.openWindow(InterfaceConstants.AVATAR_DESIGN);
|
||||
}
|
||||
|
||||
@@ -794,15 +791,6 @@ public final class Player extends Mob {
|
||||
this.clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the design flag.
|
||||
*
|
||||
* @param designedAvatar A flag indicating if the player has designed their avatar.
|
||||
*/
|
||||
public void setDesigned(boolean designedAvatar) {
|
||||
this.designedAvatar = designedAvatar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the friend {@link PrivacyState}.
|
||||
*
|
||||
@@ -857,6 +845,15 @@ public final class Player extends Mob {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new player flag.
|
||||
*
|
||||
* @param newPlayer A flag indicating if the player has played before.
|
||||
*/
|
||||
public void setNew(boolean newPlayer) {
|
||||
this.newPlayer = newPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player's prayer icon.
|
||||
*
|
||||
@@ -890,8 +887,7 @@ public final class Player extends Mob {
|
||||
* @param runEnergy The energy.
|
||||
*/
|
||||
public void setRunEnergy(int runEnergy) {
|
||||
this.runEnergy = runEnergy;
|
||||
send(new UpdateRunEnergyEvent(runEnergy));
|
||||
send(new UpdateRunEnergyEvent(this.runEnergy = runEnergy));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class SkillSet {
|
||||
/**
|
||||
* A list of skill listeners.
|
||||
*/
|
||||
private final List<SkillListener> listeners = new ArrayList<SkillListener>();
|
||||
private final List<SkillListener> listeners = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The skills.
|
||||
@@ -102,7 +102,6 @@ public final class SkillSet {
|
||||
*/
|
||||
public void addExperience(int id, double experience) {
|
||||
checkBounds(id);
|
||||
|
||||
Skill old = skills[id];
|
||||
|
||||
double newExperience = old.getExperience() + experience;
|
||||
@@ -218,14 +217,13 @@ public final class SkillSet {
|
||||
*/
|
||||
public void normalize() {
|
||||
for (int id = 0; id < skills.length; id++) {
|
||||
int current = skills[id].getCurrentLevel();
|
||||
int max = skills[id].getMaximumLevel();
|
||||
int current = skills[id].getCurrentLevel(), max = skills[id].getMaximumLevel();
|
||||
|
||||
if (current == max) {
|
||||
continue;
|
||||
}
|
||||
current += current < max ? 1 : -1;
|
||||
|
||||
current += current < max ? 1 : -1;
|
||||
setSkill(id, new Skill(skills[id].getExperience(), current, max));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class SlottedItem {
|
||||
*
|
||||
* @return The amount.
|
||||
*/
|
||||
public int getamount() {
|
||||
public int getAmount() {
|
||||
return item.getAmount();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public final class WalkingQueue {
|
||||
public String toString() {
|
||||
return Point.class.getName() + " [direction=" + direction + ", position=" + position + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,12 +59,12 @@ public final class WalkingQueue {
|
||||
/**
|
||||
* The old queue of directions.
|
||||
*/
|
||||
private final Deque<Point> oldPoints = new ArrayDeque<Point>();
|
||||
private final Deque<Point> oldPoints = new ArrayDeque<>();
|
||||
|
||||
/**
|
||||
* The queue of directions.
|
||||
*/
|
||||
private final Deque<Point> points = new ArrayDeque<Point>();
|
||||
private final Deque<Point> points = new ArrayDeque<>();
|
||||
|
||||
/**
|
||||
* Flag indicating if this queue (only) should be ran.
|
||||
@@ -100,7 +101,7 @@ public final class WalkingQueue {
|
||||
return true;
|
||||
}
|
||||
|
||||
Queue<Position> travelBackQueue = new ArrayDeque<Position>();
|
||||
Queue<Position> travelBackQueue = new ArrayDeque<>();
|
||||
|
||||
Point oldPoint;
|
||||
while ((oldPoint = oldPoints.pollLast()) != null) {
|
||||
@@ -159,11 +160,9 @@ public final class WalkingQueue {
|
||||
* @param step The step to add.
|
||||
*/
|
||||
public void addStep(Position step) {
|
||||
int x = step.getX(), y = step.getY();
|
||||
Point last = getLast();
|
||||
|
||||
int x = step.getX();
|
||||
int y = step.getY();
|
||||
|
||||
int deltaX = x - last.position.getX();
|
||||
int deltaY = y - last.position.getY();
|
||||
|
||||
@@ -212,9 +211,7 @@ public final class WalkingQueue {
|
||||
*/
|
||||
public void pulse() {
|
||||
Position position = mob.getPosition();
|
||||
|
||||
Direction first = Direction.NONE;
|
||||
Direction second = Direction.NONE;
|
||||
Direction first = Direction.NONE, second = Direction.NONE;
|
||||
|
||||
Point next = points.poll();
|
||||
if (next != null) {
|
||||
|
||||
@@ -62,6 +62,7 @@ public final class World {
|
||||
* Indicates the world is full.
|
||||
*/
|
||||
WORLD_FULL;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,8 +234,9 @@ public final class World {
|
||||
*/
|
||||
public void init(int release, IndexedFileSystem fs, PluginManager manager) throws Exception {
|
||||
this.releaseNumber = release;
|
||||
ItemDefinitionDecoder itemDefParser = new ItemDefinitionDecoder(fs);
|
||||
ItemDefinition[] itemDefs = itemDefParser.decode();
|
||||
|
||||
ItemDefinitionDecoder itemDefDecoder = new ItemDefinitionDecoder(fs);
|
||||
ItemDefinition[] itemDefs = itemDefDecoder.decode();
|
||||
ItemDefinition.init(itemDefs);
|
||||
logger.info("Loaded " + itemDefs.length + " item definitions.");
|
||||
|
||||
@@ -339,8 +341,7 @@ public final class World {
|
||||
return RegistrationStatus.OK;
|
||||
}
|
||||
|
||||
logger.warning("Failed to register player (server full): " + player + " [count=" + playerRepository.size()
|
||||
+ "]");
|
||||
logger.warning("Failed to register player: " + player + " [count=" + playerRepository.size() + "]");
|
||||
return RegistrationStatus.WORLD_FULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public final class WorldConstants {
|
||||
/**
|
||||
* The maximum number of npcs.
|
||||
*/
|
||||
public static final int MAXIMUM_NPCS = 2000;
|
||||
public static final int MAXIMUM_NPCS = 32768;
|
||||
|
||||
/**
|
||||
* The maximum number of players.
|
||||
|
||||
@@ -174,13 +174,12 @@ public final class InterfaceSet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the enter amount dialog.
|
||||
* Opens the enter amount dialogue.
|
||||
*
|
||||
* @param listener The enter amount listener.
|
||||
*/
|
||||
public void openEnterAmountDialog(EnterAmountListener listener) {
|
||||
public void openEnterAmountDialogue(EnterAmountListener listener) {
|
||||
amountListener = listener;
|
||||
|
||||
player.send(new EnterAmountEvent());
|
||||
}
|
||||
|
||||
@@ -204,7 +203,6 @@ public final class InterfaceSet {
|
||||
this.listener = listener;
|
||||
|
||||
interfaces.put(InterfaceType.WINDOW, windowId);
|
||||
|
||||
player.send(new OpenInterfaceEvent(windowId));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class SynchronizationInventoryListener extends InventoryAdapter {
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* Creates the syncrhonization inventory listener.
|
||||
* Creates the synchronization inventory listener.
|
||||
*
|
||||
* @param player The player.
|
||||
* @param interfaceId The interface id.
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.apollo.game.model.def.ObjectDefinition;
|
||||
* @author Chris Fletcher
|
||||
* @author Major
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public final class GameObject extends Entity {
|
||||
|
||||
/**
|
||||
@@ -29,7 +28,7 @@ public final class GameObject extends Entity {
|
||||
private final int type;
|
||||
|
||||
/**
|
||||
* Creates a new static object.
|
||||
* Creates a game object.
|
||||
*
|
||||
* @param id The object's id.
|
||||
* @param position The position.
|
||||
|
||||
@@ -93,7 +93,7 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
||||
player.setRunEnergy(runEnergy);
|
||||
player.setScreenBrightness(brightness);
|
||||
|
||||
player.setDesigned(designed);
|
||||
player.setNew(designed);
|
||||
player.setAppearance(new Appearance(gender, style, colors));
|
||||
|
||||
// read inventories
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class BinaryPlayerSaver implements PlayerSaver {
|
||||
out.writeByte(position.getHeight());
|
||||
|
||||
// write appearance
|
||||
out.writeBoolean(player.hasDesignedAvatar());
|
||||
out.writeBoolean(player.isNewPlayer());
|
||||
Appearance appearance = player.getAppearance();
|
||||
out.writeByte(appearance.getGender().toInteger());
|
||||
int[] style = appearance.getStyle();
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.meta.PacketType;
|
||||
import org.apollo.net.release.EventEncoder;
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,7 @@ public final class SetPlayerActionEventEncoder extends EventEncoder<SetPlayerAct
|
||||
|
||||
@Override
|
||||
public GamePacket encode(SetPlayerActionEvent event) {
|
||||
GamePacketBuilder builder = new GamePacketBuilder(104);
|
||||
GamePacketBuilder builder = new GamePacketBuilder(104, PacketType.VARIABLE_BYTE);
|
||||
builder.put(DataType.BYTE, DataTransformation.NEGATE, event.getSlot());
|
||||
builder.put(DataType.BYTE, DataTransformation.ADD, event.isPrimaryAction() ? 0 : 1);
|
||||
builder.putString(event.getText());
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.apollo.net.codec.game.DataTransformation;
|
||||
import org.apollo.net.codec.game.DataType;
|
||||
import org.apollo.net.codec.game.GamePacket;
|
||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
||||
import org.apollo.net.meta.PacketType;
|
||||
import org.apollo.net.release.EventEncoder;
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,7 @@ public final class SetPlayerActionEventEncoder extends EventEncoder<SetPlayerAct
|
||||
|
||||
@Override
|
||||
public GamePacket encode(SetPlayerActionEvent event) {
|
||||
GamePacketBuilder builder = new GamePacketBuilder(157);
|
||||
GamePacketBuilder builder = new GamePacketBuilder(157, PacketType.VARIABLE_BYTE);
|
||||
builder.put(DataType.BYTE, DataTransformation.NEGATE, event.getSlot());
|
||||
builder.putString(event.getText());
|
||||
builder.put(DataType.BYTE, event.isPrimaryAction() ? 0 : 1);
|
||||
|
||||
@@ -30,7 +30,12 @@ public final class RubyPluginEnvironment implements PluginEnvironment {
|
||||
|
||||
@Override
|
||||
public void parse(InputStream is, String name) {
|
||||
container.runScriptlet(is, name);
|
||||
try {
|
||||
container.runScriptlet(is, name);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Error parsing scriptlet " + name + ".");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user