mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-12 08:41:00 -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.
|
||||
*/
|
||||
public class PacketRecieveEvent extends ProtocolEvent<ProtocolListener> {
|
||||
public class PacketReceiveEvent extends ProtocolEvent<ProtocolListener> {
|
||||
|
||||
/**
|
||||
* The received packet.
|
||||
|
@ -16,7 +16,7 @@ public class PacketRecieveEvent extends ProtocolEvent<ProtocolListener> {
|
|||
* Creates a new packet receive event instance.
|
||||
* @param packet Packet being received.
|
||||
*/
|
||||
public PacketRecieveEvent(Packet packet) {
|
||||
public PacketReceiveEvent(Packet packet) {
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class PacketRecieveEvent extends ProtocolEvent<ProtocolListener> {
|
|||
public <T extends Packet> T getPacket(Class<T> clazz) {
|
||||
try {
|
||||
return (T) this.packet;
|
||||
} catch (ClassCastException e) {
|
||||
} catch(ClassCastException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ public class PacketSendEvent extends ProtocolEvent<ProtocolListener> {
|
|||
public <T extends Packet> T getPacket(Class<T> clazz) {
|
||||
try {
|
||||
return (T) this.packet;
|
||||
} catch (ClassCastException e) {
|
||||
} catch(ClassCastException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ import ch.spacebase.mcprotocol.standard.packet.PacketWindowItems;
|
|||
import ch.spacebase.mcprotocol.standard.packet.PacketWindowProperty;
|
||||
|
||||
/**
|
||||
* Empty implementation of the PacketVisitor interface for convenience.
|
||||
* Usually used when most methods are not implemented.
|
||||
* Empty implementation of the PacketVisitor interface for convenience. Usually
|
||||
* used when most methods are not implemented.
|
||||
*
|
||||
* @author dconnor
|
||||
*/
|
||||
|
|
|
@ -9,7 +9,7 @@ public abstract class ProtocolListener {
|
|||
* Called when a packet is received.
|
||||
* @param event The called event.
|
||||
*/
|
||||
public abstract void onPacketReceive(PacketRecieveEvent event);
|
||||
public abstract void onPacketReceive(PacketReceiveEvent event);
|
||||
|
||||
/**
|
||||
* Called when a packet is sent.
|
||||
|
|
|
@ -48,7 +48,8 @@ public interface Connection {
|
|||
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.
|
||||
*/
|
||||
public void setUsername(String name);
|
||||
|
|
|
@ -27,7 +27,7 @@ public abstract class PacketRegistry {
|
|||
public Class<? extends Packet> getPacket(int id) {
|
||||
try {
|
||||
return this.packets[id];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
} catch(ArrayIndexOutOfBoundsException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
|
||||
try {
|
||||
url = new URL("https://login.minecraft.net/");
|
||||
} catch (MalformedURLException e) {
|
||||
} catch(MalformedURLException e) {
|
||||
throw new LoginException("Login URL is malformed?", e);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
|
||||
try {
|
||||
params = "user=" + URLEncoder.encode(username, "UTF-8") + "&password=" + URLEncoder.encode(password, "UTF-8") + "&version=" + Constants.LAUNCHER_VERSION;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
throw new LoginException("UTF-8 unsupported", e);
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
this.loggedIn = true;
|
||||
|
||||
new Thread(new KeepAliveTask()).start();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
} catch(ArrayIndexOutOfBoundsException e) {
|
||||
throw new LoginException("Response contained incorrect amount of parameters: " + result);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
throw new LoginException(result.trim());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
throw new LoginException("Failed to login", e);
|
||||
} finally {
|
||||
if(conn != null) conn.disconnect();
|
||||
|
@ -167,7 +167,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
public KeepAliveTask() throws LoginException {
|
||||
try {
|
||||
this.url = new URL("https://login.minecraft.net/");
|
||||
} catch (MalformedURLException e) {
|
||||
} catch(MalformedURLException e) {
|
||||
throw new LoginException("Failed to create keep alive URL!", e);
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
conn.setDoOutput(true);
|
||||
conn.setReadTimeout(1000 * 60 * 10);
|
||||
conn.connect();
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Util.logger().severe("Failed to send keep alive to login.minecraft.net!");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
@ -198,7 +198,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,9 +212,9 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
sock.setTrafficClass(24);
|
||||
super.connect(sock);
|
||||
this.send(new PacketHandshake(this.getUsername(), this.getRemoteHost(), this.getRemotePort()));
|
||||
} catch (UnknownHostException e) {
|
||||
} catch(UnknownHostException e) {
|
||||
throw new ConnectException("Unknown host: " + this.getRemoteHost());
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
throw new ConnectException("Failed to open stream: " + this.getRemoteHost(), e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.bouncycastle.crypto.params.KeyParameter;
|
|||
import org.bouncycastle.crypto.params.ParametersWithIV;
|
||||
|
||||
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.exception.ConnectException;
|
||||
import ch.spacebase.mcprotocol.net.BaseConnection;
|
||||
|
@ -98,9 +98,9 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
this.connected = true;
|
||||
new ListenThread().start();
|
||||
new WriteThread().start();
|
||||
} catch (UnknownHostException e) {
|
||||
} catch(UnknownHostException e) {
|
||||
throw new ConnectException("Unknown host: " + this.getRemoteHost());
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
throw new ConnectException("Failed to open stream: " + this.getRemoteHost(), e);
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
|
||||
Packet packet = getPacketRegistry().getPacket(opcode).newInstance();
|
||||
packet.read(input);
|
||||
call(new PacketRecieveEvent(packet));
|
||||
call(new PacketReceiveEvent(packet));
|
||||
if(StandardConnection.this instanceof Client) {
|
||||
packet.handleClient((Client) StandardConnection.this);
|
||||
} else if(StandardConnection.this instanceof ServerConnection) {
|
||||
|
@ -186,7 +186,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
}
|
||||
} catch(EOFException e) {
|
||||
disconnect("End of Stream");
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
Util.logger().severe("Error while listening to connection!");
|
||||
e.printStackTrace();
|
||||
disconnect("Error while listening to connection!");
|
||||
|
@ -194,7 +194,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
output.writeByte(packet.getId());
|
||||
packet.write(output);
|
||||
output.flush();
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
Util.logger().severe("Error while writing packet \"" + packet.getId() + "\"!");
|
||||
e.printStackTrace();
|
||||
disconnect("Error while writing packet.");
|
||||
|
@ -227,7 +227,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
|
||||
writing = false;
|
||||
|
@ -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 {
|
||||
@Override
|
||||
|
@ -244,13 +245,13 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
while(writing) {
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
sock.close();
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
System.err.println("Failed to close socket.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -47,12 +47,11 @@ public class StandardServer extends Server {
|
|||
KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
|
||||
gen.initialize(1024);
|
||||
this.keys = gen.generateKeyPair();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch(NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the server's key pair.
|
||||
* @return The server's key pair.
|
||||
|
@ -72,7 +71,7 @@ public class StandardServer extends Server {
|
|||
ServerSocket sock = new ServerSocket();
|
||||
sock.bind(new InetSocketAddress(this.getHost(), this.getPort()));
|
||||
new ServerConnectionThread(sock).start();
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Util.logger().severe("Failed to bind to " + this.getHost() + ":" + this.getPort() + "!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -119,11 +118,11 @@ public class StandardServer extends Server {
|
|||
conn.connect();
|
||||
connections.add(conn);
|
||||
call(new ConnectEvent(conn));
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
Util.logger().severe("Failed to create server connection!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Util.logger().severe("Failed to accept connection from client!");
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
|
@ -131,7 +130,7 @@ public class StandardServer extends Server {
|
|||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public class StandardServerConnection extends StandardConnection implements Serv
|
|||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 stackSize Size 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 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.ProtocolListener;
|
||||
import ch.spacebase.mcprotocol.exception.ConnectException;
|
||||
|
@ -37,7 +37,7 @@ public class ChatBot {
|
|||
|
||||
try {
|
||||
this.client.connect();
|
||||
} catch (ConnectException e) {
|
||||
} catch(ConnectException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class ChatBot {
|
|||
|
||||
private class Listener extends ProtocolListener {
|
||||
@Override
|
||||
public void onPacketReceive(PacketRecieveEvent event) {
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
Packet packet = event.getPacket();
|
||||
|
||||
switch(event.getPacket().getId()) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import ch.spacebase.mcprotocol.exception.OutdatedLibraryException;
|
|||
import java.text.DecimalFormat;
|
||||
|
||||
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.PacketVisitor;
|
||||
import ch.spacebase.mcprotocol.event.PacketVisitorAdapter;
|
||||
|
@ -37,7 +37,6 @@ public class ChatBotVisitor {
|
|||
private Listener listener;
|
||||
private PacketVisitor visitor;
|
||||
|
||||
|
||||
public ChatBotVisitor(String host, int port) {
|
||||
this.client = new StandardClient(host, port);
|
||||
this.listener = new Listener();
|
||||
|
@ -50,14 +49,14 @@ public class ChatBotVisitor {
|
|||
public void login(String username, String password) {
|
||||
try {
|
||||
this.client.login(username, password);
|
||||
} catch (LoginException ex) {
|
||||
} catch(LoginException ex) {
|
||||
Logger.getLogger("Login Error: " + ex.getLocalizedMessage());
|
||||
} catch (OutdatedLibraryException ex) {
|
||||
} catch(OutdatedLibraryException ex) {
|
||||
Logger.getLogger(ChatBotVisitor.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
try {
|
||||
this.client.connect();
|
||||
} catch (ConnectException e) {
|
||||
} catch(ConnectException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -81,14 +80,14 @@ public class ChatBotVisitor {
|
|||
client.send(packet);
|
||||
DecimalFormat format = new DecimalFormat("#.00");
|
||||
|
||||
ChatBotVisitor.this.say("Hello, this is "+USERNAME+" at coordinate (" + format.format(packet.x) + ", " + format.format(packet.y) + ", " + format.format(packet.z) + ")");
|
||||
ChatBotVisitor.this.say("Hello, this is " + USERNAME + " at coordinate (" + format.format(packet.x) + ", " + format.format(packet.y) + ", " + format.format(packet.z) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
private class Listener extends ProtocolListener {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketRecieveEvent event) {
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
Packet packet = event.getPacket();
|
||||
packet.accept(visitor);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class PacketClientStatus extends Packet {
|
|||
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
response = reader.readLine();
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
response = e.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@ public class PacketDestroyEntity extends Packet {
|
|||
}
|
||||
|
||||
public PacketDestroyEntity(int... entityIds) {
|
||||
this.entityIds = entityIds;
|
||||
this.entityIds = entityIds.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
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++) {
|
||||
this.entityIds[count] = in.readInt();
|
||||
}
|
||||
|
|
|
@ -68,5 +68,4 @@ public class PacketEntityTeleport extends Packet {
|
|||
visitor.visit(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -111,15 +111,15 @@ public class PacketKeyRequest extends Packet {
|
|||
Cipher cipher = Cipher.getInstance(key.getAlgorithm());
|
||||
cipher.init(1, key);
|
||||
return cipher.doFinal(bytes);
|
||||
} catch (InvalidKeyException e) {
|
||||
} catch(InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch(NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchPaddingException e) {
|
||||
} catch(NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
} catch(IllegalBlockSizeException e) {
|
||||
e.printStackTrace();
|
||||
} catch (BadPaddingException e) {
|
||||
} catch(BadPaddingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -137,11 +137,11 @@ public class PacketKeyRequest extends Packet {
|
|||
X509EncodedKeySpec spec = new X509EncodedKeySpec(key);
|
||||
KeyFactory factory = KeyFactory.getInstance("RSA");
|
||||
return factory.generatePublic(spec);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch(NoSuchAlgorithmException e) {
|
||||
Util.logger().warning("Failed to get public key from array!");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (InvalidKeySpecException e) {
|
||||
} catch(InvalidKeySpecException e) {
|
||||
Util.logger().warning("Failed to get public key from array!");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
@ -155,7 +155,7 @@ public class PacketKeyRequest extends Packet {
|
|||
String response = reader.readLine();
|
||||
reader.close();
|
||||
return response;
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,15 +90,15 @@ public class PacketKeyResponse extends Packet {
|
|||
Cipher cipher = Cipher.getInstance(key.getAlgorithm());
|
||||
cipher.init(2, key);
|
||||
return cipher.doFinal(bytes);
|
||||
} catch (InvalidKeyException e) {
|
||||
} catch(InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch(NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchPaddingException e) {
|
||||
} catch(NoSuchPaddingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
} catch(IllegalBlockSizeException e) {
|
||||
e.printStackTrace();
|
||||
} catch (BadPaddingException e) {
|
||||
} catch(BadPaddingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class PacketMapChunk extends Packet {
|
|||
|
||||
try {
|
||||
inflater.inflate(this.data);
|
||||
} catch (DataFormatException e) {
|
||||
} catch(DataFormatException e) {
|
||||
throw new IOException("Bad compressed data format");
|
||||
} finally {
|
||||
inflater.end();
|
||||
|
|
|
@ -65,7 +65,7 @@ public class PacketMapChunkBulk extends Packet {
|
|||
|
||||
try {
|
||||
inflater.inflate(decompressed);
|
||||
} catch (DataFormatException e) {
|
||||
} catch(DataFormatException e) {
|
||||
throw new IOException("Bad compressed data format");
|
||||
} finally {
|
||||
inflater.end();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ch.spacebase.mcprotocol.standard.packet;
|
||||
|
||||
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.NetOutput;
|
||||
|
|
|
@ -18,18 +18,18 @@ public class PacketWindowClick extends Packet {
|
|||
public short slot;
|
||||
public byte mousebutton;
|
||||
public short action;
|
||||
public boolean shift;
|
||||
public byte type;
|
||||
public StandardItemStack clicked;
|
||||
|
||||
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.slot = slot;
|
||||
this.mousebutton = mousebutton;
|
||||
this.action = action;
|
||||
this.shift = shift;
|
||||
this.type = type;
|
||||
this.clicked = clicked;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class PacketWindowClick extends Packet {
|
|||
this.slot = in.readShort();
|
||||
this.mousebutton = in.readByte();
|
||||
this.action = in.readShort();
|
||||
this.shift = in.readBoolean();
|
||||
this.type = in.readByte();
|
||||
this.clicked = ((StandardInput) in).readItem();
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class PacketWindowClick extends Packet {
|
|||
out.writeShort(this.slot);
|
||||
out.writeByte(this.mousebutton);
|
||||
out.writeShort(this.action);
|
||||
out.writeBoolean(this.shift);
|
||||
out.writeByte(this.type);
|
||||
if(this.clicked != null) {
|
||||
((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.
|
||||
* @return This plugin message builder.
|
||||
*/
|
||||
|
|
|
@ -95,6 +95,16 @@ public class Constants {
|
|||
public static final byte SHAKING_WATER = 8;
|
||||
public static final byte EATING_ACCEPT = 9;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,10 +76,10 @@ public class Util {
|
|||
digest.update(secret.getEncoded());
|
||||
digest.update(key.getEncoded());
|
||||
return digest.digest();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch(NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -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 serverPort Port of the server.
|
||||
* @return The prepared packet.
|
||||
|
|
Loading…
Reference in a new issue