1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-06 07:32:46 +00:00

Implements task oriented ThreadService

This commit is contained in:
2011-12-17 18:25:49 -02:00
parent ccbc29d330
commit cea66c9363
16 changed files with 441 additions and 179 deletions

View File

@@ -9,22 +9,71 @@
<xs:complexType name="ItemType">
<xs:complexContent>
<xs:extension base="AbstractTemplateType">
<xs:sequence>
<xs:element name="weight" type="xs:int" />
<xs:element name="price" type="xs:int" />
<xs:element name="icon" type="xs:string" minOccurs="0" />
<xs:element name="effect" type="ItemEffectsType"
minOccurs="0" />
<xs:element name="stats" type="ItemStatsType" minOccurs="0" />
<xs:element name="material" type="ItemMaterialType" />
<xs:element name="itemType" type="ItemEnumType"
minOccurs="0" />
<xs:element name="weaponType" type="WeaponType"
minOccurs="0" />
<xs:element name="armorType" type="ArmorType" minOccurs="0" />
</xs:sequence>
<xs:all>
<xs:element name="attributes">
<xs:complexType>
<xs:sequence>
<xs:element name="cost">
<xs:complexType>
<xs:attribute name="adena" />
</xs:complexType>
</xs:element>
<xs:element name="equipment">
<xs:complexType>
<xs:attribute name="part" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="weigth" />
<xs:attribute name="type" />
<xs:attribute name="material" />
</xs:complexType>
</xs:element>
<xs:element name="controller">
<xs:complexType>
<xs:attribute name="defaultAction" />
</xs:complexType>
</xs:element>
<xs:element name="effect">
<xs:complexType>
<xs:attribute name="type" />
</xs:complexType>
</xs:element>
<xs:choice>
<xs:element name="weapon">
<xs:complexType>
<xs:attribute name="part" />
</xs:complexType>
</xs:element>
<xs:element name="armor">
<xs:complexType>
<xs:sequence>
<xs:element name="cost">
<xs:complexType>
<xs:attribute name="adena" />
</xs:complexType>
</xs:element>
<xs:element name="equipment">
<xs:complexType>
<xs:attribute name="part" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="weigth" />
<xs:attribute name="type" />
<xs:attribute name="material" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:all>
<xs:attribute name="id" type="xs:int" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="icon" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>

View File

@@ -1,32 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- <template:item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" -->
<!-- xsi:schemaLocation="http://schemas.l2jserver2.com/item ../item.xsd" -->
<!-- xmlns:template="http://schemas.l2jserver2.com/item" id="1" icon="icon.etc_adena_i00"> -->
<!-- <name>Short Sword</name> -->
<!-- <material>STEEL</material> -->
<!-- <effect type="IMMEDIATE" /> -->
<!-- <price>1</price> -->
<!-- <stats> -->
<!-- <physicalDamage> -->
<!-- <set order="128">510</set> -->
<!-- </physicalDamage> -->
<!-- <magicalDamage> -->
<!-- <set order="128">508</set> -->
<!-- </magicalDamage> -->
<!-- <criticalChance> -->
<!-- <set order="128">8</set> -->
<!-- </criticalChance> -->
<!-- <physicalAttackSpeed> -->
<!-- <set order="128">379</set> -->
<!-- </physicalAttackSpeed> -->
<!-- </stats> -->
<!-- </template:item> -->
<template:item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.l2jserver2.com/item ../item.xsd"
xmlns:template="http://schemas.l2jserver2.com/item" id="1" name="Short sword">
<weight>1</weight>
<price>1</price>
<icon>icon.etc_adena_i00</icon>
<material>GOLD</material>
<!-- <effect type="IMMEDIATE" /> -->
</template:item>
xmlns:template="http://schemas.l2jserver2.com/item" id="1"
icon="icon.weapon_small_sword_i00" name="Short Sword">
<attributes weigth="1600" type="SWORD" material="STEEL">
<cost adena="590" />
<equipment part="RIGHT_HAND" />
</attributes>
<controller defaultAction="EQUIP" />
<effect type="IMMEDIATE" />
<weapon part="RIGHT_HAND">
<physicalDamage>
<set order="128">8</set>
<random order="127">10</random>
</physicalDamage>
<magicalDamage>
<set order="128">6</set>
</magicalDamage>
<criticalChance>
<set order="128">8</set>
</criticalChance>
<physicalAttackSpeed>
<set order="128">379</set>
</physicalAttackSpeed>
</weapon>
</template:item>

View File

@@ -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
*/

View File

@@ -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);

View File

@@ -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);