1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-06 07:32:46 +00:00

Change-Id: Ie09760fc3cc7b8d2cae93aa433e1e2cf684c8ae3

This commit is contained in:
rogiel
2011-04-30 07:54:49 -03:00
parent f454e3c35a
commit 8984654ed5
12 changed files with 237 additions and 189 deletions

View File

@@ -1,6 +1,8 @@
package com.l2jserver;
import com.google.inject.AbstractModule;
import com.l2jserver.db.dao.mysql5.DAOModuleMySQL5;
import com.l2jserver.model.id.factory.IDFactoryModule;
import com.l2jserver.routines.GameServerInitializationRoutine;
import com.l2jserver.service.BasicServiceModule;
import com.l2jserver.service.ServiceModule;
@@ -10,6 +12,8 @@ public class GameServerModule extends AbstractModule {
protected void configure() {
install(new BasicServiceModule());
install(new ServiceModule());
install(new IDFactoryModule());
install(new DAOModuleMySQL5());
// routines
bind(GameServerInitializationRoutine.class);

View File

@@ -9,9 +9,9 @@ import org.jboss.netty.logging.InternalLogLevel;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.l2jserver.game.net.codec.Lineage2Decoder;
import com.l2jserver.game.net.codec.Lineage2FrameDecoder;
import com.l2jserver.game.net.codec.Lineage2Decrypter;
import com.l2jserver.game.net.codec.Lineage2Encoder;
import com.l2jserver.game.net.codec.Lineage2FrameEncoder;
import com.l2jserver.game.net.codec.Lineage2Encrypter;
import com.l2jserver.game.net.codec.Lineage2PacketReader;
import com.l2jserver.game.net.codec.Lineage2PacketWriter;
@@ -30,8 +30,8 @@ public class Lineage2PipelineFactory implements ChannelPipelineFactory {
public ChannelPipeline getPipeline() throws Exception {
final ChannelPipeline pipeline = pipeline();
pipeline.addLast("header.encoder", new Lineage2Encoder());
pipeline.addLast("header.decoder", new Lineage2Decoder());
pipeline.addLast("frame.encoder", new Lineage2FrameEncoder());
pipeline.addLast("frame.decoder", new Lineage2FrameDecoder());
pipeline.addLast(Lineage2Encrypter.HANDLER_NAME,
new Lineage2Encrypter());

View File

@@ -14,7 +14,7 @@ public class Lineage2Decrypter extends OneToOneDecoder {
private final byte[] key = new byte[16];
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel,
protected synchronized Object decode(ChannelHandlerContext ctx, Channel channel,
Object msg) throws Exception {
if (!(msg instanceof ChannelBuffer))
return msg;
@@ -22,8 +22,6 @@ public class Lineage2Decrypter extends OneToOneDecoder {
return msg;
final ChannelBuffer buffer = (ChannelBuffer) msg;
System.out.println("Decrypting...");
final int offset = buffer.readerIndex();
final int size = buffer.readableBytes();
int temp = 0;

View File

@@ -1,14 +1,11 @@
package com.l2jserver.game.net.codec;
import java.util.Arrays;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
import com.l2jserver.util.BlowFishKeygen;
public class Lineage2Encrypter extends OneToOneEncoder {
public static final String HANDLER_NAME = "crypto.encoder";
@@ -16,7 +13,7 @@ public class Lineage2Encrypter extends OneToOneEncoder {
private final byte[] key = new byte[16];
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel,
protected synchronized Object encode(ChannelHandlerContext ctx, Channel channel,
Object msg) throws Exception {
if (!(msg instanceof ChannelBuffer))
return msg;
@@ -24,13 +21,13 @@ public class Lineage2Encrypter extends OneToOneEncoder {
return msg;
final ChannelBuffer buffer = (ChannelBuffer) msg;
System.out.println("Encrypting...");
System.out.println(ChannelBuffers.hexDump(buffer));
final int offset = buffer.readerIndex();
final int size = buffer.readableBytes();
final int offset = buffer.readerIndex() + 2; //skip header
final int size = buffer.readableBytes() - 2;
int temp = 0;
for (int i = 0; i < size; i++) {
int temp2 = buffer.getUnsignedByte(offset + i);
int temp2 = buffer.getUnsignedByte(offset + i) & 0xFF;
buffer.setByte(offset + i, (byte) (temp2 ^ key[i & 15] ^ temp));
temp = temp2;
}

View File

@@ -8,7 +8,7 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
public class Lineage2Decoder extends FrameDecoder {
public class Lineage2FrameDecoder extends FrameDecoder {
private static final int HEADER_SIZE = 2;
@Override
@@ -21,7 +21,6 @@ public class Lineage2Decoder extends FrameDecoder {
buffer.markReaderIndex();
final int pending = buffer.readUnsignedShort() - HEADER_SIZE;
System.out.println(ChannelBuffers.hexDump(buffer));
if (pending == 0) {
return null;
}

View File

@@ -1,11 +1,12 @@
package com.l2jserver.game.net.codec;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
public class Lineage2Encoder extends OneToOneEncoder {
public class Lineage2FrameEncoder extends OneToOneEncoder {
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel,
Object msg) throws Exception {
@@ -13,6 +14,9 @@ public class Lineage2Encoder extends OneToOneEncoder {
return msg;
final ChannelBuffer buffer = (ChannelBuffer) msg;
buffer.setShort(0, buffer.readableBytes() - 2);
System.out.println(ChannelBuffers.hexDump(buffer));
return buffer;
}
}

View File

@@ -8,6 +8,7 @@ import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.l2jserver.game.net.packet.ClientPacket;
import com.l2jserver.game.net.packet.client.AuthLoginPacket;
import com.l2jserver.game.net.packet.client.ProtocolVersionPacket;
import com.l2jserver.service.logging.Logger;
import com.l2jserver.service.logging.LoggingService;
@@ -36,6 +37,8 @@ public class Lineage2PacketReader extends OneToOneDecoder {
}
private ClientPacket createPacket(Class<? extends ClientPacket> type) {
if (type == null)
return null;
return injector.getInstance(type);
}
@@ -44,6 +47,8 @@ public class Lineage2PacketReader extends OneToOneDecoder {
switch (opcode) {
case ProtocolVersionPacket.OPCODE:
return ProtocolVersionPacket.class;
case AuthLoginPacket.OPCODE:
return AuthLoginPacket.class;
default:
logger.info("Unknown opcode: " + Integer.toHexString(opcode));
break;

View File

@@ -1,19 +1,23 @@
package com.l2jserver.game.net.packet.client;
import java.nio.charset.Charset;
import org.jboss.netty.buffer.ChannelBuffer;
import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.game.net.packet.server.CharSelectionInfoPacket;
import com.l2jserver.model.id.factory.CharacterIDFactory;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.util.BufferUtil;
public class AuthLoginPacket extends AbstractClientPacket {
public static final int OPCODE = 0x0e;
public static final int OPCODE = 0x2b;
@Inject
private WorldService world;
@Inject
private CharacterIDFactory idFactory;
// packet
private String loginName;
@@ -24,8 +28,8 @@ public class AuthLoginPacket extends AbstractClientPacket {
@Override
public void read(ChannelBuffer buffer) {
this.loginName = buffer.readBytes(buffer.bytesBefore((byte) 0x00))
.toString(Charset.defaultCharset());
this.loginName = BufferUtil.readString(buffer);
System.out.println(loginName);
this.playKey1 = buffer.readInt();
this.playKey2 = buffer.readInt();
this.loginKey1 = buffer.readInt();
@@ -36,7 +40,9 @@ public class AuthLoginPacket extends AbstractClientPacket {
public void process(final Lineage2Connection conn) {
// assume it is correct, for now
// send character list
world.getEventDispatcher().dispatch(null);
// world.getEventDispatcher().dispatch(null);
final L2Character c = idFactory.createID(268435456).getObject();
conn.write(new CharSelectionInfoPacket(loginName, playKey1, -1, c));
}
/**

View File

@@ -4,183 +4,164 @@ import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.packet.AbstractServerPacket;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.util.BufferUtil;
public class CharSelectionInfoPacket extends AbstractServerPacket {
public static final int OPCODE = 0x09;
private final String loginName;
private final int sessionId;
private final int activeId;
private int lastCharacterId;
private final L2Character[] characters;
public CharSelectionInfoPacket(int opcode, String loginName, int sessionId,
int activeId, L2Character... characters) {
super(opcode);
public CharSelectionInfoPacket(String loginName, int sessionId,
int lastCharacterId, L2Character... characters) {
super(OPCODE);
this.loginName = loginName;
this.sessionId = sessionId;
this.activeId = activeId;
this.lastCharacterId = lastCharacterId;
this.characters = characters;
}
@Override
public void write(ChannelBuffer buffer) {
// buffer.writeByte(0x09);
// int size = (characters.length);
// buffer.writeInt(size);
//
// // Can prevent players from creating new characters (if 0); (if 1,
buffer.writeInt(characters.length);
// Can prevent players from creating new characters (if 0); (if 1,
// the client will ask if chars may be created (0x13) Response: (0x0D) )
// buffer.writeInt(0x07);
// buffer.writeByte(0x00);
//
// long lastAccess = 0L;
//
// // if (activeId == -1) {
// // for (int i = 0; i < size; i++) {
// // if (lastAccess < characters[i].getLastAccess()) {
// // lastAccess = characters[i].getLastAccess();
// // _activeId = i;
// // }
// // }
// // }
//
// for (int i = 0; i < size; i++)
// {
// Character character = characters[i];
//
// buffer.writeBytes(character.getName());
// buffer.writeInt(character.getCharId());
// writeS(_loginName);
// buffer.writeInt(_sessionId);
// buffer.writeInt(character.getClanId());
// buffer.writeInt(0x00); // ??
//
// buffer.writeInt(character.getSex());
// buffer.writeInt(character.getRace());
//
// if (character.getClassId() == character.getBaseClassId())
// buffer.writeInt(character.getClassId());
// else
// buffer.writeInt(character.getBaseClassId());
//
// buffer.writeInt(0x01); // active ??
//
// buffer.writeInt(character.getX()); // x
// buffer.writeInt(character.getY()); // y
// buffer.writeInt(character.getZ()); // z
//
// buffer.writeDouble(character.getCurrentHp()); // hp cur
// buffer.writeDouble(character.getCurrentMp()); // mp cur
//
// buffer.writeInt(character.getSp());
// writeQ(character.getExp());
// buffer.writeInt(character.getLevel());
//
// buffer.writeInt(character.getKarma()); // karma
// buffer.writeInt(character.getPkKills());
//
// buffer.writeInt(character.getPvPKills());
// buffer.writeInt(0x00);
// buffer.writeInt(0x00);
// buffer.writeInt(0x00);
// buffer.writeInt(0x00);
// buffer.writeInt(0x00);
// buffer.writeInt(0x00);
// buffer.writeInt(0x00);
//
//
// for(int id = 0; id <27; id++) {
// buffer.writeInt(0x00);
// }
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_REAR));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_NECK));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_CLOAK));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LBRACELET));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO1));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO2));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO3));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO4));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO5));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO6));
// //
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_BELT));
//
// buffer.writeInt(character.getHairStyle());
// buffer.writeInt(character.getHairColor());
// buffer.writeInt(character.getFace());
//
// buffer.writeDouble(character.getMaxHp()); // hp max
// buffer.writeDouble(character.getMaxMp()); // mp max
//
// long deleteTime = character.getDeleteTimer();
// int deletedays = 0;
// if (deleteTime > 0)
// deletedays = (int)((deleteTime-System.currentTimeMillis())/1000);
// buffer.writeInt(deletedays); // days left before
// // delete .. if != 0
// // then char is inactive
// buffer.writeInt(character.getClassId());
// if (i == _activeId)
// buffer.writeInt(0x01);
// else
// buffer.writeInt(0x00); //c3 auto-select char
//
// buffer.writeByte(character.getEnchantEffect() > 127 ? 127 :
// character.getEnchantEffect());
//
// buffer.writeInt(character.getAugmentationId());
//
// //buffer.writeInt(charInfoPackage.getTransformId()); // Used to
// display Transformations
// buffer.writeInt(0x00); // Currently on retail when you are on
// character select you don't see your transformation.
//
// // Freya by Vistall:
// buffer.writeInt(0); // npdid - 16024 Tame Tiny Baby Kookaburra A9E89C
// buffer.writeInt(0); // level
// buffer.writeInt(0); // ?
// buffer.writeInt(0); // food? - 1200
// buffer.writeDouble(0); // max Hp
// buffer.writeDouble(0); // cur Hp
buffer.writeInt(0x07);
buffer.writeByte(0x00);
long lastAccess = 0L;
if (lastCharacterId == -1) {
for (int i = 0; i < characters.length; i++) {
if (characters[i].getLastAccess() == null)
continue;
if (lastAccess < characters[i].getLastAccess().getTime()) {
lastAccess = characters[i].getLastAccess().getTime();
lastCharacterId = i;
}
}
}
int i = 0;
for (final L2Character character : characters) {
// buffer.writeBytes(character.getName().getBytes());
// buffer.writeByte(0x00); // NULL termination
BufferUtil.writeString(buffer, character.getName());
buffer.writeInt(character.getID().getID());
BufferUtil.writeString(buffer, loginName);
// buffer.writeBytes(loginName.getBytes());
// buffer.writeByte(0x00); // NULL termination
buffer.writeInt(sessionId);
if (character.getClanID() == null) {
buffer.writeInt(0x00); // clan id
} else {
buffer.writeInt(character.getClanID().getID()); // clan id
}
buffer.writeInt(0x00); // ??
buffer.writeInt(0x00); // sex
buffer.writeInt(0x00); // race
// if (character.getClassId() == character.getBaseClassId())
buffer.writeInt(0x00);
// else
// buffer.writeInt(character.getBaseClassId());
buffer.writeInt(0x01); // active ??
buffer.writeInt(-71338); // x
buffer.writeInt(258271); // y
buffer.writeInt(-3104); // z
buffer.writeDouble(20); // hp cur
buffer.writeDouble(20); // mp cur
buffer.writeInt(3000); // sp
buffer.writeLong(0); // exp
buffer.writeInt(0x01); // level
buffer.writeInt(0x00); // karma
buffer.writeInt(0x00); // pk
buffer.writeInt(0x00); // pvp
buffer.writeInt(0x00);
buffer.writeInt(0x00);
buffer.writeInt(0x00);
buffer.writeInt(0x00);
buffer.writeInt(0x00);
buffer.writeInt(0x00);
buffer.writeInt(0x00);
for (int id = 0; id < 26; id++) {
buffer.writeInt(0x00); // paperdolls
}
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_REAR));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_NECK));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_CLOAK));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_LBRACELET));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO1));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO2));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO3));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO4));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO5));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_DECO6));
// buffer.writeInt(charInfoPackage.getPaperdollItemId(Inventory.PAPERDOLL_BELT));
buffer.writeInt(0x01); // hair style
buffer.writeInt(0x01); // hair color
buffer.writeInt(0x01); // face
buffer.writeDouble(30); // hp max
buffer.writeDouble(30); // mp max
long deleteTime = 0;
int deletedays = 0;
if (deleteTime > 0)
deletedays = (int) ((deleteTime - System.currentTimeMillis()) / 1000);
buffer.writeInt(deletedays); // days left before
// delete .. if != 0
// then char is inactive
buffer.writeInt(0x00); // class
buffer.writeInt(0x01); // c3 auto-select char
buffer.writeByte(0x00); // enchant effect
buffer.writeInt(0x00); // augmentation id
// buffer.writeInt(charInfoPackage.getTransformId()); // Used to
// display Transformations
buffer.writeInt(0x00); // Currently on retail when you are on
// character select you don't see your transformation.
// Freya by Vistall:
buffer.writeInt(0); // npdid - 16024 Tame Tiny Baby Kookaburra
// A9E89C
buffer.writeInt(0); // level
buffer.writeInt(0); // ?
buffer.writeInt(0); // food? - 1200
buffer.writeDouble(0); // max Hp
buffer.writeDouble(0); // cur Hp
i++;
}
}
}

View File

@@ -1,5 +1,7 @@
package com.l2jserver.model.world;
import java.sql.Date;
import com.l2jserver.model.id.CharacterID;
import com.l2jserver.model.id.ClanID;
import com.l2jserver.model.id.PetID;
@@ -28,6 +30,10 @@ public class L2Character extends Player {
* The character's status
*/
private boolean online;
/**
* Date of character's last access
*/
private Date lastAccess;
/**
* This character's inventory
@@ -121,6 +127,21 @@ public class L2Character extends Player {
this.online = online;
}
/**
* @return the lastAccess
*/
public Date getLastAccess() {
return lastAccess;
}
/**
* @param lastAccess
* the lastAccess to set
*/
public void setLastAccess(Date lastAccess) {
this.lastAccess = lastAccess;
}
/**
* @return the inventory
*/

View File

@@ -2,6 +2,10 @@ package com.l2jserver.service;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import com.l2jserver.service.game.world.WorldEventDispatcher;
import com.l2jserver.service.game.world.WorldEventDispatcherImpl;
import com.l2jserver.service.game.world.WorldService;
import com.l2jserver.service.game.world.WorldServiceImpl;
import com.l2jserver.service.network.NettyNetworkService;
import com.l2jserver.service.network.NetworkService;
@@ -10,5 +14,10 @@ public class ServiceModule extends AbstractModule {
protected void configure() {
bind(NetworkService.class).to(NettyNetworkService.class).in(
Scopes.SINGLETON);
bind(WorldService.class).to(WorldServiceImpl.class)
.in(Scopes.SINGLETON);
bind(WorldEventDispatcher.class).to(WorldEventDispatcherImpl.class).in(
Scopes.SINGLETON);
}
}

View File

@@ -0,0 +1,24 @@
package com.l2jserver.util;
import java.util.Arrays;
import org.jboss.netty.buffer.ChannelBuffer;
public class BufferUtil {
public static final String readString(ChannelBuffer buffer) {
char[] str = new char[buffer.readableBytes()];
int index = 0;
char c;
while ((c = buffer.readChar()) != 0) {
str[index++] = c;
}
return String.valueOf(Arrays.copyOfRange(str, 0, index));
}
public static final void writeString(ChannelBuffer buffer, String str) {
for (char c : str.toCharArray()) {
buffer.writeChar(c);
}
buffer.writeChar(0x00);
}
}