Skip to content
This repository has been archived by the owner on May 3, 2018. It is now read-only.

Commit

Permalink
re-added client disconnect support
Browse files Browse the repository at this point in the history
  • Loading branch information
DefinitlyEvil committed May 9, 2015
1 parent 66aa9d6 commit e9c1f95
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Map;
import net.glowstone.entity.GlowPlayer;
import org.dragonet.entity.metadata.type.ByteMeta;
import org.dragonet.entity.metadata.type.CoordinateMeta;
import org.dragonet.entity.metadata.type.ShortMeta;
import org.dragonet.utilities.io.PEBinaryWriter;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/dragonet/net/packet/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public final class Protocol {

static {
protocol = new HashMap<>();
registerDecoder(PEPacketIDs.BATCH_PACKET,BatchPacket.class);
registerDecoder(PEPacketIDs.DISCONNECT_PACKET, DisconnectPacket.class);
registerDecoder(PEPacketIDs.BATCH_PACKET, BatchPacket.class);
registerDecoder(PEPacketIDs.TEXT_PACKET, ChatPacket.class);
registerDecoder(PEPacketIDs.CLIENT_CONNECT, ClientConnectPacket.class);
registerDecoder(PEPacketIDs.CLIENT_HANDSHAKE, ClientHandshakePacket.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.dragonet.entity.metadata.EntityMetaData;
import org.dragonet.utilities.io.PEBinaryWriter;

public class AddEntityPacket1 extends PEPacket {
public class AddEntityPacket extends PEPacket {

@Data
public static class EntityLink{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public ItemTranslator_v0_11() {
for (int i = 91; i <= 92; i++) {
itemMap_PC_to_PE.put(i, i);
}
/*
for (int i = 95; i <= 96; i++) {
itemMap_PC_to_PE.put(i, i);
}
Expand Down Expand Up @@ -79,14 +78,14 @@ public ItemTranslator_v0_11() {
for (int i = 243; i <= 249; i++) {
itemMap_PC_to_PE.put(i, i);
}
*/
//itemMap_PC_to_PE.put(8, 8);
//itemMap_PC_to_PE.put(9, 9);
//itemMap_PC_to_PE.put(10, 10);
//itemMap_PC_to_PE.put(11, 11);
//for (int i = 1; i <= 12; i++) {
// itemMap_PC_to_PE.put(i, i);
//}

itemMap_PC_to_PE.put(8, 8);
itemMap_PC_to_PE.put(9, 9);
itemMap_PC_to_PE.put(10, 10);
itemMap_PC_to_PE.put(11, 11);
for (int i = 1; i <= 12; i++) {
itemMap_PC_to_PE.put(i, i);
}
//TODO: More blocks/items

/* ===== PE to PC ===== */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public KickMessageTranslator(Translator_v0_11 translator, DragonetSession sessio

@Override
public PEPacket[] handleSpecific(KickMessage packet) {
String msg = "";
String msg;
try {
//String msg = ((ChatMessage) message).text.asPlaintext();
Object json = new JSONParser().parse(packet.text.encode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.glowstone.net.message.play.entity.RelativeEntityPositionMessage;
import org.bukkit.entity.Entity;
import org.dragonet.net.DragonetSession;
import org.dragonet.net.packet.minecraft.MoveEntitiesPacket;
import org.dragonet.net.packet.minecraft.MovePlayerPacket;
import org.dragonet.net.packet.minecraft.PEPacket;
import org.dragonet.net.translator.MessageTranslatorToPE;
Expand All @@ -31,8 +32,15 @@ public PEPacket[] handleSpecific(RelativeEntityPositionMessage packet) {
MovePlayerPacket pkMovePlayer = new MovePlayerPacket(packet.id, (float) entity.getLocation().getX(), (float) entity.getLocation().getY(), (float) entity.getLocation().getZ(), entity.getLocation().getYaw(), entity.getLocation().getPitch(), entity.getLocation().getYaw(), isTeleport);
return new PEPacket[]{pkMovePlayer};
} else {
//TODO: Handle other entities
return null;
MoveEntitiesPacket.MoveEntityData data = new MoveEntitiesPacket.MoveEntityData();
data.eid = packet.id;
data.x = (float) entity.getLocation().getX();
data.y = (float) entity.getLocation().getY();
data.z = (float) entity.getLocation().getZ();
data.yaw = entity.getLocation().getYaw();
data.pitch = entity.getLocation().getPitch();
MoveEntitiesPacket pk = new MoveEntitiesPacket(new MoveEntitiesPacket.MoveEntityData[]{data});
return new PEPacket[]{pk};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.glowstone.net.message.play.entity.RelativeEntityPositionRotationMessage;
import org.bukkit.entity.Entity;
import org.dragonet.net.DragonetSession;
import org.dragonet.net.packet.minecraft.MoveEntitiesPacket;
import org.dragonet.net.packet.minecraft.MovePlayerPacket;
import org.dragonet.net.packet.minecraft.PEPacket;
import org.dragonet.net.translator.MessageTranslatorToPE;
Expand All @@ -31,8 +32,15 @@ public PEPacket[] handleSpecific(RelativeEntityPositionRotationMessage packet) {
MovePlayerPacket pkMovePlayer = new MovePlayerPacket(packet.id, (float) entity.getLocation().getX(), (float) entity.getLocation().getY(), (float) entity.getLocation().getZ(), entity.getLocation().getYaw(), entity.getLocation().getPitch(), entity.getLocation().getYaw(), isTeleport);
return new PEPacket[]{pkMovePlayer};
} else {
//TODO: Handle other entities
return null;
MoveEntitiesPacket.MoveEntityData data = new MoveEntitiesPacket.MoveEntityData();
data.eid = packet.id;
data.x = (float) entity.getLocation().getX();
data.y = (float) entity.getLocation().getY();
data.z = (float) entity.getLocation().getZ();
data.yaw = entity.getLocation().getYaw();
data.pitch = entity.getLocation().getPitch();
MoveEntitiesPacket pk = new MoveEntitiesPacket(new MoveEntitiesPacket.MoveEntityData[]{data});
return new PEPacket[]{pk};
}
}

Expand Down

0 comments on commit e9c1f95

Please sign in to comment.