mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Pre-1.7 misc. fixes (Waiting for 1.7.2 MCP update)
This commit is contained in:
parent
435a20230e
commit
7112e67607
115 changed files with 945 additions and 934 deletions
|
@ -5,7 +5,7 @@ import ch.spacebase.mcprotocol.packet.Packet;
|
||||||
/**
|
/**
|
||||||
* Called when a packet is received.
|
* Called when a packet is received.
|
||||||
*/
|
*/
|
||||||
public class PacketRecieveEvent extends ProtocolEvent<ProtocolListener> {
|
public class PacketReceiveEvent extends ProtocolEvent<ProtocolListener> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The received packet.
|
* The received packet.
|
||||||
|
@ -16,7 +16,7 @@ public class PacketRecieveEvent extends ProtocolEvent<ProtocolListener> {
|
||||||
* Creates a new packet receive event instance.
|
* Creates a new packet receive event instance.
|
||||||
* @param packet Packet being received.
|
* @param packet Packet being received.
|
||||||
*/
|
*/
|
||||||
public PacketRecieveEvent(Packet packet) {
|
public PacketReceiveEvent(Packet packet) {
|
||||||
this.packet = packet;
|
this.packet = packet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,8 @@ import ch.spacebase.mcprotocol.standard.packet.PacketWindowItems;
|
||||||
import ch.spacebase.mcprotocol.standard.packet.PacketWindowProperty;
|
import ch.spacebase.mcprotocol.standard.packet.PacketWindowProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty implementation of the PacketVisitor interface for convenience.
|
* Empty implementation of the PacketVisitor interface for convenience. Usually
|
||||||
* Usually used when most methods are not implemented.
|
* used when most methods are not implemented.
|
||||||
*
|
*
|
||||||
* @author dconnor
|
* @author dconnor
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,7 +9,7 @@ public abstract class ProtocolListener {
|
||||||
* Called when a packet is received.
|
* Called when a packet is received.
|
||||||
* @param event The called event.
|
* @param event The called event.
|
||||||
*/
|
*/
|
||||||
public abstract void onPacketReceive(PacketRecieveEvent event);
|
public abstract void onPacketReceive(PacketReceiveEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a packet is sent.
|
* Called when a packet is sent.
|
||||||
|
|
|
@ -48,7 +48,8 @@ public interface Connection {
|
||||||
public String getUsername();
|
public String getUsername();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the connection's username if it isn't already set, ignoring any authentication.
|
* Sets the connection's username if it isn't already set, ignoring any
|
||||||
|
* authentication.
|
||||||
* @param name The new username.
|
* @param name The new username.
|
||||||
*/
|
*/
|
||||||
public void setUsername(String name);
|
public void setUsername(String name);
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.bouncycastle.crypto.params.KeyParameter;
|
||||||
import org.bouncycastle.crypto.params.ParametersWithIV;
|
import org.bouncycastle.crypto.params.ParametersWithIV;
|
||||||
|
|
||||||
import ch.spacebase.mcprotocol.event.DisconnectEvent;
|
import ch.spacebase.mcprotocol.event.DisconnectEvent;
|
||||||
import ch.spacebase.mcprotocol.event.PacketRecieveEvent;
|
import ch.spacebase.mcprotocol.event.PacketReceiveEvent;
|
||||||
import ch.spacebase.mcprotocol.event.PacketSendEvent;
|
import ch.spacebase.mcprotocol.event.PacketSendEvent;
|
||||||
import ch.spacebase.mcprotocol.exception.ConnectException;
|
import ch.spacebase.mcprotocol.exception.ConnectException;
|
||||||
import ch.spacebase.mcprotocol.net.BaseConnection;
|
import ch.spacebase.mcprotocol.net.BaseConnection;
|
||||||
|
@ -178,7 +178,7 @@ public abstract class StandardConnection extends BaseConnection {
|
||||||
|
|
||||||
Packet packet = getPacketRegistry().getPacket(opcode).newInstance();
|
Packet packet = getPacketRegistry().getPacket(opcode).newInstance();
|
||||||
packet.read(input);
|
packet.read(input);
|
||||||
call(new PacketRecieveEvent(packet));
|
call(new PacketReceiveEvent(packet));
|
||||||
if(StandardConnection.this instanceof Client) {
|
if(StandardConnection.this instanceof Client) {
|
||||||
packet.handleClient((Client) StandardConnection.this);
|
packet.handleClient((Client) StandardConnection.this);
|
||||||
} else if(StandardConnection.this instanceof ServerConnection) {
|
} else if(StandardConnection.this instanceof ServerConnection) {
|
||||||
|
@ -236,7 +236,8 @@ public abstract class StandardConnection extends BaseConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A thread that waits for the connection to finish writing before closing it.
|
* A thread that waits for the connection to finish writing before closing
|
||||||
|
* it.
|
||||||
*/
|
*/
|
||||||
private class CloseThread extends Thread {
|
private class CloseThread extends Thread {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class StandardServer extends Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the server's key pair.
|
* Gets the server's key pair.
|
||||||
* @return The server's key pair.
|
* @return The server's key pair.
|
||||||
|
|
|
@ -53,7 +53,8 @@ public class StandardItemStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack with the given id, size, damage value, and compressed NBT data.
|
* Creates an item stack with the given id, size, damage value, and
|
||||||
|
* compressed NBT data.
|
||||||
* @param item Item id of the stack.
|
* @param item Item id of the stack.
|
||||||
* @param stackSize Size of the stack.
|
* @param stackSize Size of the stack.
|
||||||
* @param damage Damage value of the stack.
|
* @param damage Damage value of the stack.
|
||||||
|
|
|
@ -3,7 +3,7 @@ package ch.spacebase.mcprotocol.standard.example;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import ch.spacebase.mcprotocol.event.DisconnectEvent;
|
import ch.spacebase.mcprotocol.event.DisconnectEvent;
|
||||||
import ch.spacebase.mcprotocol.event.PacketRecieveEvent;
|
import ch.spacebase.mcprotocol.event.PacketReceiveEvent;
|
||||||
import ch.spacebase.mcprotocol.event.PacketSendEvent;
|
import ch.spacebase.mcprotocol.event.PacketSendEvent;
|
||||||
import ch.spacebase.mcprotocol.event.ProtocolListener;
|
import ch.spacebase.mcprotocol.event.ProtocolListener;
|
||||||
import ch.spacebase.mcprotocol.exception.ConnectException;
|
import ch.spacebase.mcprotocol.exception.ConnectException;
|
||||||
|
@ -56,7 +56,7 @@ public class ChatBot {
|
||||||
|
|
||||||
private class Listener extends ProtocolListener {
|
private class Listener extends ProtocolListener {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceive(PacketRecieveEvent event) {
|
public void onPacketReceive(PacketReceiveEvent event) {
|
||||||
Packet packet = event.getPacket();
|
Packet packet = event.getPacket();
|
||||||
|
|
||||||
switch(event.getPacket().getId()) {
|
switch(event.getPacket().getId()) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import ch.spacebase.mcprotocol.exception.OutdatedLibraryException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import ch.spacebase.mcprotocol.event.DisconnectEvent;
|
import ch.spacebase.mcprotocol.event.DisconnectEvent;
|
||||||
import ch.spacebase.mcprotocol.event.PacketRecieveEvent;
|
import ch.spacebase.mcprotocol.event.PacketReceiveEvent;
|
||||||
import ch.spacebase.mcprotocol.event.PacketSendEvent;
|
import ch.spacebase.mcprotocol.event.PacketSendEvent;
|
||||||
import ch.spacebase.mcprotocol.event.PacketVisitor;
|
import ch.spacebase.mcprotocol.event.PacketVisitor;
|
||||||
import ch.spacebase.mcprotocol.event.PacketVisitorAdapter;
|
import ch.spacebase.mcprotocol.event.PacketVisitorAdapter;
|
||||||
|
@ -37,7 +37,6 @@ public class ChatBotVisitor {
|
||||||
private Listener listener;
|
private Listener listener;
|
||||||
private PacketVisitor visitor;
|
private PacketVisitor visitor;
|
||||||
|
|
||||||
|
|
||||||
public ChatBotVisitor(String host, int port) {
|
public ChatBotVisitor(String host, int port) {
|
||||||
this.client = new StandardClient(host, port);
|
this.client = new StandardClient(host, port);
|
||||||
this.listener = new Listener();
|
this.listener = new Listener();
|
||||||
|
@ -88,7 +87,7 @@ public class ChatBotVisitor {
|
||||||
private class Listener extends ProtocolListener {
|
private class Listener extends ProtocolListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceive(PacketRecieveEvent event) {
|
public void onPacketReceive(PacketReceiveEvent event) {
|
||||||
Packet packet = event.getPacket();
|
Packet packet = event.getPacket();
|
||||||
packet.accept(visitor);
|
packet.accept(visitor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,12 @@ public class PacketDestroyEntity extends Packet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketDestroyEntity(int... entityIds) {
|
public PacketDestroyEntity(int... entityIds) {
|
||||||
this.entityIds = entityIds;
|
this.entityIds = entityIds.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(NetInput in) throws IOException {
|
public void read(NetInput in) throws IOException {
|
||||||
this.entityIds = new int[in.readByte()];
|
this.entityIds = new int[in.readUnsignedByte()];
|
||||||
for(int count = 0; count < this.entityIds.length; count++) {
|
for(int count = 0; count < this.entityIds.length; count++) {
|
||||||
this.entityIds[count] = in.readInt();
|
this.entityIds[count] = in.readInt();
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,5 +68,4 @@ public class PacketEntityTeleport extends Packet {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package ch.spacebase.mcprotocol.standard.packet;
|
package ch.spacebase.mcprotocol.standard.packet;
|
||||||
|
|
||||||
import ch.spacebase.mcprotocol.event.PacketVisitor;
|
|
||||||
import ch.spacebase.mcprotocol.event.PacketVisitor;
|
import ch.spacebase.mcprotocol.event.PacketVisitor;
|
||||||
import ch.spacebase.mcprotocol.net.io.NetInput;
|
import ch.spacebase.mcprotocol.net.io.NetInput;
|
||||||
import ch.spacebase.mcprotocol.net.io.NetOutput;
|
import ch.spacebase.mcprotocol.net.io.NetOutput;
|
||||||
|
|
|
@ -18,18 +18,18 @@ public class PacketWindowClick extends Packet {
|
||||||
public short slot;
|
public short slot;
|
||||||
public byte mousebutton;
|
public byte mousebutton;
|
||||||
public short action;
|
public short action;
|
||||||
public boolean shift;
|
public byte type;
|
||||||
public StandardItemStack clicked;
|
public StandardItemStack clicked;
|
||||||
|
|
||||||
public PacketWindowClick() {
|
public PacketWindowClick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketWindowClick(byte id, short slot, byte mousebutton, short action, boolean shift, StandardItemStack clicked) {
|
public PacketWindowClick(byte id, short slot, byte mousebutton, short action, byte type, StandardItemStack clicked) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
this.mousebutton = mousebutton;
|
this.mousebutton = mousebutton;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.shift = shift;
|
this.type = type;
|
||||||
this.clicked = clicked;
|
this.clicked = clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class PacketWindowClick extends Packet {
|
||||||
this.slot = in.readShort();
|
this.slot = in.readShort();
|
||||||
this.mousebutton = in.readByte();
|
this.mousebutton = in.readByte();
|
||||||
this.action = in.readShort();
|
this.action = in.readShort();
|
||||||
this.shift = in.readBoolean();
|
this.type = in.readByte();
|
||||||
this.clicked = ((StandardInput) in).readItem();
|
this.clicked = ((StandardInput) in).readItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class PacketWindowClick extends Packet {
|
||||||
out.writeShort(this.slot);
|
out.writeShort(this.slot);
|
||||||
out.writeByte(this.mousebutton);
|
out.writeByte(this.mousebutton);
|
||||||
out.writeShort(this.action);
|
out.writeShort(this.action);
|
||||||
out.writeBoolean(this.shift);
|
out.writeByte(this.type);
|
||||||
if(this.clicked != null) {
|
if(this.clicked != null) {
|
||||||
((StandardOutput) out).writeItem(this.clicked);
|
((StandardOutput) out).writeItem(this.clicked);
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,8 @@ public class PluginMessageBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a byte array to the plugin message data, prepending the array length.
|
* Writes a byte array to the plugin message data, prepending the array
|
||||||
|
* length.
|
||||||
* @param b Bytes to write.
|
* @param b Bytes to write.
|
||||||
* @return This plugin message builder.
|
* @return This plugin message builder.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -95,6 +95,16 @@ public class Constants {
|
||||||
public static final byte SHAKING_WATER = 8;
|
public static final byte SHAKING_WATER = 8;
|
||||||
public static final byte EATING_ACCEPT = 9;
|
public static final byte EATING_ACCEPT = 9;
|
||||||
public static final byte SHEEP_EATING = 10;
|
public static final byte SHEEP_EATING = 10;
|
||||||
|
public static final byte IRON_GOLEM_ROSE = 11;
|
||||||
|
public static final byte SPAWN_HEART_PARTICLES = 12;
|
||||||
|
public static final byte SPAWN_ANGRY_PARTICLES = 13;
|
||||||
|
public static final byte SPAWN_LOVE_PARTICLES = 14;
|
||||||
|
public static final byte SPAWN_MAGIC_PARTICLES = 15;
|
||||||
|
public static final byte ZOMBIE_INTO_VILLAGER = 16;
|
||||||
|
public static final byte EXPLODING_FIREWORK = 17;
|
||||||
|
public static final byte MOVE_TO_REPLICAPARTITION = 125;
|
||||||
|
public static final byte CONVERT_TO_AUTHORITATIVE = 126;
|
||||||
|
public static final byte CONVERT_TO_REPLICA = 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -97,7 +97,8 @@ public class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares a plugin message packet with client data to be sent after a ping request packet.
|
* Prepares a plugin message packet with client data to be sent after a ping
|
||||||
|
* request packet.
|
||||||
* @param serverIp IP of the server.
|
* @param serverIp IP of the server.
|
||||||
* @param serverPort Port of the server.
|
* @param serverPort Port of the server.
|
||||||
* @return The prepared packet.
|
* @return The prepared packet.
|
||||||
|
|
Loading…
Reference in a new issue