mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<teleports>
|
|
||||||
<region id="KAMAEL_VILLAGE" x="" y="" z="" />
|
|
||||||
</teleports>
|
|
||||||
10
data/teleports.xml
Normal file
10
data/teleports.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<teleports xsi:noNamespaceSchemaLocation="teleports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<teleport id="TOWN_OF_GLUDIO" name="The Town of Gludio">
|
||||||
|
<coordinate x="-12787" y="122779" z="-3112" />
|
||||||
|
</teleport>
|
||||||
|
|
||||||
|
<teleport id="ELVEN_FOREST" name="Elven Forest">
|
||||||
|
<coordinate x="21362" y="51122" z="-3688" />
|
||||||
|
</teleport>
|
||||||
|
</teleports>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
|
||||||
<xs:element name="npc" type="npcTemplate" />
|
<xs:element name="npc" type="npcTemplate" />
|
||||||
|
|
||||||
<xs:complexType name="npcTemplate">
|
<xs:complexType name="npcTemplate">
|
||||||
|
|||||||
@@ -1,26 +1,57 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<npc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="Teleporter" id="30006" xsi:schemaLocation="npc ../../npc.xsd" xsi:noNamespaceSchemaLocation="npc">
|
<npc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="Teleporter"
|
||||||
<info aggressive="false" targetable="true" attackable="false">
|
id="30006" xsi:schemaLocation="npc ../../npc.xsd"
|
||||||
<name display="true" send="false">Roxxy</name>
|
xsi:noNamespaceSchemaLocation="npc">
|
||||||
<title send="false">Gatekeeper</title>
|
<info aggressive="false" targetable="true" attackable="false">
|
||||||
<level>70</level>
|
<name display="true" send="false">Roxxy</name>
|
||||||
<sex>FEMALE</sex>
|
<title send="false">Gatekeeper</title>
|
||||||
<stats>
|
<level>70</level>
|
||||||
<hp regen="7.5" max="2444.46819"/>
|
<sex>FEMALE</sex>
|
||||||
<mp regen="2.7" max="1345.8"/>
|
<stats>
|
||||||
<attack critical="4" evasion="0" range="40">
|
<hp regen="7.5" max="2444.46819" />
|
||||||
<physical speed="253.0" damage="688.86373"/>
|
<mp regen="2.7" max="1345.8" />
|
||||||
<magical speed="333.0" damage="470.40463"/>
|
<attack critical="4" evasion="0" range="40">
|
||||||
</attack>
|
<physical speed="253.0" damage="688.86373" />
|
||||||
<defense>
|
<magical speed="333.0" damage="470.40463" />
|
||||||
<physical value="295.91597"/>
|
</attack>
|
||||||
<magical value="216.53847"/>
|
<defense>
|
||||||
</defense>
|
<physical value="295.91597" />
|
||||||
<move walk="50.0" run="120.0"/>
|
<magical value="216.53847" />
|
||||||
<base wit="20" dex="30" men="20" con="43" str="40" int="21"/>
|
</defense>
|
||||||
</stats>
|
<move walk="50.0" run="120.0" />
|
||||||
<experience>0</experience>
|
<base wit="20" dex="30" men="20" con="43" str="40" int="21" />
|
||||||
<sp>0</sp>
|
</stats>
|
||||||
<collision heigth="25.0" radius="8.0"/>
|
<experience>0</experience>
|
||||||
</info>
|
<sp>0</sp>
|
||||||
|
<collision heigth="25.0" radius="8.0" />
|
||||||
|
</info>
|
||||||
|
<talk default="0">
|
||||||
|
<chat id="0"><![CDATA[<html><body>Gatekeeper Roxxy:<br>
|
||||||
|
Welcome! I am Gatekeeper Roxxy, dispatched from the Ivory Tower. I'm very happy to return to my hometown. Have you perhaps been to Einhovant's School of Magic? Grand Magister Gallint was my old teacher. Now then, how can I help you?<br>
|
||||||
|
<a action="bypass -h npc_%objectId%_Chat 5">Ask about the airship wharf.</a><br>
|
||||||
|
<a action="bypass -h npc_%objectId%_Chat 4">Ask about the Ivory Tower.</a><br>
|
||||||
|
<a action="bypass -h npc_%objectId%_TeleportList global">Teleport</a><br>
|
||||||
|
<a action="bypass -h npc_%objectId%_multisell 002">Exchange Dimension Diamonds.</a><br>
|
||||||
|
<a action="bypass -h npc_%objectId%_Quest 2000_NoblesseTeleport">Noblesse Exclusive Teleport</a><br>
|
||||||
|
<a action="bypass -h npc_%objectId%_Quest CharacterBirthday">Receive your Birthday Gift!</a><br>
|
||||||
|
<a action="bypass -h npc_%objectId%_Quest">Quest</a>
|
||||||
|
</body></html>]]></chat>
|
||||||
|
<chat id="4"><![CDATA[<html><body>Gatekeeper Roxxy:<br>
|
||||||
|
The Ivory Tower is the foremost temple of all Mystics. It has been well known as such ever since the age of Elmoreden. I was born here, and graduated from Einhovant's School of Wizardry. And now, I am working as a gatekeeper by the order of the Ivory Tower. If you happen to go to the Ivory Tower later on, please give my best regards to Grand Magister Valerie. She is my teacher and a wonderful, caring person.<br>
|
||||||
|
<a action="bypass -h npc_%objectId%_Chat 0">Back</a>
|
||||||
|
</body></html>]]></chat>
|
||||||
|
<chat id="5"><![CDATA[<html><body>Gatekeeper Roxxy:<br>
|
||||||
|
The Airship Field is where Airships heading to and from <font color="LEVEL">Gracia</font> dock. A powerful magic force field prevents entry to Gracia from sea or via teleportation.<br>
|
||||||
|
But Gracian-made Airships can travel safely through the force field. It is still a dangerous journey, though!<br>After several years of work, a wharf was constructed from magical stones capable of floating in mid-air. You can board one of the Airships using an <font color="LEVEL">Airship Controller</font>.<br>
|
||||||
|
If you wish to visit Gracia, this is the only way. I can teleport you to the wharf if you wish.<br>
|
||||||
|
<a action="bypass -h npc_%objectId%_goto 12120">Teleport to Gludio Airship Field.</a><br>
|
||||||
|
<a action="bypass -h npc_%objectId%_Chat 0">Back</a>
|
||||||
|
</body></html>]]></chat>
|
||||||
|
</talk>
|
||||||
|
<teleporter default="global">
|
||||||
|
<teleport id="global">
|
||||||
|
<region id="TOWN_OF_GLUDIO" price="200" item="57" />
|
||||||
|
<region id="ELVEN_FOREST" price="200" item="57" />
|
||||||
|
</teleport>
|
||||||
|
</teleporter>
|
||||||
</npc>
|
</npc>
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ public class NPCHtmlMessagePacket extends AbstractServerPacket {
|
|||||||
*/
|
*/
|
||||||
private final String html;
|
private final String html;
|
||||||
|
|
||||||
|
public NPCHtmlMessagePacket(NPC npc, String html) {
|
||||||
|
super(OPCODE);
|
||||||
|
this.npc = npc;
|
||||||
|
this.html = html;
|
||||||
|
}
|
||||||
|
|
||||||
public NPCHtmlMessagePacket(NPC npc, Html html) {
|
public NPCHtmlMessagePacket(NPC npc, Html html) {
|
||||||
super(OPCODE);
|
super(OPCODE);
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of l2jserver <l2jserver.com>.
|
||||||
|
*
|
||||||
|
* l2jserver is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* l2jserver is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.l2jserver.model.id.template;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
import com.l2jserver.model.id.TemplateID;
|
||||||
|
import com.l2jserver.model.template.SkillTemplate;
|
||||||
|
import com.l2jserver.model.template.TeleportationTemplate;
|
||||||
|
import com.l2jserver.service.game.template.TemplateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An {@link TemplateID} instance representing an {@link SkillTemplate} object
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class TeleportationTemplateID extends
|
||||||
|
TemplateID<TeleportationTemplate, String> {
|
||||||
|
/**
|
||||||
|
* The template service
|
||||||
|
*/
|
||||||
|
private final TemplateService templateService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TeleportationTemplateID(@Assisted String id,
|
||||||
|
TemplateService templateService) {
|
||||||
|
super(id);
|
||||||
|
this.templateService = templateService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TeleportationTemplate getTemplate() {
|
||||||
|
return templateService.getTemplate(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of l2jserver <l2jserver.com>.
|
||||||
|
*
|
||||||
|
* l2jserver is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* l2jserver is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.l2jserver.model.id.template.provider;
|
||||||
|
|
||||||
|
import com.l2jserver.model.id.template.SkillTemplateID;
|
||||||
|
import com.l2jserver.model.id.template.TeleportationTemplateID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new {@link SkillTemplateID} instances
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public interface TeleportationTemplateIDProvider extends
|
||||||
|
TemplateIDProvider<String, TeleportationTemplateID> {
|
||||||
|
}
|
||||||
@@ -50,6 +50,8 @@ public class ItemTemplate extends AbstractTemplate<Item> {
|
|||||||
@XmlJavaTypeAdapter(ItemTemplateIDAdapter.class)
|
@XmlJavaTypeAdapter(ItemTemplateIDAdapter.class)
|
||||||
protected ItemTemplateID id;
|
protected ItemTemplateID id;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "name")
|
||||||
|
protected String name;
|
||||||
@XmlElement(name = "weight")
|
@XmlElement(name = "weight")
|
||||||
protected int weight = 0;
|
protected int weight = 0;
|
||||||
@XmlElement(name = "price")
|
@XmlElement(name = "price")
|
||||||
@@ -81,6 +83,13 @@ public class ItemTemplate extends AbstractTemplate<Item> {
|
|||||||
return new Item(id);
|
return new Item(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the weight
|
* @return the weight
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.template;
|
package com.l2jserver.model.template;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
@@ -31,6 +32,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
|||||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||||
import com.l2jserver.model.id.template.NPCTemplateID;
|
import com.l2jserver.model.id.template.NPCTemplateID;
|
||||||
import com.l2jserver.model.id.template.TeleportationTemplateID;
|
import com.l2jserver.model.id.template.TeleportationTemplateID;
|
||||||
|
import com.l2jserver.model.template.NPCTemplate.TeleporterMetadata.TeleporterTeleportMetadata;
|
||||||
import com.l2jserver.model.world.Actor.ActorSex;
|
import com.l2jserver.model.world.Actor.ActorSex;
|
||||||
import com.l2jserver.model.world.NPC;
|
import com.l2jserver.model.world.NPC;
|
||||||
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
|
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
|
||||||
@@ -227,31 +229,55 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
|||||||
|
|
||||||
@XmlType(namespace = "npc")
|
@XmlType(namespace = "npc")
|
||||||
protected static class TeleporterMetadata {
|
protected static class TeleporterMetadata {
|
||||||
|
@XmlAttribute(name = "default")
|
||||||
|
protected String defaultTeleport = null;
|
||||||
@XmlElement(name = "teleport")
|
@XmlElement(name = "teleport")
|
||||||
protected List<TeleporterTeleportMetadata> teleports = null;
|
protected List<TeleporterTeleportMetadata> teleports = null;
|
||||||
|
|
||||||
@XmlType(namespace = "npc")
|
@XmlType(namespace = "npc")
|
||||||
protected static class TeleporterTeleportMetadata {
|
protected static class TeleporterTeleportMetadata {
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
|
protected String id;
|
||||||
protected TeleportationTemplateID id;
|
|
||||||
@XmlElement(name = "region")
|
@XmlElement(name = "region")
|
||||||
protected List<TeleporterRegionMetadata> regions = null;
|
protected List<TeleportRegion> regions = null;
|
||||||
|
|
||||||
@XmlType(namespace = "npc")
|
|
||||||
protected static class TeleporterRegionMetadata {
|
|
||||||
@XmlAttribute(name = "id")
|
|
||||||
protected String id = null;
|
|
||||||
@XmlAttribute(name = "price")
|
|
||||||
protected int price = 0;
|
|
||||||
@XmlAttribute(name = "item")
|
|
||||||
protected int item = 57;
|
|
||||||
|
|
||||||
// TODO implement conditions
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlType(namespace = "npc")
|
||||||
|
public static class TeleportRegion {
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
|
||||||
|
protected TeleportationTemplateID id;
|
||||||
|
@XmlAttribute(name = "price")
|
||||||
|
protected int price = 0;
|
||||||
|
@XmlAttribute(name = "item")
|
||||||
|
@XmlJavaTypeAdapter(ItemTemplateIDAdapter.class)
|
||||||
|
protected ItemTemplateID item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public TeleportationTemplateID getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the price
|
||||||
|
*/
|
||||||
|
public int getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the item
|
||||||
|
*/
|
||||||
|
public ItemTemplateID getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO implement conditions
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement(name = "talk")
|
@XmlElement(name = "talk")
|
||||||
protected TalkMetadata talk = null;
|
protected TalkMetadata talk = null;
|
||||||
|
|
||||||
@@ -271,7 +297,7 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
|||||||
@XmlValue
|
@XmlValue
|
||||||
protected String html = null;
|
protected String html = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElementWrapper(name = "droplist")
|
@XmlElementWrapper(name = "droplist")
|
||||||
@XmlElement(name = "item")
|
@XmlElement(name = "item")
|
||||||
protected List<DropItemMetadata> droplist = null;
|
protected List<DropItemMetadata> droplist = null;
|
||||||
@@ -717,6 +743,46 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
|||||||
return ai.script;
|
return ai.script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TeleportRegion> getTeleportRegions(String id) {
|
||||||
|
if (teleporter == null)
|
||||||
|
return Collections.emptyList();
|
||||||
|
for (final TeleporterTeleportMetadata teleport : teleporter.teleports) {
|
||||||
|
if (teleport.id.equals(id)) {
|
||||||
|
return Collections.unmodifiableList(teleport.regions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TeleportRegion> getTeleportRegions() {
|
||||||
|
if (teleporter == null)
|
||||||
|
return Collections.emptyList();
|
||||||
|
for (final TeleporterTeleportMetadata teleport : teleporter.teleports) {
|
||||||
|
if (teleport.id.equals(teleporter.defaultTeleport)) {
|
||||||
|
return Collections.unmodifiableList(teleport.regions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHTML(String id) {
|
||||||
|
if (talk == null)
|
||||||
|
return null;
|
||||||
|
if (id == null)
|
||||||
|
id = talk.defaultChat;
|
||||||
|
for (final Chat chat : this.talk.chats) {
|
||||||
|
if (chat.id.equals(id))
|
||||||
|
return chat.html;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultHTML() {
|
||||||
|
if (talk == null)
|
||||||
|
return null;
|
||||||
|
return getHTML(talk.defaultChat);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NPCTemplateID getID() {
|
public NPCTemplateID getID() {
|
||||||
return id;
|
return id;
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of l2jserver <l2jserver.com>.
|
||||||
|
*
|
||||||
|
* l2jserver is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* l2jserver is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.l2jserver.model.template;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
|
|
||||||
|
import com.l2jserver.model.id.template.TeleportationTemplateID;
|
||||||
|
import com.l2jserver.util.dimensional.Coordinate;
|
||||||
|
import com.l2jserver.util.jaxb.CoordinateAdapter;
|
||||||
|
import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template for effects
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
@XmlRootElement(name = "teleport")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(namespace = "teleports")
|
||||||
|
public class TeleportationTemplate extends AbstractTemplate<Coordinate> {
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
|
||||||
|
private TeleportationTemplateID id;
|
||||||
|
@XmlElement(name = "name")
|
||||||
|
private String name;
|
||||||
|
@XmlElement(name = "coordinate")
|
||||||
|
@XmlJavaTypeAdapter(CoordinateAdapter.class)
|
||||||
|
private Coordinate coordinate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Coordinate create() {
|
||||||
|
return coordinate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the coordinate
|
||||||
|
*/
|
||||||
|
public Coordinate getCoordinate() {
|
||||||
|
return coordinate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TeleportationTemplateID getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,8 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.npc.controller;
|
package com.l2jserver.model.world.npc.controller;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.htmlparser.Parser;
|
||||||
|
import org.htmlparser.util.ParserException;
|
||||||
|
|
||||||
import com.l2jserver.game.net.Lineage2Connection;
|
import com.l2jserver.game.net.Lineage2Connection;
|
||||||
import com.l2jserver.game.net.packet.server.NPCHtmlMessagePacket;
|
import com.l2jserver.game.net.packet.server.NPCHtmlMessagePacket;
|
||||||
|
import com.l2jserver.model.template.NPCTemplate;
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.NPC;
|
import com.l2jserver.model.world.NPC;
|
||||||
import com.l2jserver.util.exception.L2Exception;
|
import com.l2jserver.util.exception.L2Exception;
|
||||||
@@ -33,7 +39,25 @@ public class AbstractNPCController implements NPCController {
|
|||||||
@Override
|
@Override
|
||||||
public void action(NPC npc, Lineage2Connection conn, L2Character character,
|
public void action(NPC npc, Lineage2Connection conn, L2Character character,
|
||||||
String... args) throws L2Exception {
|
String... args) throws L2Exception {
|
||||||
|
if (args.length == 2) {
|
||||||
|
if (args[0].equals("Chat")) {
|
||||||
|
talk(npc, conn, character,
|
||||||
|
Arrays.copyOfRange(args, 1, args.length));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (args.length == 0 || args.length == 1) {
|
||||||
|
talk(npc, conn, character, new String[0]);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
final HtmlTemplate template = new HtmlTemplate() {
|
||||||
|
@Override
|
||||||
|
protected void build(MarkupTag body) {
|
||||||
|
body.text("Sorry ${name}, but you cannot interact with me yet!");
|
||||||
|
}
|
||||||
|
}.register("name", character.getName());
|
||||||
|
conn.write(new NPCHtmlMessagePacket(npc, template));
|
||||||
|
}
|
||||||
|
conn.sendActionFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,15 +75,43 @@ public class AbstractNPCController implements NPCController {
|
|||||||
*/
|
*/
|
||||||
protected void talk(NPC npc, Lineage2Connection conn,
|
protected void talk(NPC npc, Lineage2Connection conn,
|
||||||
L2Character character, String... args) throws L2Exception {
|
L2Character character, String... args) throws L2Exception {
|
||||||
// not yet available message
|
String id = null;
|
||||||
final HtmlTemplate template = new HtmlTemplate() {
|
if (args.length >= 1) {
|
||||||
@Override
|
id = args[0];
|
||||||
protected void build(MarkupTag body) {
|
}
|
||||||
body.text("Sorry, but I'm not implemented yet!");
|
conn.write(new NPCHtmlMessagePacket(npc, getHTML(npc, id)));
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
conn.write(new NPCHtmlMessagePacket(npc, template));
|
|
||||||
conn.sendActionFailed();
|
conn.sendActionFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the NPC HTML message
|
||||||
|
*
|
||||||
|
* @param npc
|
||||||
|
* the npc
|
||||||
|
* @param id
|
||||||
|
* the html message id
|
||||||
|
* @return the html code
|
||||||
|
*/
|
||||||
|
protected String getHTML(NPC npc, String id) {
|
||||||
|
final NPCTemplate template = npc.getTemplate();
|
||||||
|
// TODO use an decent template engine
|
||||||
|
return template.getHTML(id).replaceAll("%objectId%",
|
||||||
|
npc.getID().getID().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will try to remove empty lines and all unnecessary space from
|
||||||
|
* the HTML code.
|
||||||
|
*
|
||||||
|
* @param html
|
||||||
|
* the html code
|
||||||
|
* @return the trimmed html code
|
||||||
|
*/
|
||||||
|
protected String trimHTML(String html) {
|
||||||
|
try {
|
||||||
|
return new Parser(html).elements().nextNode().toHtml();
|
||||||
|
} catch (ParserException e) {
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.world.npc.controller;
|
package com.l2jserver.model.world.npc.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.l2jserver.game.net.Lineage2Connection;
|
||||||
|
import com.l2jserver.game.net.packet.server.NPCHtmlMessagePacket;
|
||||||
|
import com.l2jserver.model.id.template.provider.TeleportationTemplateIDProvider;
|
||||||
|
import com.l2jserver.model.template.NPCTemplate.TeleportRegion;
|
||||||
|
import com.l2jserver.model.template.TeleportationTemplate;
|
||||||
|
import com.l2jserver.model.world.L2Character;
|
||||||
|
import com.l2jserver.model.world.NPC;
|
||||||
import com.l2jserver.service.game.spawn.SpawnService;
|
import com.l2jserver.service.game.spawn.SpawnService;
|
||||||
|
import com.l2jserver.util.exception.L2Exception;
|
||||||
|
import com.l2jserver.util.html.markup.HtmlTemplate;
|
||||||
|
import com.l2jserver.util.html.markup.MarkupTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This controller is used to control teleporters (e.g. gatekeepers)
|
* This controller is used to control teleporters (e.g. gatekeepers)
|
||||||
@@ -30,5 +42,49 @@ public class TeleporterController extends AbstractNPCController {
|
|||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
protected SpawnService spawnService;
|
protected SpawnService spawnService;
|
||||||
|
@Inject
|
||||||
|
protected TeleportationTemplateIDProvider teleportationIdProvider;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(NPC npc, Lineage2Connection conn, L2Character character,
|
||||||
|
String... args) throws L2Exception {
|
||||||
|
if (args.length >= 2) {
|
||||||
|
if (args[0].equals("TeleportList")) {
|
||||||
|
final List<TeleportRegion> regions = getTeleportRegions(npc,
|
||||||
|
args[1]);
|
||||||
|
final HtmlTemplate template = new HtmlTemplate() {
|
||||||
|
@Override
|
||||||
|
protected void build(MarkupTag body) {
|
||||||
|
body.textcode(556);
|
||||||
|
for (final TeleportRegion region : regions) {
|
||||||
|
body.addLink(
|
||||||
|
region.getID().getTemplate().getName()
|
||||||
|
+ " - "
|
||||||
|
+ region.getPrice()
|
||||||
|
+ " "
|
||||||
|
+ region.getItem().getTemplate()
|
||||||
|
.getName(),
|
||||||
|
"Teleport " + region.getID().getID()).br();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
conn.write(new NPCHtmlMessagePacket(npc, template));
|
||||||
|
} else if (args[0].equals("Teleport")) {
|
||||||
|
final TeleportationTemplate tele = teleportationIdProvider
|
||||||
|
.createID(args[1]).getTemplate();
|
||||||
|
if (tele == null) {
|
||||||
|
// TODO chat
|
||||||
|
conn.sendActionFailed();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
spawnService.teleport(character, tele.getCoordinate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.action(npc, conn, character, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<TeleportRegion> getTeleportRegions(NPC npc, String id) {
|
||||||
|
return npc.getTemplate().getTeleportRegions(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,14 +21,17 @@ import java.util.List;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.l2jserver.db.dao.NPCDAO;
|
import com.l2jserver.db.dao.NPCDAO;
|
||||||
|
import com.l2jserver.game.net.Lineage2Connection;
|
||||||
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
|
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
|
||||||
import com.l2jserver.model.template.NPCTemplate;
|
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.model.world.NPC;
|
import com.l2jserver.model.world.NPC;
|
||||||
|
import com.l2jserver.model.world.npc.controller.TeleporterController;
|
||||||
import com.l2jserver.service.AbstractService;
|
import com.l2jserver.service.AbstractService;
|
||||||
import com.l2jserver.service.game.spawn.AlreadySpawnedServiceException;
|
import com.l2jserver.service.game.spawn.AlreadySpawnedServiceException;
|
||||||
import com.l2jserver.service.game.spawn.SpawnPointNotFoundServiceException;
|
import com.l2jserver.service.game.spawn.SpawnPointNotFoundServiceException;
|
||||||
import com.l2jserver.service.game.spawn.SpawnService;
|
import com.l2jserver.service.game.spawn.SpawnService;
|
||||||
|
import com.l2jserver.service.network.NetworkService;
|
||||||
|
import com.l2jserver.util.exception.L2Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default {@link NPCService} implementation
|
* Default {@link NPCService} implementation
|
||||||
@@ -40,15 +43,23 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
|||||||
* The {@link SpawnService} used to spawn the {@link NPC} instances
|
* The {@link SpawnService} used to spawn the {@link NPC} instances
|
||||||
*/
|
*/
|
||||||
private final SpawnService spawnService;
|
private final SpawnService spawnService;
|
||||||
|
/**
|
||||||
|
* The {@link NetworkService} used to discover {@link Lineage2Connection}
|
||||||
|
*/
|
||||||
|
private final NetworkService networkService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link NPCDAO}
|
* The {@link NPCDAO}
|
||||||
*/
|
*/
|
||||||
private final NPCDAO npcDao;
|
private final NPCDAO npcDao;
|
||||||
|
|
||||||
|
private final TeleporterController controller = new TeleporterController();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NPCServiceImpl(SpawnService spawnService, NPCDAO npcDao) {
|
public NPCServiceImpl(SpawnService spawnService,
|
||||||
|
NetworkService networkService, NPCDAO npcDao) {
|
||||||
this.spawnService = spawnService;
|
this.spawnService = spawnService;
|
||||||
|
this.networkService = networkService;
|
||||||
this.npcDao = npcDao;
|
this.npcDao = npcDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,12 +70,13 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
|||||||
Preconditions.checkNotNull(character, "character");
|
Preconditions.checkNotNull(character, "character");
|
||||||
Preconditions.checkNotNull(action, "action");
|
Preconditions.checkNotNull(action, "action");
|
||||||
|
|
||||||
final NPCTemplate template = npc.getTemplate();
|
final Lineage2Connection conn = networkService.discover(character
|
||||||
// try {
|
.getID());
|
||||||
// // template.action(npc, character, new String[0]);
|
try {
|
||||||
// } catch (L2Exception e) {
|
controller.action(npc, conn, character, new String[0]);
|
||||||
// throw new ActionServiceException(e);
|
} catch (L2Exception e) {
|
||||||
// }
|
throw new ActionServiceException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,12 +87,13 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
|||||||
if (args == null)
|
if (args == null)
|
||||||
args = new String[0];
|
args = new String[0];
|
||||||
|
|
||||||
final NPCTemplate template = npc.getTemplate();
|
final Lineage2Connection conn = networkService.discover(character
|
||||||
// try {
|
.getID());
|
||||||
// // template.action(npc, character, args);
|
try {
|
||||||
// } catch (L2Exception e) {
|
controller.action(npc, conn, character, args);
|
||||||
// throw new ActionServiceException(e);
|
} catch (L2Exception e) {
|
||||||
// }
|
throw new ActionServiceException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,11 +18,17 @@ package com.l2jserver.service.game.template;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
@@ -79,7 +85,7 @@ public class XMLTemplateService extends AbstractService implements
|
|||||||
try {
|
try {
|
||||||
context = JAXBContext.newInstance(CharacterTemplate.class,
|
context = JAXBContext.newInstance(CharacterTemplate.class,
|
||||||
NPCTemplate.class, ItemTemplate.class,
|
NPCTemplate.class, ItemTemplate.class,
|
||||||
TeleportationTemplate.class);
|
TeleportationTemplateContainer.class);
|
||||||
unmarshaller = context.createUnmarshaller();
|
unmarshaller = context.createUnmarshaller();
|
||||||
|
|
||||||
unmarshaller.setAdapter(NPCTemplateIDAdapter.class,
|
unmarshaller.setAdapter(NPCTemplateIDAdapter.class,
|
||||||
@@ -98,6 +104,12 @@ public class XMLTemplateService extends AbstractService implements
|
|||||||
for (final File file : files) {
|
for (final File file : files) {
|
||||||
loadTemplate(file);
|
loadTemplate(file);
|
||||||
}
|
}
|
||||||
|
TeleportationTemplateContainer container = (TeleportationTemplateContainer) unmarshaller
|
||||||
|
.unmarshal(new File(config.getTemplateDirectory(),
|
||||||
|
"../teleports.xml"));
|
||||||
|
for (final TeleportationTemplate template : container.templates) {
|
||||||
|
templates.put(template.getID(), template);
|
||||||
|
}
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
throw new ServiceStartException(e);
|
throw new ServiceStartException(e);
|
||||||
}
|
}
|
||||||
@@ -134,4 +146,12 @@ public class XMLTemplateService extends AbstractService implements
|
|||||||
unmarshaller = null;
|
unmarshaller = null;
|
||||||
context = null;
|
context = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlRootElement(name = "teleports")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(namespace = "teleports")
|
||||||
|
public static class TeleportationTemplateContainer {
|
||||||
|
@XmlElement(name = "teleport")
|
||||||
|
private List<TeleportationTemplate> templates;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,12 @@ import com.google.inject.Guice;
|
|||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.l2jserver.GameServerModule;
|
import com.l2jserver.GameServerModule;
|
||||||
import com.l2jserver.model.template.CharacterTemplate;
|
import com.l2jserver.model.template.CharacterTemplate;
|
||||||
|
import com.l2jserver.model.template.NPCTemplate;
|
||||||
|
import com.l2jserver.model.template.TeleportationTemplate;
|
||||||
import com.l2jserver.util.jaxb.CharacterTemplateIDAdapter;
|
import com.l2jserver.util.jaxb.CharacterTemplateIDAdapter;
|
||||||
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
|
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
|
||||||
import com.l2jserver.util.jaxb.NPCTemplateIDAdapter;
|
import com.l2jserver.util.jaxb.NPCTemplateIDAdapter;
|
||||||
|
import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
@@ -44,7 +47,8 @@ public class XMLMappingTest {
|
|||||||
public static void main(String[] args) throws JAXBException, IOException {
|
public static void main(String[] args) throws JAXBException, IOException {
|
||||||
// final List<NPCTemplate> templates = CollectionFactory.newList();
|
// final List<NPCTemplate> templates = CollectionFactory.newList();
|
||||||
|
|
||||||
final JAXBContext c = JAXBContext.newInstance(CharacterTemplate.class);
|
final JAXBContext c = JAXBContext.newInstance(CharacterTemplate.class,
|
||||||
|
NPCTemplate.class, TeleportationTemplate.class);
|
||||||
final Unmarshaller u = c.createUnmarshaller();
|
final Unmarshaller u = c.createUnmarshaller();
|
||||||
|
|
||||||
final Injector injector = Guice.createInjector(new GameServerModule());
|
final Injector injector = Guice.createInjector(new GameServerModule());
|
||||||
@@ -54,6 +58,8 @@ public class XMLMappingTest {
|
|||||||
injector.getInstance(ItemTemplateIDAdapter.class));
|
injector.getInstance(ItemTemplateIDAdapter.class));
|
||||||
u.setAdapter(CharacterTemplateIDAdapter.class,
|
u.setAdapter(CharacterTemplateIDAdapter.class,
|
||||||
injector.getInstance(CharacterTemplateIDAdapter.class));
|
injector.getInstance(CharacterTemplateIDAdapter.class));
|
||||||
|
u.setAdapter(TeleportationTemplateIDAdapter.class,
|
||||||
|
injector.getInstance(TeleportationTemplateIDAdapter.class));
|
||||||
|
|
||||||
// long start = System.currentTimeMillis();
|
// long start = System.currentTimeMillis();
|
||||||
// for (int i = 0; i < 200 * 1000; i++) {
|
// for (int i = 0; i < 200 * 1000; i++) {
|
||||||
@@ -65,8 +71,8 @@ public class XMLMappingTest {
|
|||||||
//
|
//
|
||||||
// System.out.println("Took " + ((end - start) / 1000) + " seconds");
|
// System.out.println("Took " + ((end - start) / 1000) + " seconds");
|
||||||
|
|
||||||
final CharacterTemplate t = (CharacterTemplate) u.unmarshal(new File(
|
final TeleportationTemplate t = (TeleportationTemplate) u
|
||||||
"data/templates/character/Adventurer.xml"));
|
.unmarshal(new File("data/templates/teleports.xml"));
|
||||||
System.out.println(t.getFemaleCollisionHeight());
|
System.out.println(t.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,8 +113,9 @@ public abstract class HtmlTemplate {
|
|||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public void register(String name, String value) {
|
public HtmlTemplate register(String name, String value) {
|
||||||
variables.put(name, value);
|
variables.put(name, value);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
68
src/main/java/com/l2jserver/util/jaxb/CoordinateAdapter.java
Normal file
68
src/main/java/com/l2jserver/util/jaxb/CoordinateAdapter.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of l2jserver <l2jserver.com>.
|
||||||
|
*
|
||||||
|
* l2jserver is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* l2jserver is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.l2jserver.util.jaxb;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||||
|
|
||||||
|
import com.l2jserver.util.dimensional.Coordinate;
|
||||||
|
import com.l2jserver.util.jaxb.CoordinateAdapter.CoordinateElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This adapter converts an simple set of attributes <tt>x</tt>, <tt>y</tt> and
|
||||||
|
* <tt>z</tt> to an {@link Coordinate} object. Please note that the tag name is
|
||||||
|
* indifferent.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <coordinate x="200" y="100" z="0" />
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class CoordinateAdapter extends
|
||||||
|
XmlAdapter<CoordinateElement, Coordinate> {
|
||||||
|
@Override
|
||||||
|
public CoordinateElement marshal(Coordinate coordinate) throws Exception {
|
||||||
|
return new CoordinateElement(coordinate.getX(), coordinate.getY(),
|
||||||
|
coordinate.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Coordinate unmarshal(CoordinateElement elem) throws Exception {
|
||||||
|
return Coordinate.fromXYZ(elem.x, elem.y, elem.z);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CoordinateElement {
|
||||||
|
@XmlAttribute(name = "x")
|
||||||
|
public int x;
|
||||||
|
@XmlAttribute(name = "y")
|
||||||
|
public int y;
|
||||||
|
@XmlAttribute(name = "z")
|
||||||
|
public int z;
|
||||||
|
|
||||||
|
protected CoordinateElement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoordinateElement(int x, int y, int z) {
|
||||||
|
super();
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of l2jserver <l2jserver.com>.
|
||||||
|
*
|
||||||
|
* l2jserver is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* l2jserver is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.l2jserver.util.jaxb;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.l2jserver.model.id.template.TeleportationTemplateID;
|
||||||
|
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
|
||||||
|
import com.l2jserver.model.id.template.provider.TeleportationTemplateIDProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO this should use an {@link ItemTemplateIDProvider}!
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class TeleportationTemplateIDAdapter extends
|
||||||
|
XmlAdapter<String, TeleportationTemplateID> {
|
||||||
|
private final TeleportationTemplateIDProvider provider;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TeleportationTemplateIDAdapter(
|
||||||
|
TeleportationTemplateIDProvider provider) {
|
||||||
|
this.provider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TeleportationTemplateID unmarshal(String v) throws Exception {
|
||||||
|
if (v == null)
|
||||||
|
return null;
|
||||||
|
return provider.createID(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String marshal(TeleportationTemplateID v) throws Exception {
|
||||||
|
if (v == null)
|
||||||
|
return null;
|
||||||
|
return v.getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user