mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
@@ -31,6 +31,7 @@ import com.l2jserver.game.net.packet.client.AuthLoginPacket;
|
||||
import com.l2jserver.game.net.packet.client.CharacterChatMessagePacket;
|
||||
import com.l2jserver.game.net.packet.client.CharacterCreatePacket;
|
||||
import com.l2jserver.game.net.packet.client.CharacterSelectPacket;
|
||||
import com.l2jserver.game.net.packet.client.CharacterValidatePositionPacket;
|
||||
import com.l2jserver.game.net.packet.client.EnterWorld;
|
||||
import com.l2jserver.game.net.packet.client.LogoutPacket;
|
||||
import com.l2jserver.game.net.packet.client.ProtocolVersionPacket;
|
||||
@@ -155,6 +156,8 @@ public class Lineage2PacketReader extends OneToOneDecoder {
|
||||
return RequestRestartPacket.class;
|
||||
case CharacterChatMessagePacket.OPCODE:
|
||||
return CharacterChatMessagePacket.class;
|
||||
case CharacterValidatePositionPacket.OPCODE:
|
||||
return CharacterValidatePositionPacket.class;
|
||||
case EnterWorld.OPCODE:
|
||||
return EnterWorld.class;
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.game.net.packet.client;
|
||||
|
||||
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.model.world.character.event.CharacterMoveEvent;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
* This packet notifies the server which character the player has chosen to use.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterValidatePositionPacket extends AbstractClientPacket {
|
||||
/**
|
||||
* The packet OPCODE
|
||||
*/
|
||||
public static final int OPCODE = 0x59;
|
||||
|
||||
/**
|
||||
* The World Event Dispatcher
|
||||
*/
|
||||
private final WorldEventDispatcher eventDispatcher;
|
||||
|
||||
private Point point;
|
||||
private int extra; // vehicle id
|
||||
|
||||
@Inject
|
||||
public CharacterValidatePositionPacket(WorldEventDispatcher eventDispatcher) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
point = Point.fromXYZA(buffer.readInt(), buffer.readInt(),
|
||||
buffer.readInt(), buffer.readInt());
|
||||
extra = buffer.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
conn.getCharacter().setPoint(point);
|
||||
eventDispatcher.dispatch(new CharacterMoveEvent(conn.getCharacter(),
|
||||
point));
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,11 @@ import com.l2jserver.game.net.packet.server.GameGuardQueryPacket;
|
||||
import com.l2jserver.game.net.packet.server.InventoryPacket;
|
||||
import com.l2jserver.game.net.packet.server.UserInformationPacket;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.world.character.event.CharacterLoggedInEvent;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannel;
|
||||
import com.l2jserver.service.game.chat.channel.ChatChannelListener;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
|
||||
/**
|
||||
* The client is requesting a logout. Currently, when this packet is received
|
||||
@@ -47,6 +49,10 @@ public class EnterWorld extends AbstractClientPacket {
|
||||
* The chat service
|
||||
*/
|
||||
private final ChatService chatService;
|
||||
/**
|
||||
* The World Event Dispatcher
|
||||
*/
|
||||
private final WorldEventDispatcher eventDispatcher;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
@@ -55,8 +61,10 @@ public class EnterWorld extends AbstractClientPacket {
|
||||
* the chat service
|
||||
*/
|
||||
@Inject
|
||||
public EnterWorld(ChatService chatService) {
|
||||
public EnterWorld(ChatService chatService,
|
||||
WorldEventDispatcher eventDispatcher) {
|
||||
this.chatService = chatService;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,6 +84,7 @@ public class EnterWorld extends AbstractClientPacket {
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
// register global chat listener
|
||||
chatService.getGlobalChannel().addChatChannelListener(
|
||||
new ChatChannelListener() {
|
||||
@Override
|
||||
@@ -90,5 +99,8 @@ public class EnterWorld extends AbstractClientPacket {
|
||||
// TODO game guard enforcing
|
||||
conn.write(new GameGuardQueryPacket());
|
||||
conn.write(new InventoryPacket(conn.getCharacter().getInventory()));
|
||||
|
||||
eventDispatcher
|
||||
.dispatch(new CharacterLoggedInEvent(conn.getCharacter()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.game.net.packet.server;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket.Reason;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
|
||||
/**
|
||||
* This packet notifies the client that the chosen character has been
|
||||
* successfully selected.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
* @see Reason
|
||||
*/
|
||||
public class CharacterPositionPacket extends AbstractServerPacket {
|
||||
/**
|
||||
* The packet OPCODE
|
||||
*/
|
||||
public static final int OPCODE = 0x79;
|
||||
|
||||
/**
|
||||
* The selected character
|
||||
*/
|
||||
private final L2Character character;
|
||||
|
||||
public CharacterPositionPacket(L2Character character) {
|
||||
super(OPCODE);
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeInt(character.getID().getID());
|
||||
buffer.writeInt(character.getPoint().getX());
|
||||
buffer.writeInt(character.getPoint().getY());
|
||||
buffer.writeInt(character.getPoint().getZ());
|
||||
buffer.writeInt((int) character.getPoint().getAngle());
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class UserInformationPacket extends AbstractServerPacket {
|
||||
|
||||
buffer.writeByte(0); // is party match room
|
||||
|
||||
buffer.writeInt(0x100000); // abnormal effect
|
||||
buffer.writeInt(0x00); // abnormal effect
|
||||
buffer.writeByte(0x0); // flying mounted = 2; otherwise: 0
|
||||
|
||||
buffer.writeInt(0x00); // clan privileges
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.model.world.character.event;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.Player;
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.model.world.capability.Listenable;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
* Event triggered once a character moves
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterMoveEvent implements CharacterEvent {
|
||||
/**
|
||||
* The character that is logging in
|
||||
*/
|
||||
private final L2Character character;
|
||||
/**
|
||||
* The new point of the character
|
||||
*/
|
||||
private final Point point;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
* @param point
|
||||
* the character point
|
||||
*/
|
||||
public CharacterMoveEvent(L2Character character, Point point) {
|
||||
this.character = character;
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the point
|
||||
*/
|
||||
public Point getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor getActor() {
|
||||
return character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldObject getObject() {
|
||||
return character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2Character getCharacter() {
|
||||
return character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listenable<?, ?>[] getDispatchableObjects() {
|
||||
return new Listenable<?, ?>[] { character };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user