Pre-1.7 misc. fixes (Waiting for 1.7.2 MCP update)

This commit is contained in:
Steveice10 2013-11-01 17:43:53 -07:00
parent 435a20230e
commit 7112e67607
115 changed files with 945 additions and 934 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -7,5 +7,5 @@ package ch.spacebase.mcprotocol.event;
*/
public interface PacketVisitable {
public void accept(PacketVisitor visitor);
public void accept(PacketVisitor visitor);
}

View file

@ -9,167 +9,167 @@ import ch.spacebase.mcprotocol.standard.packet.*;
*/
public interface PacketVisitor {
public void visit(PacketKeepAlive packet);
public void visit(PacketKeepAlive packet);
public void visit(PacketLogin packet);
public void visit(PacketLogin packet);
public void visit(PacketHandshake packet);
public void visit(PacketHandshake packet);
public void visit(PacketChat packet);
public void visit(PacketChat packet);
public void visit(PacketTimeUpdate packet);
public void visit(PacketTimeUpdate packet);
public void visit(PacketEntityEquipment packet);
public void visit(PacketEntityEquipment packet);
public void visit(PacketSpawnPosition packet);
public void visit(PacketSpawnPosition packet);
public void visit(PacketUseEntity packet);
public void visit(PacketUseEntity packet);
public void visit(PacketHealthUpdate packet);
public void visit(PacketHealthUpdate packet);
public void visit(PacketRespawn packet);
public void visit(PacketRespawn packet);
public void visit(PacketPlayer packet);
public void visit(PacketPlayer packet);
public void visit(PacketPlayerPosition packet);
public void visit(PacketPlayerPosition packet);
public void visit(PacketPlayerLook packet);
public void visit(PacketPlayerLook packet);
public void visit(PacketPlayerPositionLook packet);
public void visit(PacketPlayerPositionLook packet);
public void visit(PacketPlayerDigging packet);
public void visit(PacketPlayerDigging packet);
public void visit(PacketPlayerBlockPlace packet);
public void visit(PacketPlayerBlockPlace packet);
public void visit(PacketHeldItemChange packet);
public void visit(PacketHeldItemChange packet);
public void visit(PacketUseBed packet);
public void visit(PacketUseBed packet);
public void visit(PacketAnimation packet);
public void visit(PacketAnimation packet);
public void visit(PacketEntityAction packet);
public void visit(PacketEntityAction packet);
public void visit(PacketSpawnNamedEntity packet);
public void visit(PacketSpawnNamedEntity packet);
public void visit(PacketCollectItem packet);
public void visit(PacketCollectItem packet);
public void visit(PacketSpawnObject packet);
public void visit(PacketSpawnObject packet);
public void visit(PacketSpawnMob packet);
public void visit(PacketSpawnMob packet);
public void visit(PacketSpawnPainting packet);
public void visit(PacketSpawnPainting packet);
public void visit(PacketSpawnExpOrb packet);
public void visit(PacketSpawnExpOrb packet);
public void visit(PacketSteerVehicle packet);
public void visit(PacketSteerVehicle packet);
public void visit(PacketEntityVelocity packet);
public void visit(PacketEntityVelocity packet);
public void visit(PacketDestroyEntity packet);
public void visit(PacketDestroyEntity packet);
public void visit(PacketEntity packet);
public void visit(PacketEntity packet);
public void visit(PacketEntityRelativeMove packet);
public void visit(PacketEntityRelativeMove packet);
public void visit(PacketEntityLook packet);
public void visit(PacketEntityLook packet);
public void visit(PacketEntityLookRelativeMove packet);
public void visit(PacketEntityLookRelativeMove packet);
public void visit(PacketEntityTeleport packet);
public void visit(PacketEntityTeleport packet);
public void visit(PacketEntityHeadYaw packet);
public void visit(PacketEntityHeadYaw packet);
public void visit(PacketEntityStatus packet);
public void visit(PacketEntityStatus packet);
public void visit(PacketAttachEntity packet);
public void visit(PacketAttachEntity packet);
public void visit(PacketEntityMetadata packet);
public void visit(PacketEntityMetadata packet);
public void visit(PacketEntityEffect packet);
public void visit(PacketEntityEffect packet);
public void visit(PacketRemoveEntityEffect packet);
public void visit(PacketRemoveEntityEffect packet);
public void visit(PacketSetExperience packet);
public void visit(PacketSetExperience packet);
public void visit(PacketEntityAttributes packet);
public void visit(PacketEntityAttributes packet);
public void visit(PacketMapChunk packet);
public void visit(PacketMapChunk packet);
public void visit(PacketMultiBlockChange packet);
public void visit(PacketMultiBlockChange packet);
public void visit(PacketBlockChange packet);
public void visit(PacketBlockChange packet);
public void visit(PacketBlockAction packet);
public void visit(PacketBlockAction packet);
public void visit(PacketBlockBreakAnimation packet);
public void visit(PacketBlockBreakAnimation packet);
public void visit(PacketMapChunkBulk packet);
public void visit(PacketMapChunkBulk packet);
public void visit(PacketExplosion packet);
public void visit(PacketExplosion packet);
public void visit(PacketEffect packet);
public void visit(PacketEffect packet);
public void visit(PacketNamedSound packet);
public void visit(PacketNamedSound packet);
public void visit(PacketSpawnParticle packet);
public void visit(PacketSpawnParticle packet);
public void visit(PacketGameState packet);
public void visit(PacketGameState packet);
public void visit(PacketLightning packet);
public void visit(PacketLightning packet);
public void visit(PacketOpenWindow packet);
public void visit(PacketOpenWindow packet);
public void visit(PacketCloseWindow packet);
public void visit(PacketCloseWindow packet);
public void visit(PacketWindowClick packet);
public void visit(PacketWindowClick packet);
public void visit(PacketSetSlot packet);
public void visit(PacketSetSlot packet);
public void visit(PacketWindowItems packet);
public void visit(PacketWindowItems packet);
public void visit(PacketWindowProperty packet);
public void visit(PacketWindowProperty packet);
public void visit(PacketConfirmTransaction packet);
public void visit(PacketConfirmTransaction packet);
public void visit(PacketCreativeSlot packet);
public void visit(PacketCreativeSlot packet);
public void visit(PacketEnchantItem packet);
public void visit(PacketEnchantItem packet);
public void visit(PacketUpdateSign packet);
public void visit(PacketUpdateSign packet);
public void visit(PacketItemData packet);
public void visit(PacketItemData packet);
public void visit(PacketUpdateTileEntity packet);
public void visit(PacketUpdateTileEntity packet);
public void visit(PacketOpenTileEditor packet);
public void visit(PacketOpenTileEditor packet);
public void visit(PacketIncrementStatistic packet);
public void visit(PacketIncrementStatistic packet);
public void visit(PacketPlayerListItem packet);
public void visit(PacketPlayerListItem packet);
public void visit(PacketPlayerAbilities packet);
public void visit(PacketPlayerAbilities packet);
public void visit(PacketTabComplete packet);
public void visit(PacketTabComplete packet);
public void visit(PacketClientInfo packet);
public void visit(PacketClientInfo packet);
public void visit(PacketClientStatus packet);
public void visit(PacketClientStatus packet);
public void visit(PacketScoreboardObjective packet);
public void visit(PacketScoreboardObjective packet);
public void visit(PacketUpdateScoreboard packet);
public void visit(PacketUpdateScoreboard packet);
public void visit(PacketDisplayScoreboard packet);
public void visit(PacketDisplayScoreboard packet);
public void visit(PacketTeam packet);
public void visit(PacketTeam packet);
public void visit(PacketPluginMessage packet);
public void visit(PacketPluginMessage packet);
public void visit(PacketKeyResponse packet);
public void visit(PacketKeyResponse packet);
public void visit(PacketKeyRequest packet);
public void visit(PacketKeyRequest packet);
public void visit(PacketServerPing packet);
public void visit(PacketServerPing packet);
public void visit(PacketDisconnect packet);
public void visit(PacketDisconnect packet);
}

