Format line endings

This commit is contained in:
atomicint
2015-03-23 09:04:37 -07:00
parent 7cf31a2888
commit b4176e8097
25 changed files with 47 additions and 77 deletions
@@ -116,11 +116,9 @@ public final class GameObjectDecoder {
block = true;
}
Predicate<Integer> walls = (value) -> value >= ObjectType.LENGTHWISE_WALL.getValue()
&& value <= ObjectType.RECTANGULAR_CORNER.getValue() || value == ObjectType.DIAGONAL_WALL.getValue();
Predicate<Integer> walls = (value) -> value >= ObjectType.LENGTHWISE_WALL.getValue() && value <= ObjectType.RECTANGULAR_CORNER.getValue() || value == ObjectType.DIAGONAL_WALL.getValue();
Predicate<Integer> roofs = (value) -> value > ObjectType.DIAGONAL_INTERACTABLE.getValue()
&& value < ObjectType.FLOOR_DECORATION.getValue();
Predicate<Integer> roofs = (value) -> value > ObjectType.DIAGONAL_INTERACTABLE.getValue() && value < ObjectType.FLOOR_DECORATION.getValue();
if (walls.test(type) || roofs.test(type)) {
block = true;
@@ -128,7 +128,7 @@ public final class ObjectDefinitionDecoder {
data.getShort();
data.getShort();
int count = data.get();
for (int i = 0; i <= count; i++){
for (int i = 0; i <= count; i++) {
data.getShort();
}
} else {
+3 -5
View File
@@ -50,8 +50,7 @@ public final class GameService extends Service {
/**
* The scheduled executor service.
*/
private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory(
"GameService"));
private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("GameService"));
/**
* The {@link ClientSynchronizer}.
@@ -157,7 +156,7 @@ public final class GameService extends Service {
*/
public RegistrationStatus registerPlayer(Player player, GameSession session) {
World world = World.getWorld();
synchronized (this) {
RegistrationStatus status = world.register(player);
if (status == RegistrationStatus.OK) {
@@ -176,8 +175,7 @@ public final class GameService extends Service {
*/
@Override
public void start() {
scheduledExecutor.scheduleAtFixedRate(new GamePulseHandler(this), GameConstants.PULSE_DELAY, GameConstants.PULSE_DELAY,
TimeUnit.MILLISECONDS);
scheduledExecutor.scheduleAtFixedRate(new GamePulseHandler(this), GameConstants.PULSE_DELAY, GameConstants.PULSE_DELAY, TimeUnit.MILLISECONDS);
}
/**
@@ -34,7 +34,6 @@ public final class ObjectActionVerificationHandler extends MessageHandler<Object
ctx.breakHandlerChain();
return;
}
Position position = message.getPosition();
Region region = repository.fromPosition(position);
@@ -53,8 +53,7 @@ public final class PlayerSynchronizationMessage extends Message {
* @param localPlayers The number of local players.
* @param segments A list of segments.
*/
public PlayerSynchronizationMessage(Position lastKnownRegion, Position position, boolean regionChanged,
SynchronizationSegment segment, int localPlayers, List<SynchronizationSegment> segments) {
public PlayerSynchronizationMessage(Position lastKnownRegion, Position position, boolean regionChanged, SynchronizationSegment segment, int localPlayers, List<SynchronizationSegment> segments) {
this.lastKnownRegion = lastKnownRegion;
this.position = position;
this.regionChanged = regionChanged;
+1 -2
View File
@@ -226,8 +226,7 @@ public final class Position {
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("x", getX()).add("y", getY()).add("height", getHeight())
.add("region", getRegionCoordinates()).toString();
return MoreObjects.toStringHelper(this).add("x", getX()).add("y", getY()).add("height", getHeight()).add("region", getRegionCoordinates()).toString();
}
}
+3 -6
View File
@@ -41,8 +41,7 @@ public final class Region {
@Override
public void execute(Region region, Entity entity, EntityUpdateType update) {
EntityType type = entity.getEntityType();
if (type != EntityType.PLAYER && type != EntityType.NPC
&& (type != EntityType.STATIC_OBJECT || update == EntityUpdateType.REMOVE)) {
if (type != EntityType.PLAYER && type != EntityType.NPC && (type != EntityType.STATIC_OBJECT || update == EntityUpdateType.REMOVE)) {
region.record(entity, update);
}
}
@@ -190,8 +189,7 @@ public final class Region {
Set<EntityType> set = new HashSet<>(Arrays.asList(types));
@SuppressWarnings("unchecked")
Set<T> filtered = (Set<T>) local.stream().filter(entity -> set.contains(entity.getEntityType()))
.collect(Collectors.toSet());
Set<T> filtered = (Set<T>) local.stream().filter(entity -> set.contains(entity.getEntityType())).collect(Collectors.toSet());
return ImmutableSet.copyOf(filtered);
}
@@ -291,8 +289,7 @@ public final class Region {
* @throws IllegalArgumentException If the specified position is not included in this Region.
*/
private void checkPosition(Position position) {
Preconditions.checkArgument(coordinates.equals(RegionCoordinates.fromPosition(position)),
"Position is not included in this Region.");
Preconditions.checkArgument(coordinates.equals(RegionCoordinates.fromPosition(position)), "Position is not included in this Region.");
}
/**
@@ -184,8 +184,7 @@ public final class CollisionMatrix {
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("width", width).add("length", length).add("matrix", Arrays.toString(matrix))
.toString();
return MoreObjects.toStringHelper(this).add("width", width).add("length", length).add("matrix", Arrays.toString(matrix)).toString();
}
/**
@@ -1,4 +1,4 @@
/**
* Contains snapshot-related classes.
* Contains snapshot-related classes.
*/
package org.apollo.game.model.area.update;
+2 -2
View File
@@ -196,8 +196,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;
+3 -6
View File
@@ -942,8 +942,7 @@ public final class Player extends Mob {
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("username", getUsername()).add("privilege", privilegeLevel)
.add("client version", getClientVersion()).toString();
return MoreObjects.toStringHelper(this).add("username", getUsername()).add("privilege", privilegeLevel).add("client version", getClientVersion()).toString();
}
/**
@@ -962,11 +961,9 @@ public final class Player extends Mob {
InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE);
InventoryListener appearanceListener = new AppearanceInventoryListener(this);
InventoryListener syncInventoryListener = new SynchronizationInventoryListener(this,
SynchronizationInventoryListener.INVENTORY_ID);
InventoryListener syncInventoryListener = new SynchronizationInventoryListener(this, SynchronizationInventoryListener.INVENTORY_ID);
InventoryListener syncBankListener = new SynchronizationInventoryListener(this, BankConstants.BANK_INVENTORY_ID);
InventoryListener syncEquipmentListener = new SynchronizationInventoryListener(this,
SynchronizationInventoryListener.EQUIPMENT_ID);
InventoryListener syncEquipmentListener = new SynchronizationInventoryListener(this, SynchronizationInventoryListener.EQUIPMENT_ID);
inventory.addListener(syncInventoryListener);
inventory.addListener(fullInventoryListener);
@@ -33,7 +33,7 @@ public final class StringAttribute extends Attribute<String> {
public byte[] encode() {
byte[] bytes = value.getBytes(Charset.forName("UTF-8"));
int length = bytes.length;
bytes = Arrays.copyOf(bytes, length + 1);
bytes[length - 1] = 0;
return bytes;
@@ -89,8 +89,7 @@ public abstract class GameObject extends Entity {
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("id", getId()).add("type", getType()).add("orientation", getOrientation())
.toString();
return MoreObjects.toStringHelper(this).add("id", getId()).add("type", getType()).add("orientation", getOrientation()).toString();
}
@Override
@@ -38,8 +38,7 @@ public enum ObjectGroup {
* @throws IllegalArgumentException If there is no ObjectGroup with the specified value.
*/
public static ObjectGroup valueOf(int value) {
return Arrays.stream(values()).filter(group -> group.value == value).findAny()
.orElseThrow(() -> new IllegalArgumentException("No ObjectGroup with a value of " + value + " exists."));
return Arrays.stream(values()).filter(group -> group.value == value).findAny().orElseThrow(() -> new IllegalArgumentException("No ObjectGroup with a value of " + value + " exists."));
}
/**
@@ -1,4 +1,4 @@
/**
* Contains object-related classes.
* Contains object-related classes.
*/
package org.apollo.game.model.entity.obj;
@@ -79,8 +79,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
* @param updates The {@link Map} containing {@link Region} updates.
* @param snapshots The Map containing Region snapshots.
*/
public PrePlayerSynchronizationTask(Player player, Map<RegionCoordinates, List<RegionUpdateMessage>> updates,
Map<RegionCoordinates, List<RegionUpdateMessage>> snapshots) {
public PrePlayerSynchronizationTask(Player player, Map<RegionCoordinates, List<RegionUpdateMessage>> updates, Map<RegionCoordinates, List<RegionUpdateMessage>> snapshots) {
this.player = player;
this.updates = updates;
this.snapshots = snapshots;
@@ -210,8 +209,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);
}
/**
@@ -224,8 +222,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
* @param repository The {@link RegionRepository} containing the Regions.
* @return The Optional containing the GroupedRegionUpdateMessage.
*/
private Optional<GroupedRegionUpdateMessage> toUpdateMessage(RegionUpdateMode mode, Position position,
RegionCoordinates coordinates, RegionRepository repository) {
private Optional<GroupedRegionUpdateMessage> toUpdateMessage(RegionUpdateMode mode, Position position, RegionCoordinates coordinates, RegionRepository repository) {
List<RegionUpdateMessage> messages;
/*
@@ -241,8 +238,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
messages = updates.get(coordinates);
if (messages == null) {
synchronized (updates) {
messages = updates.computeIfAbsent(coordinates,
coords -> repository.get(coords).getUpdates(position.getHeight()));
messages = updates.computeIfAbsent(coordinates, coords -> repository.get(coords).getUpdates(position.getHeight()));
}
}
@@ -251,8 +247,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
messages = snapshots.get(coordinates);
if (messages == null) {
synchronized (snapshots) {
messages = snapshots.computeIfAbsent(coordinates,
coords -> repository.get(coords).getSnapshot(position.getHeight()));
messages = snapshots.computeIfAbsent(coordinates, coords -> repository.get(coords).getSnapshot(position.getHeight()));
}
}
@@ -261,8 +256,7 @@ public final class PrePlayerSynchronizationTask extends SynchronizationTask {
throw new IllegalArgumentException("Unrecognised RegionUpdateMode " + mode + ".");
}
return messages.isEmpty() ? Optional.empty() : Optional
.of(new GroupedRegionUpdateMessage(position, coordinates, messages));
return messages.isEmpty() ? Optional.empty() : Optional.of(new GroupedRegionUpdateMessage(position, coordinates, messages));
}
}
+2 -4
View File
@@ -72,8 +72,7 @@ public final class NetworkConstants {
Preconditions.checkState(rsa != null, "Root node must have a child named 'rsa'.");
XmlNode modulus = rsa.getChild("modulus"), exponent = rsa.getChild("private-exponent");
Preconditions.checkState(modulus != null && exponent != null,
"Rsa node must have two children: 'modulus' and 'private-exponent'.");
Preconditions.checkState(modulus != null && exponent != null, "Rsa node must have two children: 'modulus' and 'private-exponent'.");
RSA_MODULUS = new BigInteger(modulus.getValue());
RSA_EXPONENT = new BigInteger(exponent.getValue());
@@ -82,8 +81,7 @@ public final class NetworkConstants {
Preconditions.checkState(ports != null, "Root node must have a child named 'ports'.");
XmlNode http = ports.getChild("http"), service = ports.getChild("service"), jaggrab = ports.getChild("jaggrab");
Preconditions.checkState(http != null && service != null && jaggrab != null,
"Ports node must have three children: 'http', 'service', and 'jaggrab'.");
Preconditions.checkState(http != null && service != null && jaggrab != null, "Ports node must have three children: 'http', 'service', and 'jaggrab'.");
HTTP_PORT = Integer.parseInt(http.getValue());
SERVICE_PORT = Integer.parseInt(service.getValue());
@@ -44,8 +44,7 @@ public final class GroupedRegionUpdateMessageEncoder extends MessageEncoder<Grou
for (RegionUpdateMessage update : message.getMessages()) {
System.out.println("==== Sending " + update + " as part of grum");
@SuppressWarnings("unchecked")
MessageEncoder<RegionUpdateMessage> encoder = (MessageEncoder<RegionUpdateMessage>) release.getMessageEncoder(update
.getClass());
MessageEncoder<RegionUpdateMessage> encoder = (MessageEncoder<RegionUpdateMessage>) release.getMessageEncoder(update.getClass());
GamePacket packet = encoder.encode(update);
builder.put(DataType.BYTE, packet.getOpcode());
@@ -194,8 +194,8 @@ public final class NpcSynchronizationMessageEncoder extends MessageEncoder<NpcSy
private static void putGraphicBlock(GraphicBlock block, GamePacketBuilder builder) {
Graphic graphic = block.getGraphic();
builder.put(DataType.SHORT, graphic.getId());
builder.put(DataType.INT, graphic.getHeight() << 16 | graphic.getDelay() & 0xFFFF);
}
builder.put(DataType.INT, graphic.getHeight() << 16 | graphic.getDelay() & 0xFFFF);
}
/**
* Puts a hit update block into the specified builder.
@@ -20,8 +20,7 @@ public final class RemoveObjectMessageEncoder extends MessageEncoder<RemoveObjec
builder.put(DataType.BYTE, DataTransformation.NEGATE, message.getType() << 2 | message.getOrientation());
builder.put(DataType.BYTE, message.getPositionOffset());
System.out.println("Sending rm obj: type=" + message.getType() + ", orient=" + message.getOrientation() + ",posoff="
+ Integer.toBinaryString(message.getPositionOffset()));
System.out.println("Sending rm obj: type=" + message.getType() + ", orient=" + message.getOrientation() + ",posoff=" + Integer.toBinaryString(message.getPositionOffset()));
return builder.toGamePacket();
}
@@ -32,8 +32,7 @@ public final class GroupedRegionUpdateMessageEncoder extends MessageEncoder<Grou
*
* @param encoders The Map of RegionUpdateMessages to MessageEncoders.
*/
public GroupedRegionUpdateMessageEncoder(
Map<Class<? extends RegionUpdateMessage>, MessageEncoder<? extends RegionUpdateMessage>> encoders) {
public GroupedRegionUpdateMessageEncoder(Map<Class<? extends RegionUpdateMessage>, MessageEncoder<? extends RegionUpdateMessage>> encoders) {
this.encoders = ImmutableMap.copyOf(encoders);
}
@@ -49,8 +48,7 @@ public final class GroupedRegionUpdateMessageEncoder extends MessageEncoder<Grou
@SuppressWarnings("unchecked")
MessageEncoder<RegionUpdateMessage> encoder = (MessageEncoder<RegionUpdateMessage>) encoders.get(update);
Preconditions.checkState(encoder != null, update.getClass()
+ " does not have a registered encoder in GroupedRegionUpdateMessageEncoder.");
Preconditions.checkState(encoder != null, update.getClass() + " does not have a registered encoder in GroupedRegionUpdateMessageEncoder.");
GamePacket packet = encoder.encode(update);
builder.put(DataType.BYTE, packet.getOpcode());
@@ -194,7 +194,7 @@ public final class NpcSynchronizationMessageEncoder extends MessageEncoder<NpcSy
private static void putGraphicBlock(GraphicBlock block, GamePacketBuilder builder) {
Graphic graphic = block.getGraphic();
builder.put(DataType.SHORT, graphic.getId());
builder.put(DataType.INT, graphic.getHeight() << 16 | graphic.getDelay() & 0xFFFF);
builder.put(DataType.INT, graphic.getHeight() << 16 | graphic.getDelay() & 0xFFFF);
}
/**
@@ -221,8 +221,7 @@ public final class Release377 extends Release {
regionUpdates.put(SendObjectMessage.class, new SendObjectMessageEncoder());
regionUpdates.put(RemoveObjectMessage.class, new RemoveObjectMessageEncoder());
for (Map.Entry<Class<? extends RegionUpdateMessage>, MessageEncoder<? extends RegionUpdateMessage>> entry : regionUpdates
.entrySet()) {
for (Map.Entry<Class<? extends RegionUpdateMessage>, MessageEncoder<? extends RegionUpdateMessage>> entry : regionUpdates.entrySet()) {
@SuppressWarnings("unchecked")
Class<RegionUpdateMessage> clazz = (Class<RegionUpdateMessage>) entry.getKey();
@SuppressWarnings("unchecked")
@@ -9,8 +9,7 @@ import io.netty.channel.Channel;
*
* @param <T> The type of request.
*/
public final class ComparableChannelRequest<T extends Comparable<T>> extends ChannelRequest<T> implements
Comparable<ComparableChannelRequest<T>> {
public final class ComparableChannelRequest<T extends Comparable<T>> extends ChannelRequest<T> implements Comparable<ComparableChannelRequest<T>> {
/**
* Creates the ComparableChannelRequest.
+8 -8
View File
@@ -146,14 +146,14 @@ public final class XmlNode implements Iterable<XmlNode> {
return value;
}
/**
* Gets the value of this node, wrapped in an {@link Optional}
*
* @return The value of this node if it exists otherwise {@link Optional#empty()} is returned
*/
public Optional<String> getOptionalValue() {
return Optional.ofNullable(value);
}
/**
* Gets the value of this node, wrapped in an {@link Optional}
*
* @return The value of this node if it exists otherwise {@link Optional#empty()} is returned
*/
public Optional<String> getOptionalValue() {
return Optional.ofNullable(value);
}
/**
* Checks if this node has a value.