mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-05 23:22:47 +00:00
Implements task oriented ThreadService
This commit is contained in:
@@ -33,6 +33,7 @@ import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.actor.event.ActorAttackHitEvent;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.core.threading.AbstractTask;
|
||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.l2jserver.service.core.threading.ThreadService;
|
||||
import com.l2jserver.service.game.npc.NPCService;
|
||||
@@ -99,7 +100,7 @@ public class AttackServiceImpl extends AbstractService implements AttackService
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
private class AttackCallable implements Callable<AttackHit> {
|
||||
private class AttackCallable extends AbstractTask<AttackHit> {
|
||||
/**
|
||||
* The attacker
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,6 @@ 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;
|
||||
@@ -42,6 +41,7 @@ import com.l2jserver.model.world.npc.event.NPCDieEvent;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.core.threading.AbstractTask;
|
||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.l2jserver.service.core.threading.ThreadService;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
@@ -244,7 +244,7 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
final double seconds = distance / npc.getTemplate().getRunSpeed();
|
||||
// TODO this is an dirty implementation!
|
||||
return threadService.async((int) (seconds * 1000),
|
||||
TimeUnit.MILLISECONDS, new Callable<Boolean>() {
|
||||
TimeUnit.MILLISECONDS, new AbstractTask<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
npc.setState(null);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -42,6 +41,7 @@ import com.l2jserver.model.world.npc.event.NPCUnspawnEvent;
|
||||
import com.l2jserver.model.world.player.event.PlayerTeleportedEvent;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.core.threading.AbstractTask;
|
||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.l2jserver.service.core.threading.ThreadService;
|
||||
import com.l2jserver.service.game.world.WorldService;
|
||||
@@ -158,7 +158,7 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
log.debug("Scheduling spawn of {} at {} in {}ms", new Object[] {
|
||||
object, point, unit.toMillis(time) });
|
||||
|
||||
return threadService.async(time, unit, new Callable<T>() {
|
||||
return threadService.async(time, unit, new AbstractTask<T>() {
|
||||
@Override
|
||||
public T call() throws Exception {
|
||||
spawn(object, point);
|
||||
@@ -208,7 +208,7 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
log.debug("Scheduling unspawn of {} in {}ms", object,
|
||||
unit.toMillis(time));
|
||||
|
||||
return threadService.async(time, unit, new Callable<T>() {
|
||||
return threadService.async(time, unit, new AbstractTask<T>() {
|
||||
@Override
|
||||
public T call() throws Exception {
|
||||
unspawn(object);
|
||||
|
||||
Reference in New Issue
Block a user