mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 04:41:06 -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
|
@ -11,12 +11,12 @@ public class DisconnectEvent extends ProtocolEvent<ProtocolListener> {
|
|||
* The connection that was disconnected.
|
||||
*/
|
||||
private Connection conn;
|
||||
|
||||
|
||||
/**
|
||||
* The given reason for disconnecting.
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new disconnect event instance.
|
||||
* @param conn Connection that is disconnecting.
|
||||
|
@ -34,7 +34,7 @@ public class DisconnectEvent extends ProtocolEvent<ProtocolListener> {
|
|||
public Connection getConnection() {
|
||||
return this.conn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the given reason for disconnecting.
|
||||
* @return The reason for disconnecting.
|
||||
|
@ -42,7 +42,7 @@ public class DisconnectEvent extends ProtocolEvent<ProtocolListener> {
|
|||
public String getReason() {
|
||||
return this.reason;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void call(ProtocolListener listener) {
|
||||
listener.onDisconnect(this);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@ package ch.spacebase.mcprotocol.event;
|
|||
*/
|
||||
public interface PacketVisitable {
|
||||
|
||||
public void accept(PacketVisitor visitor);
|
||||
public void accept(PacketVisitor visitor);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ 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.
|
||||
* @param event The called event.
|
||||
*/
|
||||
public abstract void onPacketSend(PacketSendEvent event);
|
||||
|
||||
|
||||
/**
|
||||
* Called when a connection is disconnected.
|
||||
* @param event The called event.
|
||||
|
|
|
@ -10,5 +10,5 @@ public abstract class ServerListener {
|
|||
* @param event The called event.
|
||||
*/
|
||||
public abstract void onConnect(ConnectEvent event);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,17 +15,17 @@ public abstract class BaseConnection implements Connection {
|
|||
* The connection's remote host.
|
||||
*/
|
||||
private String host;
|
||||
|
||||
|
||||
/**
|
||||
* The connection's remote port.
|
||||
*/
|
||||
private int port;
|
||||
|
||||
|
||||
/**
|
||||
* The connection's username.
|
||||
*/
|
||||
private String username;
|
||||
|
||||
|
||||
/**
|
||||
* The connection's packets.
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ public abstract class BaseConnection implements Connection {
|
|||
* Listeners listening to this connection.
|
||||
*/
|
||||
private List<ProtocolListener> listeners = new ArrayList<ProtocolListener>();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new connection.
|
||||
* @param host Host to connect to.
|
||||
|
@ -56,26 +56,26 @@ public abstract class BaseConnection implements Connection {
|
|||
public int getRemotePort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PacketRegistry getPacketRegistry() {
|
||||
return this.packets;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setUsername(String name) {
|
||||
if(this.username != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.username = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void listen(ProtocolListener listener) {
|
||||
this.listeners.add(listener);
|
||||
|
@ -89,5 +89,5 @@ public abstract class BaseConnection implements Connection {
|
|||
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public interface Connection {
|
|||
* @return The connection's protocol type.
|
||||
*/
|
||||
public abstract PacketRegistry getPacketRegistry();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the remote host of this connection.
|
||||
* @return The connection's remote host.
|
||||
|
@ -27,7 +27,7 @@ public interface Connection {
|
|||
* @return The connection's remote port.
|
||||
*/
|
||||
public int getRemotePort();
|
||||
|
||||
|
||||
/**
|
||||
* Adds a listener to listen to this connection.
|
||||
* @param listener Listener to add.
|
||||
|
@ -40,48 +40,49 @@ public interface Connection {
|
|||
* @return The event called.
|
||||
*/
|
||||
public <T extends ProtocolEvent<ProtocolListener>> T call(T event);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the connection's username.
|
||||
* @return The connection's username.
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* Gets whether the connection is connected.
|
||||
* @return True if the connection is connected.
|
||||
*/
|
||||
public boolean isConnected();
|
||||
|
||||
|
||||
/**
|
||||
* Connects this connection.
|
||||
* @throws ConnectException If a connection error occurs.
|
||||
*/
|
||||
public void connect() throws ConnectException;
|
||||
|
||||
|
||||
/**
|
||||
* Disconnects this connection, sending a packet with a reason.
|
||||
* @param reason Reason to disconnect.
|
||||
*/
|
||||
public void disconnect(String reason);
|
||||
|
||||
|
||||
/**
|
||||
* Disconnects this connection, sending a packet with a reason.
|
||||
* @param reason Reason to disconnect.
|
||||
* @param packet Whether a disconnect packet is necessary.
|
||||
*/
|
||||
public void disconnect(String reason, boolean packet);
|
||||
|
||||
|
||||
/**
|
||||
* Sends a packet.
|
||||
* @param packet Packet to send.
|
||||
*/
|
||||
public void send(Packet packet);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ public abstract class PacketRegistry {
|
|||
public Class<? extends Packet> getPacket(int id) {
|
||||
try {
|
||||
return this.packets[id];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
} catch(ArrayIndexOutOfBoundsException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,33 +15,33 @@ public abstract class Server {
|
|||
* The server's host to listen on.
|
||||
*/
|
||||
private String host;
|
||||
|
||||
|
||||
/**
|
||||
* The server's port to listen on.
|
||||
*/
|
||||
private int port;
|
||||
|
||||
|
||||
/**
|
||||
* Whether auth is enabled.
|
||||
*/
|
||||
private boolean auth;
|
||||
|
||||
|
||||
/**
|
||||
* Listeners listening to this server.
|
||||
*/
|
||||
private List<ServerListener> listeners = new ArrayList<ServerListener>();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new server instance.
|
||||
* @param host Host to listen on.
|
||||
* @param port Port to listen on.
|
||||
*/
|
||||
public Server(String host, int port, boolean auth) {
|
||||
public Server(String host, int port, boolean auth) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the host of this server.
|
||||
* @return The server's host.
|
||||
|
@ -57,7 +57,7 @@ public abstract class Server {
|
|||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets whether authentication is enabled.
|
||||
* @return Whether auth is enabled.
|
||||
|
@ -65,7 +65,7 @@ public abstract class Server {
|
|||
public boolean isAuthEnabled() {
|
||||
return this.auth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a listener to listen to this server.
|
||||
* @param listener Listener to add.
|
||||
|
@ -86,27 +86,27 @@ public abstract class Server {
|
|||
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets whether the server is active.
|
||||
* @return Whether the server is active.
|
||||
*/
|
||||
public abstract boolean isActive();
|
||||
|
||||
|
||||
/**
|
||||
* Binds the server to its host and port.
|
||||
*/
|
||||
public abstract void bind();
|
||||
|
||||
|
||||
/**
|
||||
* Shuts the server down.
|
||||
*/
|
||||
public abstract void shutdown();
|
||||
|
||||
|
||||
/**
|
||||
* Gets a list of connections connected to this server.
|
||||
* @return The server's connections.
|
||||
*/
|
||||
public abstract List<ServerConnection> getConnections();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,70 +13,70 @@ public interface NetInput {
|
|||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public boolean readBoolean() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next byte.
|
||||
* @return The next byte.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public byte readByte() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next unsigned byte.
|
||||
* @return The next unsigned byte.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public int readUnsignedByte() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next short.
|
||||
* @return The next short.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public short readShort() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next unsigned short.
|
||||
* @return The next unsigned short.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public int readUnsignedShort() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next char.
|
||||
* @return The next char.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public char readChar() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next integer.
|
||||
* @return The next integer.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public int readInt() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next long.
|
||||
* @return The next long.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public long readLong() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next float.
|
||||
* @return The next float.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public float readFloat() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next double.
|
||||
* @return The next double.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public double readDouble() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next byte array.
|
||||
* @param The length of the byte array.
|
||||
|
@ -84,18 +84,18 @@ public interface NetInput {
|
|||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public byte[] readBytes(int length) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next string.
|
||||
* @return The next string.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public String readString() throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number of available bytes.
|
||||
* @return The number of available bytes.
|
||||
*/
|
||||
public int available() throws IOException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,63 +10,63 @@ public interface NetOutput {
|
|||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeBoolean(boolean b) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a byte.
|
||||
* @param b Byte to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeByte(int b) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a short.
|
||||
* @param s Short to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeShort(int s) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a char.
|
||||
* @param c Char to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeChar(int c) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a integer.
|
||||
* @param i Integer to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeInt(int i) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a long.
|
||||
* @param l Long to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeLong(long l) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a float.
|
||||
* @param f Float to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeFloat(float f) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a double.
|
||||
* @param d Double to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeDouble(double d) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a byte array.
|
||||
* @param b Byte array to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeBytes(byte b[]) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a byte array, using the given amount of bytes.
|
||||
* @param b Byte array to write.
|
||||
|
@ -74,18 +74,18 @@ public interface NetOutput {
|
|||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeBytes(byte b[], int length) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a string.
|
||||
* @param s String to write.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void writeString(String s) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Flushes the output.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
public void flush() throws IOException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,6 @@ public abstract class Packet implements PacketVisitable {
|
|||
* Gets the id of this packet.
|
||||
* @return The packet's id.
|
||||
*/
|
||||
public abstract int getId();
|
||||
public abstract int getId();
|
||||
|
||||
}
|
||||
|
|
|
@ -30,12 +30,12 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
* The client's session id.
|
||||
*/
|
||||
private String sessionId;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the client is logged in.
|
||||
*/
|
||||
private boolean loggedIn;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new standard client.
|
||||
* @param host Host to connect to.
|
||||
|
@ -44,7 +44,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
public StandardClient(String host, int port) {
|
||||
super(host, port);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the client's session id.
|
||||
* @return The client's session id.
|
||||
|
@ -58,12 +58,12 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
if(this.loggedIn || this.getUsername() != null) {
|
||||
throw new IllegalStateException("Already logged in with username: " + this.getUsername());
|
||||
}
|
||||
|
||||
|
||||
URL url = null;
|
||||
|
||||
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,20 +132,20 @@ 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();
|
||||
conn = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void disconnect(String reason, boolean packet) {
|
||||
this.loggedIn = false;
|
||||
super.disconnect(reason, packet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A task that keeps the client's minecraft.net session alive.
|
||||
*/
|
||||
|
@ -154,7 +154,7 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
* The minecraft.net session URL.
|
||||
*/
|
||||
private URL url;
|
||||
|
||||
|
||||
/**
|
||||
* The time when a keep alive was last sent.
|
||||
*/
|
||||
|
@ -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 {
|
||||
|
@ -195,10 +195,10 @@ public class StandardClient extends StandardConnection implements Client {
|
|||
conn = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,11 +212,11 @@ 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;
|
||||
|
@ -35,42 +35,42 @@ import ch.spacebase.mcprotocol.util.Util;
|
|||
* A connection implementing standard Minecraft protocol.
|
||||
*/
|
||||
public abstract class StandardConnection extends BaseConnection {
|
||||
|
||||
|
||||
/**
|
||||
* The connection's socket.
|
||||
*/
|
||||
private Socket sock;
|
||||
|
||||
|
||||
/**
|
||||
* The connection's input stream.
|
||||
*/
|
||||
private StandardInput input;
|
||||
|
||||
|
||||
/**
|
||||
* The connection's output stream.
|
||||
*/
|
||||
private StandardOutput output;
|
||||
|
||||
|
||||
/**
|
||||
* The connection's packet write queue.
|
||||
*/
|
||||
private Queue<Packet> packets = new ConcurrentLinkedQueue<Packet>();
|
||||
|
||||
|
||||
/**
|
||||
* Whether the connection is writing.
|
||||
*/
|
||||
private boolean writing = false;
|
||||
|
||||
|
||||
/**
|
||||
* Whether the connection is connected.
|
||||
*/
|
||||
private boolean connected = false;
|
||||
|
||||
|
||||
/**
|
||||
* The connection's secret key.
|
||||
*/
|
||||
private SecretKey key;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new standard connection.
|
||||
* @param host Host to connect to.
|
||||
|
@ -98,13 +98,13 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void disconnect(String reason) {
|
||||
this.disconnect(reason, true);
|
||||
|
@ -116,7 +116,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
if(packet && this.isConnected()) {
|
||||
this.send(new PacketDisconnect(reason));
|
||||
}
|
||||
|
||||
|
||||
new CloseThread().start();
|
||||
this.connected = false;
|
||||
this.call(new DisconnectEvent(this, reason));
|
||||
|
@ -126,7 +126,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
public void send(Packet packet) {
|
||||
this.packets.add(packet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the protocol's secret key.
|
||||
* @return The protocol's secret key.
|
||||
|
@ -142,7 +142,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
public void setSecretKey(SecretKey key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enabled AES encryption on the connection.
|
||||
* @param conn Connection to enable AES on.
|
||||
|
@ -156,7 +156,7 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
this.input = new StandardInput(new CipherInputStream(this.input.getStream(), in));
|
||||
this.output = new StandardOutput(new CipherOutputStream(this.output.getStream(), out));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A thread listening for incoming packets.
|
||||
*/
|
||||
|
@ -175,10 +175,10 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
disconnect("Bad packet ID: " + opcode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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,15 +186,15 @@ 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!");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,32 +211,33 @@ public abstract class StandardConnection extends BaseConnection {
|
|||
writing = true;
|
||||
Packet packet = packets.poll();
|
||||
call(new PacketSendEvent(packet));
|
||||
|
||||
|
||||
try {
|
||||
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.");
|
||||
}
|
||||
|
||||
|
||||
writing = false;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
|
||||
|
||||
writing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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,17 +245,17 @@ 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();
|
||||
}
|
||||
|
||||
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,5 +173,5 @@ public class StandardPackets extends PacketRegistry {
|
|||
this.registerPacket(254, PacketServerPing.class);
|
||||
this.registerPacket(255, PacketDisconnect.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ public class StandardServer extends Server {
|
|||
* The connections connected to the server.
|
||||
*/
|
||||
private List<ServerConnection> connections = new CopyOnWriteArrayList<ServerConnection>();
|
||||
|
||||
|
||||
/**
|
||||
* The server's key pair.
|
||||
*/
|
||||
private KeyPair keys;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new standard server.
|
||||
* @param host Host to listen on.
|
||||
|
@ -47,11 +47,10 @@ 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.
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -91,7 +90,7 @@ public class StandardServer extends Server {
|
|||
public List<ServerConnection> getConnections() {
|
||||
return this.connections;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Listens for new server connections.
|
||||
*/
|
||||
|
@ -119,19 +118,19 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,37 +12,37 @@ import ch.spacebase.mcprotocol.util.Util;
|
|||
* A server connection for the standard minecraft protocol.
|
||||
*/
|
||||
public class StandardServerConnection extends StandardConnection implements ServerConnection {
|
||||
|
||||
|
||||
/**
|
||||
* The server this connection belongs to.
|
||||
*/
|
||||
private Server server;
|
||||
|
||||
|
||||
/**
|
||||
* The connection's temporary socket variable.
|
||||
*/
|
||||
private Socket sock;
|
||||
|
||||
|
||||
/**
|
||||
* The last time a keep alive was sent.
|
||||
*/
|
||||
private long aliveTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
/**
|
||||
* The last sent server keep alive id.
|
||||
*/
|
||||
private int aliveId;
|
||||
|
||||
|
||||
/**
|
||||
* The protocol's login key.
|
||||
*/
|
||||
private String loginKey;
|
||||
|
||||
|
||||
/**
|
||||
* The protocol's security token.
|
||||
*/
|
||||
private byte token[];
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new server connection.
|
||||
* @param server Server the connection belongs to.
|
||||
|
@ -53,7 +53,7 @@ public class StandardServerConnection extends StandardConnection implements Serv
|
|||
this.server = server;
|
||||
this.sock = sock;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the last id used in a keep alive to this connection.
|
||||
* @return The last keep alive id.
|
||||
|
@ -61,7 +61,7 @@ public class StandardServerConnection extends StandardConnection implements Serv
|
|||
public int getLastAliveId() {
|
||||
return this.aliveId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the last time a keep alive was performed.
|
||||
* @return The last keep alive time.
|
||||
|
@ -81,7 +81,7 @@ public class StandardServerConnection extends StandardConnection implements Serv
|
|||
this.sock = null;
|
||||
new KeepAliveThread().start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the connection's login key.
|
||||
* @return The connection's login key.
|
||||
|
@ -113,7 +113,7 @@ public class StandardServerConnection extends StandardConnection implements Serv
|
|||
public void setToken(byte token[]) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A thread that keeps the connection alive.
|
||||
*/
|
||||
|
@ -126,13 +126,13 @@ public class StandardServerConnection extends StandardConnection implements Serv
|
|||
aliveId = Util.random().nextInt();
|
||||
send(new PacketKeepAlive(aliveId));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class AttributeModifier {
|
|||
* The modifier's operation.
|
||||
*/
|
||||
private int operation;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new modifier.
|
||||
* @param uid Unique id of the modifier.
|
||||
|
@ -31,7 +31,7 @@ public class AttributeModifier {
|
|||
this.amount = amount;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the modifier's unique id.
|
||||
* @return The modifier's unique id.
|
||||
|
@ -39,7 +39,7 @@ public class AttributeModifier {
|
|||
public UUID getUID() {
|
||||
return this.uid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the modifier's amount.
|
||||
* @return The modifier's amount.
|
||||
|
@ -47,7 +47,7 @@ public class AttributeModifier {
|
|||
public double getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the modifier's operation.
|
||||
* @return The modifier's operation.
|
||||
|
@ -55,5 +55,5 @@ public class AttributeModifier {
|
|||
public int getOperation() {
|
||||
return this.operation;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ public class Coordinates {
|
|||
* The X coordinate.
|
||||
*/
|
||||
private int x;
|
||||
|
||||
|
||||
/**
|
||||
* The Y coordinate.
|
||||
*/
|
||||
private int y;
|
||||
|
||||
|
||||
/**
|
||||
* The Z coordinate.
|
||||
*/
|
||||
|
|
|
@ -20,7 +20,7 @@ public class EntityAttribute {
|
|||
* The attribute's modifiers.
|
||||
*/
|
||||
private List<AttributeModifier> modifiers;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new entity attribute instance.
|
||||
* @param name Name of the attribute.
|
||||
|
@ -29,7 +29,7 @@ public class EntityAttribute {
|
|||
public EntityAttribute(String name, double value) {
|
||||
this(name, value, new ArrayList<AttributeModifier>());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new entity attribute instance.
|
||||
* @param name Name of the attribute.
|
||||
|
@ -41,7 +41,7 @@ public class EntityAttribute {
|
|||
this.value = value;
|
||||
this.modifiers = modifiers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the attribute's name.
|
||||
* @return The attribute's name.
|
||||
|
@ -49,7 +49,7 @@ public class EntityAttribute {
|
|||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the attribute's value.
|
||||
* @return The attribute's value.
|
||||
|
@ -57,7 +57,7 @@ public class EntityAttribute {
|
|||
public double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the attribute's modifiers.
|
||||
* @return The attribute's modifiers.
|
||||
|
@ -65,7 +65,7 @@ public class EntityAttribute {
|
|||
public List<AttributeModifier> getModifiers() {
|
||||
return this.modifiers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a modifier to the attribute.
|
||||
* @param mod Modifier to add.
|
||||
|
@ -73,5 +73,5 @@ public class EntityAttribute {
|
|||
public void addModifier(AttributeModifier mod) {
|
||||
this.modifiers.add(mod);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,17 +9,17 @@ public class StandardItemStack {
|
|||
* Id of the items in the stack.
|
||||
*/
|
||||
private short item;
|
||||
|
||||
|
||||
/**
|
||||
* The size of the item stack.
|
||||
*/
|
||||
private byte stackSize;
|
||||
|
||||
|
||||
/**
|
||||
* The damage value of the items in the stack.
|
||||
*/
|
||||
private short damage;
|
||||
|
||||
|
||||
/**
|
||||
* The compressed NBT data of the item stack.
|
||||
*/
|
||||
|
@ -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.
|
||||
|
@ -73,7 +74,7 @@ public class StandardItemStack {
|
|||
public short getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the item id of the stack.
|
||||
* @param item New item id of the stack.
|
||||
|
|
|
@ -9,12 +9,12 @@ public class WatchableObject {
|
|||
* The type id of the object.
|
||||
*/
|
||||
private int type;
|
||||
|
||||
|
||||
/**
|
||||
* The id of the object.
|
||||
*/
|
||||
private int id;
|
||||
|
||||
|
||||
/**
|
||||
* The value of the object.
|
||||
*/
|
||||
|
|
|
@ -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,20 +56,20 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPacketSend(PacketSendEvent event) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectEvent event) {
|
||||
Util.logger().info("Disconnected: " + event.getReason());
|
||||
|
|
|
@ -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.visitor = new Visitor();
|
||||
}
|
||||
this.client.listen(this.listener);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
this.visitor = new Visitor();
|
||||
}
|
||||
|
||||
public void say(String text) {
|
||||
PacketChat chat = new PacketChat();
|
||||
chat.message = text;
|
||||
this.client.send(chat);
|
||||
}
|
||||
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 static void main(String[] args) {
|
||||
ChatBotVisitor bot = new ChatBotVisitor(HOST, PORT);
|
||||
Util.logger().info("Logging in...");
|
||||
bot.login(USERNAME, PASSWORD);
|
||||
}
|
||||
public void say(String text) {
|
||||
PacketChat chat = new PacketChat();
|
||||
chat.message = text;
|
||||
this.client.send(chat);
|
||||
}
|
||||
|
||||
private class Visitor extends PacketVisitorAdapter {
|
||||
public static void main(String[] args) {
|
||||
ChatBotVisitor bot = new ChatBotVisitor(HOST, PORT);
|
||||
Util.logger().info("Logging in...");
|
||||
bot.login(USERNAME, PASSWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(PacketPlayerPositionLook packet) {
|
||||
client.send(packet);
|
||||
DecimalFormat format = new DecimalFormat("#.00");
|
||||
private class Visitor extends PacketVisitorAdapter {
|
||||
|
||||
ChatBotVisitor.this.say("Hello, this is "+USERNAME+" at coordinate (" + format.format(packet.x) + ", " + format.format(packet.y) + ", " + format.format(packet.z) + ")");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void visit(PacketPlayerPositionLook packet) {
|
||||
client.send(packet);
|
||||
DecimalFormat format = new DecimalFormat("#.00");
|
||||
|
||||
private class Listener extends ProtocolListener {
|
||||
ChatBotVisitor.this.say("Hello, this is " + USERNAME + " at coordinate (" + format.format(packet.x) + ", " + format.format(packet.y) + ", " + format.format(packet.z) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketRecieveEvent event) {
|
||||
Packet packet = event.getPacket();
|
||||
packet.accept(visitor);
|
||||
}
|
||||
private class Listener extends ProtocolListener {
|
||||
|
||||
@Override
|
||||
public void onPacketSend(PacketSendEvent event) {
|
||||
}
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
Packet packet = event.getPacket();
|
||||
packet.accept(visitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectEvent event) {
|
||||
Util.logger().info("Disconnected: " + event.getReason());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPacketSend(PacketSendEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectEvent event) {
|
||||
Util.logger().info("Disconnected: " + event.getReason());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ import ch.spacebase.mcprotocol.util.Constants;
|
|||
public class StandardInput implements NetInput {
|
||||
|
||||
private InputStream in;
|
||||
|
||||
|
||||
public StandardInput(InputStream in) {
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
|
||||
public InputStream getStream() {
|
||||
return this.in;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class StandardInput implements NetInput {
|
|||
public boolean readBoolean() throws IOException {
|
||||
return this.readByte() == 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte readByte() throws IOException {
|
||||
return (byte) this.readUnsignedByte();
|
||||
|
@ -40,7 +40,7 @@ public class StandardInput implements NetInput {
|
|||
if(b < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -94,17 +94,17 @@ public class StandardInput implements NetInput {
|
|||
if(length < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
|
||||
int n = 0;
|
||||
while(n < length) {
|
||||
int count = this.in.read(b, n, length - n);
|
||||
if(count < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
|
||||
|
||||
n += count;
|
||||
}
|
||||
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -118,12 +118,12 @@ public class StandardInput implements NetInput {
|
|||
|
||||
return new String(characters);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return this.in.available();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads an entity's metadata.
|
||||
* @return The read metadata objects.
|
||||
|
@ -166,7 +166,7 @@ public class StandardInput implements NetInput {
|
|||
|
||||
return objects.toArray(new WatchableObject[objects.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads an item stack.
|
||||
* @return The read item stack.
|
||||
|
@ -185,10 +185,10 @@ public class StandardInput implements NetInput {
|
|||
nbt = this.readBytes(length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new StandardItemStack(item, stackSize, damage, nbt);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads a coordinate group.
|
||||
* @return The read coordinates.
|
||||
|
@ -200,5 +200,5 @@ public class StandardInput implements NetInput {
|
|||
int z = this.readInt();
|
||||
return new Coordinates(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,15 +11,15 @@ import ch.spacebase.mcprotocol.util.Constants;
|
|||
public class StandardOutput implements NetOutput {
|
||||
|
||||
private OutputStream out;
|
||||
|
||||
|
||||
public StandardOutput(OutputStream out) {
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
|
||||
public OutputStream getStream() {
|
||||
return this.out;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeBoolean(boolean b) throws IOException {
|
||||
this.writeByte(b ? 1 : 0);
|
||||
|
@ -76,7 +76,7 @@ public class StandardOutput implements NetOutput {
|
|||
public void writeBytes(byte b[]) throws IOException {
|
||||
this.writeBytes(b, b.length);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeBytes(byte b[], int length) throws IOException {
|
||||
this.out.write(b, 0, length);
|
||||
|
@ -87,7 +87,7 @@ public class StandardOutput implements NetOutput {
|
|||
if(s == null) {
|
||||
throw new IllegalArgumentException("String cannot be null!");
|
||||
}
|
||||
|
||||
|
||||
int len = s.length();
|
||||
if(len >= 65536) {
|
||||
throw new IllegalArgumentException("String too long.");
|
||||
|
@ -98,12 +98,12 @@ public class StandardOutput implements NetOutput {
|
|||
this.writeChar(s.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
this.out.flush();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes an entity's metadata.
|
||||
* @param data Metadata objects to write.
|
||||
|
@ -140,7 +140,7 @@ public class StandardOutput implements NetOutput {
|
|||
|
||||
this.writeByte(127);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes an item stack.
|
||||
* @param item Item stack to write.
|
||||
|
@ -159,7 +159,7 @@ public class StandardOutput implements NetOutput {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes a coordinate group.
|
||||
* @param coords Coordinates to write.
|
||||
|
@ -170,5 +170,5 @@ public class StandardOutput implements NetOutput {
|
|||
this.writeInt(coords.getY());
|
||||
this.writeInt(coords.getZ());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,10 +46,10 @@ public class PacketCollectItem extends Packet {
|
|||
public int getId() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(PacketVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(PacketVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class PacketEntityAction extends Packet {
|
|||
public PacketEntityAction(int entityId, byte action) {
|
||||
this(entityId, action, 0);
|
||||
}
|
||||
|
||||
|
||||
public PacketEntityAction(int entityId, byte action, int jumpBar) {
|
||||
this.entityId = entityId;
|
||||
this.action = action;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import ch.spacebase.mcprotocol.packet.Packet;
|
|||
public class PacketLogin extends Packet {
|
||||
|
||||
public static boolean FORGE = false;
|
||||
|
||||
|
||||
public int entityId;
|
||||
public String levelType;
|
||||
public byte gameMode;
|
||||
|
@ -44,7 +44,7 @@ public class PacketLogin extends Packet {
|
|||
} else {
|
||||
this.dimension = in.readByte();
|
||||
}
|
||||
|
||||
|
||||
this.difficulty = in.readByte();
|
||||
this.unused = in.readByte();
|
||||
this.maxPlayers = in.readByte();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
@ -82,7 +82,7 @@ public class PacketMapChunk extends Packet {
|
|||
} finally {
|
||||
deflater.end();
|
||||
}
|
||||
|
||||
|
||||
out.writeInt(this.x);
|
||||
out.writeInt(this.z);
|
||||
out.writeBoolean(this.groundUp);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class PacketOpenWindow extends Packet {
|
|||
|
||||
public PacketOpenWindow() {
|
||||
}
|
||||
|
||||
|
||||
public PacketOpenWindow(byte id, byte type, String name, byte slots, boolean useTitle) {
|
||||
this(id, type, name, slots, useTitle, 0);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class PacketPlayerBlockPlace extends Packet {
|
|||
if(this.item != null) {
|
||||
((StandardOutput) out).writeItem(this.item);
|
||||
}
|
||||
|
||||
|
||||
out.writeByte(this.cursorX);
|
||||
out.writeByte(this.cursorY);
|
||||
out.writeByte(this.cursorZ);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue