mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
Gatekeeper complete implementation
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
3413
data/teleports.xml
3413
data/teleports.xml
File diff suppressed because it is too large
Load Diff
@@ -1,185 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
||||||
<xs:schema version="1.0" targetNamespace="npc" xmlns:tns="npc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
||||||
|
|
||||||
<xs:import schemaLocation="npc.xsd"/>
|
|
||||||
|
|
||||||
<xs:complexType name="npcTemplate">
|
|
||||||
<xs:complexContent>
|
|
||||||
<xs:extension base="actorTemplate">
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="info" type="tns:npcInformationMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="ai" type="tns:aiMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="teleporter" type="tns:teleporterMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="talk" type="tns:talkMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="droplist" minOccurs="0">
|
|
||||||
<xs:complexType>
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="item" type="tns:dropItemMetadata" minOccurs="0" maxOccurs="unbounded"/>
|
|
||||||
</xs:sequence>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
</xs:sequence>
|
|
||||||
<xs:attribute name="id" type="xs:int"/>
|
|
||||||
<xs:attribute name="type" type="xs:string"/>
|
|
||||||
</xs:extension>
|
|
||||||
</xs:complexContent>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="npcInformationMetadata">
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="name" type="tns:npcNameMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="title" type="tns:npcTitleMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="level" type="xs:int"/>
|
|
||||||
<xs:element name="sex" type="actorSex" minOccurs="0"/>
|
|
||||||
<xs:element name="stats" type="tns:npcStatsMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="experience" type="xs:long"/>
|
|
||||||
<xs:element name="sp" type="xs:int"/>
|
|
||||||
<xs:element name="item" type="tns:itemMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="collision" type="tns:collisionMetadata" minOccurs="0"/>
|
|
||||||
</xs:sequence>
|
|
||||||
<xs:attribute name="attackable" type="xs:boolean" use="required"/>
|
|
||||||
<xs:attribute name="targetable" type="xs:boolean" use="required"/>
|
|
||||||
<xs:attribute name="aggressive" type="xs:boolean" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="npcNameMetadata">
|
|
||||||
<xs:simpleContent>
|
|
||||||
<xs:extension base="xs:string">
|
|
||||||
<xs:attribute name="send" type="xs:boolean"/>
|
|
||||||
<xs:attribute name="display" type="xs:boolean"/>
|
|
||||||
</xs:extension>
|
|
||||||
</xs:simpleContent>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="npcTitleMetadata">
|
|
||||||
<xs:simpleContent>
|
|
||||||
<xs:extension base="xs:string">
|
|
||||||
<xs:attribute name="send" type="xs:boolean"/>
|
|
||||||
</xs:extension>
|
|
||||||
</xs:simpleContent>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="npcStatsMetadata">
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="hp" type="tns:stat" minOccurs="0"/>
|
|
||||||
<xs:element name="mp" type="tns:stat" minOccurs="0"/>
|
|
||||||
<xs:element name="attack" type="tns:attackMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="defense" type="tns:defenseMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="move" type="tns:moveMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="base" type="tns:baseMetadata" minOccurs="0"/>
|
|
||||||
</xs:sequence>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="stat">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="max" type="xs:double" use="required"/>
|
|
||||||
<xs:attribute name="regen" type="xs:double" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="attackMetadata">
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="physical" type="tns:attackValueMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="magical" type="tns:attackValueMetadata" minOccurs="0"/>
|
|
||||||
</xs:sequence>
|
|
||||||
<xs:attribute name="range" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="evasion" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="critical" type="xs:int" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="attackValueMetadata">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="damage" type="xs:double" use="required"/>
|
|
||||||
<xs:attribute name="speed" type="xs:double" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="defenseMetadata">
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="physical" type="tns:defenseValueMetadata" minOccurs="0"/>
|
|
||||||
<xs:element name="magical" type="tns:defenseValueMetadata" minOccurs="0"/>
|
|
||||||
</xs:sequence>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="defenseValueMetadata">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="value" type="xs:double" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="moveMetadata">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="run" type="xs:double" use="required"/>
|
|
||||||
<xs:attribute name="walk" type="xs:double" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="baseMetadata">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="int" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="str" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="con" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="men" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="dex" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="wit" type="xs:int" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="itemMetadata">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="righthand" type="xs:int"/>
|
|
||||||
<xs:attribute name="lefthand" type="xs:int"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="collisionMetadata">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="radius" type="xs:double" use="required"/>
|
|
||||||
<xs:attribute name="heigth" type="xs:double" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="aiMetadata">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="script" type="xs:string"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="teleporterMetadata">
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="teleport" type="tns:teleporterTeleportMetadata" minOccurs="0" maxOccurs="unbounded"/>
|
|
||||||
</xs:sequence>
|
|
||||||
<xs:attribute name="default" type="xs:string"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="teleporterTeleportMetadata">
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="region" type="tns:teleportRegion" minOccurs="0" maxOccurs="unbounded"/>
|
|
||||||
</xs:sequence>
|
|
||||||
<xs:attribute name="id" type="xs:string"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="teleportRegion">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="id" type="xs:string"/>
|
|
||||||
<xs:attribute name="price" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="item" type="xs:int"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="talkMetadata">
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="chat" type="tns:chat" minOccurs="0" maxOccurs="unbounded"/>
|
|
||||||
</xs:sequence>
|
|
||||||
<xs:attribute name="default" type="xs:string"/>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="chat">
|
|
||||||
<xs:simpleContent>
|
|
||||||
<xs:extension base="xs:string">
|
|
||||||
<xs:attribute name="id" type="xs:string"/>
|
|
||||||
</xs:extension>
|
|
||||||
</xs:simpleContent>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:complexType name="dropItemMetadata">
|
|
||||||
<xs:sequence/>
|
|
||||||
<xs:attribute name="id" type="xs:int"/>
|
|
||||||
<xs:attribute name="min" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="max" type="xs:int" use="required"/>
|
|
||||||
<xs:attribute name="category" type="dropCategory"/>
|
|
||||||
<xs:attribute name="chance" type="xs:int" use="required"/>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:schema>
|
|
||||||
|
|
||||||
|
|||||||
@@ -100,29 +100,33 @@ public class Lineage2PacketHandler extends SimpleChannelHandler {
|
|||||||
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event)
|
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final Throwable e = event.getCause();
|
final Throwable e = event.getCause();
|
||||||
if (e instanceof ChannelException)
|
try {
|
||||||
return;
|
if (e instanceof ChannelException)
|
||||||
if (e instanceof IOException)
|
return;
|
||||||
return;
|
if (e instanceof IOException)
|
||||||
if (!connection.isConnected())
|
return;
|
||||||
// no point sending error messages if the client is disconnected
|
if (!connection.isConnected())
|
||||||
return;
|
// no point sending error messages if the client is disconnected
|
||||||
|
return;
|
||||||
// TODO only send exception stack trace in development mode!
|
|
||||||
final String exception = Throwables.getStackTraceAsString(e)
|
// TODO only send exception stack trace in development mode!
|
||||||
.replaceAll("\n", "<br>").replace(" ", "");
|
final String exception = Throwables.getStackTraceAsString(e)
|
||||||
final HtmlTemplate template = new HtmlTemplate("Java Exception") {
|
.replaceAll("\n", "<br>").replace(" ", "");
|
||||||
@Override
|
final HtmlTemplate template = new HtmlTemplate("Java Exception") {
|
||||||
public void build(MarkupTag body) {
|
@Override
|
||||||
body.text(exception);
|
public void build(MarkupTag body) {
|
||||||
|
body.text(exception);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
connection.write(new NPCHtmlMessagePacket(null, template));
|
||||||
|
connection.sendActionFailed(); // order client not to wait any packet
|
||||||
|
|
||||||
|
final String[] lines = Throwables.getStackTraceAsString(e).split("\n");
|
||||||
|
for(final String line : lines) {
|
||||||
|
connection.sendMessage(line);
|
||||||
}
|
}
|
||||||
};
|
} finally {
|
||||||
connection.write(new NPCHtmlMessagePacket(null, template));
|
e.printStackTrace();
|
||||||
connection.sendActionFailed(); // order client not to wait any packet
|
|
||||||
|
|
||||||
final String[] lines = Throwables.getStackTraceAsString(e).split("\n");
|
|
||||||
for(final String line : lines) {
|
|
||||||
connection.sendMessage(line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
|||||||
*/
|
*/
|
||||||
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
|
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
|
||||||
public class TeleportationTemplateID extends
|
public class TeleportationTemplateID extends
|
||||||
TemplateID<TeleportationTemplate, String> {
|
TemplateID<TeleportationTemplate, Integer> {
|
||||||
/**
|
/**
|
||||||
* The template service
|
* The template service
|
||||||
*/
|
*/
|
||||||
private final TemplateService templateService;
|
private final TemplateService templateService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TeleportationTemplateID(@Assisted String id,
|
public TeleportationTemplateID(@Assisted int id,
|
||||||
TemplateService templateService) {
|
TemplateService templateService) {
|
||||||
super(id);
|
super(id);
|
||||||
this.templateService = templateService;
|
this.templateService = templateService;
|
||||||
|
|||||||
@@ -25,5 +25,5 @@ import com.l2jserver.model.id.template.TeleportationTemplateID;
|
|||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface TeleportationTemplateIDProvider extends
|
public interface TeleportationTemplateIDProvider extends
|
||||||
TemplateIDProvider<String, TeleportationTemplateID> {
|
TemplateIDProvider<Integer, TeleportationTemplateID> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
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;
|
||||||
@@ -33,19 +32,16 @@ import org.eclipse.persistence.oxm.annotations.XmlCDATA;
|
|||||||
|
|
||||||
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.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;
|
||||||
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>
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "npc")
|
@XmlRootElement(name = "npc")
|
||||||
@XmlType(namespace = "npc")
|
@XmlType(namespace = "npc", name = "npc")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class NPCTemplate extends ActorTemplate<NPC> {
|
public class NPCTemplate extends ActorTemplate<NPC> {
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
@@ -226,60 +222,6 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
|||||||
protected String script = null;
|
protected String script = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "teleporter")
|
|
||||||
protected TeleporterMetadata teleporter = null;
|
|
||||||
|
|
||||||
@XmlType(namespace = "npc")
|
|
||||||
protected static class TeleporterMetadata {
|
|
||||||
@XmlAttribute(name = "default")
|
|
||||||
protected String defaultTeleport = null;
|
|
||||||
@XmlElement(name = "teleport")
|
|
||||||
protected List<TeleporterTeleportMetadata> teleports = null;
|
|
||||||
|
|
||||||
@XmlType(namespace = "npc")
|
|
||||||
protected static class TeleporterTeleportMetadata {
|
|
||||||
@XmlAttribute(name = "id")
|
|
||||||
protected String id;
|
|
||||||
@XmlElement(name = "region")
|
|
||||||
protected List<TeleportRegion> regions = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlType(namespace = "npc")
|
|
||||||
public static class TeleportRegion {
|
|
||||||
@XmlAttribute(name = "id")
|
|
||||||
@XmlJavaTypeAdapter(value = 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;
|
||||||
|
|
||||||
@@ -746,28 +688,6 @@ 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) {
|
public String getHTML(String id) {
|
||||||
if (talk == null)
|
if (talk == null)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.l2jserver.model.template;
|
package com.l2jserver.model.template;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
@@ -24,9 +26,11 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
|
|
||||||
|
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||||
import com.l2jserver.model.id.template.TeleportationTemplateID;
|
import com.l2jserver.model.id.template.TeleportationTemplateID;
|
||||||
import com.l2jserver.util.dimensional.Coordinate;
|
import com.l2jserver.util.dimensional.Coordinate;
|
||||||
import com.l2jserver.util.jaxb.CoordinateAdapter;
|
import com.l2jserver.util.jaxb.CoordinateAdapter;
|
||||||
|
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
|
||||||
import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,12 +44,25 @@ import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
|||||||
public class TeleportationTemplate extends AbstractTemplate<Coordinate> {
|
public class TeleportationTemplate extends AbstractTemplate<Coordinate> {
|
||||||
@XmlAttribute(name = "id")
|
@XmlAttribute(name = "id")
|
||||||
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
|
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
|
||||||
private TeleportationTemplateID id;
|
protected TeleportationTemplateID id;
|
||||||
@XmlElement(name = "name")
|
@XmlAttribute(name = "name")
|
||||||
private String name;
|
protected String name;
|
||||||
@XmlElement(name = "coordinate")
|
|
||||||
|
@XmlAttribute(name = "item")
|
||||||
|
@XmlJavaTypeAdapter(ItemTemplateIDAdapter.class)
|
||||||
|
protected ItemTemplateID itemTemplateID;
|
||||||
|
@XmlAttribute(name = "price")
|
||||||
|
protected int price;
|
||||||
|
|
||||||
|
@XmlElement(name = "point")
|
||||||
@XmlJavaTypeAdapter(CoordinateAdapter.class)
|
@XmlJavaTypeAdapter(CoordinateAdapter.class)
|
||||||
private Coordinate coordinate;
|
protected Coordinate coordinate;
|
||||||
|
|
||||||
|
protected List<TeleportRestriction> restrictions;
|
||||||
|
|
||||||
|
public enum TeleportRestriction {
|
||||||
|
NOBLE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Coordinate create() {
|
public Coordinate create() {
|
||||||
@@ -59,6 +76,27 @@ public class TeleportationTemplate extends AbstractTemplate<Coordinate> {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public TeleportationTemplateID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the itemTemplateID
|
||||||
|
*/
|
||||||
|
public ItemTemplateID getItemTemplateID() {
|
||||||
|
return itemTemplateID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the price
|
||||||
|
*/
|
||||||
|
public int getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the coordinate
|
* @return the coordinate
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,20 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
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.Lineage2Connection;
|
||||||
import com.l2jserver.game.net.packet.server.NPCHtmlMessagePacket;
|
|
||||||
import com.l2jserver.model.id.template.provider.TeleportationTemplateIDProvider;
|
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.template.TeleportationTemplate;
|
||||||
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.service.game.spawn.SpawnService;
|
import com.l2jserver.service.game.spawn.SpawnService;
|
||||||
import com.l2jserver.util.exception.L2Exception;
|
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)
|
||||||
@@ -49,29 +43,9 @@ public class TeleporterController extends AbstractNPCController {
|
|||||||
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.length >= 2) {
|
||||||
if (args[0].equals("TeleportList")) {
|
if (args[0].equals("goto")) {
|
||||||
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
|
final TeleportationTemplate tele = teleportationIdProvider
|
||||||
.createID(args[1]).getTemplate();
|
.createID(Integer.parseInt(args[1])).getTemplate();
|
||||||
if (tele == null) {
|
if (tele == null) {
|
||||||
// TODO chat
|
// TODO chat
|
||||||
conn.sendActionFailed();
|
conn.sendActionFailed();
|
||||||
@@ -83,8 +57,4 @@ public class TeleporterController extends AbstractNPCController {
|
|||||||
}
|
}
|
||||||
super.action(npc, conn, character, args);
|
super.action(npc, conn, character, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<TeleportRegion> getTeleportRegions(NPC npc, String id) {
|
|
||||||
return npc.getTemplate().getTeleportRegions(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,11 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
|||||||
*/
|
*/
|
||||||
private final NPCDAO npcDao;
|
private final NPCDAO npcDao;
|
||||||
|
|
||||||
private final TeleporterController controller = new TeleporterController();
|
/**
|
||||||
|
* Temporary only
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private TeleporterController controller;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NPCServiceImpl(SpawnService spawnService,
|
public NPCServiceImpl(SpawnService spawnService,
|
||||||
|
|||||||
@@ -163,6 +163,6 @@ public class XMLTemplateService extends AbstractService implements
|
|||||||
@XmlType(namespace = "teleports")
|
@XmlType(namespace = "teleports")
|
||||||
public static class TeleportationTemplateContainer {
|
public static class TeleportationTemplateContainer {
|
||||||
@XmlElement(name = "teleport")
|
@XmlElement(name = "teleport")
|
||||||
private List<TeleportationTemplate> templates;
|
public List<TeleportationTemplate> templates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import com.l2jserver.model.id.template.provider.TeleportationTemplateIDProvider;
|
|||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public class TeleportationTemplateIDAdapter extends
|
public class TeleportationTemplateIDAdapter extends
|
||||||
XmlAdapter<String, TeleportationTemplateID> {
|
XmlAdapter<Integer, TeleportationTemplateID> {
|
||||||
private final TeleportationTemplateIDProvider provider;
|
private final TeleportationTemplateIDProvider provider;
|
||||||
|
|
||||||
public TeleportationTemplateIDAdapter() {
|
public TeleportationTemplateIDAdapter() {
|
||||||
@@ -43,7 +43,7 @@ public class TeleportationTemplateIDAdapter extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TeleportationTemplateID unmarshal(String v) throws Exception {
|
public TeleportationTemplateID unmarshal(Integer v) throws Exception {
|
||||||
if (v == null)
|
if (v == null)
|
||||||
return null;
|
return null;
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
@@ -52,7 +52,7 @@ public class TeleportationTemplateIDAdapter extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String marshal(TeleportationTemplateID v) throws Exception {
|
public Integer marshal(TeleportationTemplateID v) throws Exception {
|
||||||
if (v == null)
|
if (v == null)
|
||||||
return null;
|
return null;
|
||||||
return v.getID();
|
return v.getID();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -32,7 +33,6 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.MarshalException;
|
|
||||||
import javax.xml.bind.Marshaller;
|
import javax.xml.bind.Marshaller;
|
||||||
import javax.xml.bind.SchemaOutputResolver;
|
import javax.xml.bind.SchemaOutputResolver;
|
||||||
import javax.xml.transform.Result;
|
import javax.xml.transform.Result;
|
||||||
@@ -42,6 +42,7 @@ import org.apache.commons.io.FileUtils;
|
|||||||
|
|
||||||
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.template.NPCTemplate.Chat;
|
import com.l2jserver.model.template.NPCTemplate.Chat;
|
||||||
import com.l2jserver.model.template.NPCTemplate.DropItemMetadata;
|
import com.l2jserver.model.template.NPCTemplate.DropItemMetadata;
|
||||||
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata;
|
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata;
|
||||||
@@ -58,7 +59,10 @@ import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsM
|
|||||||
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.Stat;
|
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCStatsMetadata.Stat;
|
||||||
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCTitleMetadata;
|
import com.l2jserver.model.template.NPCTemplate.NPCInformationMetadata.NPCTitleMetadata;
|
||||||
import com.l2jserver.model.template.NPCTemplate.TalkMetadata;
|
import com.l2jserver.model.template.NPCTemplate.TalkMetadata;
|
||||||
|
import com.l2jserver.model.template.TeleportationTemplate.TeleportRestriction;
|
||||||
import com.l2jserver.model.world.Actor.ActorSex;
|
import com.l2jserver.model.world.Actor.ActorSex;
|
||||||
|
import com.l2jserver.service.game.template.XMLTemplateService.TeleportationTemplateContainer;
|
||||||
|
import com.l2jserver.util.dimensional.Coordinate;
|
||||||
import com.l2jserver.util.factory.CollectionFactory;
|
import com.l2jserver.util.factory.CollectionFactory;
|
||||||
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
|
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
|
||||||
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
|
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
|
||||||
@@ -72,6 +76,7 @@ public class NPCTemplateConverter {
|
|||||||
|
|
||||||
private static List<NPCTemplate> templates = CollectionFactory.newList();
|
private static List<NPCTemplate> templates = CollectionFactory.newList();
|
||||||
private static Collection<File> htmlScannedFiles;
|
private static Collection<File> htmlScannedFiles;
|
||||||
|
private static TeleportationTemplateContainer teleportation = new TeleportationTemplateContainer();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void main(String[] args) throws SQLException, IOException,
|
public static void main(String[] args) throws SQLException, IOException,
|
||||||
@@ -83,24 +88,63 @@ public class NPCTemplateConverter {
|
|||||||
htmlScannedFiles = FileUtils.listFiles(L2J_HTML_FOLDER, new String[] {
|
htmlScannedFiles = FileUtils.listFiles(L2J_HTML_FOLDER, new String[] {
|
||||||
"html", "htm" }, true);
|
"html", "htm" }, true);
|
||||||
|
|
||||||
System.out.println("Generating template XML files...");
|
final JAXBContext c = JAXBContext.newInstance(NPCTemplate.class,
|
||||||
|
TeleportationTemplateContainer.class);
|
||||||
|
|
||||||
final JAXBContext c = JAXBContext.newInstance(NPCTemplate.class);
|
final Connection conn = DriverManager.getConnection(JDBC_URL,
|
||||||
|
JDBC_USERNAME, JDBC_PASSWORD);
|
||||||
|
{
|
||||||
|
System.out.println("Converting teleport templates...");
|
||||||
|
teleportation.templates = CollectionFactory.newList();
|
||||||
|
|
||||||
|
final Marshaller m = c.createMarshaller();
|
||||||
|
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||||
|
m.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION,
|
||||||
|
"teleportation");
|
||||||
|
m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
|
||||||
|
"teleportation teleportation.xsd");
|
||||||
|
|
||||||
|
final PreparedStatement st = conn
|
||||||
|
.prepareStatement("SELECT * FROM teleport");
|
||||||
|
st.execute();
|
||||||
|
final ResultSet rs = st.getResultSet();
|
||||||
|
while (rs.next()) {
|
||||||
|
final TeleportationTemplate template = new TeleportationTemplate();
|
||||||
|
|
||||||
|
template.id = new TeleportationTemplateID(rs.getInt("id"), null);
|
||||||
|
template.name = rs.getString("Description");
|
||||||
|
template.coordinate = Coordinate.fromXYZ(rs.getInt("loc_x"),
|
||||||
|
rs.getInt("loc_y"), rs.getInt("loc_z"));
|
||||||
|
template.price = rs.getInt("price");
|
||||||
|
template.itemTemplateID = new ItemTemplateID(
|
||||||
|
rs.getInt("itemId"), null);
|
||||||
|
if (rs.getBoolean("fornoble")) {
|
||||||
|
template.restrictions = Arrays
|
||||||
|
.asList(TeleportRestriction.NOBLE);
|
||||||
|
}
|
||||||
|
teleportation.templates.add(template);
|
||||||
|
}
|
||||||
|
m.marshal(teleportation, getXMLSerializer(new FileOutputStream(
|
||||||
|
new File(target, "../teleports.xml"))));
|
||||||
|
// System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Generating template XML files...");
|
||||||
c.generateSchema(new SchemaOutputResolver() {
|
c.generateSchema(new SchemaOutputResolver() {
|
||||||
@Override
|
@Override
|
||||||
public Result createOutput(String namespaceUri,
|
public Result createOutput(String namespaceUri,
|
||||||
String suggestedFileName) throws IOException {
|
String suggestedFileName) throws IOException {
|
||||||
return new StreamResult(new File(target, "npc.xsd"));
|
// System.out.println(new File(target, suggestedFileName));
|
||||||
|
// return null;
|
||||||
|
return new StreamResult(new File(target, suggestedFileName));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Marshaller m = c.createMarshaller();
|
|
||||||
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
|
||||||
m.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, "npc");
|
|
||||||
|
|
||||||
final Connection conn = DriverManager.getConnection(JDBC_URL,
|
|
||||||
JDBC_USERNAME, JDBC_PASSWORD);
|
|
||||||
try {
|
try {
|
||||||
|
final Marshaller m = c.createMarshaller();
|
||||||
|
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||||
|
m.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, "npc");
|
||||||
|
|
||||||
final PreparedStatement st = conn
|
final PreparedStatement st = conn
|
||||||
.prepareStatement("SELECT * FROM npc");
|
.prepareStatement("SELECT * FROM npc");
|
||||||
st.execute();
|
st.execute();
|
||||||
@@ -127,19 +171,14 @@ public class NPCTemplateConverter {
|
|||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
templates.add(t);
|
templates.add(t);
|
||||||
|
|
||||||
// if (t.id.getID() == 30059) {
|
// try {
|
||||||
// m.marshal(t, getXMLSerializer(System.out));
|
// m.marshal(t, getXMLSerializer(new FileOutputStream(file)));
|
||||||
// System.exit(0);
|
// } catch (MarshalException e) {
|
||||||
|
// System.err
|
||||||
|
// .println("Could not generate XML template file for "
|
||||||
|
// + t.getName() + " - " + t.getID());
|
||||||
|
// file.delete();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
try {
|
|
||||||
m.marshal(t, getXMLSerializer(new FileOutputStream(file)));
|
|
||||||
} catch (MarshalException e) {
|
|
||||||
System.err
|
|
||||||
.println("Could not generate XML template file for "
|
|
||||||
+ t.getName() + " - " + t.getID());
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Generated " + templates.size() + " templates");
|
System.out.println("Generated " + templates.size() + " templates");
|
||||||
@@ -168,6 +207,7 @@ public class NPCTemplateConverter {
|
|||||||
IOException {
|
IOException {
|
||||||
final NPCTemplate template = new NPCTemplate();
|
final NPCTemplate template = new NPCTemplate();
|
||||||
template.id = new NPCTemplateID(rs.getInt("idTemplate"), null);
|
template.id = new NPCTemplateID(rs.getInt("idTemplate"), null);
|
||||||
|
|
||||||
template.type = createParentType(rs.getString("type"));
|
template.type = createParentType(rs.getString("type"));
|
||||||
template.info = new NPCInformationMetadata();
|
template.info = new NPCInformationMetadata();
|
||||||
|
|
||||||
@@ -249,8 +289,6 @@ public class NPCTemplateConverter {
|
|||||||
template.info.collision.radius = rs.getDouble("collision_radius");
|
template.info.collision.radius = rs.getDouble("collision_radius");
|
||||||
template.info.collision.height = rs.getDouble("collision_height");
|
template.info.collision.height = rs.getDouble("collision_height");
|
||||||
|
|
||||||
// TODO import teleporter data
|
|
||||||
|
|
||||||
template.droplist = fillDropList(rs, template.id.getID());
|
template.droplist = fillDropList(rs, template.id.getID());
|
||||||
template.talk = fillHtmlChat(template.id.getID());
|
template.talk = fillHtmlChat(template.id.getID());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user