mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
14
pom.xml
14
pom.xml
@@ -113,6 +113,20 @@
|
|||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.htmlparser</groupId>
|
||||||
|
<artifactId>htmlparser</artifactId>
|
||||||
|
<version>2.1</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.htmlparser</groupId>
|
||||||
|
<artifactId>sitecapturer</artifactId>
|
||||||
|
<version>2.1</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ public class L2JGameServerMain {
|
|||||||
.getInstance(NPCTemplateIDProvider.class);
|
.getInstance(NPCTemplateIDProvider.class);
|
||||||
final NPCIDProvider provider = injector
|
final NPCIDProvider provider = injector
|
||||||
.getInstance(NPCIDProvider.class);
|
.getInstance(NPCIDProvider.class);
|
||||||
final SpawnService spawnService = injector.getInstance(SpawnService.class);
|
final SpawnService spawnService = injector
|
||||||
|
.getInstance(SpawnService.class);
|
||||||
|
|
||||||
final NPCTemplateID id = templateProvider.createID(12077);
|
final NPCTemplateID id = templateProvider.createID(12077);
|
||||||
final NPC npc = id.getTemplate().create();
|
final NPC npc = id.getTemplate().create();
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ import com.l2jserver.game.net.codec.Lineage2Encrypter;
|
|||||||
import com.l2jserver.game.net.codec.Lineage2PacketReader;
|
import com.l2jserver.game.net.codec.Lineage2PacketReader;
|
||||||
import com.l2jserver.game.net.codec.Lineage2PacketWriter;
|
import com.l2jserver.game.net.codec.Lineage2PacketWriter;
|
||||||
import com.l2jserver.game.net.packet.ServerPacket;
|
import com.l2jserver.game.net.packet.ServerPacket;
|
||||||
|
import com.l2jserver.game.net.packet.server.ActionFailedPacket;
|
||||||
|
import com.l2jserver.game.net.packet.server.SystemMessagePacket;
|
||||||
import com.l2jserver.model.id.object.CharacterID;
|
import com.l2jserver.model.id.object.CharacterID;
|
||||||
|
import com.l2jserver.model.template.ItemTemplate;
|
||||||
|
import com.l2jserver.model.world.Item;
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
import com.l2jserver.service.game.world.WorldService;
|
import com.l2jserver.service.game.world.WorldService;
|
||||||
import com.l2jserver.service.game.world.filter.impl.CharacterBroadcastFilter;
|
import com.l2jserver.service.game.world.filter.impl.CharacterBroadcastFilter;
|
||||||
@@ -242,6 +246,71 @@ public class Lineage2Connection {
|
|||||||
return channel.write(packet);
|
return channel.write(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a string message to this client
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* the message
|
||||||
|
* @return the {@link ChannelFuture} that will be notified once the packet
|
||||||
|
* has been written.
|
||||||
|
*/
|
||||||
|
public ChannelFuture sendMessage(String message) {
|
||||||
|
return write(new SystemMessagePacket(SystemMessage.S1)
|
||||||
|
.addString(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@link SystemMessage} to this client
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* the {@link SystemMessage}
|
||||||
|
* @return the {@link ChannelFuture} that will be notified once the packet
|
||||||
|
* has been written.
|
||||||
|
*/
|
||||||
|
public ChannelFuture sendSystemMessage(SystemMessage message) {
|
||||||
|
return write(message.packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@link SystemMessage} to this client
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* the {@link SystemMessage}
|
||||||
|
* @param args
|
||||||
|
* the arguments of the message, they will be automatically
|
||||||
|
* detected and inserted. See {@link SystemMessagePacket} for
|
||||||
|
* more about supported formats.
|
||||||
|
* @return the {@link ChannelFuture} that will be notified once the packet
|
||||||
|
* has been written.
|
||||||
|
* @see SystemMessagePacket
|
||||||
|
*/
|
||||||
|
public ChannelFuture sendSystemMessage(SystemMessage message,
|
||||||
|
Object... args) {
|
||||||
|
final SystemMessagePacket packet = new SystemMessagePacket(message);
|
||||||
|
for (final Object obj : args) {
|
||||||
|
if (obj instanceof String)
|
||||||
|
packet.addString((String) obj);
|
||||||
|
else if (obj instanceof ItemTemplate)
|
||||||
|
packet.addItem((ItemTemplate) obj);
|
||||||
|
else if (obj instanceof Item)
|
||||||
|
packet.addItem((Item) obj);
|
||||||
|
}
|
||||||
|
return write(message.packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a {@link ActionFailedPacket} to the client.
|
||||||
|
* <p>
|
||||||
|
* This is an convenience method for <blockquote><code>
|
||||||
|
* conn.write(ActionFailedPacket.SHARED_INSTANCE);</code></blockquote>
|
||||||
|
*
|
||||||
|
* @return the {@link ChannelFuture} that will be notified once the packet
|
||||||
|
* has been written.
|
||||||
|
*/
|
||||||
|
public ChannelFuture sendActionFailed() {
|
||||||
|
return write(ActionFailedPacket.SHARED_INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast a packet to all characters in this character knownlist.
|
* Broadcast a packet to all characters in this character knownlist.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -261,7 +330,7 @@ public class Lineage2Connection {
|
|||||||
.iterable(new CharacterBroadcastFilter(characterID.getObject()))) {
|
.iterable(new CharacterBroadcastFilter(characterID.getObject()))) {
|
||||||
final Lineage2Connection conn = networkService.discover(character
|
final Lineage2Connection conn = networkService.discover(character
|
||||||
.getID());
|
.getID());
|
||||||
if(conn == null)
|
if (conn == null)
|
||||||
continue;
|
continue;
|
||||||
futures.add(conn.write(packet));
|
futures.add(conn.write(packet));
|
||||||
}
|
}
|
||||||
|
|||||||
15216
src/main/java/com/l2jserver/game/net/SystemMessage.java
Normal file
15216
src/main/java/com/l2jserver/game/net/SystemMessage.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -42,9 +42,6 @@ public class CharacterActionPacket extends AbstractClientPacket {
|
|||||||
*/
|
*/
|
||||||
public static final int OPCODE = 0x1f;
|
public static final int OPCODE = 0x1f;
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
|
||||||
|
|
||||||
private final WorldService worldService;
|
|
||||||
private final ObjectIDResolver idResolver;
|
private final ObjectIDResolver idResolver;
|
||||||
|
|
||||||
private int objectId;
|
private int objectId;
|
||||||
@@ -73,9 +70,7 @@ public class CharacterActionPacket extends AbstractClientPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CharacterActionPacket(WorldService worldService,
|
public CharacterActionPacket(ObjectIDResolver idResolver) {
|
||||||
ObjectIDResolver idResolver) {
|
|
||||||
this.worldService = worldService;
|
|
||||||
this.idResolver = idResolver;
|
this.idResolver = idResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,9 +85,13 @@ public class CharacterActionPacket extends AbstractClientPacket {
|
|||||||
@Override
|
@Override
|
||||||
public void process(final Lineage2Connection conn) {
|
public void process(final Lineage2Connection conn) {
|
||||||
// since this is an erasure type, this is safe.
|
// since this is an erasure type, this is safe.
|
||||||
|
System.out.println(objectId);
|
||||||
final ObjectID<NPC> id = idResolver.resolve(objectId);
|
final ObjectID<NPC> id = idResolver.resolve(objectId);
|
||||||
if (!(id instanceof NPCID))
|
if (!(id instanceof NPCID)) {
|
||||||
|
System.out.println("Incorrect type: " + id);
|
||||||
|
conn.sendActionFailed();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
final NPC npc = id.getObject();
|
final NPC npc = id.getObject();
|
||||||
npc.action(conn.getCharacter(), action);
|
npc.action(conn.getCharacter(), action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,14 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
|||||||
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.AbstractClientPacket;
|
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||||
|
import com.l2jserver.game.net.packet.server.ActionFailedPacket;
|
||||||
|
import com.l2jserver.service.game.chat.ChatMessageDestination;
|
||||||
import com.l2jserver.service.game.chat.ChatService;
|
import com.l2jserver.service.game.chat.ChatService;
|
||||||
import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
import com.l2jserver.service.game.chat.ChatService.CannotChatToSelfChatServiceException;
|
||||||
|
import com.l2jserver.service.game.chat.ChatService.ChatBanActiveChatServiceException;
|
||||||
|
import com.l2jserver.service.game.chat.ChatService.TargetNotFoundChatServiceException;
|
||||||
import com.l2jserver.util.BufferUtils;
|
import com.l2jserver.util.BufferUtils;
|
||||||
|
import com.l2jserver.util.exception.L2ChatServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Completes the creation of an character. Creates the object, inserts into the
|
* Completes the creation of an character. Creates the object, inserts into the
|
||||||
@@ -44,54 +49,7 @@ public class CharacterChatMessagePacket extends AbstractClientPacket {
|
|||||||
private final ChatService chatService;
|
private final ChatService chatService;
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
private MessageDestination destination;
|
private ChatMessageDestination destination;
|
||||||
|
|
||||||
public enum MessageDestination {
|
|
||||||
/**
|
|
||||||
* Everyone
|
|
||||||
*/
|
|
||||||
ALL(0),
|
|
||||||
/**
|
|
||||||
* !
|
|
||||||
*/
|
|
||||||
SHOUT(1),
|
|
||||||
/**
|
|
||||||
* Private message
|
|
||||||
*/
|
|
||||||
TELL(2),
|
|
||||||
/**
|
|
||||||
* #
|
|
||||||
*/
|
|
||||||
PARTY(3),
|
|
||||||
/**
|
|
||||||
* @
|
|
||||||
*/
|
|
||||||
CLAN(4), GM(5), PETITION_PLAYER(6), PETITION_GM(7),
|
|
||||||
/**
|
|
||||||
* +
|
|
||||||
*/
|
|
||||||
TRADE(8),
|
|
||||||
/**
|
|
||||||
* $
|
|
||||||
*/
|
|
||||||
ALLIANCE(9), ANNOUNCEMENT(10), BOAT(11), L2FRIEND(12), MSNCHAT(13), PARTYMATCH_ROOM(
|
|
||||||
14), PARTYROOM_COMMANDER(15), PARTYROOM_ALL(16), HERO_VOICE(17), CRITICAL_ANNOUNCE(
|
|
||||||
18), SCREEN_ANNOUNCE(19), BATTLEFIELD(20), MPCC_ROOM(21);
|
|
||||||
|
|
||||||
public final int id;
|
|
||||||
|
|
||||||
MessageDestination(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MessageDestination fromID(int id) {
|
|
||||||
for (final MessageDestination dest : values()) {
|
|
||||||
if (dest.id == id)
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String target;
|
private String target;
|
||||||
|
|
||||||
@@ -103,16 +61,32 @@ public class CharacterChatMessagePacket extends AbstractClientPacket {
|
|||||||
@Override
|
@Override
|
||||||
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
|
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
this.message = BufferUtils.readString(buffer);
|
this.message = BufferUtils.readString(buffer);
|
||||||
this.destination = MessageDestination.fromID(buffer.readInt());
|
this.destination = ChatMessageDestination.fromID(buffer.readInt());
|
||||||
if (this.destination == MessageDestination.TELL) { // private message
|
if (this.destination == ChatMessageDestination.TELL) { // private
|
||||||
|
// message
|
||||||
this.target = BufferUtils.readString(buffer);
|
this.target = BufferUtils.readString(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(final Lineage2Connection conn) {
|
public void process(final Lineage2Connection conn) {
|
||||||
final PublicChatChannel channel = chatService.getGlobalChannel();
|
if (message.length() == 0 || destination == null) {
|
||||||
// TODO handle chat destination!!!
|
conn.write(ActionFailedPacket.SHARED_INSTANCE);
|
||||||
channel.send(conn.getCharacterID(), message);
|
conn.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
chatService.send(conn.getCharacterID(), destination, message, target);
|
||||||
|
} catch (TargetNotFoundChatServiceException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (CannotChatToSelfChatServiceException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ChatBanActiveChatServiceException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
|||||||
|
|
||||||
import com.l2jserver.game.net.Lineage2Connection;
|
import com.l2jserver.game.net.Lineage2Connection;
|
||||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||||
import com.l2jserver.game.net.packet.client.CharacterChatMessagePacket.MessageDestination;
|
|
||||||
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket.Reason;
|
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket.Reason;
|
||||||
import com.l2jserver.model.world.L2Character;
|
import com.l2jserver.model.world.L2Character;
|
||||||
|
import com.l2jserver.service.game.chat.ChatMessageDestination;
|
||||||
import com.l2jserver.util.BufferUtils;
|
import com.l2jserver.util.BufferUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,12 +42,12 @@ public class ActorChatMessagePacket extends AbstractServerPacket {
|
|||||||
* The selected character
|
* The selected character
|
||||||
*/
|
*/
|
||||||
private final L2Character character;
|
private final L2Character character;
|
||||||
private MessageDestination destination;
|
private ChatMessageDestination destination;
|
||||||
private String message = null;
|
private String message = null;
|
||||||
private int messageID = 0;
|
private int messageID = 0;
|
||||||
|
|
||||||
public ActorChatMessagePacket(L2Character character,
|
public ActorChatMessagePacket(L2Character character,
|
||||||
MessageDestination destination, String message) {
|
ChatMessageDestination destination, String message) {
|
||||||
super(OPCODE);
|
super(OPCODE);
|
||||||
this.character = character;
|
this.character = character;
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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.game.net.packet.server;
|
||||||
|
|
||||||
|
import org.htmlparser.tags.Html;
|
||||||
|
import org.jboss.netty.buffer.ChannelBuffer;
|
||||||
|
|
||||||
|
import com.l2jserver.game.net.Lineage2Connection;
|
||||||
|
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||||
|
import com.l2jserver.model.world.NPC;
|
||||||
|
import com.l2jserver.util.BufferUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This packet sends an HTML message to be displayed in the client.
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class NPCHtmlMessagePacket extends AbstractServerPacket {
|
||||||
|
/**
|
||||||
|
* The packet OPCODE
|
||||||
|
*/
|
||||||
|
public static final int OPCODE = 0x19;
|
||||||
|
|
||||||
|
private final NPC npc;
|
||||||
|
private final Html html;
|
||||||
|
|
||||||
|
public NPCHtmlMessagePacket(NPC npc, Html html) {
|
||||||
|
super(OPCODE);
|
||||||
|
this.npc = npc;
|
||||||
|
this.html = html;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(npc.getID().getID());
|
||||||
|
BufferUtils.writeString(buffer, html.toHtml());
|
||||||
|
buffer.writeInt(0x00); // item id
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
/*
|
||||||
|
* 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.game.net.packet.server;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jboss.netty.buffer.ChannelBuffer;
|
||||||
|
|
||||||
|
import com.l2jserver.game.net.Lineage2Connection;
|
||||||
|
import com.l2jserver.game.net.SystemMessage;
|
||||||
|
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||||
|
import com.l2jserver.model.game.Fort;
|
||||||
|
import com.l2jserver.model.game.Skill;
|
||||||
|
import com.l2jserver.model.template.ItemTemplate;
|
||||||
|
import com.l2jserver.model.template.SkillTemplate;
|
||||||
|
import com.l2jserver.model.world.Item;
|
||||||
|
import com.l2jserver.model.world.capability.Actor;
|
||||||
|
import com.l2jserver.util.BufferUtils;
|
||||||
|
import com.l2jserver.util.factory.CollectionFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This packet sends an System Message to the client. Most messages appear in
|
||||||
|
* the console.
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class SystemMessagePacket extends AbstractServerPacket {
|
||||||
|
/**
|
||||||
|
* The packet OPCODE
|
||||||
|
*/
|
||||||
|
public static final int OPCODE = 0x62;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The System message id
|
||||||
|
*/
|
||||||
|
private int id;
|
||||||
|
/**
|
||||||
|
* The system message parameters
|
||||||
|
*/
|
||||||
|
private List<SystemMessagePacketParameter> params = CollectionFactory
|
||||||
|
.newList();
|
||||||
|
|
||||||
|
public interface SystemMessagePacketParameter {
|
||||||
|
public static final byte TYPE_SYSTEM_STRING = 13;
|
||||||
|
public static final byte TYPE_PLAYER_NAME = 12;
|
||||||
|
// id 11 - unknown
|
||||||
|
public static final byte TYPE_INSTANCE_NAME = 10;
|
||||||
|
public static final byte TYPE_ELEMENT_NAME = 9;
|
||||||
|
// id 8 - same as 3
|
||||||
|
public static final byte TYPE_ZONE_NAME = 7;
|
||||||
|
public static final byte TYPE_ITEM_NUMBER = 6;
|
||||||
|
public static final byte TYPE_CASTLE_NAME = 5;
|
||||||
|
public static final byte TYPE_SKILL_NAME = 4;
|
||||||
|
public static final byte TYPE_ITEM_NAME = 3;
|
||||||
|
public static final byte TYPE_NPC_NAME = 2;
|
||||||
|
public static final byte TYPE_NUMBER = 1;
|
||||||
|
public static final byte TYPE_TEXT = 0;
|
||||||
|
|
||||||
|
void write(Lineage2Connection conn, ChannelBuffer buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance
|
||||||
|
*/
|
||||||
|
public SystemMessagePacket(SystemMessage message) {
|
||||||
|
super(OPCODE);
|
||||||
|
this.id = message.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(id);
|
||||||
|
buffer.writeInt(params.size());
|
||||||
|
for (final SystemMessagePacketParameter param : params) {
|
||||||
|
param.write(conn, buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addString(final String text) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_TEXT);
|
||||||
|
BufferUtils.writeString(buffer, text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Castlename-e.dat<br>
|
||||||
|
* 0-9 Castle names<br>
|
||||||
|
* 21-64 CH names<br>
|
||||||
|
* 81-89 Territory names<br>
|
||||||
|
* 101-121 Fortress names<br>
|
||||||
|
*
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final SystemMessagePacket addFort(final Fort fort) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_CASTLE_NAME);
|
||||||
|
buffer.writeInt(fort.getID().getID());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addNumber(final int number) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_NUMBER);
|
||||||
|
buffer.writeInt(number);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addItemCount(final long number) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_ITEM_NUMBER);
|
||||||
|
buffer.writeLong(number);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addActorName(final Actor actor) {
|
||||||
|
// params.add(new SystemMessagePacketParameter() {
|
||||||
|
// @Override
|
||||||
|
// public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
// // buffer.writeInt(TYPE_TEXT);
|
||||||
|
// // buffer.writeInt(number);
|
||||||
|
// // TODO
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addItem(final ItemTemplate item) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_ITEM_NAME);
|
||||||
|
buffer.writeInt(item.getID().getID());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addItem(final Item item) {
|
||||||
|
return addItem(item.getTemplateID().getTemplate());
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addZoneName(final int x, final int y,
|
||||||
|
final int z) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_ZONE_NAME);
|
||||||
|
buffer.writeInt(x);
|
||||||
|
buffer.writeInt(y);
|
||||||
|
buffer.writeInt(z);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addSkill(final SkillTemplate skill,
|
||||||
|
final int level) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_SKILL_NAME);
|
||||||
|
buffer.writeInt(skill.getID().getID());
|
||||||
|
buffer.writeInt(level);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final SystemMessagePacket addSkill(final Skill skill) {
|
||||||
|
return addSkill(skill.getSkillTemplate(), skill.getLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Elemental name - 0(Fire) ...
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final SystemMessagePacket addElemntal(final int type) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_ELEMENT_NAME);
|
||||||
|
buffer.writeInt(type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID from sysstring-e.dat
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final SystemMessagePacket addSystemString(final int type) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_SYSTEM_STRING);
|
||||||
|
buffer.writeInt(type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instance name from instantzonedata-e.dat
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* id of instance
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public final SystemMessagePacket addInstanceName(final int type) {
|
||||||
|
params.add(new SystemMessagePacketParameter() {
|
||||||
|
@Override
|
||||||
|
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||||
|
buffer.writeInt(TYPE_INSTANCE_NAME);
|
||||||
|
buffer.writeInt(type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ package com.l2jserver.model.template;
|
|||||||
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.client.CharacterActionPacket.CharacterAction;
|
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
|
||||||
|
import com.l2jserver.game.net.packet.server.NPCHtmlMessagePacket;
|
||||||
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.provider.ItemTemplateIDProvider;
|
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
|
||||||
@@ -29,6 +30,9 @@ import com.l2jserver.model.world.capability.Actor;
|
|||||||
import com.l2jserver.service.game.CharacterService;
|
import com.l2jserver.service.game.CharacterService;
|
||||||
import com.l2jserver.service.network.NetworkService;
|
import com.l2jserver.service.network.NetworkService;
|
||||||
import com.l2jserver.util.calculator.Calculator;
|
import com.l2jserver.util.calculator.Calculator;
|
||||||
|
import com.l2jserver.util.html.markup.Markup;
|
||||||
|
import com.l2jserver.util.html.markup.Markup.Builder;
|
||||||
|
import com.l2jserver.util.html.markup.MarkupTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template for {@link NPC}
|
* Template for {@link NPC}
|
||||||
@@ -103,7 +107,19 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> {
|
|||||||
.getID());
|
.getID());
|
||||||
if (conn == null)
|
if (conn == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// target this npc
|
||||||
charService.target(character, npc);
|
charService.target(character, npc);
|
||||||
|
|
||||||
|
// generate not implemented message
|
||||||
|
final Markup markup = new Markup(name + " - Notice", new Builder() {
|
||||||
|
@Override
|
||||||
|
public void build(MarkupTag body) {
|
||||||
|
body.text("This NPC is not yet implemented!");
|
||||||
|
body.addLink("Click me!", "test");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
conn.write(new NPCHtmlMessagePacket(npc, markup.build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package com.l2jserver.service.game;
|
|||||||
|
|
||||||
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.client.CharacterChatMessagePacket.MessageDestination;
|
import com.l2jserver.game.net.SystemMessage;
|
||||||
import com.l2jserver.game.net.packet.server.ActionFailedPacket;
|
import com.l2jserver.game.net.packet.server.ActionFailedPacket;
|
||||||
import com.l2jserver.game.net.packet.server.ActorChatMessagePacket;
|
import com.l2jserver.game.net.packet.server.ActorChatMessagePacket;
|
||||||
import com.l2jserver.game.net.packet.server.ActorMovementPacket;
|
import com.l2jserver.game.net.packet.server.ActorMovementPacket;
|
||||||
@@ -46,6 +46,7 @@ import com.l2jserver.model.world.npc.event.NPCSpawnEvent;
|
|||||||
import com.l2jserver.service.AbstractService;
|
import com.l2jserver.service.AbstractService;
|
||||||
import com.l2jserver.service.AbstractService.Depends;
|
import com.l2jserver.service.AbstractService.Depends;
|
||||||
import com.l2jserver.service.game.ai.AIService;
|
import com.l2jserver.service.game.ai.AIService;
|
||||||
|
import com.l2jserver.service.game.chat.ChatMessageDestination;
|
||||||
import com.l2jserver.service.game.chat.ChatService;
|
import com.l2jserver.service.game.chat.ChatService;
|
||||||
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
||||||
import com.l2jserver.service.game.chat.channel.ChatChannelListener;
|
import com.l2jserver.service.game.chat.channel.ChatChannelListener;
|
||||||
@@ -120,7 +121,15 @@ public class CharacterServiceImpl extends AbstractService implements
|
|||||||
public void onMessage(ChatChannel channel, CharacterID source,
|
public void onMessage(ChatChannel channel, CharacterID source,
|
||||||
String message) {
|
String message) {
|
||||||
conn.write(new ActorChatMessagePacket(source.getObject(),
|
conn.write(new ActorChatMessagePacket(source.getObject(),
|
||||||
MessageDestination.ALL, message));
|
ChatMessageDestination.ALL, message));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final ChatChannelListener tradeChatListener = new ChatChannelListener() {
|
||||||
|
@Override
|
||||||
|
public void onMessage(ChatChannel channel, CharacterID source,
|
||||||
|
String message) {
|
||||||
|
conn.write(new ActorChatMessagePacket(source.getObject(),
|
||||||
|
ChatMessageDestination.TRADE, message));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,7 +167,9 @@ public class CharacterServiceImpl extends AbstractService implements
|
|||||||
// remove chat listeners
|
// remove chat listeners
|
||||||
chatService.getGlobalChannel().removeChatChannelListener(
|
chatService.getGlobalChannel().removeChatChannelListener(
|
||||||
globalChatListener);
|
globalChatListener);
|
||||||
|
chatService.getTradeChannel().removeChatChannelListener(
|
||||||
|
tradeChatListener);
|
||||||
|
|
||||||
// remove broadcast listener
|
// remove broadcast listener
|
||||||
eventDispatcher.removeListener(broadcastListener);
|
eventDispatcher.removeListener(broadcastListener);
|
||||||
|
|
||||||
@@ -170,6 +181,7 @@ public class CharacterServiceImpl extends AbstractService implements
|
|||||||
// register global chat listener
|
// register global chat listener
|
||||||
chatService.getGlobalChannel().addChatChannelListener(
|
chatService.getGlobalChannel().addChatChannelListener(
|
||||||
globalChatListener);
|
globalChatListener);
|
||||||
|
chatService.getTradeChannel().addChatChannelListener(tradeChatListener);
|
||||||
|
|
||||||
// send this user information
|
// send this user information
|
||||||
conn.write(new CharacterInformationPacket(character));
|
conn.write(new CharacterInformationPacket(character));
|
||||||
@@ -177,6 +189,10 @@ public class CharacterServiceImpl extends AbstractService implements
|
|||||||
conn.write(new GameGuardQueryPacket());
|
conn.write(new GameGuardQueryPacket());
|
||||||
conn.write(new CharacterInventoryPacket(character.getInventory()));
|
conn.write(new CharacterInventoryPacket(character.getInventory()));
|
||||||
|
|
||||||
|
conn.sendSystemMessage(SystemMessage.WELCOME_TO_LINEAGE);
|
||||||
|
conn.sendMessage("This an an development version for l2jserver 2.0");
|
||||||
|
conn.sendMessage("Please note that many of the features are not yet implemented.");
|
||||||
|
|
||||||
// characters start in run mode
|
// characters start in run mode
|
||||||
run(character);
|
run(character);
|
||||||
|
|
||||||
@@ -237,6 +253,8 @@ public class CharacterServiceImpl extends AbstractService implements
|
|||||||
eventDispatcher.dispatch(new CharacterTargetSelectedEvent(
|
eventDispatcher.dispatch(new CharacterTargetSelectedEvent(
|
||||||
character, target));
|
character, target));
|
||||||
conn.write(new CharacterTargetSelectedPacket(target));
|
conn.write(new CharacterTargetSelectedPacket(target));
|
||||||
|
} else {
|
||||||
|
conn.sendActionFailed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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.service.game.chat;
|
||||||
|
|
||||||
|
public enum ChatMessageDestination {
|
||||||
|
/**
|
||||||
|
* Everyone
|
||||||
|
*/
|
||||||
|
ALL(0),
|
||||||
|
/**
|
||||||
|
* !
|
||||||
|
*/
|
||||||
|
SHOUT(1),
|
||||||
|
/**
|
||||||
|
* Private message
|
||||||
|
*/
|
||||||
|
TELL(2),
|
||||||
|
/**
|
||||||
|
* #
|
||||||
|
*/
|
||||||
|
PARTY(3),
|
||||||
|
/**
|
||||||
|
* @
|
||||||
|
*/
|
||||||
|
CLAN(4), GM(5), PETITION_PLAYER(6), PETITION_GM(7),
|
||||||
|
/**
|
||||||
|
* +
|
||||||
|
*/
|
||||||
|
TRADE(8),
|
||||||
|
/**
|
||||||
|
* $
|
||||||
|
*/
|
||||||
|
ALLIANCE(9), ANNOUNCEMENT(10), BOAT(11), L2FRIEND(12), MSNCHAT(13), PARTYMATCH_ROOM(
|
||||||
|
14), PARTYROOM_COMMANDER(15), PARTYROOM_ALL(16), HERO_VOICE(17), CRITICAL_ANNOUNCE(
|
||||||
|
18), SCREEN_ANNOUNCE(19), BATTLEFIELD(20), MPCC_ROOM(21);
|
||||||
|
|
||||||
|
public final int id;
|
||||||
|
|
||||||
|
ChatMessageDestination(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ChatMessageDestination fromID(int id) {
|
||||||
|
for (final ChatMessageDestination dest : values()) {
|
||||||
|
if (dest.id == id)
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ import com.l2jserver.service.Service;
|
|||||||
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
||||||
import com.l2jserver.service.game.chat.channel.PrivateChatChannel;
|
import com.l2jserver.service.game.chat.channel.PrivateChatChannel;
|
||||||
import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
||||||
|
import com.l2jserver.util.exception.L2ChatServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service chatting in the server
|
* This service chatting in the server
|
||||||
@@ -30,6 +31,29 @@ import com.l2jserver.service.game.chat.channel.PublicChatChannel;
|
|||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface ChatService extends Service {
|
public interface ChatService extends Service {
|
||||||
|
/**
|
||||||
|
* Sends a message to a public chat channel.
|
||||||
|
*
|
||||||
|
* @param sender
|
||||||
|
* the sender
|
||||||
|
* @param chat
|
||||||
|
* the chat type
|
||||||
|
* @param message
|
||||||
|
* the message
|
||||||
|
* @param extra
|
||||||
|
* the the extra message field
|
||||||
|
* @throws TargetNotFoundChatServiceException
|
||||||
|
* if target object not found
|
||||||
|
* @throws CannotChatToSelfChatServiceException
|
||||||
|
* if trying to send a private message to self
|
||||||
|
* @throws ChatBanActiveChatServiceException
|
||||||
|
* if there is chat ban active
|
||||||
|
*/
|
||||||
|
void send(CharacterID sender, ChatMessageDestination chat, String message,
|
||||||
|
String extra) throws TargetNotFoundChatServiceException,
|
||||||
|
CannotChatToSelfChatServiceException,
|
||||||
|
ChatBanActiveChatServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Global {@link ChatChannel}. Messages sent in this chat are
|
* Get the Global {@link ChatChannel}. Messages sent in this chat are
|
||||||
* broadcasted to everyone online.
|
* broadcasted to everyone online.
|
||||||
@@ -38,6 +62,22 @@ public interface ChatService extends Service {
|
|||||||
*/
|
*/
|
||||||
PublicChatChannel getGlobalChannel();
|
PublicChatChannel getGlobalChannel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Trade {@link ChatChannel}. Messages sent in this chat are
|
||||||
|
* broadcasted to everyone online.
|
||||||
|
*
|
||||||
|
* @return the trade {@link ChatChannel}
|
||||||
|
*/
|
||||||
|
PublicChatChannel getTradeChannel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Announcement {@link ChatChannel}. Messages sent in this chat are
|
||||||
|
* broadcasted to everyone online.
|
||||||
|
*
|
||||||
|
* @return the announcement {@link ChatChannel}
|
||||||
|
*/
|
||||||
|
PublicChatChannel getAnnouncementChannel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Region {@link ChatChannel}. Messages sent in this chat are
|
* Get the Region {@link ChatChannel}. Messages sent in this chat are
|
||||||
* broadcasted to everyone nearby.
|
* broadcasted to everyone nearby.
|
||||||
@@ -69,4 +109,19 @@ public interface ChatService extends Service {
|
|||||||
PublicChatChannel getChannel(ClanID clan);
|
PublicChatChannel getChannel(ClanID clan);
|
||||||
|
|
||||||
// TODO party chat
|
// TODO party chat
|
||||||
|
|
||||||
|
public class TargetNotFoundChatServiceException extends
|
||||||
|
L2ChatServiceException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CannotChatToSelfChatServiceException extends
|
||||||
|
L2ChatServiceException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ChatBanActiveChatServiceException extends
|
||||||
|
L2ChatServiceException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.l2jserver.db.dao.CharacterDAO;
|
||||||
import com.l2jserver.model.id.object.CharacterID;
|
import com.l2jserver.model.id.object.CharacterID;
|
||||||
import com.l2jserver.model.id.object.ClanID;
|
import com.l2jserver.model.id.object.ClanID;
|
||||||
import com.l2jserver.model.world.Clan;
|
import com.l2jserver.model.world.Clan;
|
||||||
@@ -42,12 +43,27 @@ import com.l2jserver.util.factory.CollectionFactory;
|
|||||||
*/
|
*/
|
||||||
// @Depends(RegionService.class)
|
// @Depends(RegionService.class)
|
||||||
public class SimpleChatService extends AbstractService implements ChatService {
|
public class SimpleChatService extends AbstractService implements ChatService {
|
||||||
|
/**
|
||||||
|
* The {@link RegionService}
|
||||||
|
*/
|
||||||
private final RegionService regionService;
|
private final RegionService regionService;
|
||||||
|
/**
|
||||||
|
* The {@link L2Character} DAO
|
||||||
|
*/
|
||||||
|
private final CharacterDAO charDao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The global chat channel
|
* The global {@link ChatChannel}
|
||||||
*/
|
*/
|
||||||
private GlobalChatChannelImpl global;
|
private GlobalChatChannelImpl global;
|
||||||
|
/**
|
||||||
|
* The trade {@link ChatChannel}
|
||||||
|
*/
|
||||||
|
private TradeChatChannelImpl trade;
|
||||||
|
/**
|
||||||
|
* The announcement {@link ChatChannel}
|
||||||
|
*/
|
||||||
|
private AnnouncementChatChannelImpl announcement;
|
||||||
/**
|
/**
|
||||||
* The list of private chat channels
|
* The list of private chat channels
|
||||||
*/
|
*/
|
||||||
@@ -70,24 +86,70 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
|||||||
* the region service
|
* the region service
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public SimpleChatService() {
|
public SimpleChatService(CharacterDAO charDao) {
|
||||||
// this.regionService = regionService;
|
// this.regionService = regionService;
|
||||||
this.regionService = null;
|
this.regionService = null;
|
||||||
|
this.charDao = charDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws ServiceStartException {
|
protected void doStart() throws ServiceStartException {
|
||||||
this.global = new GlobalChatChannelImpl();
|
this.global = new GlobalChatChannelImpl();
|
||||||
|
this.trade = new TradeChatChannelImpl();
|
||||||
|
this.announcement = new AnnouncementChatChannelImpl();
|
||||||
this.privateChannels = CollectionFactory.newMap();
|
this.privateChannels = CollectionFactory.newMap();
|
||||||
this.clanChannels = CollectionFactory.newMap();
|
this.clanChannels = CollectionFactory.newMap();
|
||||||
this.regionChannels = CollectionFactory.newMap();
|
this.regionChannels = CollectionFactory.newMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void send(CharacterID sender, ChatMessageDestination chat,
|
||||||
|
String message, String extra)
|
||||||
|
throws TargetNotFoundChatServiceException,
|
||||||
|
CannotChatToSelfChatServiceException {
|
||||||
|
final ChatChannel channel;
|
||||||
|
switch (chat) {
|
||||||
|
case ALL:
|
||||||
|
channel = getGlobalChannel();
|
||||||
|
break;
|
||||||
|
case TRADE:
|
||||||
|
channel = getTradeChannel();
|
||||||
|
break;
|
||||||
|
case CLAN:
|
||||||
|
channel = getChannel(sender.getObject().getClanID());
|
||||||
|
break;
|
||||||
|
case TELL:
|
||||||
|
final L2Character character = charDao.selectByName(extra);
|
||||||
|
if (character == null)
|
||||||
|
throw new TargetNotFoundChatServiceException();
|
||||||
|
if (character.equals(sender))
|
||||||
|
throw new CannotChatToSelfChatServiceException();
|
||||||
|
channel = getChannel(character.getID());
|
||||||
|
break;
|
||||||
|
case ANNOUNCEMENT:
|
||||||
|
channel = getAnnouncementChannel();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
channel.send(sender, message);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PublicChatChannel getGlobalChannel() {
|
public PublicChatChannel getGlobalChannel() {
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PublicChatChannel getTradeChannel() {
|
||||||
|
return trade;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PublicChatChannel getAnnouncementChannel() {
|
||||||
|
return announcement;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PublicChatChannel getRegionChannel(L2Character character) {
|
public PublicChatChannel getRegionChannel(L2Character character) {
|
||||||
final Region region = regionService.getRegion(character);
|
final Region region = regionService.getRegion(character);
|
||||||
@@ -101,6 +163,8 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PrivateChatChannel getChannel(CharacterID character) {
|
public PrivateChatChannel getChannel(CharacterID character) {
|
||||||
|
if (character == null)
|
||||||
|
return null;
|
||||||
PrivateChatChannelImpl channel = privateChannels.get(character);
|
PrivateChatChannelImpl channel = privateChannels.get(character);
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
channel = new PrivateChatChannelImpl(character);
|
channel = new PrivateChatChannelImpl(character);
|
||||||
@@ -111,6 +175,8 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PublicChatChannel getChannel(ClanID clan) {
|
public PublicChatChannel getChannel(ClanID clan) {
|
||||||
|
if (clan == null)
|
||||||
|
return null;
|
||||||
ClanChatChannelImpl channel = clanChannels.get(clan);
|
ClanChatChannelImpl channel = clanChannels.get(clan);
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
channel = new ClanChatChannelImpl(clan);
|
channel = new ClanChatChannelImpl(clan);
|
||||||
@@ -171,13 +237,13 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharacterID getTarget() {
|
public CharacterID getDestination() {
|
||||||
return character;
|
return character;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global {@link PublicChatChannel} implemenetation
|
* Global {@link PublicChatChannel} implementation
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
@@ -186,7 +252,25 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link PublicChatChannel} implemenetation for {@link Clan clans}
|
* Trade {@link PublicChatChannel} implementation
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
private class TradeChatChannelImpl extends ChatChannelImpl implements
|
||||||
|
PublicChatChannel {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Announcement {@link PublicChatChannel} implementation
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
private class AnnouncementChatChannelImpl extends ChatChannelImpl implements
|
||||||
|
PublicChatChannel {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link PublicChatChannel} implementation for {@link Clan clans}
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
@@ -209,7 +293,7 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link PublicChatChannel} implemenetation for {@link Region regions}
|
* {@link PublicChatChannel} implementation for {@link Region regions}
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ import com.l2jserver.model.id.object.CharacterID;
|
|||||||
* An private {@link ChatChannel}. Please note that the concept of "private"
|
* An private {@link ChatChannel}. Please note that the concept of "private"
|
||||||
* does not mean it requires a password or something like that to join, but the
|
* does not mean it requires a password or something like that to join, but the
|
||||||
* message is only broadcasted to a single character (i.e. private messages).
|
* message is only broadcasted to a single character (i.e. private messages).
|
||||||
* The target can be retrieved by {@link #getTarget()}.
|
* The destination can be retrieved by {@link #getDestination()}.
|
||||||
*
|
*
|
||||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
*/
|
*/
|
||||||
public interface PrivateChatChannel extends ChatChannel {
|
public interface PrivateChatChannel extends ChatChannel {
|
||||||
/**
|
/**
|
||||||
* @return the target of this private chat channel.
|
* @return the destination of this private chat channel.
|
||||||
*/
|
*/
|
||||||
CharacterID getTarget();
|
CharacterID getDestination();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class CachedWorldIDService extends AbstractService implements
|
|||||||
cache = new Cache(new CacheConfiguration("id-cache",
|
cache = new Cache(new CacheConfiguration("id-cache",
|
||||||
IDAllocator.ALLOCABLE_IDS)
|
IDAllocator.ALLOCABLE_IDS)
|
||||||
.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
|
.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
|
||||||
.overflowToDisk(true).eternal(false).timeToLiveSeconds(60)
|
.overflowToDisk(true).eternal(true).timeToLiveSeconds(60)
|
||||||
.timeToIdleSeconds(30).diskPersistent(false)
|
.timeToIdleSeconds(30).diskPersistent(false)
|
||||||
.diskExpiryThreadIntervalSeconds(0));
|
.diskExpiryThreadIntervalSeconds(0));
|
||||||
cacheService.register(cache);
|
cacheService.register(cache);
|
||||||
@@ -113,6 +113,7 @@ public class CachedWorldIDService extends AbstractService implements
|
|||||||
public <I extends ObjectID<?>> void add(I id) {
|
public <I extends ObjectID<?>> void add(I id) {
|
||||||
if(id == null)
|
if(id == null)
|
||||||
return;
|
return;
|
||||||
|
System.out.println("Registering ID: "+id);
|
||||||
cache.put(new Element(id.getID(), id));
|
cache.put(new Element(id.getID(), id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class L2ChatServiceException extends L2ServiceException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2ChatServiceException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public L2ChatServiceException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public L2ChatServiceException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public L2ChatServiceException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base exception for Lineage 2
|
||||||
|
*
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class L2ServiceException extends Exception {
|
||||||
|
/**
|
||||||
|
* Default Serial Version UID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Exception#Exception()
|
||||||
|
*/
|
||||||
|
public L2ServiceException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Exception#Exception(String, Throwable)
|
||||||
|
*/
|
||||||
|
public L2ServiceException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Exception#Exception(String)
|
||||||
|
*/
|
||||||
|
public L2ServiceException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Exception#Exception(Throwable)
|
||||||
|
*/
|
||||||
|
public L2ServiceException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/main/java/com/l2jserver/util/html/L2BodyTag.java
Normal file
38
src/main/java/com/l2jserver/util/html/L2BodyTag.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.BodyTag;
|
||||||
|
import org.htmlparser.util.NodeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class L2BodyTag extends BodyTag {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2BodyTag() {
|
||||||
|
super.setTagName("body");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/body");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setChildren(new NodeList());
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/main/java/com/l2jserver/util/html/L2BrTag.java
Normal file
37
src/main/java/com/l2jserver/util/html/L2BrTag.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.Span;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class L2BrTag extends Span {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2BrTag() {
|
||||||
|
super.setTagName("br");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/br");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setEmptyXmlTag(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
src/main/java/com/l2jserver/util/html/L2CenterTag.java
Normal file
36
src/main/java/com/l2jserver/util/html/L2CenterTag.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.Span;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class L2CenterTag extends Span {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2CenterTag() {
|
||||||
|
super.setTagName("center");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/center");
|
||||||
|
super.setEndTag(end);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/main/java/com/l2jserver/util/html/L2DivTag.java
Normal file
38
src/main/java/com/l2jserver/util/html/L2DivTag.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.Div;
|
||||||
|
import org.htmlparser.util.NodeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class L2DivTag extends Div {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2DivTag() {
|
||||||
|
super.setTagName("div");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/div");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setChildren(new NodeList());
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/main/java/com/l2jserver/util/html/L2FontTag.java
Normal file
38
src/main/java/com/l2jserver/util/html/L2FontTag.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.Span;
|
||||||
|
import org.htmlparser.util.NodeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class L2FontTag extends Span {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2FontTag() {
|
||||||
|
super.setTagName("font");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/font");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setChildren(new NodeList());
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/main/java/com/l2jserver/util/html/L2HeadTag.java
Normal file
37
src/main/java/com/l2jserver/util/html/L2HeadTag.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.HeadTag;
|
||||||
|
import org.htmlparser.util.NodeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class L2HeadTag extends HeadTag {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2HeadTag() {
|
||||||
|
super.setTagName("head");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/head");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setChildren(new NodeList());
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/main/java/com/l2jserver/util/html/L2HtmlTag.java
Normal file
38
src/main/java/com/l2jserver/util/html/L2HtmlTag.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.Html;
|
||||||
|
import org.htmlparser.util.NodeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class L2HtmlTag extends Html {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2HtmlTag() {
|
||||||
|
super.setTagName("html");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/html");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setChildren(new NodeList());
|
||||||
|
}
|
||||||
|
}
|
||||||
36
src/main/java/com/l2jserver/util/html/L2ImageTag.java
Normal file
36
src/main/java/com/l2jserver/util/html/L2ImageTag.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.ImageTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class L2ImageTag extends ImageTag {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2ImageTag() {
|
||||||
|
super.setTagName("img");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/img");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setEmptyXmlTag(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/main/java/com/l2jserver/util/html/L2LinkTag.java
Normal file
38
src/main/java/com/l2jserver/util/html/L2LinkTag.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.LinkTag;
|
||||||
|
import org.htmlparser.util.NodeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class L2LinkTag extends LinkTag {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2LinkTag() {
|
||||||
|
super.setTagName("a");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/a");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setChildren(new NodeList());
|
||||||
|
super.setEmptyXmlTag(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/main/java/com/l2jserver/util/html/L2NewLineTag.java
Normal file
37
src/main/java/com/l2jserver/util/html/L2NewLineTag.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.Span;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class L2NewLineTag extends Span {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2NewLineTag() {
|
||||||
|
super.setTagName("p");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/pp");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setEmptyXmlTag(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/main/java/com/l2jserver/util/html/L2TitleTag.java
Normal file
37
src/main/java/com/l2jserver/util/html/L2TitleTag.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.html;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TagNode;
|
||||||
|
import org.htmlparser.tags.TitleTag;
|
||||||
|
import org.htmlparser.util.NodeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*/
|
||||||
|
public class L2TitleTag extends TitleTag {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public L2TitleTag() {
|
||||||
|
super.setTagName("title");
|
||||||
|
Tag end = new TagNode();
|
||||||
|
end.setTagName("/title");
|
||||||
|
super.setEndTag(end);
|
||||||
|
super.setChildren(new NodeList());
|
||||||
|
}
|
||||||
|
}
|
||||||
57
src/main/java/com/l2jserver/util/html/markup/Markup.java
Normal file
57
src/main/java/com/l2jserver/util/html/markup/Markup.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.html.markup;
|
||||||
|
|
||||||
|
import org.htmlparser.nodes.TextNode;
|
||||||
|
import org.htmlparser.tags.HeadTag;
|
||||||
|
import org.htmlparser.tags.Html;
|
||||||
|
import org.htmlparser.tags.TitleTag;
|
||||||
|
|
||||||
|
import com.l2jserver.util.html.L2HeadTag;
|
||||||
|
import com.l2jserver.util.html.L2HtmlTag;
|
||||||
|
import com.l2jserver.util.html.L2TitleTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Markup {
|
||||||
|
private final Builder builder;
|
||||||
|
private final String title;
|
||||||
|
|
||||||
|
public Markup(String title, Builder builder) {
|
||||||
|
this.builder = builder;
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Html build() {
|
||||||
|
final Html html = new L2HtmlTag();
|
||||||
|
final HeadTag head = new L2HeadTag();
|
||||||
|
final TitleTag title = new L2TitleTag();
|
||||||
|
|
||||||
|
head.getChildren().add(head);
|
||||||
|
head.getChildren().add(title);
|
||||||
|
title.getChildren().add(new TextNode(this.title));
|
||||||
|
|
||||||
|
this.builder.build(new MarkupTag(html));
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Builder {
|
||||||
|
void build(MarkupTag body);
|
||||||
|
}
|
||||||
|
}
|
||||||
123
src/main/java/com/l2jserver/util/html/markup/MarkupTag.java
Normal file
123
src/main/java/com/l2jserver/util/html/markup/MarkupTag.java
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
* 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.html.markup;
|
||||||
|
|
||||||
|
import org.htmlparser.Tag;
|
||||||
|
import org.htmlparser.nodes.TextNode;
|
||||||
|
|
||||||
|
import com.l2jserver.util.html.L2BrTag;
|
||||||
|
import com.l2jserver.util.html.L2CenterTag;
|
||||||
|
import com.l2jserver.util.html.L2DivTag;
|
||||||
|
import com.l2jserver.util.html.L2FontTag;
|
||||||
|
import com.l2jserver.util.html.L2ImageTag;
|
||||||
|
import com.l2jserver.util.html.L2LinkTag;
|
||||||
|
import com.l2jserver.util.html.L2NewLineTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MarkupTag {
|
||||||
|
private final Tag tag;
|
||||||
|
private final MarkupTag parent;
|
||||||
|
|
||||||
|
public MarkupTag(Tag tag, MarkupTag parent) {
|
||||||
|
this.tag = tag;
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag(Tag tag) {
|
||||||
|
this(tag, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag attr(String name, String value) {
|
||||||
|
tag.setAttribute(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag text(String text) {
|
||||||
|
tag.getChildren().add(new TextNode(text));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag text(String text, String color) {
|
||||||
|
final Tag font = new L2FontTag();
|
||||||
|
font.setAttribute("color", color);
|
||||||
|
font.getChildren().add(new TextNode(text));
|
||||||
|
this.tag.getChildren().add(font);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag div() {
|
||||||
|
final Tag tag = new L2DivTag();
|
||||||
|
this.tag.getChildren().add(tag);
|
||||||
|
return new MarkupTag(tag, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag br() {
|
||||||
|
final Tag tag = new L2BrTag();
|
||||||
|
this.tag.getChildren().add(tag);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag p() {
|
||||||
|
final Tag tag = new L2NewLineTag();
|
||||||
|
this.tag.getChildren().add(tag);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag center() {
|
||||||
|
final Tag tag = new L2CenterTag();
|
||||||
|
this.tag.getChildren().add(tag);
|
||||||
|
return new MarkupTag(this.tag, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag addImage(String src, int height, int width) {
|
||||||
|
final Tag tag = new L2ImageTag();
|
||||||
|
this.tag.getChildren().add(tag);
|
||||||
|
tag.setAttribute("height", Integer.toString(height));
|
||||||
|
tag.setAttribute("width", Integer.toString(width));
|
||||||
|
tag.setAttribute("src", src);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag addLink(String text, String action) {
|
||||||
|
final Tag tag = new L2LinkTag();
|
||||||
|
this.tag.getChildren().add(tag);
|
||||||
|
tag.setAttribute("action", "bypass -h " + action);
|
||||||
|
tag.getChildren().add(new TextNode(text));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarkupTag close() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tag
|
||||||
|
*/
|
||||||
|
public Tag getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the parent
|
||||||
|
*/
|
||||||
|
public MarkupTag getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user