View file

@ -84,256 +84,256 @@ 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
*/
public class PacketVisitorAdapter implements PacketVisitor {
public void visit(PacketKeepAlive packet) {
}
public void visit(PacketKeepAlive packet) {
}
public void visit(PacketLogin packet) {
}
public void visit(PacketLogin packet) {
}
public void visit(PacketHandshake packet) {
}
public void visit(PacketHandshake packet) {
}
public void visit(PacketChat packet) {
}
public void visit(PacketChat packet) {
}
public void visit(PacketTimeUpdate packet) {
}
public void visit(PacketTimeUpdate packet) {
}
public void visit(PacketEntityEquipment packet) {
}
public void visit(PacketEntityEquipment packet) {
}
public void visit(PacketSpawnPosition packet) {
}
public void visit(PacketSpawnPosition packet) {
}
public void visit(PacketUseEntity packet) {
}
public void visit(PacketUseEntity packet) {
}
public void visit(PacketHealthUpdate packet) {
}
public void visit(PacketHealthUpdate packet) {
}
public void visit(PacketRespawn packet) {
}
public void visit(PacketRespawn packet) {
}
public void visit(PacketPlayer packet) {
}
public void visit(PacketPlayer packet) {
}
public void visit(PacketPlayerPosition packet) {
}
public void visit(PacketPlayerPosition packet) {
}
public void visit(PacketPlayerLook packet) {
}
public void visit(PacketPlayerLook packet) {
}
public void visit(PacketPlayerPositionLook packet) {
}
public void visit(PacketPlayerPositionLook packet) {
}
public void visit(PacketPlayerDigging packet) {
}
public void visit(PacketPlayerDigging packet) {
}
public void visit(PacketPlayerBlockPlace packet) {
}
public void visit(PacketPlayerBlockPlace packet) {
}
public void visit(PacketHeldItemChange packet) {
}
public void visit(PacketHeldItemChange packet) {
}
public void visit(PacketUseBed packet) {
}
public void visit(PacketUseBed packet) {
}
public void visit(PacketAnimation packet) {
}
public void visit(PacketAnimation packet) {
}
public void visit(PacketEntityAction packet) {
}
public void visit(PacketEntityAction packet) {
}
public void visit(PacketSpawnNamedEntity packet) {
}
public void visit(PacketSpawnNamedEntity packet) {
}
public void visit(PacketCollectItem packet) {
}
public void visit(PacketCollectItem packet) {
}
public void visit(PacketSpawnObject packet) {
}
public void visit(PacketSpawnObject packet) {
}
public void visit(PacketSpawnMob packet) {
}
public void visit(PacketSpawnMob packet) {
}
public void visit(PacketSpawnPainting packet) {
}
public void visit(PacketSpawnPainting packet) {
}
public void visit(PacketSpawnExpOrb packet) {
}
public void visit(PacketSpawnExpOrb packet) {
}
public void visit(PacketSteerVehicle packet) {
}
public void visit(PacketSteerVehicle packet) {
}
public void visit(PacketEntityVelocity packet) {
}
public void visit(PacketEntityVelocity packet) {
}
public void visit(PacketDestroyEntity packet) {
}
public void visit(PacketDestroyEntity packet) {
}
public void visit(PacketEntity packet) {
}
public void visit(PacketEntity packet) {
}
public void visit(PacketEntityRelativeMove packet) {
}
public void visit(PacketEntityRelativeMove packet) {
}
public void visit(PacketEntityLook packet) {
}
public void visit(PacketEntityLook packet) {
}
public void visit(PacketEntityLookRelativeMove packet) {
}
public void visit(PacketEntityLookRelativeMove packet) {
}
public void visit(PacketEntityTeleport packet) {
}
public void visit(PacketEntityTeleport packet) {
}
public void visit(PacketEntityHeadYaw packet) {
}
public void visit(PacketEntityHeadYaw packet) {
}
public void visit(PacketEntityStatus packet) {
}
public void visit(PacketEntityStatus packet) {
}
public void visit(PacketAttachEntity packet) {
}
public void visit(PacketAttachEntity packet) {
}
public void visit(PacketEntityMetadata packet) {
}
public void visit(PacketEntityMetadata packet) {
}
public void visit(PacketEntityEffect packet) {
}
public void visit(PacketEntityEffect packet) {
}
public void visit(PacketRemoveEntityEffect packet) {
}
public void visit(PacketRemoveEntityEffect packet) {
}
public void visit(PacketSetExperience packet) {
}
public void visit(PacketSetExperience packet) {
}
public void visit(PacketEntityAttributes packet) {
}
public void visit(PacketEntityAttributes packet) {
}
public void visit(PacketMapChunk packet) {
}
public void visit(PacketMapChunk packet) {
}
public void visit(PacketMultiBlockChange packet) {
}
public void visit(PacketMultiBlockChange packet) {
}
public void visit(PacketBlockChange packet) {
}
public void visit(PacketBlockChange packet) {
}
public void visit(PacketBlockAction packet) {
}
public void visit(PacketBlockAction packet) {
}
public void visit(PacketBlockBreakAnimation packet) {
}
public void visit(PacketBlockBreakAnimation packet) {
}
public void visit(PacketMapChunkBulk packet) {
}
public void visit(PacketMapChunkBulk packet) {
}
public void visit(PacketExplosion packet) {
}
public void visit(PacketExplosion packet) {
}
public void visit(PacketEffect packet) {
}
public void visit(PacketEffect packet) {
}
public void visit(PacketNamedSound packet) {
}
public void visit(PacketNamedSound packet) {
}
public void visit(PacketSpawnParticle packet) {
}
public void visit(PacketSpawnParticle packet) {
}
public void visit(PacketGameState packet) {
}
public void visit(PacketGameState packet) {
}
public void visit(PacketLightning packet) {
}
public void visit(PacketLightning packet) {
}
public void visit(PacketOpenWindow packet) {
}
public void visit(PacketOpenWindow packet) {
}
public void visit(PacketCloseWindow packet) {
}
public void visit(PacketCloseWindow packet) {
}
public void visit(PacketWindowClick packet) {
}
public void visit(PacketWindowClick packet) {
}
public void visit(PacketSetSlot packet) {
}
public void visit(PacketSetSlot packet) {
}
public void visit(PacketWindowItems packet) {
}
public void visit(PacketWindowItems packet) {
}
public void visit(PacketWindowProperty packet) {
}
public void visit(PacketWindowProperty packet) {
}
public void visit(PacketConfirmTransaction packet) {
}
public void visit(PacketConfirmTransaction packet) {
}
public void visit(PacketCreativeSlot packet) {
}
public void visit(PacketCreativeSlot packet) {
}
public void visit(PacketEnchantItem packet) {
}
public void visit(PacketEnchantItem packet) {
}
public void visit(PacketUpdateSign packet) {
}
public void visit(PacketUpdateSign packet) {
}
public void visit(PacketItemData packet) {
}
public void visit(PacketItemData packet) {
}
public void visit(PacketUpdateTileEntity packet) {
}
public void visit(PacketUpdateTileEntity packet) {
}
public void visit(PacketOpenTileEditor packet) {
}
public void visit(PacketOpenTileEditor packet) {
}
public void visit(PacketIncrementStatistic packet) {
}
public void visit(PacketIncrementStatistic packet) {
}
public void visit(PacketPlayerListItem packet) {
}
public void visit(PacketPlayerListItem packet) {
}
public void visit(PacketPlayerAbilities packet) {
}
public void visit(PacketPlayerAbilities packet) {
}
public void visit(PacketTabComplete packet) {
}
public void visit(PacketTabComplete packet) {
}
public void visit(PacketClientInfo packet) {
}
public void visit(PacketClientInfo packet) {
}
public void visit(PacketClientStatus packet) {
}
public void visit(PacketClientStatus packet) {
}
public void visit(PacketScoreboardObjective packet) {
}
public void visit(PacketScoreboardObjective packet) {
}
public void visit(PacketUpdateScoreboard packet) {
}
public void visit(PacketUpdateScoreboard packet) {
}
public void visit(PacketDisplayScoreboard packet) {
}
public void visit(PacketDisplayScoreboard packet) {
}
public void visit(PacketTeam packet) {
}
public void visit(PacketTeam packet) {
}
public void visit(PacketPluginMessage packet) {
}
public void visit(PacketPluginMessage packet) {
}
public void visit(PacketKeyResponse packet) {
}
public void visit(PacketKeyResponse packet) {
}
public void visit(PacketKeyRequest packet) {
}
public void visit(PacketKeyRequest packet) {
}
public void visit(PacketServerPing packet) {
}
public void visit(PacketServerPing packet) {
}
public void visit(PacketDisconnect packet) {
}
public void visit(PacketDisconnect packet) {
}
}

