mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-05 23:22:47 +00:00
Implemented several debug messages in many services
This commit is contained in:
@@ -152,4 +152,9 @@ public class ChatMessage extends AbstractModel<ChatMessageID> implements
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChatMessage [" + sender + "@" + date + ": " + message + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ import net.sf.ehcache.config.Configuration;
|
||||
import net.sf.ehcache.config.DiskStoreConfiguration;
|
||||
import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
@@ -41,6 +44,11 @@ import com.l2jserver.service.ServiceStopException;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class EhCacheService extends AbstractService implements CacheService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The cache manager
|
||||
*/
|
||||
@@ -65,6 +73,8 @@ public class EhCacheService extends AbstractService implements CacheService {
|
||||
Preconditions.checkArgument(interfaceType.isInterface(),
|
||||
"interfaceType is not an interface");
|
||||
|
||||
log.debug("Decorating {} with cache", interfaceType);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final T proxy = (T) Proxy.newProxyInstance(this.getClass()
|
||||
.getClassLoader(), new Class[] { interfaceType },
|
||||
@@ -94,43 +104,13 @@ public class EhCacheService extends AbstractService implements CacheService {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Cache createCache(String name, int size) {
|
||||
// Preconditions.checkNotNull(name, "name");
|
||||
// Preconditions.checkArgument(size > 0, "size <= 0");
|
||||
//
|
||||
// Cache cache = new Cache(new CacheConfiguration(name, size)
|
||||
// .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
|
||||
// .overflowToDisk(true).eternal(false).timeToLiveSeconds(60)
|
||||
// .timeToIdleSeconds(30).diskPersistent(false)
|
||||
// .diskExpiryThreadIntervalSeconds(0));
|
||||
// register(cache);
|
||||
// return cache;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Cache createCache(String name) {
|
||||
// Preconditions.checkNotNull(name, "name");
|
||||
// return createCache(name, 200);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void register(Cache cache) {
|
||||
// Preconditions.checkNotNull(cache, "cache");
|
||||
// manager.addCache(cache);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void unregister(Cache cache) {
|
||||
// Preconditions.checkNotNull(cache, "cache");
|
||||
// manager.removeCache(cache.getName());
|
||||
// }
|
||||
|
||||
@Override
|
||||
public <K, V> Cache<K, V> createCache(String name, int size) {
|
||||
Preconditions.checkNotNull(name, "name");
|
||||
Preconditions.checkArgument(size > 0, "size <= 0");
|
||||
|
||||
log.debug("Creating cache {} with minimum size of {}", name, size);
|
||||
|
||||
net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache(
|
||||
new CacheConfiguration(name, size)
|
||||
.memoryStoreEvictionPolicy(
|
||||
@@ -148,6 +128,9 @@ public class EhCacheService extends AbstractService implements CacheService {
|
||||
Preconditions.checkNotNull(name, "name");
|
||||
Preconditions.checkArgument(size > 0, "size <= 0");
|
||||
|
||||
log.debug("Creating eternal cache {} with minimum size of {}", name,
|
||||
size);
|
||||
|
||||
net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache(
|
||||
new CacheConfiguration(name, size)
|
||||
.memoryStoreEvictionPolicy(
|
||||
@@ -160,20 +143,16 @@ public class EhCacheService extends AbstractService implements CacheService {
|
||||
|
||||
@Override
|
||||
public <K, V> Cache<K, V> createCache(String name) {
|
||||
net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache(
|
||||
new CacheConfiguration(name, 200)
|
||||
.memoryStoreEvictionPolicy(
|
||||
MemoryStoreEvictionPolicy.LRU)
|
||||
.overflowToDisk(true).eternal(true)
|
||||
.diskExpiryThreadIntervalSeconds(0));
|
||||
manager.addCache(cache);
|
||||
return new EhCacheFacade<K, V>(cache);
|
||||
return createCache(name, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> void dispose(Cache<K, V> cache) {
|
||||
if (cache instanceof EhCacheFacade) {
|
||||
log.debug("Disposing cache {}", cache);
|
||||
manager.removeCache(((EhCacheFacade<K, V>) cache).cache.getName());
|
||||
} else {
|
||||
log.warn("Trying to dispose {} cache when it is not EhCacheFacade type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
@@ -36,6 +39,11 @@ import com.l2jserver.service.ServiceStopException;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SoftCacheService extends AbstractService implements CacheService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The interface cache
|
||||
*/
|
||||
@@ -53,6 +61,8 @@ public class SoftCacheService extends AbstractService implements CacheService {
|
||||
Preconditions.checkNotNull(instance, "instance");
|
||||
Preconditions.checkArgument(interfaceType.isInterface(),
|
||||
"interfaceType is not an interface");
|
||||
|
||||
log.debug("Decorating {} with cache", interfaceType);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final T proxy = (T) Proxy.newProxyInstance(this.getClass()
|
||||
@@ -85,21 +95,24 @@ public class SoftCacheService extends AbstractService implements CacheService {
|
||||
|
||||
@Override
|
||||
public <K, V> Cache<K, V> createCache(String name, int size) {
|
||||
log.debug("Creating cache {} with minimum size of {}", name, size);
|
||||
return new SoftCache<K, V>(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> Cache<K, V> createEternalCache(String name, int size) {
|
||||
log.debug("Creating eternal cache {} with minimum size of {}", name, size);
|
||||
return new EternalCache<K, V>(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> Cache<K, V> createCache(String name) {
|
||||
return new SoftCache<K, V>(name);
|
||||
return createCache(name, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> void dispose(Cache<K, V> cache) {
|
||||
log.debug("Disposing {}", cache);
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
@@ -36,6 +39,11 @@ import com.l2jserver.service.ServiceStopException;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class WeakCacheService extends AbstractService implements CacheService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The interface cache
|
||||
*/
|
||||
@@ -54,6 +62,8 @@ public class WeakCacheService extends AbstractService implements CacheService {
|
||||
Preconditions.checkArgument(interfaceType.isInterface(),
|
||||
"interfaceType is not an interface");
|
||||
|
||||
log.debug("Decorating {} with cache", interfaceType);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final T proxy = (T) Proxy.newProxyInstance(this.getClass()
|
||||
.getClassLoader(), new Class[] { interfaceType },
|
||||
@@ -85,21 +95,25 @@ public class WeakCacheService extends AbstractService implements CacheService {
|
||||
|
||||
@Override
|
||||
public <K, V> Cache<K, V> createCache(String name, int size) {
|
||||
log.debug("Creating cache {} with minimum size of {}", name, size);
|
||||
return new WeakCache<K, V>(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> Cache<K, V> createEternalCache(String name, int size) {
|
||||
log.debug("Creating eternal cache {} with minimum size of {}", name,
|
||||
size);
|
||||
return new EternalCache<K, V>(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> Cache<K, V> createCache(String name) {
|
||||
return new WeakCache<K, V>(name);
|
||||
return createCache(name, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> void dispose(Cache<K, V> cache) {
|
||||
log.debug("Disposing {}", cache);
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,8 +59,7 @@ public class ProxyConfigurationService extends AbstractService implements
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger logger = LoggerFactory
|
||||
.getLogger(ProxyConfigurationService.class);
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The cache of configuration objects
|
||||
@@ -81,13 +80,13 @@ public class ProxyConfigurationService extends AbstractService implements
|
||||
|
||||
if (cache.containsKey(config))
|
||||
return (C) cache.get(config);
|
||||
logger.debug("Trying to create {} proxy", config);
|
||||
log.debug("Trying to create {} proxy", config);
|
||||
Properties properties;
|
||||
try {
|
||||
properties = findProperties(config);
|
||||
} catch (IOException e) {
|
||||
properties = new Properties();
|
||||
logger.warn(
|
||||
log.warn(
|
||||
"Configuration file for {} not found, falling back to default values",
|
||||
config);
|
||||
}
|
||||
@@ -114,7 +113,7 @@ public class ProxyConfigurationService extends AbstractService implements
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args)
|
||||
throws Throwable {
|
||||
logger.debug("Configuration service, method invoked: {}",
|
||||
log.debug("Configuration service, method invoked: {}",
|
||||
method.getName());
|
||||
if (args == null || args.length == 0) {
|
||||
final ConfigurationPropertyGetter getter = method
|
||||
|
||||
@@ -60,6 +60,8 @@ public class ThreadServiceImpl extends AbstractService implements ThreadService
|
||||
@Override
|
||||
public <T> AsyncFuture<T> async(Callable<T> callable) {
|
||||
Preconditions.checkNotNull(callable, "callable");
|
||||
|
||||
log.debug("Scheduling async task: {}", callable);
|
||||
return pool.async(callable);
|
||||
}
|
||||
|
||||
@@ -69,6 +71,9 @@ public class ThreadServiceImpl extends AbstractService implements ThreadService
|
||||
Preconditions.checkArgument(delay >= 0, "delay < 0");
|
||||
Preconditions.checkNotNull(unit, "unit");
|
||||
Preconditions.checkNotNull(callable, "callable");
|
||||
|
||||
log.debug("Scheduling async task in {}ms: {}", unit.toMillis(delay),
|
||||
callable);
|
||||
return pool.async(delay, unit, callable);
|
||||
}
|
||||
|
||||
@@ -79,17 +84,22 @@ public class ThreadServiceImpl extends AbstractService implements ThreadService
|
||||
Preconditions.checkArgument(repeat >= 0, "repeat < 0");
|
||||
Preconditions.checkNotNull(unit, "unit");
|
||||
Preconditions.checkNotNull(task, "task");
|
||||
|
||||
log.debug("Scheduling repeating async task in {}ms each {}ms: {}", new Object[] {
|
||||
unit.toMillis(delay), unit.toMillis(repeat), task });
|
||||
return pool.async(delay, unit, repeat, task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThreadPool createThreadPool(String name, int maxThreads) {
|
||||
log.debug("Creating new ThreadPool {} with maximum of {} threads", name, maxThreads);
|
||||
return new ThreadPoolImpl(name,
|
||||
Executors.newScheduledThreadPool(maxThreads));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(ThreadPool pool) {
|
||||
log.debug("Disposing ThreadPool {}", pool);
|
||||
if (pool instanceof ThreadPoolImpl)
|
||||
((ThreadPoolImpl) pool).executor.shutdown();
|
||||
throw new UnsupportedOperationException(
|
||||
|
||||
@@ -66,6 +66,7 @@ public class VFSServiceImpl extends AbstractService implements VFSService {
|
||||
|
||||
@Override
|
||||
public FileObject resolve(String uri) {
|
||||
log.debug("Resolving file {}", uri);
|
||||
try {
|
||||
return manager.resolveFile(uri);
|
||||
} catch (FileSystemException e) {
|
||||
|
||||
@@ -230,6 +230,7 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
Preconditions.checkNotNull(query, "query");
|
||||
try {
|
||||
final Connection conn = dataSource.getConnection();
|
||||
log.debug("Executing query {} with {}", query, conn);
|
||||
try {
|
||||
return query.query(conn);
|
||||
} catch (SQLException e) {
|
||||
@@ -246,22 +247,26 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
|
||||
public Object getCachedObject(Object id) {
|
||||
Preconditions.checkNotNull(id, "id");
|
||||
log.debug("Fetching cached object {}", id);
|
||||
return objectCache.get(id);
|
||||
}
|
||||
|
||||
public boolean hasCachedObject(Object id) {
|
||||
Preconditions.checkNotNull(id, "id");
|
||||
log.debug("Locating cached object {}", id);
|
||||
return objectCache.contains(id);
|
||||
}
|
||||
|
||||
public void updateCache(ID<?> key, Model<?> value) {
|
||||
Preconditions.checkNotNull(key, "key");
|
||||
Preconditions.checkNotNull(value, "value");
|
||||
log.debug("Updating cached object {} with {}", key, value);
|
||||
objectCache.put(key, value);
|
||||
}
|
||||
|
||||
public void removeCache(Object key) {
|
||||
Preconditions.checkNotNull(key, "key");
|
||||
log.debug("Removing cached object {}", key);
|
||||
objectCache.remove(key);
|
||||
}
|
||||
|
||||
@@ -321,6 +326,12 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
* the query return type
|
||||
*/
|
||||
public static abstract class InsertUpdateQuery<T> implements Query<Integer> {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory
|
||||
.getLogger(InsertUpdateQuery.class);
|
||||
|
||||
private final Iterator<T> iterator;
|
||||
|
||||
/**
|
||||
@@ -347,24 +358,39 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
@Override
|
||||
public Integer query(Connection conn) throws SQLException {
|
||||
Preconditions.checkNotNull(conn, "conn");
|
||||
|
||||
log.debug("Starting INSERT/UPDATE query execution");
|
||||
|
||||
int rows = 0;
|
||||
while (iterator.hasNext()) {
|
||||
final T object = iterator.next();
|
||||
final PreparedStatement st = conn.prepareStatement(query(),
|
||||
final String queryString = query();
|
||||
|
||||
log.debug("Preparing statement for {}: {}", object, queryString);
|
||||
final PreparedStatement st = conn.prepareStatement(queryString,
|
||||
Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
log.debug("Parametizing statement {} with {}", st, object);
|
||||
this.parametize(st, object);
|
||||
|
||||
log.debug("Sending query to database for {}", object);
|
||||
rows += st.executeUpdate();
|
||||
log.debug("Query inserted or updated {} rows for {}", rows, object);
|
||||
|
||||
// update object desire --it has been realized
|
||||
if (object instanceof Model && rows > 0) {
|
||||
log.debug("Updating Model ObjectDesire to NONE");
|
||||
((Model<?>) object).setObjectDesire(ObjectDesire.NONE);
|
||||
|
||||
final Mapper<? extends ID<?>> mapper = keyMapper();
|
||||
if (mapper == null)
|
||||
continue;
|
||||
final ResultSet rs = st.getGeneratedKeys();
|
||||
log.debug("Mapping generated keys with {} using {}", mapper, rs);
|
||||
while (rs.next()) {
|
||||
((Model<ID<?>>) object).setID(mapper.map(rs));
|
||||
final ID<?> generatedID = mapper.map(rs);
|
||||
log.debug("Generated ID for {} is {}", object, generatedID);
|
||||
((Model<ID<?>>) object).setID(generatedID);
|
||||
mapper.map(rs);
|
||||
}
|
||||
}
|
||||
@@ -413,20 +439,42 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
* the query return type
|
||||
*/
|
||||
public static abstract class SelectListQuery<T> implements Query<List<T>> {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory
|
||||
.getLogger(SelectListQuery.class);
|
||||
|
||||
@Override
|
||||
public List<T> query(Connection conn) throws SQLException {
|
||||
Preconditions.checkNotNull(conn, "conn");
|
||||
|
||||
log.debug("Starting SELECT List<?> query execution");
|
||||
|
||||
final String queryString = query();
|
||||
log.debug("Preparing statement with {}", queryString);
|
||||
final PreparedStatement st = conn.prepareStatement(query());
|
||||
|
||||
log.debug("Parametizing statement {}", st);
|
||||
parametize(st);
|
||||
|
||||
log.debug("Sending query to database for {}", st);
|
||||
st.execute();
|
||||
|
||||
final List<T> list = CollectionFactory.newList();
|
||||
final ResultSet rs = st.getResultSet();
|
||||
final Mapper<T> mapper = mapper();
|
||||
log.debug("Database returned {}", rs);
|
||||
while (rs.next()) {
|
||||
final T obj = mapper().map(rs);
|
||||
if (obj == null)
|
||||
log.debug("Mapping row with {}", mapper);
|
||||
final T obj = mapper.map(rs);
|
||||
if (obj == null) {
|
||||
log.debug("Mapper {} returned a null row", mapper);
|
||||
continue;
|
||||
}
|
||||
if (obj instanceof Model)
|
||||
((Model<?>) obj).setObjectDesire(ObjectDesire.NONE);
|
||||
log.debug("Mapper {} returned {}", mapper, obj);
|
||||
list.add(obj);
|
||||
}
|
||||
return list;
|
||||
@@ -473,17 +521,37 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
* the query return type
|
||||
*/
|
||||
public static abstract class SelectSingleQuery<T> implements Query<T> {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory
|
||||
.getLogger(SelectSingleQuery.class);
|
||||
|
||||
@Override
|
||||
public T query(Connection conn) throws SQLException {
|
||||
Preconditions.checkNotNull(conn, "conn");
|
||||
|
||||
log.debug("Starting SELECT single query execution");
|
||||
|
||||
final String queryString = query();
|
||||
log.debug("Preparing statement with {}", queryString);
|
||||
final PreparedStatement st = conn.prepareStatement(query());
|
||||
|
||||
log.debug("Parametizing statement {}", st);
|
||||
parametize(st);
|
||||
|
||||
log.debug("Sending query to database for {}", st);
|
||||
st.execute();
|
||||
|
||||
final ResultSet rs = st.getResultSet();
|
||||
final Mapper<T> mapper = mapper();
|
||||
log.debug("Database returned {}", rs);
|
||||
while (rs.next()) {
|
||||
final T object = mapper().map(rs);
|
||||
log.debug("Mapping row {} with {}", rs, mapper);
|
||||
final T object = mapper.map(rs);
|
||||
if (object instanceof Model)
|
||||
((Model<?>) object).setObjectDesire(ObjectDesire.NONE);
|
||||
log.debug("Mapper {} returned {}", mapper, object);
|
||||
return object;
|
||||
}
|
||||
return null;
|
||||
@@ -557,6 +625,12 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
*/
|
||||
public abstract static class CachedMapper<T extends Model<?>, I extends ID<?>>
|
||||
implements Mapper<T> {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory
|
||||
.getLogger(SelectSingleQuery.class);
|
||||
|
||||
/**
|
||||
* The database service instance
|
||||
*/
|
||||
@@ -578,15 +652,21 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final T map(ResultSet rs) throws SQLException {
|
||||
log.debug("Mapping row {} ID with {}", rs, idMapper);
|
||||
final I id = idMapper.map(rs);
|
||||
Preconditions.checkNotNull(id, "id");
|
||||
|
||||
log.debug("ID={}, locating cached object", id);
|
||||
|
||||
if (database.hasCachedObject(id))
|
||||
return (T) database.getCachedObject(id);
|
||||
|
||||
log.debug("Cached object not found, creating...");
|
||||
|
||||
final T object = map(id, rs);
|
||||
if (object != null)
|
||||
database.updateCache(id, object);
|
||||
log.debug("Object {} created", object);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ package com.l2jserver.service.game;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.server.AttackHit;
|
||||
@@ -45,6 +48,11 @@ public class AttackServiceImpl extends AbstractService implements AttackService
|
||||
*/
|
||||
private static final AttackCalculator PHYSICAL_ATTACK_CALCULATOR = new PhysicalAttackCalculator();
|
||||
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The {@link ThreadService} is used to schedule asynchronous attacks
|
||||
*/
|
||||
@@ -74,6 +82,7 @@ public class AttackServiceImpl extends AbstractService implements AttackService
|
||||
Preconditions.checkNotNull(target, "target");
|
||||
Preconditions.checkArgument(!attacker.equals(target),
|
||||
"attacker must not be equal to target");
|
||||
log.debug("{} starting attack to {}", attacker, target);
|
||||
return threadService.async(new AttackCallable(attacker, target));
|
||||
}
|
||||
|
||||
@@ -107,6 +116,8 @@ public class AttackServiceImpl extends AbstractService implements AttackService
|
||||
// TODO calculate miss
|
||||
// TODO calculate critical
|
||||
// TODO calculate soulshot
|
||||
|
||||
log.debug("Attack dealt {} damage, but only {} is effective", damage, dealDamage);
|
||||
|
||||
// reduce target life
|
||||
target.setHP(target.getHP() - dealDamage);
|
||||
@@ -115,6 +126,7 @@ public class AttackServiceImpl extends AbstractService implements AttackService
|
||||
eventDispatcher.dispatch(new ActorAttackHitEvent(hit));
|
||||
|
||||
if (target.getHP() <= 0) {
|
||||
log.debug("{} hitpoins reached zero, killing object", target);
|
||||
if (target instanceof NPC)
|
||||
npcService.die((NPC) target, attacker);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.service.game;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
|
||||
@@ -25,6 +28,12 @@ import com.l2jserver.service.AbstractService;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class DuelServiceImpl extends AbstractService implements DuelService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Override
|
||||
public void start(L2Character character1, L2Character character2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.service.game;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.service.AbstractService;
|
||||
|
||||
/**
|
||||
@@ -25,6 +28,12 @@ import com.l2jserver.service.AbstractService;
|
||||
*/
|
||||
public class GameTimeServiceImpl extends AbstractService implements
|
||||
GameTimeService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Override
|
||||
public int getGameTime() {
|
||||
return (int) (System.currentTimeMillis() % GAME_DAY) / 1000;
|
||||
|
||||
@@ -18,6 +18,9 @@ package com.l2jserver.service.game.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Client;
|
||||
import com.l2jserver.game.net.packet.server.SM_HTML;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
@@ -31,12 +34,18 @@ import com.l2jserver.service.game.admin.panel.AdminHomeTemplate;
|
||||
*/
|
||||
public class AdministratorServiceImpl extends AbstractService implements
|
||||
AdministratorService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private List<CharacterID> online;
|
||||
|
||||
@Override
|
||||
public void command(Lineage2Client conn, L2Character character,
|
||||
String command, String... args) {
|
||||
log.debug("{} is opening admin control panel", character);
|
||||
conn.write(new SM_HTML(null, new AdminHomeTemplate()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.ai;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
@@ -37,6 +40,12 @@ import com.l2jserver.util.geometry.Coordinate;
|
||||
@Depends({ WorldService.class, TemplateService.class, ThreadService.class,
|
||||
NetworkService.class })
|
||||
public class AIServiceImpl extends AbstractService implements AIService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The {@link WorldService}
|
||||
*/
|
||||
|
||||
@@ -169,6 +169,11 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
throws CharacterInvalidNameException,
|
||||
CharacterInvalidAppearanceException,
|
||||
CharacterNameAlreadyExistsException {
|
||||
log.debug(
|
||||
"Requested creation of new character (name={}, sex={}, class={}, hairStyle={}, hairColor={}, face={})",
|
||||
new Object[] { name, sex, characterClass, hairStyle, hairColor,
|
||||
face });
|
||||
|
||||
if ((name.length() < 1) || (name.length() > 16)) {
|
||||
throw new CharacterInvalidNameException();
|
||||
}
|
||||
@@ -180,6 +185,7 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
throw new CharacterInvalidAppearanceException();
|
||||
|
||||
// existence check
|
||||
log.debug("Checking name existence {}", name);
|
||||
final L2Character existenceCheck = characterDao.selectByName(name);
|
||||
if (existenceCheck != null)
|
||||
throw new CharacterNameAlreadyExistsException();
|
||||
@@ -217,10 +223,17 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
throws SpawnPointNotFoundServiceException,
|
||||
AlreadySpawnedServiceException {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
|
||||
log.debug("Character {} is entering world", character);
|
||||
|
||||
final CharacterID id = character.getID();
|
||||
final Lineage2Client conn = networkService.discover(id);
|
||||
if (conn == null)
|
||||
if (conn == null) {
|
||||
log.debug(
|
||||
"Character {} cannot enter world, no Lineage2Client object found",
|
||||
character);
|
||||
return;
|
||||
}
|
||||
|
||||
itemDao.loadInventory(character);
|
||||
|
||||
@@ -252,6 +265,10 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
if (!(e instanceof CharacterLeaveWorldEvent))
|
||||
return true;
|
||||
|
||||
log.debug(
|
||||
"Character {} is leaving world, removing chat listeners",
|
||||
character);
|
||||
|
||||
// remove chat listeners
|
||||
chatService.getGlobalChannel().removeMessageListener(
|
||||
globalChatListener);
|
||||
@@ -276,10 +293,12 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
ggService.query(conn);
|
||||
|
||||
// send this user information
|
||||
log.debug("Sending character information packets");
|
||||
conn.write(new SM_CHAR_INFO(character));
|
||||
conn.write(new SM_CHAR_INFO_EXTRA(character));
|
||||
conn.write(new SM_CHAR_INVENTORY(character.getInventory()));
|
||||
|
||||
log.debug("Sending greeting message to client");
|
||||
conn.sendSystemMessage(SystemMessage.WELCOME_TO_LINEAGE);
|
||||
conn.sendMessage("This an an development version for l2jserver 2.0");
|
||||
conn.sendMessage("Please note that many of the features are not yet implemented.");
|
||||
@@ -310,6 +329,9 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
public void leaveWorld(L2Character character)
|
||||
throws NotSpawnedServiceException {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
|
||||
log.debug("Character {} is leaving world", character);
|
||||
|
||||
spawnService.unspawn(character);
|
||||
eventDispatcher.dispatch(new CharacterLeaveWorldEvent(character));
|
||||
character.setOnline(false);
|
||||
@@ -320,6 +342,9 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
throws CannotSetTargetServiceException {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
Preconditions.checkNotNull(target, "target");
|
||||
|
||||
log.debug("Setting {} target to {}", character, target);
|
||||
|
||||
final CharacterID id = character.getID();
|
||||
final Lineage2Client conn = networkService.discover(id);
|
||||
|
||||
@@ -361,17 +386,24 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
NotAttackableNPCServiceException {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
Preconditions.checkNotNull(target, "target");
|
||||
|
||||
log.debug("Character {} is trying to attack {}", character, target);
|
||||
|
||||
final CharacterID id = character.getID();
|
||||
final Lineage2Client conn = networkService.discover(id);
|
||||
// check if this Actor can be attacked
|
||||
if (target instanceof NPC) {
|
||||
final NPC npc = (NPC) target;
|
||||
log.debug("{} is an NPC instance", npc);
|
||||
|
||||
// first try to target this, if it is not already
|
||||
if (!npc.getID().equals(character.getTargetID()))
|
||||
if (!npc.getID().equals(character.getTargetID())) {
|
||||
log.debug("{} is not targetted by {}", npc, character);
|
||||
target(character, target);
|
||||
}
|
||||
|
||||
// now attack the npc
|
||||
log.debug("Sending {} attack request to NPCService", character);
|
||||
npcService.attack(npc, conn, character);
|
||||
} else {
|
||||
// TODO throw an exception
|
||||
@@ -401,6 +433,9 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
public void move(L2Character character, Coordinate coordinate) {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
Preconditions.checkNotNull(coordinate, "coordinate");
|
||||
|
||||
log.debug("{} is moving to {}", character, coordinate);
|
||||
|
||||
final CharacterID id = character.getID();
|
||||
final Lineage2Client conn = networkService.discover(id);
|
||||
// we don't set the character coordinate here, this will be done by
|
||||
@@ -432,6 +467,9 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
// ignore while teleporting, for some reason the client sends a
|
||||
// validation just before teleport packet
|
||||
return;
|
||||
|
||||
log.debug("{} client is validating its position to {}", character, point);
|
||||
|
||||
final Point3D old = character.getPoint();
|
||||
character.setPoint(point);
|
||||
// BroadcastService will catch this event and update the knownlist
|
||||
@@ -454,6 +492,9 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
// test if character is running
|
||||
if (character.getMoveType() == CharacterMoveType.WALK)
|
||||
throw new CharacterAlreadyWalkingServiceException();
|
||||
|
||||
log.debug("{} move type is being set to WALK", character);
|
||||
|
||||
// if running set mode to walk and broadcast packet
|
||||
character.setMoveType(CharacterMoveType.WALK);
|
||||
|
||||
@@ -470,6 +511,9 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
// test if character is walking
|
||||
if (character.getMoveType() == CharacterMoveType.RUN)
|
||||
throw new CharacterAlreadyRunningServiceException();
|
||||
|
||||
log.debug("{} move type is being set to RUN", character);
|
||||
|
||||
// if running walking mode to run and broadcast packet
|
||||
character.setMoveType(CharacterMoveType.RUN);
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
import com.l2jserver.service.Service;
|
||||
@@ -33,6 +35,9 @@ import com.l2jserver.service.Service;
|
||||
* <p>
|
||||
* <b>{@link ChatChannelFilter} will be called before logging can occur. If any
|
||||
* filter refuses the message, it will NOT be logged.</b>
|
||||
* <p>
|
||||
* This service, however, does not need to log the message using {@link Logger}
|
||||
* object, because this is already done by {@link ChatService}.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,9 @@ package com.l2jserver.service.game.chat;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.dao.CharacterDAO;
|
||||
@@ -42,8 +45,15 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
*/
|
||||
@Depends(ChatLoggingService.class)
|
||||
public class SimpleChatService extends AbstractService implements ChatService {
|
||||
private final ChatLoggingService chatLoggingService;
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The {@link ChatLoggingService} implementation
|
||||
*/
|
||||
private final ChatLoggingService chatLoggingService;
|
||||
/**
|
||||
* The {@link RegionService}
|
||||
*/
|
||||
@@ -115,6 +125,9 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
Preconditions.checkNotNull(sender, "sender");
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
|
||||
log.debug("Sending message {} from {} to {}", new Object[] { message,
|
||||
sender, chat });
|
||||
|
||||
final ChatChannel channel;
|
||||
switch (chat) {
|
||||
case ALL:
|
||||
@@ -232,13 +245,16 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
for (final ChatChannelFilter filter : filters) {
|
||||
if (!filter.filter(sender, this, textMessage))
|
||||
// discard message
|
||||
return null;
|
||||
log.debug("Message {} discarded by {}", textMessage, filter);
|
||||
return null;
|
||||
}
|
||||
|
||||
// log this chat message
|
||||
ChatMessage message = chatLoggingService.log(sender, this,
|
||||
textMessage);
|
||||
|
||||
log.debug("[{}]: {}", this, message);
|
||||
|
||||
for (final ChatChannelListener listener : listeners) {
|
||||
listener.onMessage(this, message);
|
||||
}
|
||||
@@ -249,24 +265,28 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
@Override
|
||||
public void addMessageListener(ChatChannelListener listener) {
|
||||
Preconditions.checkNotNull(listener, "listener");
|
||||
log.debug("Added {} to {}", listener, this);
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMessageListener(ChatChannelListener listener) {
|
||||
Preconditions.checkNotNull(listener, "listener");
|
||||
log.debug("Removed {} to {}", listener, this);
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageFilter(ChatChannelFilter filter) {
|
||||
Preconditions.checkNotNull(filter, "filter");
|
||||
log.debug("Added {} to {}", filter, this);
|
||||
filters.add(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMessageFilter(ChatChannelFilter filter) {
|
||||
Preconditions.checkNotNull(filter, "filter");
|
||||
log.debug("Removed {} to {}", filter, this);
|
||||
filters.remove(filter);
|
||||
}
|
||||
|
||||
@@ -279,6 +299,17 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
public int getChannelID() {
|
||||
return getMessageType().id;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChatChannelImpl [" + getChannelName() + "("
|
||||
+ getChannelID() + ")]";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.map.pathing;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.model.world.PositionableObject;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
@@ -32,6 +35,12 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
@Depends({ CharacterService.class, WorldService.class })
|
||||
public class AStarPathingService extends AbstractService implements
|
||||
PathingService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Override
|
||||
public Path findPath(PositionableObject object, Point3D point) {
|
||||
return null;
|
||||
|
||||
@@ -16,11 +16,15 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.npc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
@@ -61,6 +65,11 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
@Depends({ SpawnService.class, NetworkService.class, CharacterService.class,
|
||||
ThreadService.class, AttackService.class, DatabaseService.class })
|
||||
public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The {@link SpawnService} used to spawn the {@link NPC} instances
|
||||
*/
|
||||
@@ -142,6 +151,9 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
Preconditions.checkNotNull(action, "action");
|
||||
|
||||
log.debug("{} interacting with {} (action={})", new Object[] {
|
||||
character, npc, action });
|
||||
|
||||
final Lineage2Client conn = networkService.discover(character.getID());
|
||||
try {
|
||||
final NPCController controller = getController(npc);
|
||||
@@ -159,6 +171,9 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
if (args == null)
|
||||
args = new String[0];
|
||||
|
||||
log.debug("{} interacting with {} (action={})", new Object[] {
|
||||
character, npc, Arrays.toString(args) });
|
||||
|
||||
final Lineage2Client conn = networkService.discover(character.getID());
|
||||
try {
|
||||
final NPCController controller = getController(npc);
|
||||
@@ -173,6 +188,8 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
Preconditions.checkNotNull(npc, "npc");
|
||||
Preconditions.checkNotNull(killer, "killer");
|
||||
|
||||
log.debug("{} was killed by {}", npc, killer);
|
||||
|
||||
// set npc as dead
|
||||
npc.setState(ActorState.DEAD);
|
||||
|
||||
@@ -196,6 +213,9 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
// TODO throw an exception
|
||||
return null;
|
||||
npc.setState(ActorState.MOVING);
|
||||
|
||||
log.debug("{} is moving to {}", npc, point);
|
||||
|
||||
// calculate walking time
|
||||
final Point3D start = npc.getPoint();
|
||||
final double distance = start.getDistance(point);
|
||||
@@ -218,6 +238,8 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
Preconditions.checkNotNull(npc, "npc");
|
||||
Preconditions.checkNotNull(conn, "conn");
|
||||
Preconditions.checkNotNull(attacker, "attacker");
|
||||
|
||||
log.debug("{} is being attacked by {}", npc, attacker);
|
||||
|
||||
final NPCTemplate template = npc.getTemplate();
|
||||
if (!template.isAttackable()) {
|
||||
|
||||
@@ -19,6 +19,9 @@ package com.l2jserver.service.game.spawn;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Client;
|
||||
@@ -55,6 +58,11 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
*/
|
||||
@Depends({ WorldService.class, NetworkService.class, ThreadService.class })
|
||||
public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The {@link WorldService}
|
||||
*/
|
||||
@@ -101,6 +109,8 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
throw new SpawnPointNotFoundServiceException();
|
||||
}
|
||||
|
||||
log.debug("Spawning {} at {}", object, point);
|
||||
|
||||
// set the spawning point
|
||||
if (updatePoint)
|
||||
object.setPoint(point);
|
||||
@@ -135,6 +145,10 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
Preconditions.checkNotNull(object, "object");
|
||||
Preconditions.checkArgument(time > 0, "time < 0");
|
||||
Preconditions.checkNotNull(unit, "unit");
|
||||
|
||||
log.debug("Scheduling spawn of {} at {} in {}ms", new Object[] {
|
||||
object, point, unit.toMillis(time) });
|
||||
|
||||
return threadService.async(time, unit, new Callable<T>() {
|
||||
@Override
|
||||
public T call() throws Exception {
|
||||
@@ -156,6 +170,7 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
if (!worldService.remove(object))
|
||||
throw new NotSpawnedServiceException();
|
||||
|
||||
log.debug("Unspawning {}", object);
|
||||
final Point3D point = object.getPoint();
|
||||
|
||||
// create the SpawnEvent
|
||||
@@ -180,6 +195,10 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
Preconditions.checkNotNull(object, "object");
|
||||
Preconditions.checkArgument(time > 0, "time <= 0");
|
||||
Preconditions.checkNotNull(unit, "unit");
|
||||
|
||||
log.debug("Scheduling unspawn of {} in {}ms", object,
|
||||
unit.toMillis(time));
|
||||
|
||||
return threadService.async(time, unit, new Callable<T>() {
|
||||
@Override
|
||||
public T call() throws Exception {
|
||||
@@ -194,6 +213,10 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
throws CharacterAlreadyTeleportingServiceException {
|
||||
Preconditions.checkNotNull(player, "player");
|
||||
Preconditions.checkNotNull(coordinate, "coordinate");
|
||||
|
||||
log.debug("Teleporting {} to {}", player,
|
||||
coordinate);
|
||||
|
||||
if (player instanceof L2Character) {
|
||||
if (((L2Character) player).isTeleporting())
|
||||
throw new CharacterAlreadyTeleportingServiceException();
|
||||
@@ -225,6 +248,8 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
|
||||
if (!character.isTeleporting())
|
||||
throw new CharacterNotTeleportingServiceException();
|
||||
|
||||
log.debug("Finishing teleport of {}", character);
|
||||
|
||||
character.setState(null);
|
||||
character.setPoint(character.getTargetLocation());
|
||||
|
||||
@@ -166,6 +166,7 @@ public class XMLTemplateService extends AbstractService implements
|
||||
try {
|
||||
final Template<?> template = (Template<?>) unmarshaller
|
||||
.unmarshal(in);
|
||||
log.debug("Template loaded: {}", template);
|
||||
if (template.getID() != null)
|
||||
templates.put(template.getID(), template);
|
||||
} finally {
|
||||
@@ -175,6 +176,7 @@ public class XMLTemplateService extends AbstractService implements
|
||||
|
||||
public void removeTemplate(Template<?> template) {
|
||||
Preconditions.checkNotNull(template, "template");
|
||||
log.debug("Removing template {}", template);
|
||||
templates.remove(template.getID());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ package com.l2jserver.service.game.world;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.dao.CharacterDAO;
|
||||
@@ -43,6 +46,11 @@ import com.l2jserver.service.database.DatabaseService;
|
||||
@Depends({ DatabaseService.class, CacheService.class })
|
||||
public class CachedWorldIDService extends AbstractService implements
|
||||
WorldIDService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The cache service
|
||||
*/
|
||||
@@ -96,14 +104,19 @@ public class CachedWorldIDService extends AbstractService implements
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
log.debug("Loading IDs from database");
|
||||
|
||||
load(characterDao.selectIDs());
|
||||
load(itemDao.selectIDs());
|
||||
load(npcDao.selectIDs());
|
||||
|
||||
log.debug("IDs loaded from database");
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
log.debug("Clearing load IDs");
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
@@ -115,7 +128,9 @@ public class CachedWorldIDService extends AbstractService implements
|
||||
*/
|
||||
private void load(Collection<? extends ObjectID<?>> ids) {
|
||||
Preconditions.checkNotNull(ids, "ids");
|
||||
log.debug("Loading {} IDs", ids.size());
|
||||
for (final ObjectID<?> id : ids) {
|
||||
log.debug("Loading {}", id);
|
||||
allocator.allocate(id.getID());
|
||||
add(id);
|
||||
}
|
||||
@@ -129,6 +144,7 @@ public class CachedWorldIDService extends AbstractService implements
|
||||
// ignore resolving before all IDs are loaded
|
||||
return null;
|
||||
}
|
||||
log.debug("Resolving {}", id);
|
||||
return (I) cache.get(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.jboss.netty.channel.ServerChannel;
|
||||
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
import org.jboss.netty.logging.Slf4JLoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
@@ -51,6 +53,11 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
WorldService.class })
|
||||
public class NettyNetworkService extends AbstractService implements
|
||||
NetworkService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The {@link WorldService} instance
|
||||
*/
|
||||
@@ -100,6 +107,9 @@ public class NettyNetworkService extends AbstractService implements
|
||||
@Override
|
||||
public void register(final Lineage2Client client) {
|
||||
Preconditions.checkNotNull(client, "client");
|
||||
|
||||
log.debug("Registering client: {}", client);
|
||||
|
||||
clients.add(client);
|
||||
client.getChannel().getCloseFuture()
|
||||
.addListener(new ChannelFutureListener() {
|
||||
@@ -114,12 +124,17 @@ public class NettyNetworkService extends AbstractService implements
|
||||
@Override
|
||||
public void unregister(Lineage2Client client) {
|
||||
Preconditions.checkNotNull(client, "client");
|
||||
|
||||
log.debug("Unregistering client: {}", client);
|
||||
clients.remove(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lineage2Client discover(CharacterID character) {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
|
||||
log.debug("Discovering client object for {}", character);
|
||||
|
||||
for (final Lineage2Client client : clients) {
|
||||
if (character.equals(client.getCharacterID()))
|
||||
return client;
|
||||
@@ -130,6 +145,9 @@ public class NettyNetworkService extends AbstractService implements
|
||||
@Override
|
||||
public void broadcast(ServerPacket packet) {
|
||||
Preconditions.checkNotNull(packet, "packet");
|
||||
|
||||
log.debug("Broadcasting {} packet to all connected clients", packet);
|
||||
|
||||
channel.write(packet);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.service.network.broadcast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Client;
|
||||
@@ -61,6 +64,11 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
@Depends({ NetworkService.class, WorldService.class })
|
||||
public class BroadcastServiceImpl extends AbstractService implements
|
||||
BroadcastService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final WorldService worldService;
|
||||
private final WorldEventDispatcher eventDispatcher;
|
||||
|
||||
@@ -77,6 +85,8 @@ public class BroadcastServiceImpl extends AbstractService implements
|
||||
final L2Character character = conn.getCharacter();
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
final CharacterID id = character.getID();
|
||||
|
||||
log.debug("Starting character broadcast");
|
||||
|
||||
// broadcast everything nearby
|
||||
// broadcast(conn);
|
||||
@@ -89,6 +99,7 @@ public class BroadcastServiceImpl extends AbstractService implements
|
||||
new KnownListFilter(character)) {
|
||||
@Override
|
||||
protected boolean dispatch(WorldEvent e, PositionableObject object) {
|
||||
log.debug("Broadcast event received: {}", e);
|
||||
if (e instanceof NPCSpawnEvent) {
|
||||
broadcast(conn, e.getObject());
|
||||
} else if (e instanceof CharacterMoveEvent) {
|
||||
@@ -123,6 +134,7 @@ public class BroadcastServiceImpl extends AbstractService implements
|
||||
final WorldListener sendPacketListener = new WorldListener() {
|
||||
@Override
|
||||
public boolean dispatch(WorldEvent e) {
|
||||
log.debug("Broadcast event received: {}", e);
|
||||
if (e instanceof CharacterMoveEvent) {
|
||||
final CharacterMoveEvent evt = (CharacterMoveEvent) e;
|
||||
// process update known list
|
||||
@@ -153,6 +165,7 @@ public class BroadcastServiceImpl extends AbstractService implements
|
||||
* the character
|
||||
*/
|
||||
private void broadcastAll(Lineage2Client conn, L2Character character) {
|
||||
log.debug("Broadcasting all near objects to {}", character);
|
||||
for (final WorldObject o : worldService.iterable(new KnownListFilter(
|
||||
character))) {
|
||||
broadcast(conn, o);
|
||||
@@ -172,6 +185,7 @@ public class BroadcastServiceImpl extends AbstractService implements
|
||||
*/
|
||||
private void broadcastUpdate(Lineage2Client conn, L2Character character,
|
||||
Point3D point) {
|
||||
log.debug("Broadcasting only new near objects to {}", character);
|
||||
for (final WorldObject o : worldService
|
||||
.iterable(new KnownListUpdateFilter(character, point))) {
|
||||
broadcast(conn, o);
|
||||
@@ -187,6 +201,7 @@ public class BroadcastServiceImpl extends AbstractService implements
|
||||
* the character
|
||||
*/
|
||||
private void broadcast(Lineage2Client conn, WorldObject o) {
|
||||
log.debug("Broadcasting {} to {}", o, conn);
|
||||
if (o instanceof NPC) {
|
||||
conn.write(new SM_NPC_INFO((NPC) o));
|
||||
} else if (o instanceof L2Character) {
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.concurrent.Future;
|
||||
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ChannelFutureListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.util.concurrent.AbstractFuture;
|
||||
import com.l2jserver.game.net.Lineage2Client;
|
||||
@@ -42,6 +44,11 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
@Depends({ NetworkService.class })
|
||||
public class GameGuardServiceImpl extends AbstractService implements
|
||||
GameGuardService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The static key used to validate game guards
|
||||
*/
|
||||
@@ -81,6 +88,7 @@ public class GameGuardServiceImpl extends AbstractService implements
|
||||
|
||||
@Override
|
||||
public Future<GameGuardResponse> query(final Lineage2Client conn) {
|
||||
log.debug("Quering client for GameGuard authentication key");
|
||||
conn.write(new SM_GG_QUERY(STATIC_KEY)).addListener(
|
||||
new ChannelFutureListener() {
|
||||
@Override
|
||||
@@ -98,6 +106,8 @@ public class GameGuardServiceImpl extends AbstractService implements
|
||||
|
||||
@Override
|
||||
public GameGuardResponse key(Lineage2Client conn, byte[] key) {
|
||||
log.debug("GameGuard authentication key received for {}", conn);
|
||||
|
||||
final GGFuture future = futures.remove(conn);
|
||||
final boolean validated = validate(conn, key);
|
||||
final GameGuardResponse response = (validated ? GameGuardResponse.VALID
|
||||
|
||||
@@ -18,6 +18,9 @@ package com.l2jserver.service.network.keygen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
@@ -30,6 +33,11 @@ import com.l2jserver.service.ServiceStopException;
|
||||
*/
|
||||
public class PseudoRandomBlowfishKeygenService extends AbstractService
|
||||
implements BlowfishKeygenService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The random number generator
|
||||
*/
|
||||
@@ -42,6 +50,8 @@ public class PseudoRandomBlowfishKeygenService extends AbstractService
|
||||
|
||||
@Override
|
||||
public byte[] generate() {
|
||||
log.debug("Generating a new key");
|
||||
|
||||
final byte[] key = new byte[16];
|
||||
// randomize the 8 first bytes
|
||||
for (int i = 0; i < key.length; i++) {
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.l2jserver.service.network.keygen;
|
||||
|
||||
import org.apache.commons.math.random.RandomData;
|
||||
import org.apache.commons.math.random.RandomDataImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
@@ -32,6 +34,11 @@ import com.l2jserver.service.ServiceStopException;
|
||||
*/
|
||||
public class SecureBlowfishKeygenService extends AbstractService implements
|
||||
BlowfishKeygenService {
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* The random number generator
|
||||
*/
|
||||
@@ -44,6 +51,8 @@ public class SecureBlowfishKeygenService extends AbstractService implements
|
||||
|
||||
@Override
|
||||
public byte[] generate() {
|
||||
log.debug("Generating a new key");
|
||||
|
||||
final byte[] key = new byte[16];
|
||||
// randomize the 8 first bytes
|
||||
for (int i = 0; i < key.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user