1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Renamed Lineage2Connection to Lineage2Client to better match its

purpose

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-07-29 16:22:05 -03:00
parent ebb2b2a81a
commit f917602de1
89 changed files with 258 additions and 387 deletions

View File

@@ -25,7 +25,8 @@ import org.slf4j.LoggerFactory;
import com.l2jserver.util.factory.CollectionFactory;
/**
* Cache class for an eternal cache
* Cache class for an eternal cache. Entries in this cache instance won't ever
* be automatically removed, even if the JVM is running out of memory.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
@@ -34,7 +35,7 @@ import com.l2jserver.util.factory.CollectionFactory;
* @param <V>
* the value type
*/
class EternalCache<K, V> implements Cache<K, V> {
public class EternalCache<K, V> implements Cache<K, V> {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
/**

View File

@@ -45,6 +45,9 @@ public class ThreadServiceImpl extends AbstractService implements ThreadService
*/
private final Logger log = LoggerFactory.getLogger(this.getClass());
/**
* The public shared thread pool
*/
private ThreadPool pool;
@Override

View File

@@ -16,7 +16,7 @@
*/
package com.l2jserver.service.game.admin;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.Service;
@@ -38,7 +38,7 @@ public interface AdministratorService extends Service {
* @param args
* the arguments
*/
void command(Lineage2Connection conn, L2Character character,
void command(Lineage2Client conn, L2Character character,
String command, String... args);
/**

View File

@@ -18,7 +18,7 @@ package com.l2jserver.service.game.admin;
import java.util.List;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.packet.server.SM_HTML;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.world.L2Character;
@@ -35,7 +35,7 @@ public class AdministratorServiceImpl extends AbstractService implements
private List<CharacterID> online;
@Override
public void command(Lineage2Connection conn, L2Character character,
public void command(Lineage2Client conn, L2Character character,
String command, String... args) {
conn.write(new SM_HTML(null, new AdminHomeTemplate()));
}

View File

@@ -19,7 +19,7 @@ package com.l2jserver.service.game.character;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.l2jserver.db.dao.ItemDAO;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.SystemMessage;
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO;
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO_EXTRA;
@@ -134,7 +134,7 @@ public class CharacterServiceImpl extends AbstractService implements
AlreadySpawnedServiceException {
Preconditions.checkNotNull(character, "character");
final CharacterID id = character.getID();
final Lineage2Connection conn = networkService.discover(id);
final Lineage2Client conn = networkService.discover(id);
if (conn == null)
return;
@@ -240,7 +240,7 @@ public class CharacterServiceImpl extends AbstractService implements
Preconditions.checkNotNull(character, "character");
Preconditions.checkNotNull(target, "target");
final CharacterID id = character.getID();
final Lineage2Connection conn = networkService.discover(id);
final Lineage2Client conn = networkService.discover(id);
if (target == null && character.getTargetID() != null) {
// if is trying to select null (remove target) and the character has
@@ -281,7 +281,7 @@ public class CharacterServiceImpl extends AbstractService implements
Preconditions.checkNotNull(character, "character");
Preconditions.checkNotNull(target, "target");
final CharacterID id = character.getID();
final Lineage2Connection conn = networkService.discover(id);
final Lineage2Client conn = networkService.discover(id);
// check if this Actor can be attacked
if (target instanceof NPC) {
final NPC npc = (NPC) target;
@@ -321,7 +321,7 @@ public class CharacterServiceImpl extends AbstractService implements
Preconditions.checkNotNull(character, "character");
Preconditions.checkNotNull(coordinate, "coordinate");
final CharacterID id = character.getID();
final Lineage2Connection conn = networkService.discover(id);
final Lineage2Client conn = networkService.discover(id);
// we don't set the character coordinate here, this will be done by
// validation packets, sent by client
@@ -368,7 +368,7 @@ public class CharacterServiceImpl extends AbstractService implements
throws CharacterAlreadyWalkingServiceException {
Preconditions.checkNotNull(character, "character");
final CharacterID id = character.getID();
final Lineage2Connection conn = networkService.discover(id);
final Lineage2Client conn = networkService.discover(id);
// test if character is running
if (character.getMoveType() == CharacterMoveType.WALK)
throw new CharacterAlreadyWalkingServiceException();
@@ -384,7 +384,7 @@ public class CharacterServiceImpl extends AbstractService implements
throws CharacterAlreadyRunningServiceException {
Preconditions.checkNotNull(character, "character");
final CharacterID id = character.getID();
final Lineage2Connection conn = networkService.discover(id);
final Lineage2Client conn = networkService.discover(id);
// test if character is walking
if (character.getMoveType() == CharacterMoveType.RUN)
throw new CharacterAlreadyRunningServiceException();

View File

@@ -16,7 +16,7 @@
*/
package com.l2jserver.service.game.npc;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.packet.client.CM_CHAR_ACTION.CharacterAction;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.Actor;
@@ -93,12 +93,12 @@ public interface NPCService extends Service {
* @param npc
* the npc
* @param conn
* the {@link Lineage2Connection} object
* the {@link Lineage2Client} object
* @param attacker
* the character
* @throws NotAttackableNPCServiceException
* if {@link NPC} is not attackable
*/
void attack(NPC npc, Lineage2Connection conn, L2Character attacker)
void attack(NPC npc, Lineage2Client conn, L2Character attacker)
throws NotAttackableNPCServiceException;
}

View File

@@ -25,7 +25,7 @@ import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.l2jserver.db.dao.NPCDAO;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.packet.client.CM_CHAR_ACTION.CharacterAction;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.model.world.Actor;
@@ -66,7 +66,7 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
*/
private final SpawnService spawnService;
/**
* The {@link NetworkService} used to discover {@link Lineage2Connection}
* The {@link NetworkService} used to discover {@link Lineage2Client}
*/
private final NetworkService networkService;
/**
@@ -142,7 +142,7 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
Preconditions.checkNotNull(character, "character");
Preconditions.checkNotNull(action, "action");
final Lineage2Connection conn = networkService.discover(character
final Lineage2Client conn = networkService.discover(character
.getID());
try {
final NPCController controller = getController(npc);
@@ -160,7 +160,7 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
if (args == null)
args = new String[0];
final Lineage2Connection conn = networkService.discover(character
final Lineage2Client conn = networkService.discover(character
.getID());
try {
final NPCController controller = getController(npc);
@@ -215,7 +215,7 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
}
@Override
public void attack(NPC npc, Lineage2Connection conn, L2Character attacker)
public void attack(NPC npc, Lineage2Client conn, L2Character attacker)
throws NotAttackableNPCServiceException {
Preconditions.checkNotNull(npc, "npc");
Preconditions.checkNotNull(conn, "conn");

View File

@@ -16,13 +16,11 @@
*/
package com.l2jserver.service.game.spawn;
/**
* Exception thrown when the target spawn point is not found
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class SpawnPointNotFoundServiceException extends
SpawnServiceException {
public class SpawnPointNotFoundServiceException extends SpawnServiceException {
private static final long serialVersionUID = 1L;
}

View File

@@ -72,7 +72,7 @@ public interface SpawnService extends Service {
* the unit of <tt>time</tt>
* @return an future that can be used to obtain spawn exceptions
*/
AsyncFuture<?> spawn(PositionableObject object, Point3D point, long time,
<T extends PositionableObject> AsyncFuture<T> spawn(T object, Point3D point, long time,
TimeUnit unit);
/**
@@ -97,7 +97,7 @@ public interface SpawnService extends Service {
* the unit of <tt>time</tt>
* @return an future that can be used to obtain spawn exceptions
*/
AsyncFuture<?> unspawn(PositionableObject object, long time, TimeUnit unit);
<T extends PositionableObject> AsyncFuture<T> unspawn(T object, long time, TimeUnit unit);
/**
* Teleports the object to the given <tt>point</tt>.

View File

@@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO;
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO_EXTRA;
import com.l2jserver.game.net.packet.server.SM_TELEPORT;
@@ -130,15 +130,15 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
}
@Override
public AsyncFuture<?> spawn(final PositionableObject object,
public <T extends PositionableObject> AsyncFuture<T> spawn(final T object,
final Point3D point, long time, TimeUnit unit) {
Preconditions.checkNotNull(object, "object");
Preconditions.checkArgument(time > 0, "time < 0");
Preconditions.checkNotNull(unit, "unit");
return threadService.async(time, unit,
new Callable<PositionableObject>() {
new Callable<T>() {
@Override
public PositionableObject call() throws Exception {
public T call() throws Exception {
spawn(object, point);
return object;
}
@@ -176,15 +176,15 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
}
@Override
public AsyncFuture<?> unspawn(final PositionableObject object, long time,
public <T extends PositionableObject> AsyncFuture<T> unspawn(final T object, long time,
TimeUnit unit) {
Preconditions.checkNotNull(object, "object");
Preconditions.checkArgument(time > 0, "time <= 0");
Preconditions.checkNotNull(unit, "unit");
return threadService.async(time, unit,
new Callable<PositionableObject>() {
new Callable<T>() {
@Override
public PositionableObject call() throws Exception {
public T call() throws Exception {
unspawn(object);
return object;
}
@@ -200,7 +200,7 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
if (((L2Character) player).isTeleporting())
throw new CharacterAlreadyTeleportingServiceException();
final Lineage2Connection conn = networkService
final Lineage2Client conn = networkService
.discover((CharacterID) player.getID());
if (conn == null)
// TODO throw an exception here
@@ -223,7 +223,7 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
throws CharacterNotTeleportingServiceException {
Preconditions.checkNotNull(character, "character");
final CharacterID id = character.getID();
final Lineage2Connection conn = networkService.discover(id);
final Lineage2Client conn = networkService.discover(id);
if (!character.isTeleporting())
throw new CharacterNotTeleportingServiceException();

View File

@@ -30,7 +30,7 @@ import org.jboss.netty.logging.Slf4JLoggerFactory;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.Lineage2PipelineFactory;
import com.l2jserver.game.net.packet.ServerPacket;
import com.l2jserver.model.id.object.CharacterID;
@@ -76,7 +76,7 @@ public class NettyNetworkService extends AbstractService implements
/**
* The client list. This list all active clients in the server
*/
private Set<Lineage2Connection> clients = CollectionFactory.newSet();
private Set<Lineage2Client> clients = CollectionFactory.newSet();
@Inject
public NettyNetworkService(ConfigurationService configService,
@@ -98,7 +98,7 @@ public class NettyNetworkService extends AbstractService implements
}
@Override
public void register(final Lineage2Connection client) {
public void register(final Lineage2Client client) {
Preconditions.checkNotNull(client, "client");
clients.add(client);
client.getChannel().getCloseFuture()
@@ -112,15 +112,15 @@ public class NettyNetworkService extends AbstractService implements
}
@Override
public void unregister(Lineage2Connection client) {
public void unregister(Lineage2Client client) {
Preconditions.checkNotNull(client, "client");
clients.remove(client);
}
@Override
public Lineage2Connection discover(CharacterID character) {
public Lineage2Client discover(CharacterID character) {
Preconditions.checkNotNull(character, "character");
for (final Lineage2Connection client : clients) {
for (final Lineage2Client client : clients) {
if (character.equals(client.getCharacterID()))
return client;
}

View File

@@ -16,7 +16,7 @@
*/
package com.l2jserver.service.network;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.packet.ServerPacket;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.service.Service;
@@ -34,7 +34,7 @@ public interface NetworkService extends Service {
* @param client
* the client
*/
void register(Lineage2Connection client);
void register(Lineage2Client client);
/**
* Unregisters a client
@@ -42,7 +42,7 @@ public interface NetworkService extends Service {
* @param client
* the client
*/
void unregister(Lineage2Connection client);
void unregister(Lineage2Client client);
/**
* Discover the client using <tt>character</tt>
@@ -51,7 +51,7 @@ public interface NetworkService extends Service {
* the character
* @return the found connection
*/
Lineage2Connection discover(CharacterID character);
Lineage2Client discover(CharacterID character);
/**
* Broadcast an given <tt>packet</tt> to all clients connected

View File

@@ -16,7 +16,7 @@
*/
package com.l2jserver.service.network.broadcast;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.service.Service;
@@ -27,5 +27,11 @@ import com.l2jserver.service.Service;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface BroadcastService extends Service {
void broadcast(Lineage2Connection conn);
/**
* Broadcast all nearby objects to the given <tt>client</tt>
*
* @param conn
* the Lineage 2 client
*/
void broadcast(Lineage2Client conn);
}

View File

@@ -18,7 +18,7 @@ package com.l2jserver.service.network.broadcast;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.SystemMessage;
import com.l2jserver.game.net.packet.server.SM_ATTACK;
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO_BROADCAST;
@@ -72,7 +72,7 @@ public class BroadcastServiceImpl extends AbstractService implements
}
@Override
public void broadcast(final Lineage2Connection conn) {
public void broadcast(final Lineage2Client conn) {
Preconditions.checkNotNull(conn, "conn");
final L2Character character = conn.getCharacter();
Preconditions.checkNotNull(character, "character");
@@ -152,7 +152,7 @@ public class BroadcastServiceImpl extends AbstractService implements
* @param character
* the character
*/
private void broadcastAll(Lineage2Connection conn, L2Character character) {
private void broadcastAll(Lineage2Client conn, L2Character character) {
for (final WorldObject o : worldService.iterable(new KnownListFilter(
character))) {
broadcast(conn, o);
@@ -170,7 +170,7 @@ public class BroadcastServiceImpl extends AbstractService implements
* @param point
* the old point
*/
private void broadcastUpdate(Lineage2Connection conn,
private void broadcastUpdate(Lineage2Client conn,
L2Character character, Point3D point) {
for (final WorldObject o : worldService
.iterable(new KnownListUpdateFilter(character, point))) {
@@ -186,7 +186,7 @@ public class BroadcastServiceImpl extends AbstractService implements
* @param character
* the character
*/
private void broadcast(Lineage2Connection conn, WorldObject o) {
private void broadcast(Lineage2Client conn, WorldObject o) {
if (o instanceof NPC) {
conn.write(new SM_NPC_INFO((NPC) o));
} else if (o instanceof L2Character) {

View File

@@ -18,7 +18,7 @@ package com.l2jserver.service.network.gameguard;
import java.util.concurrent.Future;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.service.Service;
/**
@@ -34,7 +34,7 @@ public interface GameGuardService extends Service {
* the lineage 2 connection
* @return an future that will be used to obtain validation status
*/
Future<GameGuardResponse> query(Lineage2Connection conn);
Future<GameGuardResponse> query(Lineage2Client conn);
/**
* The Game guard key state
@@ -62,5 +62,5 @@ public interface GameGuardService extends Service {
* the key
* @return the validation state
*/
GameGuardResponse key(Lineage2Connection conn, byte[] key);
GameGuardResponse key(Lineage2Client conn, byte[] key);
}

View File

@@ -25,7 +25,7 @@ import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelFutureListener;
import com.google.common.util.concurrent.AbstractFuture;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.Lineage2Client;
import com.l2jserver.game.net.packet.server.SM_GG_QUERY;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
@@ -54,7 +54,7 @@ public class GameGuardServiceImpl extends AbstractService implements
/**
* The map containing all pending futures
*/
private Map<Lineage2Connection, GGFuture> futures;
private Map<Lineage2Client, GGFuture> futures;
/**
* The {@link MessageDigest} for SHA-1.
* <p>
@@ -74,7 +74,7 @@ public class GameGuardServiceImpl extends AbstractService implements
}
@Override
public Future<GameGuardResponse> query(final Lineage2Connection conn) {
public Future<GameGuardResponse> query(final Lineage2Client conn) {
conn.write(new SM_GG_QUERY()).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future)
@@ -90,7 +90,7 @@ public class GameGuardServiceImpl extends AbstractService implements
}
@Override
public GameGuardResponse key(Lineage2Connection conn, byte[] key) {
public GameGuardResponse key(Lineage2Client conn, byte[] key) {
final GGFuture future = futures.remove(conn);
final boolean validated = validate(conn, key);
final GameGuardResponse response = (validated ? GameGuardResponse.VALID
@@ -109,7 +109,7 @@ public class GameGuardServiceImpl extends AbstractService implements
* the key
* @return true if key is valid
*/
private boolean validate(Lineage2Connection conn, byte[] key) {
private boolean validate(Lineage2Client conn, byte[] key) {
// synchronized (digester) {
// return Arrays.equals(VALID_KEY_SHA1, digester.digest(key));
// }