View file

@ -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.

View file

@ -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);

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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();
}

View file

@ -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) {
}
}
}

View file

@ -129,7 +129,7 @@ public class StandardServerConnection extends StandardConnection implements Serv
try {
Thread.sleep(2);
} catch (InterruptedException e) {
} catch(InterruptedException e) {
}
}
}

View file

@ -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.

View file

@ -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,13 +56,13 @@ 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()) {
case 0x0D:
onPositionLook((PacketPlayerPositionLook) packet);
break;
case 0x0D:
onPositionLook((PacketPlayerPositionLook) packet);
break;
}
}

View file

@ -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;
@ -28,78 +28,77 @@ import java.util.logging.Logger;
*/
public class ChatBotVisitor {
private static final String USERNAME = "";
private static final String PASSWORD = "";
private static final String HOST = "127.0.0.1";
private static final int PORT = 25565;
private static final String USERNAME = "";
private static final String PASSWORD = "";
private static final String HOST = "127.0.0.1";
private static final int PORT = 25565;
private Client client;
private Listener listener;
private PacketVisitor visitor;
private Client client;
private Listener listener;
private PacketVisitor visitor;
public ChatBotVisitor(String host, int port) {
this.client = new StandardClient(host, port);
this.listener = new Listener();
public ChatBotVisitor(String host, int port) {
this.client = new StandardClient(host, port);
this.listener = new Listener();
this.client.listen(this.listener);
this.client.listen(this.listener);
this.visitor = new Visitor();
}
this.visitor = new Visitor();
}
public void login(String username, String password) {
try {
this.client.login(username, password);
} catch(LoginException ex) {
Logger.getLogger("Login Error: " + ex.getLocalizedMessage());
} catch(OutdatedLibraryException ex) {
Logger.getLogger(ChatBotVisitor.class.getName()).log(Level.SEVERE, null, ex);
}
try {
this.client.connect();
} catch(ConnectException e) {
e.printStackTrace();
}
}
public void login(String username, String password) {
try {
this.client.login(username, password);
} catch (LoginException ex) {
Logger.getLogger("Login Error: " + ex.getLocalizedMessage());
} catch (OutdatedLibraryException ex) {
Logger.getLogger(ChatBotVisitor.class.getName()).log(Level.SEVERE, null, ex);
}
try {
this.client.connect();
} catch (ConnectException e) {
e.printStackTrace();
}
}
public void say(String text) {
PacketChat chat = new PacketChat();
chat.message = text;
this.client.send(chat);
}
public void say(String text) {
PacketChat chat = new PacketChat();
chat.message = text;
this.client.send(chat);
}
public static void main(String[] args) {
ChatBotVisitor bot = new ChatBotVisitor(HOST, PORT);
Util.logger().info("Logging in...");
bot.login(USERNAME, PASSWORD);
}
public static void main(String[] args) {
ChatBotVisitor bot = new ChatBotVisitor(HOST, PORT);
Util.logger().info("Logging in...");
bot.login(USERNAME, PASSWORD);
}
private class Visitor extends PacketVisitorAdapter {
private class Visitor extends PacketVisitorAdapter {
@Override
public void visit(PacketPlayerPositionLook packet) {
client.send(packet);
DecimalFormat format = new DecimalFormat("#.00");
@Override
public void visit(PacketPlayerPositionLook packet) {
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 {
private class Listener extends ProtocolListener {
@Override
public void onPacketReceive(PacketReceiveEvent event) {
Packet packet = event.getPacket();
packet.accept(visitor);
}
@Override
public void onPacketReceive(PacketRecieveEvent event) {
Packet packet = event.getPacket();
packet.accept(visitor);
}
@Override
public void onPacketSend(PacketSendEvent event) {
}
@Override
public void onPacketSend(PacketSendEvent event) {
}
@Override
public void onDisconnect(DisconnectEvent event) {
Util.logger().info("Disconnected: " + event.getReason());
}
}
@Override
public void onDisconnect(DisconnectEvent event) {
Util.logger().info("Disconnected: " + event.getReason());
}
}
}

View file

@ -47,9 +47,9 @@ public class PacketAnimation extends Packet {
return 18;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketAttachEntity extends Packet {
return 39;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -63,9 +63,9 @@ public class PacketBlockAction extends Packet {
return 54;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketBlockBreakAnimation extends Packet {
return 55;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketBlockChange extends Packet {
return 53;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketChat extends Packet {
return 3;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketClientInfo extends Packet {
return 204;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -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();
}
@ -80,9 +80,9 @@ public class PacketClientStatus extends Packet {
return 205;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -43,9 +43,9 @@ public class PacketCloseWindow extends Packet {
return 101;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketCollectItem extends Packet {
return 22;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketConfirmTransaction extends Packet {
return 106;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -52,9 +52,9 @@ public class PacketCreativeSlot extends Packet {
return 107;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -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();
}
@ -49,9 +49,9 @@ public class PacketDestroyEntity extends Packet {
return 29;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -49,9 +49,9 @@ public class PacketDisconnect extends Packet {
return 255;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -46,9 +46,9 @@ public class PacketDisplayScoreboard extends Packet {
return 208;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -63,9 +63,9 @@ public class PacketEffect extends Packet {
return 61;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketEnchantItem extends Packet {
return 108;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -43,9 +43,9 @@ public class PacketEntity extends Packet {
return 30;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -55,9 +55,9 @@ public class PacketEntityAction extends Packet {
return 19;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -74,9 +74,9 @@ public class PacketEntityAttributes extends Packet {
return 44;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -55,9 +55,9 @@ public class PacketEntityEffect extends Packet {
return 41;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -66,9 +66,9 @@ public class PacketEntityEquipment extends Packet {
return 5;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketEntityHeadYaw extends Packet {
return 35;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketEntityLook extends Packet {
return 32;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -63,9 +63,9 @@ public class PacketEntityLookRelativeMove extends Packet {
return 33;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -50,9 +50,9 @@ public class PacketEntityMetadata extends Packet {
return 40;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -55,9 +55,9 @@ public class PacketEntityRelativeMove extends Packet {
return 31;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketEntityStatus extends Packet {
return 38;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -63,10 +63,9 @@ public class PacketEntityTeleport extends Packet {
return 34;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -55,9 +55,9 @@ public class PacketEntityVelocity extends Packet {
return 28;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -72,9 +72,9 @@ public class PacketExplosion extends Packet {
return 60;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketGameState extends Packet {
return 70;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -78,9 +78,9 @@ public class PacketHandshake extends Packet {
return 2;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketHealthUpdate extends Packet {
return 8;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -43,9 +43,9 @@ public class PacketHeldItemChange extends Packet {
return 16;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketIncrementStatistic extends Packet {
return 200;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -52,9 +52,9 @@ public class PacketItemData extends Packet {
return 131;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -44,9 +44,9 @@ public class PacketKeepAlive extends Packet {
return 0;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -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,14 +155,14 @@ public class PacketKeyRequest extends Packet {
String response = reader.readLine();
reader.close();
return response;
} catch (IOException e) {
} catch(IOException e) {
return e.toString();
}
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -90,24 +90,24 @@ 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();
}
return null;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketLightning extends Packet {
return 71;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -78,9 +78,9 @@ public class PacketLogin extends Packet {
return 1;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -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();
@ -105,9 +105,9 @@ public class PacketMapChunk extends Packet {
return 51;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -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();
@ -117,9 +117,9 @@ public class PacketMapChunkBulk extends Packet {
return 56;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -63,9 +63,9 @@ public class PacketMultiBlockChange extends Packet {
return 52;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -63,9 +63,9 @@ public class PacketNamedSound extends Packet {
return 62;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -55,9 +55,9 @@ public class PacketOpenTileEditor extends Packet {
return 133;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -72,9 +72,9 @@ public class PacketOpenWindow extends Packet {
return 100;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -43,9 +43,9 @@ public class PacketPlayer extends Packet {
return 10;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -67,9 +67,9 @@ public class PacketPlayerAbilities extends Packet {
return 202;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -78,9 +78,9 @@ public class PacketPlayerBlockPlace extends Packet {
return 15;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketPlayerDigging extends Packet {
return 14;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketPlayerListItem extends Packet {
return 201;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketPlayerLook extends Packet {
return 12;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketPlayerPosition extends Packet {
return 11;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -67,9 +67,9 @@ public class PacketPlayerPositionLook extends Packet {
return 13;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -48,9 +48,9 @@ public class PacketPluginMessage extends Packet {
return 250;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketRemoveEntityEffect extends Packet {
return 42;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketRespawn extends Packet {
return 9;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -50,9 +50,9 @@ public class PacketScoreboardObjective extends Packet {
return 206;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -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;
@ -41,9 +40,9 @@ public class PacketServerPing extends Packet {
return 254;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketSetExperience extends Packet {
return 43;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -56,9 +56,9 @@ public class PacketSetSlot extends Packet {
return 103;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketSpawnExpOrb extends Packet {
return 26;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -90,9 +90,9 @@ public class PacketSpawnMob extends Packet {
return 24;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -78,9 +78,9 @@ public class PacketSpawnNamedEntity extends Packet {
return 20;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -87,9 +87,9 @@ public class PacketSpawnObject extends Packet {
return 23;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -63,9 +63,9 @@ public class PacketSpawnPainting extends Packet {
return 25;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -72,9 +72,9 @@ public class PacketSpawnParticle extends Packet {
return 63;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketSpawnPosition extends Packet {
return 6;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -55,9 +55,9 @@ public class PacketSteerVehicle extends Packet {
return 27;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -43,9 +43,9 @@ public class PacketTabComplete extends Packet {
return 203;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -161,9 +161,9 @@ public class PacketTeam extends Packet {
return 209;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -47,9 +47,9 @@ public class PacketTimeUpdate extends Packet {
return 4;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -58,9 +58,9 @@ public class PacketUpdateScoreboard extends Packet {
return 207;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -63,9 +63,9 @@ public class PacketUpdateSign extends Packet {
return 130;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -62,9 +62,9 @@ public class PacketUpdateTileEntity extends Packet {
return 132;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -59,9 +59,9 @@ public class PacketUseBed extends Packet {
return 17;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketUseEntity extends Packet {
return 7;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -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);
}
@ -68,9 +68,9 @@ public class PacketWindowClick extends Packet {
return 102;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -56,9 +56,9 @@ public class PacketWindowItems extends Packet {
return 104;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -51,9 +51,9 @@ public class PacketWindowProperty extends Packet {
return 105;
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
@Override
public void accept(PacketVisitor visitor) {
visitor.visit(this);
}
}

View file

@ -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.
*/

View file

@ -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;
}
/**

View file

@ -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.