Search in sources :

Example 21 with PEPacket

use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.

the class ChatMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(ChatMessage packet) {
    String msg = "";
    try {
        //String msg = ((ChatMessage) message).text.asPlaintext();
        Object json = new JSONParser().parse(packet.text.encode());
        if (json instanceof JSONObject) {
            msg = this.getTranslator().translateChatMessage((JSONObject) json);
        } else {
            msg = packet.text.asPlaintext();
        }
    } catch (ParseException ex) {
        return null;
    }
    //if(json)
    ChatPacket pkMessage = new ChatPacket();
    pkMessage.source = "";
    pkMessage.type = ChatPacket.TextType.RAW;
    pkMessage.message = msg;
    return new PEPacket[] { pkMessage };
}
Also used : ChatPacket(org.dragonet.net.packet.minecraft.ChatPacket) JSONObject(org.json.simple.JSONObject) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) JSONObject(org.json.simple.JSONObject) JSONParser(org.json.simple.parser.JSONParser) ParseException(org.json.simple.parser.ParseException)

Example 22 with PEPacket

use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.

the class PENetworkClient method processPacketBuffer.

public void processPacketBuffer(byte[] buffer) {
    PEPacket packet = Protocol.decode(buffer);
    if (packet == null) {
        return;
    }
    handlePacket(packet);
}
Also used : PEPacket(org.dragonet.net.packet.minecraft.PEPacket)

Aggregations

PEPacket (org.dragonet.net.packet.minecraft.PEPacket)22 MovePlayerPacket (org.dragonet.net.packet.minecraft.MovePlayerPacket)4 GlowPlayer (net.glowstone.entity.GlowPlayer)3 PEInventorySlot (org.dragonet.inventory.PEInventorySlot)3 Entity (org.bukkit.entity.Entity)2 MoveEntitiesPacket (org.dragonet.net.packet.minecraft.MoveEntitiesPacket)2 PlayerListPacket (org.dragonet.net.packet.minecraft.PlayerListPacket)2 UpdateBlockPacket (org.dragonet.net.packet.minecraft.UpdateBlockPacket)2 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 PlayerProfile (net.glowstone.entity.meta.profile.PlayerProfile)1 SpawnObjectMessage (net.glowstone.net.message.play.entity.SpawnObjectMessage)1 BlockChangeMessage (net.glowstone.net.message.play.game.BlockChangeMessage)1 MultiBlockChangeMessage (net.glowstone.net.message.play.game.MultiBlockChangeMessage)1 CloseWindowMessage (net.glowstone.net.message.play.inv.CloseWindowMessage)1 Player (org.bukkit.entity.Player)1 PocketPotionEffect (org.dragonet.PocketPotionEffect)1 AddItemEntityPacket (org.dragonet.net.packet.minecraft.AddItemEntityPacket)1 AddPlayerPacket (org.dragonet.net.packet.minecraft.AddPlayerPacket)1 AnimatePacket (org.dragonet.net.packet.minecraft.AnimatePacket)1