1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-08 08:23:11 +00:00

NPC Html chat messages

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-25 13:54:59 -03:00
parent 7033518023
commit 4a003b21e0
10103 changed files with 56028 additions and 20460 deletions

View File

@@ -16,6 +16,8 @@
*/
package com.l2jserver.model.id.template;
import javax.xml.bind.annotation.XmlTransient;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.TemplateID;
@@ -40,6 +42,7 @@ public class ActorTemplateID<T extends ActorTemplate<?>> extends TemplateID<T, I
}
@Override
@XmlTransient
public T getTemplate() {
return templateService.getTemplate(this);
}

View File

@@ -16,6 +16,8 @@
*/
package com.l2jserver.model.id.template;
import javax.xml.bind.annotation.XmlTransient;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.TemplateID;
@@ -27,6 +29,7 @@ import com.l2jserver.service.game.template.TemplateService;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
@XmlTransient
public class ItemTemplateID extends TemplateID<ItemTemplate, Integer> {
/**
* The template service

View File

@@ -16,20 +16,29 @@
*/
package com.l2jserver.model.id.template;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.TemplateID;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.service.game.template.TemplateService;
import com.l2jserver.util.jaxb.NPCTemplateIDAdapter;
/**
* An {@link TemplateID} instance representing an {@link NPCTemplate} object
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
@XmlJavaTypeAdapter(value = NPCTemplateIDAdapter.class)
public class NPCTemplateID extends ActorTemplateID<NPCTemplate> {
@Inject
protected NPCTemplateID(@Assisted int id, TemplateService templateService) {
public NPCTemplateID(@Assisted int id, TemplateService templateService) {
super(id, templateService);
}
@Override
public NPCTemplate getTemplate() {
return super.getTemplate();
}
}

View File

@@ -16,18 +16,22 @@
*/
package com.l2jserver.model.id.template;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
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;
import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
/**
* An {@link TemplateID} instance representing an {@link SkillTemplate} object
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
public class TeleportationTemplateID extends
TemplateID<TeleportationTemplate, String> {
/**

View File

@@ -29,6 +29,8 @@ import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.eclipse.persistence.oxm.annotations.XmlCDATA;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.id.template.TeleportationTemplateID;
@@ -87,11 +89,11 @@ public class NPCTemplate extends ActorTemplate<NPC> {
protected ActorSex sex = null;
@XmlAttribute(name = "attackable")
protected Boolean attackable = null;
protected boolean attackable;
@XmlAttribute(name = "targetable")
protected Boolean targetable = null;
protected boolean targetable;
@XmlAttribute(name = "aggressive")
protected Boolean aggressive = null;
protected boolean aggressive;
@XmlElement(name = "stats")
protected NPCStatsMetadata stats = null;
@@ -246,7 +248,7 @@ public class NPCTemplate extends ActorTemplate<NPC> {
@XmlType(namespace = "npc")
public static class TeleportRegion {
@XmlAttribute(name = "id")
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
@XmlJavaTypeAdapter(value = TeleportationTemplateIDAdapter.class)
protected TeleportationTemplateID id;
@XmlAttribute(name = "price")
protected int price = 0;
@@ -295,6 +297,7 @@ public class NPCTemplate extends ActorTemplate<NPC> {
@XmlAttribute(name = "id")
protected String id = null;
@XmlValue
@XmlCDATA
protected String html = null;
}

View File

@@ -93,10 +93,16 @@ public class AbstractNPCController implements NPCController {
* @return the html code
*/
protected String getHTML(NPC npc, String id) {
// id correction - on l2j default chat is also "0".
if ("0".equals(id)) // avoid NullPointerException
id = null;
final NPCTemplate template = npc.getTemplate();
String html = template.getHTML(id);
if (html == null)
return null;
// TODO use an decent template engine
return template.getHTML(id).replaceAll("%objectId%",
npc.getID().getID().toString());
return html.replaceAll("%objectId%", npc.getID().getID().toString());
}
/**