1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-11 09:42:54 +00:00

NPC Chatting

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-25 02:38:15 -03:00
parent ad6a2e89d2
commit 7033518023
21 changed files with 613 additions and 75 deletions

View File

@@ -50,6 +50,8 @@ public class ItemTemplate extends AbstractTemplate<Item> {
@XmlJavaTypeAdapter(ItemTemplateIDAdapter.class)
protected ItemTemplateID id;
@XmlAttribute(name = "name")
protected String name;
@XmlElement(name = "weight")
protected int weight = 0;
@XmlElement(name = "price")
@@ -81,6 +83,13 @@ public class ItemTemplate extends AbstractTemplate<Item> {
return new Item(id);
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the weight
*/

View File

@@ -16,6 +16,7 @@
*/
package com.l2jserver.model.template;
import java.util.Collections;
import java.util.List;
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.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.NPC;
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
@@ -227,31 +229,55 @@ public class NPCTemplate extends ActorTemplate<NPC> {
@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")
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
protected TeleportationTemplateID id;
protected String id;
@XmlElement(name = "region")
protected List<TeleporterRegionMetadata> 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
}
protected List<TeleportRegion> regions = null;
}
}
@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")
protected TalkMetadata talk = null;
@@ -271,7 +297,7 @@ public class NPCTemplate extends ActorTemplate<NPC> {
@XmlValue
protected String html = null;
}
@XmlElementWrapper(name = "droplist")
@XmlElement(name = "item")
protected List<DropItemMetadata> droplist = null;
@@ -717,6 +743,46 @@ public class NPCTemplate extends ActorTemplate<NPC> {
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
public NPCTemplateID getID() {
return id;

View File

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