mirror of
https://github.com/Rogiel/l2jserver2
synced 2026-01-28 13:42:47 +00:00
@@ -102,8 +102,8 @@ public class NPCInformationPacket extends AbstractServerPacket {
|
||||
buffer.writeInt(0x00); // C6 -- is flying
|
||||
buffer.writeInt(0x00); // unk
|
||||
buffer.writeInt(0x00);// CT1.5 Pet form and skills, Color effect
|
||||
buffer.writeByte(0x00); // hide name
|
||||
buffer.writeByte(0x00); // hide name, again
|
||||
buffer.writeByte((template.getDisplayName() ? 0x01 : 0x00)); // hide name
|
||||
buffer.writeByte((template.getDisplayName() ? 0x01 : 0x00)); // hide name, again
|
||||
|
||||
buffer.writeInt(0x00); // special effects
|
||||
buffer.writeInt(0x00); // display effect
|
||||
|
||||
@@ -24,14 +24,14 @@ import com.l2jserver.model.template.Template;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class TemplateID<T extends Template<?>> extends ID<Integer> {
|
||||
public abstract class TemplateID<T extends Template<?>, I> extends ID<I> {
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param id
|
||||
* the raw id
|
||||
*/
|
||||
public TemplateID(int id) {
|
||||
public TemplateID(I id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
|
||||
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
|
||||
import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider;
|
||||
import com.l2jserver.model.id.template.provider.SkillTemplateIDProvider;
|
||||
import com.l2jserver.model.id.template.provider.TeleportationTemplateIDProvider;
|
||||
|
||||
/**
|
||||
* Google Guice {@link IDProvider} {@link Module}
|
||||
@@ -76,5 +77,7 @@ public class IDProviderModule extends AbstractModule {
|
||||
install(new FactoryModuleBuilder()
|
||||
.build(CharacterTemplateIDProvider.class));
|
||||
install(new FactoryModuleBuilder().build(NPCTemplateIDProvider.class));
|
||||
install(new FactoryModuleBuilder()
|
||||
.build(TeleportationTemplateIDProvider.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.l2jserver.service.game.template.TemplateService;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ActorTemplateID<T extends ActorTemplate<?>> extends TemplateID<T> {
|
||||
public class ActorTemplateID<T extends ActorTemplate<?>> extends TemplateID<T, Integer> {
|
||||
/**
|
||||
* The template service
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.l2jserver.service.game.template.TemplateService;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ItemTemplateID extends TemplateID<ItemTemplate> {
|
||||
public class ItemTemplateID extends TemplateID<ItemTemplate, Integer> {
|
||||
/**
|
||||
* The template service
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.l2jserver.service.game.template.TemplateService;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SkillTemplateID extends TemplateID<SkillTemplate> {
|
||||
public class SkillTemplateID extends TemplateID<SkillTemplate, Integer> {
|
||||
/**
|
||||
* The template service
|
||||
*/
|
||||
|
||||
@@ -24,5 +24,5 @@ import com.l2jserver.model.id.template.CharacterTemplateID;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface CharacterTemplateIDProvider extends
|
||||
TemplateIDProvider<CharacterTemplateID> {
|
||||
TemplateIDProvider<Integer, CharacterTemplateID> {
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@ import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface ItemTemplateIDProvider extends
|
||||
TemplateIDProvider<ItemTemplateID> {
|
||||
TemplateIDProvider<Integer, ItemTemplateID> {
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@ import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface NPCTemplateIDProvider extends
|
||||
TemplateIDProvider<NPCTemplateID> {
|
||||
TemplateIDProvider<Integer, NPCTemplateID> {
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@ import com.l2jserver.model.id.template.SkillTemplateID;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface SkillTemplateIDProvider extends
|
||||
TemplateIDProvider<SkillTemplateID> {
|
||||
TemplateIDProvider<Integer, SkillTemplateID> {
|
||||
}
|
||||
|
||||
@@ -27,6 +27,6 @@ import com.l2jserver.model.id.provider.IDProvider;
|
||||
* @param <T>
|
||||
* the subclass of {@link TemplateID} that will be createdF
|
||||
*/
|
||||
public interface TemplateIDProvider<T extends TemplateID<?>> extends
|
||||
IDProvider<Integer, T> {
|
||||
public interface TemplateIDProvider<I, T extends TemplateID<?, I>> extends
|
||||
IDProvider<I, T> {
|
||||
}
|
||||
|
||||
@@ -42,5 +42,5 @@ public abstract class AbstractTemplate<T> implements Template<T> {
|
||||
// }
|
||||
|
||||
@Override
|
||||
public abstract TemplateID<?> getID();
|
||||
public abstract TemplateID<?, ?> getID();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import com.l2jserver.model.world.character.CharacterClass;
|
||||
import com.l2jserver.util.jaxb.CharacterTemplateIDAdapter;
|
||||
|
||||
/**
|
||||
* The {@link L2Character} template. Each character instance is backed by an template.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@XmlRootElement(name = "character")
|
||||
|
||||
@@ -28,13 +28,14 @@ import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import com.l2jserver.model.id.TemplateID;
|
||||
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.world.Actor.ActorSex;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
|
||||
import com.l2jserver.util.jaxb.NPCTemplateIDAdapter;
|
||||
import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
@@ -202,7 +203,7 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
||||
|
||||
@XmlElement(name = "collision")
|
||||
protected CollisionMetadata collision = null;
|
||||
|
||||
|
||||
@XmlType(namespace = "npc")
|
||||
protected static class CollisionMetadata {
|
||||
@XmlAttribute(name = "radius")
|
||||
@@ -232,7 +233,8 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
||||
@XmlType(namespace = "npc")
|
||||
protected static class TeleporterTeleportMetadata {
|
||||
@XmlAttribute(name = "id")
|
||||
protected String id = null;
|
||||
@XmlJavaTypeAdapter(TeleportationTemplateIDAdapter.class)
|
||||
protected TeleportationTemplateID id;
|
||||
@XmlElement(name = "region")
|
||||
protected List<TeleporterRegionMetadata> regions = null;
|
||||
|
||||
@@ -259,17 +261,17 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
||||
protected String defaultChat = null;
|
||||
|
||||
@XmlElement(name = "chat")
|
||||
protected List<ChatMetadata> chats = null;
|
||||
|
||||
@XmlType(namespace = "npc")
|
||||
protected static class ChatMetadata {
|
||||
@XmlAttribute(name = "id")
|
||||
protected String id = null;
|
||||
@XmlValue
|
||||
protected String html = null;
|
||||
}
|
||||
protected List<Chat> chats = null;
|
||||
}
|
||||
|
||||
@XmlType(namespace = "npc")
|
||||
public static class Chat {
|
||||
@XmlAttribute(name = "id")
|
||||
protected String id = null;
|
||||
@XmlValue
|
||||
protected String html = null;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "droplist")
|
||||
@XmlElement(name = "item")
|
||||
protected List<DropItemMetadata> droplist = null;
|
||||
@@ -716,7 +718,7 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateID<?> getID() {
|
||||
public NPCTemplateID getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,5 +42,5 @@ public interface Template<T> {
|
||||
*
|
||||
* @return the template id
|
||||
*/
|
||||
TemplateID<?> getID();
|
||||
TemplateID<?, ?> getID();
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.world.npc;
|
||||
|
||||
import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class Teleporter extends NPC {
|
||||
/**
|
||||
* @param templateID
|
||||
* the NPC template ID
|
||||
*/
|
||||
public Teleporter(NPCTemplateID templateID) {
|
||||
super(templateID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.world.npc.controller;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.server.NPCHtmlMessagePacket;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.util.exception.L2Exception;
|
||||
import com.l2jserver.util.html.markup.HtmlTemplate;
|
||||
import com.l2jserver.util.html.markup.MarkupTag;
|
||||
|
||||
/**
|
||||
* The {@link AbstractNPCController} handful methods for controlling NPCs.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class AbstractNPCController implements NPCController {
|
||||
@Override
|
||||
public void action(NPC npc, Lineage2Connection conn, L2Character character,
|
||||
String... args) throws L2Exception {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Talks with this NPC
|
||||
*
|
||||
* @param npc
|
||||
* the {@link NPC} instance
|
||||
* @param conn
|
||||
* the connection to {@link L2Character}
|
||||
* @param character
|
||||
* the interacting character
|
||||
* @param args
|
||||
* the action arguments
|
||||
* @throws L2Exception
|
||||
*/
|
||||
protected void talk(NPC npc, Lineage2Connection conn,
|
||||
L2Character character, String... args) throws L2Exception {
|
||||
// not yet available message
|
||||
final HtmlTemplate template = new HtmlTemplate() {
|
||||
@Override
|
||||
protected void build(MarkupTag body) {
|
||||
body.text("Sorry, but I'm not implemented yet!");
|
||||
}
|
||||
};
|
||||
|
||||
conn.write(new NPCHtmlMessagePacket(npc, template));
|
||||
conn.sendActionFailed();
|
||||
}
|
||||
}
|
||||
@@ -17,39 +17,24 @@
|
||||
package com.l2jserver.model.world.npc.controller;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.util.exception.L2Exception;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* The {@link NPC} controller is used to control any given NPC. Implementations
|
||||
* will add behaviors to each NPC.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCController {
|
||||
public interface NPCController {
|
||||
/**
|
||||
* The {@link NPC} instance
|
||||
*/
|
||||
protected final NPC npc;
|
||||
/**
|
||||
* The {@link NPC} template
|
||||
*/
|
||||
protected final NPCTemplate template;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
* Performs an interaction with this {@link NPC}.
|
||||
*
|
||||
* @param npc
|
||||
* the {@link NPC}
|
||||
*/
|
||||
public NPCController(NPC npc) {
|
||||
this.npc = npc;
|
||||
this.template = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an interaction with this template.
|
||||
*
|
||||
* the {@link NPC} instance
|
||||
* @param conn
|
||||
* the connection to {@link L2Character}
|
||||
* @param character
|
||||
* the interacting character
|
||||
* @param args
|
||||
@@ -57,27 +42,6 @@ public class NPCController {
|
||||
* @throws L2Exception
|
||||
* any {@link L2Exception}
|
||||
*/
|
||||
public void action(NPC npc, L2Character character, String... args)
|
||||
throws L2Exception {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Talks with this NPC
|
||||
*
|
||||
* @param npc
|
||||
* the npc
|
||||
* @param character
|
||||
* the character
|
||||
* @param conn
|
||||
* the lineage 2 connection
|
||||
* @param args
|
||||
* the action arguments
|
||||
* @throws L2Exception
|
||||
*/
|
||||
protected void talk(NPC npc, L2Character character,
|
||||
Lineage2Connection conn, String... args) throws L2Exception {
|
||||
|
||||
conn.sendActionFailed();
|
||||
}
|
||||
void action(NPC npc, Lineage2Connection conn, L2Character character,
|
||||
String... args) throws L2Exception;
|
||||
}
|
||||
|
||||
@@ -16,23 +16,19 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.npc.controller;
|
||||
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.service.game.spawn.SpawnService;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* This controller is used to control teleporters (e.g. gatekeepers)
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class TeleporterController extends NPCController {
|
||||
public class TeleporterController extends AbstractNPCController {
|
||||
/**
|
||||
* The {@link SpawnService}
|
||||
*/
|
||||
@Inject
|
||||
protected SpawnService spawnService;
|
||||
|
||||
/**
|
||||
* @param npc
|
||||
*/
|
||||
public TeleporterController(NPC npc) {
|
||||
super(npc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ScriptTemplateService extends AbstractService implements
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Template<?>> T getTemplate(TemplateID<T> id) {
|
||||
public <T extends Template<?>> T getTemplate(TemplateID<T, ?> id) {
|
||||
Preconditions.checkNotNull(id, "id");
|
||||
return (T) templates.get(id);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface TemplateService extends Service {
|
||||
* the template id
|
||||
* @return the template
|
||||
*/
|
||||
<T extends Template<?>> T getTemplate(TemplateID<T> id);
|
||||
<T extends Template<?>> T getTemplate(TemplateID<T, ?> id);
|
||||
|
||||
/**
|
||||
* Reload the template list.
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.template.TeleportationTemplate;
|
||||
import com.l2jserver.model.template.Template;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
@@ -43,6 +44,7 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
import com.l2jserver.util.jaxb.CharacterTemplateIDAdapter;
|
||||
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
|
||||
import com.l2jserver.util.jaxb.NPCTemplateIDAdapter;
|
||||
import com.l2jserver.util.jaxb.TeleportationTemplateIDAdapter;
|
||||
|
||||
@Depends({ LoggingService.class, ConfigurationService.class })
|
||||
public class XMLTemplateService extends AbstractService implements
|
||||
@@ -51,6 +53,7 @@ public class XMLTemplateService extends AbstractService implements
|
||||
private final NPCTemplateIDAdapter npcTemplateIdAdapter;
|
||||
private final ItemTemplateIDAdapter itemTemplateIdAdapter;
|
||||
private final CharacterTemplateIDAdapter charIdTemplateAdapter;
|
||||
private final TeleportationTemplateIDAdapter teleportationIdTemplateAdapter;
|
||||
|
||||
private JAXBContext context;
|
||||
private Unmarshaller unmarshaller;
|
||||
@@ -62,18 +65,21 @@ public class XMLTemplateService extends AbstractService implements
|
||||
public XMLTemplateService(ConfigurationService configService,
|
||||
NPCTemplateIDAdapter npcTemplateIdAdapter,
|
||||
ItemTemplateIDAdapter itemTemplateIdAdapter,
|
||||
CharacterTemplateIDAdapter charIdTemplateAdapter) {
|
||||
CharacterTemplateIDAdapter charIdTemplateAdapter,
|
||||
TeleportationTemplateIDAdapter teleportationIdTemplateAdapter) {
|
||||
this.config = configService.get(XMLTemplateServiceConfiguration.class);
|
||||
this.npcTemplateIdAdapter = npcTemplateIdAdapter;
|
||||
this.itemTemplateIdAdapter = itemTemplateIdAdapter;
|
||||
this.charIdTemplateAdapter = charIdTemplateAdapter;
|
||||
this.teleportationIdTemplateAdapter = teleportationIdTemplateAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws ServiceStartException {
|
||||
try {
|
||||
context = JAXBContext.newInstance(CharacterTemplate.class,
|
||||
NPCTemplate.class, ItemTemplate.class);
|
||||
NPCTemplate.class, ItemTemplate.class,
|
||||
TeleportationTemplate.class);
|
||||
unmarshaller = context.createUnmarshaller();
|
||||
|
||||
unmarshaller.setAdapter(NPCTemplateIDAdapter.class,
|
||||
@@ -82,6 +88,8 @@ public class XMLTemplateService extends AbstractService implements
|
||||
itemTemplateIdAdapter);
|
||||
unmarshaller.setAdapter(CharacterTemplateIDAdapter.class,
|
||||
charIdTemplateAdapter);
|
||||
unmarshaller.setAdapter(TeleportationTemplateIDAdapter.class,
|
||||
teleportationIdTemplateAdapter);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<File> files = FileUtils
|
||||
@@ -97,7 +105,7 @@ public class XMLTemplateService extends AbstractService implements
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Template<?>> T getTemplate(TemplateID<T> id) {
|
||||
public <T extends Template<?>> T getTemplate(TemplateID<T, ?> id) {
|
||||
Preconditions.checkNotNull(id, "id");
|
||||
return (T) templates.get(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user