mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 16:49:12 +00:00
Strict whitespace format, make private fields final that can be immutable
This commit is contained in:
@@ -177,16 +177,15 @@ def on_message(args, proc)
|
||||
numbers = [ 'first', 'second', 'third', 'fourth', 'fifth' ]
|
||||
message = args[0]; option = 0
|
||||
|
||||
# TODO
|
||||
# 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
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
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
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class_name = message.to_s.camelize.concat('Message')
|
||||
|
||||
@@ -68,12 +68,12 @@ public final class IsaacRandom {
|
||||
/**
|
||||
* The internal state.
|
||||
*/
|
||||
private int[] mem;
|
||||
private final int[] mem;
|
||||
|
||||
/**
|
||||
* The results given to the user.
|
||||
*/
|
||||
private int[] rsl;
|
||||
private final int[] rsl;
|
||||
|
||||
/**
|
||||
* Creates the random number generator without an initial seed.
|
||||
|
||||
@@ -27,7 +27,7 @@ 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}.
|
||||
|
||||
@@ -32,7 +32,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.
|
||||
|
||||
@@ -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;
|
||||
@@ -181,7 +183,7 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -121,17 +121,13 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class ForwardPrivateChatMessage extends Message {
|
||||
*/
|
||||
public ForwardPrivateChatMessage(String username, PrivilegeLevel level, byte[] message) {
|
||||
this.username = username;
|
||||
this.privilege = level;
|
||||
privilege = level;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.apollo.game.message.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apollo.game.message.Message;
|
||||
import org.apollo.game.model.Position;
|
||||
import org.apollo.game.model.area.RegionCoordinates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A {@link Message} sent to the client that contains multiple
|
||||
*
|
||||
@@ -37,7 +37,7 @@ public final class GroupedRegionUpdateMessage extends Message {
|
||||
*/
|
||||
public GroupedRegionUpdateMessage(Position lastKnownRegion, RegionCoordinates coordinates, List<RegionUpdateMessage> messages) {
|
||||
this.lastKnownRegion = lastKnownRegion;
|
||||
this.region = new Position(coordinates.getAbsoluteX(), coordinates.getAbsoluteY());
|
||||
region = new Position(coordinates.getAbsoluteX(), coordinates.getAbsoluteY());
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,8 +33,8 @@ public final class RemoveObjectMessage extends RegionUpdateMessage {
|
||||
*/
|
||||
public RemoveObjectMessage(GameObject object, int positionOffset) {
|
||||
this.positionOffset = positionOffset;
|
||||
this.type = object.getType();
|
||||
this.orientation = object.getOrientation();
|
||||
type = object.getType();
|
||||
orientation = object.getOrientation();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,10 +37,10 @@ public final class SendObjectMessage extends RegionUpdateMessage {
|
||||
* @param positionOffset The offset of the object's position from the region's central position.
|
||||
*/
|
||||
public SendObjectMessage(GameObject object, int positionOffset) {
|
||||
this.id = object.getId();
|
||||
id = object.getId();
|
||||
this.positionOffset = positionOffset;
|
||||
this.type = object.getType();
|
||||
this.orientation = object.getOrientation();
|
||||
type = object.getType();
|
||||
orientation = object.getOrientation();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class SetPlayerActionMessage extends Message {
|
||||
public SetPlayerActionMessage(String text, int slot, boolean primaryInteraction) {
|
||||
this.text = text;
|
||||
this.slot = slot;
|
||||
this.primaryAction = primaryInteraction;
|
||||
primaryAction = primaryInteraction;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ public final class WalkMessage extends Message {
|
||||
/**
|
||||
* The running flag.
|
||||
*/
|
||||
private boolean run;
|
||||
private final boolean run;
|
||||
|
||||
/**
|
||||
* The steps.
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class Item {
|
||||
Preconditions.checkArgument(amount >= 0, "Amount cannot be negative.");
|
||||
this.id = id;
|
||||
this.amount = amount;
|
||||
this.definition = ItemDefinition.lookup(id);
|
||||
definition = ItemDefinition.lookup(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -192,7 +192,7 @@ public final class Position {
|
||||
* @return The y coordinate.
|
||||
*/
|
||||
public int getY() {
|
||||
return (packed >> 15) & 0x7FFF;
|
||||
return packed >> 15 & 0x7FFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class World {
|
||||
/**
|
||||
* The command dispatcher.
|
||||
*/
|
||||
private CommandDispatcher commandDispatcher = new CommandDispatcher();
|
||||
private final CommandDispatcher commandDispatcher = new CommandDispatcher();
|
||||
|
||||
/**
|
||||
* The EventListenerChainSet for this World.
|
||||
@@ -208,7 +208,7 @@ public final class World {
|
||||
* @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;
|
||||
releaseNumber = release;
|
||||
|
||||
ItemDefinitionDecoder itemDecoder = new ItemDefinitionDecoder(fs);
|
||||
ItemDefinition[] items = itemDecoder.decode();
|
||||
|
||||
@@ -129,7 +129,7 @@ public final class Region {
|
||||
Set<Entity> local = entities.computeIfAbsent(position, key -> new HashSet<>(DEFAULT_SET_SIZE));
|
||||
local.add(entity);
|
||||
|
||||
if ((System.currentTimeMillis() - start) / 1000 > 10 && (entity instanceof GameObject)) {
|
||||
if ((System.currentTimeMillis() - start) / 1000 > 10 && entity instanceof GameObject) {
|
||||
System.out.println("Adding entity " + entity + " to " + entity.getPosition());
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public final class Region {
|
||||
*/
|
||||
public Set<Entity> getEntities(Position position) {
|
||||
Set<Entity> set = entities.get(position);
|
||||
return (set == null) ? ImmutableSet.of() : ImmutableSet.copyOf(set);
|
||||
return set == null ? ImmutableSet.of() : ImmutableSet.copyOf(set);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,7 +224,7 @@ public final class Region {
|
||||
* @return The Set of RegionUpdateMessages.
|
||||
*/
|
||||
public List<RegionUpdateMessage> getUpdates(int height) {
|
||||
List<RegionUpdateMessage> original = this.updates.get(height);
|
||||
List<RegionUpdateMessage> original = updates.get(height);
|
||||
List<RegionUpdateMessage> updates = new ArrayList<>(original);
|
||||
original.clear();
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public enum CollisionFlag {
|
||||
* @return The array of CollisionFlags.
|
||||
*/
|
||||
public static CollisionFlag[] forType(EntityType type) {
|
||||
return (type == EntityType.PROJECTILE) ? projectiles() : mobs();
|
||||
return type == EntityType.PROJECTILE ? projectiles() : mobs();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,7 +95,7 @@ public abstract class UpdateOperation<E extends Entity> {
|
||||
Preconditions.checkArgument(dx >= 0 && dx < Region.SIZE, position + " not in expected Region of " + region + ".");
|
||||
Preconditions.checkArgument(dy >= 0 && dy < Region.SIZE, position + " not in expected Region of " + region + ".");
|
||||
|
||||
return (dx << 4) | dy;
|
||||
return dx << 4 | dy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public final class EquipmentDefinition {
|
||||
/**
|
||||
* The array of skill requirement levels.
|
||||
*/
|
||||
private int[] levels = { 1, 1, 1, 1, 1, 1, 1 };
|
||||
private final int[] levels = { 1, 1, 1, 1, 1, 1, 1 };
|
||||
|
||||
/**
|
||||
* The slot this equipment goes into.
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class ItemDefinition {
|
||||
/**
|
||||
* The ground actions array.
|
||||
*/
|
||||
private String[] groundActions = new String[5];
|
||||
private final String[] groundActions = new String[5];
|
||||
|
||||
/**
|
||||
* The item's id.
|
||||
@@ -124,7 +124,7 @@ public final class ItemDefinition {
|
||||
/**
|
||||
* The inventory actions array.
|
||||
*/
|
||||
private String[] inventoryActions = new String[5];
|
||||
private final String[] inventoryActions = new String[5];
|
||||
|
||||
/**
|
||||
* A flag indicating if this item is members only.
|
||||
|
||||
@@ -80,7 +80,7 @@ public final class NpcDefinition {
|
||||
/**
|
||||
* An array of interaction options.
|
||||
*/
|
||||
private String[] interactions = new String[5];
|
||||
private final String[] interactions = new String[5];
|
||||
|
||||
/**
|
||||
* The name of the npc.
|
||||
|
||||
@@ -535,7 +535,7 @@ public abstract class Mob extends Entity {
|
||||
* @param position The position to face.
|
||||
*/
|
||||
public final void turnTo(Position position) {
|
||||
this.facingPosition = position;
|
||||
facingPosition = position;
|
||||
blockSet.add(SynchronizationBlock.createTurnToPositionBlock(position));
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public final class Player extends Mob {
|
||||
/**
|
||||
* This player's credentials.
|
||||
*/
|
||||
private PlayerCredentials credentials;
|
||||
private final PlayerCredentials credentials;
|
||||
|
||||
/**
|
||||
* A flag which indicates there are npcs that couldn't be added.
|
||||
@@ -870,7 +870,7 @@ public final class Player extends Mob {
|
||||
* @param brightness The screen brightness.
|
||||
*/
|
||||
public void setScreenBrightness(ScreenBrightness brightness) {
|
||||
this.screenBrightness = brightness;
|
||||
screenBrightness = brightness;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -223,7 +223,7 @@ public final class SkillSet {
|
||||
continue;
|
||||
}
|
||||
|
||||
current += (current < max ? 1 : -1);
|
||||
current += current < max ? 1 : -1;
|
||||
setSkill(id, new Skill(skills[id].getExperience(), current, max));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public final class AttributeMap {
|
||||
/**
|
||||
* The map of attribute names to attributes.
|
||||
*/
|
||||
private Map<String, Attribute<?>> attributes = new HashMap<>(DEFAULT_MAP_SIZE);
|
||||
private final Map<String, Attribute<?>> attributes = new HashMap<>(DEFAULT_MAP_SIZE);
|
||||
|
||||
/**
|
||||
* Gets the {@link Attribute} with the specified name.
|
||||
|
||||
@@ -30,13 +30,13 @@ public final class NumericalAttribute extends Attribute<Number> {
|
||||
|
||||
@Override
|
||||
public byte[] encode() {
|
||||
long encoded = (type == AttributeType.DOUBLE) ? Double.doubleToLongBits((double) value) : (long) value;
|
||||
long encoded = type == AttributeType.DOUBLE ? Double.doubleToLongBits((double) value) : (long) value;
|
||||
return Longs.toByteArray(encoded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (type == AttributeType.DOUBLE) ? Double.toString((double) value) : Long.toString((long) value);
|
||||
return type == AttributeType.DOUBLE ? Double.toString((double) value) : Long.toString((long) value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public final class DynamicGameObject extends GameObject {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Player player = get();
|
||||
return (player == null) ? 0 : player.hashCode();
|
||||
return player == null ? 0 : player.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class GameObject extends Entity {
|
||||
*/
|
||||
public GameObject(World world, int id, Position position, int type, int orientation) {
|
||||
super(world, position);
|
||||
this.packed = id << 8 | (type & 0x3F) << 2 | orientation & 0x3;
|
||||
packed = id << 8 | (type & 0x3F) << 2 | orientation & 0x3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,7 +81,7 @@ public abstract class GameObject extends Entity {
|
||||
* @return The type.
|
||||
*/
|
||||
public int getType() {
|
||||
return (packed >> 2) & 0x3F;
|
||||
return packed >> 2 & 0x3F;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -88,7 +88,7 @@ public final class SimplePathfindingAlgorithm extends PathfindingAlgorithm {
|
||||
}
|
||||
|
||||
Position last = new Position(x, y, height);
|
||||
if (!start.equals(last) && dy != 0 && traversable(last, boundaries, (dy > 0) ? Direction.SOUTH : Direction.NORTH)) {
|
||||
if (!start.equals(last) && dy != 0 && traversable(last, boundaries, dy > 0 ? Direction.SOUTH : Direction.NORTH)) {
|
||||
return addVertical(last, target, positions);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public final class SimplePathfindingAlgorithm extends PathfindingAlgorithm {
|
||||
}
|
||||
|
||||
Position last = new Position(x, y, height);
|
||||
if (!last.equals(target) && dx != 0 && traversable(last, boundaries, (dx > 0) ? Direction.WEST : Direction.EAST)) {
|
||||
if (!last.equals(target) && dx != 0 && traversable(last, boundaries, dx > 0 ? Direction.WEST : Direction.EAST)) {
|
||||
return addHorizontal(last, target, positions);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public final class EventListenerChainSet {
|
||||
public <E extends Event> boolean notify(E event) {
|
||||
@SuppressWarnings("unchecked")
|
||||
EventListenerChain<E> chain = (EventListenerChain<E>) chains.get(event.getClass());
|
||||
return (chain == null) || chain.notify(event);
|
||||
return chain == null || chain.notify(event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class InterfaceSet {
|
||||
/**
|
||||
* A map of open interfaces.
|
||||
*/
|
||||
private Map<InterfaceType, Integer> interfaces = new HashMap<>();
|
||||
private final Map<InterfaceType, Integer> interfaces = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The current listener.
|
||||
@@ -150,7 +150,7 @@ public final class InterfaceSet {
|
||||
public void openDialogue(DialogueListener listener, int dialogueId) {
|
||||
closeAndNotify();
|
||||
|
||||
this.dialogueListener = Optional.ofNullable(listener);
|
||||
dialogueListener = Optional.ofNullable(listener);
|
||||
this.listener = Optional.ofNullable(listener);
|
||||
|
||||
interfaces.put(InterfaceType.DIALOGUE, dialogueId);
|
||||
@@ -175,7 +175,7 @@ public final class InterfaceSet {
|
||||
public void openDialogueOverlay(DialogueListener listener, int dialogueId) {
|
||||
closeAndNotify();
|
||||
|
||||
this.dialogueListener = Optional.ofNullable(listener);
|
||||
dialogueListener = Optional.ofNullable(listener);
|
||||
this.listener = Optional.ofNullable(listener);
|
||||
|
||||
interfaces.put(InterfaceType.DIALOGUE, dialogueId);
|
||||
|
||||
@@ -18,7 +18,8 @@ public interface DialogueListener extends InterfaceListener {
|
||||
* </p>
|
||||
*
|
||||
* @param button The button interface id.
|
||||
* @return {@code true} if the {@link MessageHandlerChain} should be broken, {@code false} if it should be continued.
|
||||
* @return {@code true} if the {@link MessageHandlerChain} should be broken, {@code false} if it should be
|
||||
* continued.
|
||||
*/
|
||||
public boolean buttonClicked(int button);
|
||||
|
||||
|
||||
@@ -540,7 +540,7 @@ public final class Inventory {
|
||||
int removed = Math.min(amount, itemAmount);
|
||||
int remainder = itemAmount - removed;
|
||||
|
||||
set(slot, (remainder > 0) ? new Item(item.getId(), remainder) : null);
|
||||
set(slot, remainder > 0 ? new Item(item.getId(), remainder) : null);
|
||||
return removed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ public final class NpcMovementTask extends ScheduledTask {
|
||||
int currentX = current.getX(), currentY = current.getY();
|
||||
|
||||
boolean negativeX = RANDOM.nextBoolean(), negativeY = RANDOM.nextBoolean();
|
||||
int x = RANDOM.nextInt(negativeX ? (currentX - min.getX()) : (max.getX() - currentX));
|
||||
int y = RANDOM.nextInt(negativeY ? (currentY - min.getY()) : (max.getY() - currentY));
|
||||
int x = RANDOM.nextInt(negativeX ? currentX - min.getX() : max.getX() - currentX);
|
||||
int y = RANDOM.nextInt(negativeY ? currentY - min.getY() : max.getY() - currentY);
|
||||
|
||||
int dx = negativeX ? -x : x;
|
||||
int dy = negativeY ? -y : y;
|
||||
|
||||
@@ -49,8 +49,7 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
|
||||
|
||||
for (Iterator<Npc> it = localNpcs.iterator(); it.hasNext();) {
|
||||
Npc npc = it.next();
|
||||
if (!npc.isActive() || npc.isTeleporting()
|
||||
|| npc.getPosition().getLongestDelta(playerPosition) > player.getViewingDistance()) {
|
||||
if (!npc.isActive() || npc.isTeleporting() || npc.getPosition().getLongestDelta(playerPosition) > player.getViewingDistance()) {
|
||||
it.remove();
|
||||
segments.add(new RemoveMobSegment());
|
||||
} else {
|
||||
@@ -69,8 +68,7 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
|
||||
}
|
||||
|
||||
Position npcPosition = npc.getPosition();
|
||||
if (npcPosition.isWithinDistance(playerPosition, player.getViewingDistance()) && !localNpcs.contains(npc)
|
||||
&& npcPosition.getHeight() == playerPosition.getHeight()) {
|
||||
if (npcPosition.isWithinDistance(playerPosition, player.getViewingDistance()) && !localNpcs.contains(npc) && npcPosition.getHeight() == playerPosition.getHeight()) {
|
||||
localNpcs.add(npc);
|
||||
added++;
|
||||
npc.turnTo(npc.getFacingPosition());
|
||||
|
||||
@@ -80,8 +80,7 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
|
||||
int added = 0;
|
||||
|
||||
MobRepository<Player> repository = player.getWorld().getPlayerRepository();
|
||||
for (Iterator<Player> it = repository.iterator(); it.hasNext();) {
|
||||
Player other = it.next();
|
||||
for (Player other : repository) {
|
||||
if (localPlayers.size() >= 255) {
|
||||
player.flagExcessivePlayers();
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package org.apollo.game.sync.task;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apollo.game.message.impl.ClearRegionMessage;
|
||||
import org.apollo.game.message.impl.GroupedRegionUpdateMessage;
|
||||
import org.apollo.game.message.impl.RegionChangeMessage;
|
||||
@@ -11,7 +17,7 @@ import org.apollo.game.model.area.RegionCoordinates;
|
||||
import org.apollo.game.model.area.RegionRepository;
|
||||
import org.apollo.game.model.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* A {@link SynchronizationTask} which does pre-synchronization work for the specified {@link Player}.
|
||||
@@ -202,7 +208,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
|
||||
int deltaX = current.getLocalX(last);
|
||||
int deltaY = current.getLocalY(last);
|
||||
|
||||
return deltaX <= Position.MAX_DISTANCE || deltaX >= (VIEWPORT_WIDTH - Position.MAX_DISTANCE - 1) || deltaY <= Position.MAX_DISTANCE || deltaY >= (VIEWPORT_WIDTH - Position.MAX_DISTANCE - 1);
|
||||
return deltaX <= Position.MAX_DISTANCE || deltaX >= VIEWPORT_WIDTH - Position.MAX_DISTANCE - 1 || deltaY <= Position.MAX_DISTANCE || deltaY >= VIEWPORT_WIDTH - Position.MAX_DISTANCE - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -107,7 +107,7 @@ public final class BinaryPlayerSerializer extends PlayerSerializer {
|
||||
int y = in.readUnsignedShort();
|
||||
int height = in.readUnsignedByte();
|
||||
|
||||
Gender gender = (in.readUnsignedByte() == Gender.MALE.toInteger()) ? Gender.MALE : Gender.FEMALE;
|
||||
Gender gender = in.readUnsignedByte() == Gender.MALE.toInteger() ? Gender.MALE : Gender.FEMALE;
|
||||
int[] style = new int[7];
|
||||
for (int slot = 0; slot < style.length; slot++) {
|
||||
style[slot] = in.readUnsignedByte();
|
||||
|
||||
@@ -19,8 +19,8 @@ public final class FlaggedMouseEventMessageDecoder extends MessageDecoder<Flagge
|
||||
int read;
|
||||
if (reader.getLength() == 2) {
|
||||
read = (int) reader.getUnsigned(DataType.SHORT);
|
||||
int clicks = (read >> 12);
|
||||
int dX = (read >> 6) & 0x3f;
|
||||
int clicks = read >> 12;
|
||||
int dX = read >> 6 & 0x3f;
|
||||
int dY = read & 0x3f;
|
||||
return new FlaggedMouseEventMessage(clicks, dX, dY, true);
|
||||
} else if (reader.getLength() == 3) {
|
||||
@@ -29,7 +29,7 @@ public final class FlaggedMouseEventMessageDecoder extends MessageDecoder<Flagge
|
||||
read = (int) reader.getUnsigned(DataType.INT) & ~0xc0000000;
|
||||
}
|
||||
|
||||
int clicks = (read >> 19);
|
||||
int clicks = read >> 19;
|
||||
int x = (read & 0x7f) % 765;
|
||||
int y = (read & 0x7f) / 765;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class GroupedRegionUpdateMessageEncoder extends MessageEncoder<Grou
|
||||
|
||||
builder.put(DataType.BYTE, region.getLocalY(lastKnownRegion));
|
||||
builder.put(DataType.BYTE, DataTransformation.NEGATE, region.getLocalX(lastKnownRegion));
|
||||
System.out.println("Grum: local x: " + lastKnownRegion.getLocalX(region) + ", local y: " + lastKnownRegion.getLocalY(region));
|
||||
System.out.println("Grum: local x: " + lastKnownRegion.getLocalX(region) + ", local y: " + lastKnownRegion.getLocalY(region));
|
||||
|
||||
for (RegionUpdateMessage update : message.getMessages()) {
|
||||
System.out.println("==== Sending " + update + " as part of grum");
|
||||
|
||||
@@ -19,9 +19,9 @@ public final class MouseClickedMessageDecoder extends MessageDecoder<MouseClicke
|
||||
int value = (int) reader.getUnsigned(DataType.INT);
|
||||
|
||||
long delay = (value >> 20) * 50;
|
||||
boolean right = ((value >> 19) & 0x1) == 1;
|
||||
boolean right = (value >> 19 & 0x1) == 1;
|
||||
|
||||
int cords = (value & 0x3FFFF);
|
||||
int cords = value & 0x3FFFF;
|
||||
int x = cords % 765;
|
||||
int y = cords / 765;
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ public final class FlaggedMouseEventMessageDecoder extends MessageDecoder<Flagge
|
||||
|
||||
if (reader.getLength() == 2) {
|
||||
read = (int) reader.getUnsigned(DataType.SHORT);
|
||||
clicks = (read >> 12);
|
||||
x = (read >> 6) & 0x3f;
|
||||
clicks = read >> 12;
|
||||
x = read >> 6 & 0x3f;
|
||||
y = read & 0x3f;
|
||||
return new FlaggedMouseEventMessage(clicks, x, y, true);
|
||||
} else if (reader.getLength() == 3) {
|
||||
@@ -30,7 +30,7 @@ public final class FlaggedMouseEventMessageDecoder extends MessageDecoder<Flagge
|
||||
read = (int) reader.getUnsigned(DataType.INT) & ~0xc0000000;
|
||||
}
|
||||
|
||||
clicks = (read >> 19);
|
||||
clicks = read >> 19;
|
||||
x = (read & 0x7f) % 765;
|
||||
y = (read & 0x7f) / 765;
|
||||
return new FlaggedMouseEventMessage(clicks, x, y, false);
|
||||
|
||||
@@ -19,9 +19,9 @@ public final class MouseClickedMessageDecoder extends MessageDecoder<MouseClicke
|
||||
int value = (int) reader.getUnsigned(DataType.INT);
|
||||
|
||||
long delay = (value >> 20) * 50;
|
||||
boolean right = ((value >> 19) & 0x1) == 1;
|
||||
boolean right = (value >> 19 & 0x1) == 1;
|
||||
|
||||
int cords = (value & 0x3FFFF);
|
||||
int cords = value & 0x3FFFF;
|
||||
int x = cords % 765;
|
||||
int y = cords / 765;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public final class LoginSession extends Session {
|
||||
*/
|
||||
public LoginSession(ChannelHandlerContext ctx, ServerContext serverContext) {
|
||||
super(ctx.channel());
|
||||
this.channelContext = ctx;
|
||||
channelContext = ctx;
|
||||
this.serverContext = serverContext;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public final class LoginSession extends Session {
|
||||
optional = Optional.empty();
|
||||
rights = 0;
|
||||
|
||||
status = (registration == RegistrationStatus.ALREADY_ONLINE) ? LoginConstants.STATUS_ACCOUNT_ONLINE : LoginConstants.STATUS_SERVER_FULL;
|
||||
status = registration == RegistrationStatus.ALREADY_ONLINE ? LoginConstants.STATUS_ACCOUNT_ONLINE : LoginConstants.STATUS_SERVER_FULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,11 @@ public final class RsaKeyGenerator {
|
||||
do {
|
||||
p = BigInteger.probablePrime(BIT_COUNT / 2, random);
|
||||
q = BigInteger.probablePrime(BIT_COUNT / 2, random);
|
||||
phi = (p.subtract(BigInteger.ONE)).multiply(q.subtract(BigInteger.ONE));
|
||||
phi = p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE));
|
||||
|
||||
modulus = p.multiply(q);
|
||||
privateKey = publicKey.modInverse(phi);
|
||||
} while (modulus.bitLength() != BIT_COUNT || privateKey.bitLength() != BIT_COUNT
|
||||
|| !phi.gcd(publicKey).equals(BigInteger.ONE));
|
||||
} while (modulus.bitLength() != BIT_COUNT || privateKey.bitLength() != BIT_COUNT || !phi.gcd(publicKey).equals(BigInteger.ONE));
|
||||
|
||||
System.out.println("modulus: " + modulus);
|
||||
System.out.println("public key: " + publicKey);
|
||||
|
||||
@@ -29,7 +29,7 @@ public final class PluginManager {
|
||||
/**
|
||||
* A set of all author names.
|
||||
*/
|
||||
private SortedSet<String> authors = new TreeSet<>();
|
||||
private final SortedSet<String> authors = new TreeSet<>();
|
||||
|
||||
/**
|
||||
* The plugin context.
|
||||
@@ -164,8 +164,7 @@ public final class PluginManager {
|
||||
* @throws DependencyException If a dependency error occurs.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
private void start(PluginEnvironment env, PluginMetaData plugin, Map<String, PluginMetaData> plugins,
|
||||
Set<PluginMetaData> started) throws DependencyException, IOException {
|
||||
private void start(PluginEnvironment env, PluginMetaData plugin, Map<String, PluginMetaData> plugins, Set<PluginMetaData> started) throws DependencyException, IOException {
|
||||
// TODO check for cyclic dependencies! this way just won't cut it, we need an exception
|
||||
if (started.contains(plugin)) {
|
||||
return;
|
||||
|
||||
@@ -74,7 +74,7 @@ public final class XmlParser {
|
||||
/**
|
||||
* The stack of nodes, used when traversing the document and going through child nodes.
|
||||
*/
|
||||
private Stack<XmlNode> nodeStack = new Stack<>();
|
||||
private final Stack<XmlNode> nodeStack = new Stack<>();
|
||||
|
||||
/**
|
||||
* The current root node.
|
||||
|
||||
Reference in New Issue
Block a user