General cleanup, fixes, and re-versioning.

This commit is contained in:
Steven Smith 2015-07-20 11:01:13 -07:00
parent 2b39ead979
commit b22cd66d4f
240 changed files with 9618 additions and 9445 deletions

5
.gitignore vendored
View file

@ -1,12 +1,13 @@
bin
lib
target
testing
.settings
.classpath
.project
.directory
*.iml
.idea
target

View file

@ -1,4 +1,4 @@
Copyright (C) 2013-2014 Steveice10
Copyright (C) 2013-2015 Steveice10
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -1,30 +1,14 @@
<b><center><h1>MCProtocolLib</h></center></b>
==========
<b>About MCProtocolLib</b>
--------
# MCProtocolLib
MCProtocolLib is a simple library for communicating with a Minecraft client/server. It aims to allow people to make custom bots, clients, or servers for Minecraft easily.
## Example Code
See example/org/spacehq/mc/protocol/test
<b>Example Code</b>
--------
See example/org/spacehq/mc/protocol/test/Test.java
<b>Building the Source</b>
--------
## Building the Source
MCProtocolLib uses Maven to manage dependencies. Simply run 'mvn clean install' in the source's directory.
Snapshots (if any exist) can be downloaded <b>[here](http://repo.spacehq.org/content/repositories/snapshots/org/spacehq/mcprotocollib)</b>.
Releases (if any exist) can be downloaded <b>[here](http://repo.spacehq.org/content/repositories/release/org/spacehq/mcprotocollib)</b>.
Builds can be downloaded **[here](http://build.spacehq.org/job/MCProtocolLib)**.
<b>License</b>
---------
MCProtocolLib is licensed under the <b>[MIT license](http://www.opensource.org/licenses/mit-license.html)</b>.
## License
MCProtocolLib is licensed under the **[MIT license](http://www.opensource.org/licenses/mit-license.html)**.

View file

@ -0,0 +1,183 @@
package org.spacehq.mc.protocol.test;
import org.spacehq.mc.auth.GameProfile;
import org.spacehq.mc.auth.exception.AuthenticationException;
import org.spacehq.mc.protocol.MinecraftProtocol;
import org.spacehq.mc.protocol.ProtocolConstants;
import org.spacehq.mc.protocol.ProtocolMode;
import org.spacehq.mc.protocol.ServerLoginHandler;
import org.spacehq.mc.protocol.data.game.values.entity.player.GameMode;
import org.spacehq.mc.protocol.data.game.values.setting.Difficulty;
import org.spacehq.mc.protocol.data.game.values.world.WorldType;
import org.spacehq.mc.protocol.data.message.ChatColor;
import org.spacehq.mc.protocol.data.message.ChatFormat;
import org.spacehq.mc.protocol.data.message.Message;
import org.spacehq.mc.protocol.data.message.MessageStyle;
import org.spacehq.mc.protocol.data.message.TextMessage;
import org.spacehq.mc.protocol.data.message.TranslationMessage;
import org.spacehq.mc.protocol.data.status.PlayerInfo;
import org.spacehq.mc.protocol.data.status.ServerStatusInfo;
import org.spacehq.mc.protocol.data.status.VersionInfo;
import org.spacehq.mc.protocol.data.status.handler.ServerInfoBuilder;
import org.spacehq.mc.protocol.data.status.handler.ServerInfoHandler;
import org.spacehq.mc.protocol.data.status.handler.ServerPingTimeHandler;
import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import org.spacehq.packetlib.Client;
import org.spacehq.packetlib.Server;
import org.spacehq.packetlib.Session;
import org.spacehq.packetlib.event.server.ServerAdapter;
import org.spacehq.packetlib.event.server.SessionAddedEvent;
import org.spacehq.packetlib.event.server.SessionRemovedEvent;
import org.spacehq.packetlib.event.session.DisconnectedEvent;
import org.spacehq.packetlib.event.session.PacketReceivedEvent;
import org.spacehq.packetlib.event.session.SessionAdapter;
import org.spacehq.packetlib.tcp.TcpSessionFactory;
import java.net.Proxy;
import java.util.Arrays;
public class MinecraftProtocolTest {
private static final boolean SPAWN_SERVER = true;
private static final boolean VERIFY_USERS = false;
private static final String HOST = "127.0.0.1";
private static final int PORT = 25565;
private static final Proxy PROXY = Proxy.NO_PROXY;
private static final Proxy AUTH_PROXY = Proxy.NO_PROXY;
private static final String USERNAME = "Username";
private static final String PASSWORD = "Password";
public static void main(String[] args) {
if(SPAWN_SERVER) {
Server server = new Server(HOST, PORT, MinecraftProtocol.class, new TcpSessionFactory(PROXY));
server.setGlobalFlag(ProtocolConstants.AUTH_PROXY_KEY, AUTH_PROXY);
server.setGlobalFlag(ProtocolConstants.VERIFY_USERS_KEY, VERIFY_USERS);
server.setGlobalFlag(ProtocolConstants.SERVER_INFO_BUILDER_KEY, new ServerInfoBuilder() {
@Override
public ServerStatusInfo buildInfo(Session session) {
return new ServerStatusInfo(new VersionInfo(ProtocolConstants.GAME_VERSION, ProtocolConstants.PROTOCOL_VERSION), new PlayerInfo(100, 0, new GameProfile[0]), new TextMessage("Hello world!"), null);
}
});
server.setGlobalFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY, new ServerLoginHandler() {
@Override
public void loggedIn(Session session) {
session.send(new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, 0, Difficulty.PEACEFUL, 10, WorldType.DEFAULT, false));
}
});
server.setGlobalFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD, 100);
server.addListener(new ServerAdapter() {
@Override
public void sessionAdded(SessionAddedEvent event) {
event.getSession().addListener(new SessionAdapter() {
@Override
public void packetReceived(PacketReceivedEvent event) {
if(event.getPacket() instanceof ClientChatPacket) {
ClientChatPacket packet = event.getPacket();
GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY);
System.out.println(profile.getName() + ": " + packet.getMessage());
Message msg = new TextMessage("Hello, ").setStyle(new MessageStyle().setColor(ChatColor.GREEN));
Message name = new TextMessage(profile.getName()).setStyle(new MessageStyle().setColor(ChatColor.AQUA).addFormat(ChatFormat.UNDERLINED));
Message end = new TextMessage("!");
msg.addExtra(name);
msg.addExtra(end);
event.getSession().send(new ServerChatPacket(msg));
}
}
});
}
@Override
public void sessionRemoved(SessionRemovedEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.GAME) {
System.out.println("Closing server.");
event.getServer().close();
}
}
});
server.bind();
}
status();
login();
}
private static void status() {
MinecraftProtocol protocol = new MinecraftProtocol(ProtocolMode.STATUS);
Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY));
client.getSession().setFlag(ProtocolConstants.AUTH_PROXY_KEY, AUTH_PROXY);
client.getSession().setFlag(ProtocolConstants.SERVER_INFO_HANDLER_KEY, new ServerInfoHandler() {
@Override
public void handle(Session session, ServerStatusInfo info) {
System.out.println("Version: " + info.getVersionInfo().getVersionName() + ", " + info.getVersionInfo().getProtocolVersion());
System.out.println("Player Count: " + info.getPlayerInfo().getOnlinePlayers() + " / " + info.getPlayerInfo().getMaxPlayers());
System.out.println("Players: " + Arrays.toString(info.getPlayerInfo().getPlayers()));
System.out.println("Description: " + info.getDescription().getFullText());
System.out.println("Icon: " + info.getIcon());
}
});
client.getSession().setFlag(ProtocolConstants.SERVER_PING_TIME_HANDLER_KEY, new ServerPingTimeHandler() {
@Override
public void handle(Session session, long pingTime) {
System.out.println("Server ping took " + pingTime + "ms");
}
});
client.getSession().connect();
while(client.getSession().isConnected()) {
try {
Thread.sleep(5);
} catch(InterruptedException e) {
e.printStackTrace();
}
}
}
private static void login() {
MinecraftProtocol protocol = null;
if(VERIFY_USERS) {
try {
protocol = new MinecraftProtocol(USERNAME, PASSWORD, false);
System.out.println("Successfully authenticated user.");
} catch(AuthenticationException e) {
e.printStackTrace();
return;
}
} else {
protocol = new MinecraftProtocol(USERNAME);
}
Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY));
client.getSession().addListener(new SessionAdapter() {
@Override
public void packetReceived(PacketReceivedEvent event) {
if(event.getPacket() instanceof ServerJoinGamePacket) {
event.getSession().send(new ClientChatPacket("Hello, this is a test of MCProtocolLib."));
} else if(event.getPacket() instanceof ServerChatPacket) {
Message message = event.<ServerChatPacket>getPacket().getMessage();
System.out.println("Received Message: " + message.getFullText());
if(message instanceof TranslationMessage) {
System.out.println("Received Translation Components: " + Arrays.toString(((TranslationMessage) message).getTranslationParams()));
}
event.getSession().disconnect("Finished");
}
}
@Override
public void disconnected(DisconnectedEvent event) {
System.out.println("Disconnected: " + Message.fromString(event.getReason()).getFullText());
if(event.getCause() != null) {
event.getCause().printStackTrace();
}
}
});
client.getSession().connect();
}
}

View file

@ -1,177 +0,0 @@
package org.spacehq.mc.protocol.test;
import org.spacehq.mc.auth.GameProfile;
import org.spacehq.mc.auth.exception.AuthenticationException;
import org.spacehq.mc.protocol.MinecraftProtocol;
import org.spacehq.mc.protocol.ProtocolConstants;
import org.spacehq.mc.protocol.ProtocolMode;
import org.spacehq.mc.protocol.ServerLoginHandler;
import org.spacehq.mc.protocol.data.game.values.entity.player.GameMode;
import org.spacehq.mc.protocol.data.game.values.setting.Difficulty;
import org.spacehq.mc.protocol.data.game.values.world.WorldType;
import org.spacehq.mc.protocol.data.message.*;
import org.spacehq.mc.protocol.data.status.PlayerInfo;
import org.spacehq.mc.protocol.data.status.ServerStatusInfo;
import org.spacehq.mc.protocol.data.status.VersionInfo;
import org.spacehq.mc.protocol.data.status.handler.ServerInfoBuilder;
import org.spacehq.mc.protocol.data.status.handler.ServerInfoHandler;
import org.spacehq.mc.protocol.data.status.handler.ServerPingTimeHandler;
import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import org.spacehq.packetlib.Client;
import org.spacehq.packetlib.Server;
import org.spacehq.packetlib.Session;
import org.spacehq.packetlib.event.server.ServerAdapter;
import org.spacehq.packetlib.event.server.SessionAddedEvent;
import org.spacehq.packetlib.event.server.SessionRemovedEvent;
import org.spacehq.packetlib.event.session.DisconnectedEvent;
import org.spacehq.packetlib.event.session.PacketReceivedEvent;
import org.spacehq.packetlib.event.session.SessionAdapter;
import org.spacehq.packetlib.tcp.TcpSessionFactory;
import java.net.Proxy;
import java.util.Arrays;
public class Test {
private static final boolean SPAWN_SERVER = true;
private static final boolean VERIFY_USERS = false;
private static final String HOST = "127.0.0.1";
private static final int PORT = 25565;
private static final Proxy PROXY = Proxy.NO_PROXY;
private static final Proxy AUTH_PROXY = Proxy.NO_PROXY;
private static final String USERNAME = "Username";
private static final String PASSWORD = "Password";
public static void main(String[] args) {
if(SPAWN_SERVER) {
Server server = new Server(HOST, PORT, MinecraftProtocol.class, new TcpSessionFactory(PROXY));
server.setGlobalFlag(ProtocolConstants.AUTH_PROXY_KEY, AUTH_PROXY);
server.setGlobalFlag(ProtocolConstants.VERIFY_USERS_KEY, VERIFY_USERS);
server.setGlobalFlag(ProtocolConstants.SERVER_INFO_BUILDER_KEY, new ServerInfoBuilder() {
@Override
public ServerStatusInfo buildInfo(Session session) {
return new ServerStatusInfo(new VersionInfo(ProtocolConstants.GAME_VERSION, ProtocolConstants.PROTOCOL_VERSION), new PlayerInfo(100, 0, new GameProfile[0]), new TextMessage("Hello world!"), null);
}
});
server.setGlobalFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY, new ServerLoginHandler() {
@Override
public void loggedIn(Session session) {
session.send(new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, 0, Difficulty.PEACEFUL, 10, WorldType.DEFAULT, false));
}
});
server.setGlobalFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD, 100);
server.addListener(new ServerAdapter() {
@Override
public void sessionAdded(SessionAddedEvent event) {
event.getSession().addListener(new SessionAdapter() {
@Override
public void packetReceived(PacketReceivedEvent event) {
if(event.getPacket() instanceof ClientChatPacket) {
ClientChatPacket packet = event.getPacket();
GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY);
System.out.println(profile.getName() + ": " + packet.getMessage());
Message msg = new TextMessage("Hello, ").setStyle(new MessageStyle().setColor(ChatColor.GREEN));
Message name = new TextMessage(profile.getName()).setStyle(new MessageStyle().setColor(ChatColor.AQUA).addFormat(ChatFormat.UNDERLINED));
Message end = new TextMessage("!");
msg.addExtra(name);
msg.addExtra(end);
event.getSession().send(new ServerChatPacket(msg));
}
}
});
}
@Override
public void sessionRemoved(SessionRemovedEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.GAME) {
System.out.println("Closing server.");
event.getServer().close();
}
}
});
server.bind();
}
status();
login();
}
private static void status() {
MinecraftProtocol protocol = new MinecraftProtocol(ProtocolMode.STATUS);
Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY));
client.getSession().setFlag(ProtocolConstants.AUTH_PROXY_KEY, AUTH_PROXY);
client.getSession().setFlag(ProtocolConstants.SERVER_INFO_HANDLER_KEY, new ServerInfoHandler() {
@Override
public void handle(Session session, ServerStatusInfo info) {
System.out.println("Version: " + info.getVersionInfo().getVersionName() + ", " + info.getVersionInfo().getProtocolVersion());
System.out.println("Player Count: " + info.getPlayerInfo().getOnlinePlayers() + " / " + info.getPlayerInfo().getMaxPlayers());
System.out.println("Players: " + Arrays.toString(info.getPlayerInfo().getPlayers()));
System.out.println("Description: " + info.getDescription().getFullText());
System.out.println("Icon: " + info.getIcon());
}
});
client.getSession().setFlag(ProtocolConstants.SERVER_PING_TIME_HANDLER_KEY, new ServerPingTimeHandler() {
@Override
public void handle(Session session, long pingTime) {
System.out.println("Server ping took " + pingTime + "ms");
}
});
client.getSession().connect();
while(client.getSession().isConnected()) {
try {
Thread.sleep(5);
} catch(InterruptedException e) {
e.printStackTrace();
}
}
}
private static void login() {
MinecraftProtocol protocol = null;
if(VERIFY_USERS) {
try {
protocol = new MinecraftProtocol(USERNAME, PASSWORD, false);
System.out.println("Successfully authenticated user.");
} catch(AuthenticationException e) {
e.printStackTrace();
return;
}
} else {
protocol = new MinecraftProtocol(USERNAME);
}
Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(PROXY));
client.getSession().addListener(new SessionAdapter() {
@Override
public void packetReceived(PacketReceivedEvent event) {
if(event.getPacket() instanceof ServerJoinGamePacket) {
event.getSession().send(new ClientChatPacket("Hello, this is a test of MCProtocolLib."));
} else if(event.getPacket() instanceof ServerChatPacket) {
Message message = event.<ServerChatPacket>getPacket().getMessage();
System.out.println("Received Message: " + message.getFullText());
if(message instanceof TranslationMessage) {
System.out.println("Received Translation Components: " + Arrays.toString(((TranslationMessage) message).getTranslationParams()));
}
event.getSession().disconnect("Finished");
}
}
@Override
public void disconnected(DisconnectedEvent event) {
System.out.println("Disconnected: " + Message.fromString(event.getReason()).getFullText());
}
});
client.getSession().connect();
}
}

62
pom.xml
View file

@ -11,6 +11,16 @@
<description>A library for communicating with a Minecraft client or server.</description>
<url>http://github.com/Steveice10/MCProtocolLib/</url>
<scm>
<connection>scm:git:git@github.com:Steveice10/MCProtocolLib.git</connection>
<developerConnection>scm:git:git@github.com:Steveice10/MCProtocolLib.git</developerConnection>
<url>git@github.com:Steveice10/MCProtocolLib/</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<licenses>
<license>
<name>MIT</name>
@ -19,25 +29,6 @@
</license>
</licenses>
<scm>
<connection>scm:git:git@github.com:Steveice10/MCProtocolLib.git</connection>
<developerConnection>scm:git:git@github.com:Steveice10/MCProtocolLib.git</developerConnection>
<url>git@github.com:Steveice10/MCProtocolLib/</url>
</scm>
<distributionManagement>
<repository>
<id>spacehq</id>
<name>spacehq-releases</name>
<url>http://repo.spacehq.org/content/repositories/release/</url>
</repository>
<snapshotRepository>
<id>spacehq</id>
<name>spacehq-snapshots</name>
<url>http://repo.spacehq.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<developers>
<developer>
<id>steveice10</id>
@ -46,10 +37,23 @@
</developer>
</developers>
<distributionManagement>
<repository>
<id>spacehq</id>
<name>spacehq-releases</name>
<url>http://repo.spacehq.org/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>spacehq</id>
<name>spacehq-snapshots</name>
<url>http://repo.spacehq.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>spacehq-releases</id>
<url>http://repo.spacehq.org/content/repositories/release/</url>
<url>http://repo.spacehq.org/content/repositories/releases/</url>
</repository>
<repository>
<id>spacehq-snapshots</id>
@ -57,22 +61,17 @@
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.spacehq</groupId>
<artifactId>opennbt</artifactId>
<version>1.4</version>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spacehq</groupId>
<artifactId>packetlib</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -89,23 +88,21 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- JAR creation plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<version>2.6</version>
</plugin>
<!-- JAR dependency addition plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
@ -115,6 +112,7 @@
</execution>
</executions>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<filters>
<filter>
<artifact>*:*</artifact>

View file

@ -36,100 +36,100 @@ import java.net.Proxy;
public class ClientListener extends SessionAdapter {
private SecretKey key;
private SecretKey key;
@Override
public void packetReceived(PacketReceivedEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.LOGIN) {
if(event.getPacket() instanceof EncryptionRequestPacket) {
EncryptionRequestPacket packet = event.getPacket();
this.key = CryptUtil.generateSharedKey();
@Override
public void packetReceived(PacketReceivedEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.LOGIN) {
if(event.getPacket() instanceof EncryptionRequestPacket) {
EncryptionRequestPacket packet = event.getPacket();
this.key = CryptUtil.generateSharedKey();
Proxy proxy = event.getSession().<Proxy>getFlag(ProtocolConstants.AUTH_PROXY_KEY);
if(proxy == null) {
proxy = Proxy.NO_PROXY;
}
Proxy proxy = event.getSession().<Proxy>getFlag(ProtocolConstants.AUTH_PROXY_KEY);
if(proxy == null) {
proxy = Proxy.NO_PROXY;
}
GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY);
String serverHash = new BigInteger(CryptUtil.getServerIdHash(packet.getServerId(), packet.getPublicKey(), this.key)).toString(16);
String accessToken = event.getSession().getFlag(ProtocolConstants.ACCESS_TOKEN_KEY);
try {
new SessionService(proxy).joinServer(profile, accessToken, serverHash);
} catch(AuthenticationUnavailableException e) {
event.getSession().disconnect("Login failed: Authentication service unavailable.");
return;
} catch(InvalidCredentialsException e) {
event.getSession().disconnect("Login failed: Invalid login session.");
return;
} catch(AuthenticationException e) {
event.getSession().disconnect("Login failed: Authentication error: " + e.getMessage());
return;
}
GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY);
String serverHash = new BigInteger(CryptUtil.getServerIdHash(packet.getServerId(), packet.getPublicKey(), this.key)).toString(16);
String accessToken = event.getSession().getFlag(ProtocolConstants.ACCESS_TOKEN_KEY);
try {
new SessionService(proxy).joinServer(profile, accessToken, serverHash);
} catch(AuthenticationUnavailableException e) {
event.getSession().disconnect("Login failed: Authentication service unavailable.");
return;
} catch(InvalidCredentialsException e) {
event.getSession().disconnect("Login failed: Invalid login session.");
return;
} catch(AuthenticationException e) {
event.getSession().disconnect("Login failed: Authentication error: " + e.getMessage());
return;
}
event.getSession().send(new EncryptionResponsePacket(this.key, packet.getPublicKey(), packet.getVerifyToken()));
} else if(event.getPacket() instanceof LoginSuccessPacket) {
LoginSuccessPacket packet = event.getPacket();
event.getSession().setFlag(ProtocolConstants.PROFILE_KEY, packet.getProfile());
protocol.setMode(ProtocolMode.GAME, true, event.getSession());
} else if(event.getPacket() instanceof LoginDisconnectPacket) {
LoginDisconnectPacket packet = event.getPacket();
event.getSession().disconnect(packet.getReason().getFullText());
} else if(event.getPacket() instanceof LoginSetCompressionPacket) {
event.getSession().setCompressionThreshold(event.<LoginSetCompressionPacket>getPacket().getThreshold());
}
} else if(protocol.getMode() == ProtocolMode.STATUS) {
if(event.getPacket() instanceof StatusResponsePacket) {
ServerStatusInfo info = event.<StatusResponsePacket>getPacket().getInfo();
ServerInfoHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_INFO_HANDLER_KEY);
if(handler != null) {
handler.handle(event.getSession(), info);
}
event.getSession().send(new EncryptionResponsePacket(this.key, packet.getPublicKey(), packet.getVerifyToken()));
} else if(event.getPacket() instanceof LoginSuccessPacket) {
LoginSuccessPacket packet = event.getPacket();
event.getSession().setFlag(ProtocolConstants.PROFILE_KEY, packet.getProfile());
protocol.setMode(ProtocolMode.GAME, true, event.getSession());
} else if(event.getPacket() instanceof LoginDisconnectPacket) {
LoginDisconnectPacket packet = event.getPacket();
event.getSession().disconnect(packet.getReason().getFullText());
} else if(event.getPacket() instanceof LoginSetCompressionPacket) {
event.getSession().setCompressionThreshold(event.<LoginSetCompressionPacket>getPacket().getThreshold());
}
} else if(protocol.getMode() == ProtocolMode.STATUS) {
if(event.getPacket() instanceof StatusResponsePacket) {
ServerStatusInfo info = event.<StatusResponsePacket>getPacket().getInfo();
ServerInfoHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_INFO_HANDLER_KEY);
if(handler != null) {
handler.handle(event.getSession(), info);
}
event.getSession().send(new StatusPingPacket(System.currentTimeMillis()));
} else if(event.getPacket() instanceof StatusPongPacket) {
long time = System.currentTimeMillis() - event.<StatusPongPacket>getPacket().getPingTime();
ServerPingTimeHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_PING_TIME_HANDLER_KEY);
if(handler != null) {
handler.handle(event.getSession(), time);
}
event.getSession().send(new StatusPingPacket(System.currentTimeMillis()));
} else if(event.getPacket() instanceof StatusPongPacket) {
long time = System.currentTimeMillis() - event.<StatusPongPacket>getPacket().getPingTime();
ServerPingTimeHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_PING_TIME_HANDLER_KEY);
if(handler != null) {
handler.handle(event.getSession(), time);
}
event.getSession().disconnect("Finished");
}
} else if(protocol.getMode() == ProtocolMode.GAME) {
if(event.getPacket() instanceof ServerKeepAlivePacket) {
event.getSession().send(new ClientKeepAlivePacket(event.<ServerKeepAlivePacket>getPacket().getPingId()));
} else if(event.getPacket() instanceof ServerDisconnectPacket) {
event.getSession().disconnect(event.<ServerDisconnectPacket>getPacket().getReason().getFullText());
} else if(event.getPacket() instanceof ServerSetCompressionPacket) {
event.getSession().setCompressionThreshold(event.<ServerSetCompressionPacket>getPacket().getThreshold());
}
}
}
event.getSession().disconnect("Finished");
}
} else if(protocol.getMode() == ProtocolMode.GAME) {
if(event.getPacket() instanceof ServerKeepAlivePacket) {
event.getSession().send(new ClientKeepAlivePacket(event.<ServerKeepAlivePacket>getPacket().getPingId()));
} else if(event.getPacket() instanceof ServerDisconnectPacket) {
event.getSession().disconnect(event.<ServerDisconnectPacket>getPacket().getReason().getFullText());
} else if(event.getPacket() instanceof ServerSetCompressionPacket) {
event.getSession().setCompressionThreshold(event.<ServerSetCompressionPacket>getPacket().getThreshold());
}
}
}
@Override
public void packetSent(PacketSentEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.LOGIN && event.getPacket() instanceof EncryptionResponsePacket) {
protocol.enableEncryption(this.key);
}
}
@Override
public void packetSent(PacketSentEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.LOGIN && event.getPacket() instanceof EncryptionResponsePacket) {
protocol.enableEncryption(this.key);
}
}
@Override
public void connected(ConnectedEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.LOGIN) {
GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY);
protocol.setMode(ProtocolMode.HANDSHAKE, true, event.getSession());
event.getSession().send(new HandshakePacket(ProtocolConstants.PROTOCOL_VERSION, event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.LOGIN));
protocol.setMode(ProtocolMode.LOGIN, true, event.getSession());
event.getSession().send(new LoginStartPacket(profile != null ? profile.getName() : ""));
} else if(protocol.getMode() == ProtocolMode.STATUS) {
protocol.setMode(ProtocolMode.HANDSHAKE, true, event.getSession());
event.getSession().send(new HandshakePacket(ProtocolConstants.PROTOCOL_VERSION, event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.STATUS));
protocol.setMode(ProtocolMode.STATUS, true, event.getSession());
event.getSession().send(new StatusQueryPacket());
}
}
@Override
public void connected(ConnectedEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.LOGIN) {
GameProfile profile = event.getSession().getFlag(ProtocolConstants.PROFILE_KEY);
protocol.setMode(ProtocolMode.HANDSHAKE, true, event.getSession());
event.getSession().send(new HandshakePacket(ProtocolConstants.PROTOCOL_VERSION, event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.LOGIN));
protocol.setMode(ProtocolMode.LOGIN, true, event.getSession());
event.getSession().send(new LoginStartPacket(profile != null ? profile.getName() : ""));
} else if(protocol.getMode() == ProtocolMode.STATUS) {
protocol.setMode(ProtocolMode.HANDSHAKE, true, event.getSession());
event.getSession().send(new HandshakePacket(ProtocolConstants.PROTOCOL_VERSION, event.getSession().getHost(), event.getSession().getPort(), HandshakeIntent.STATUS));
protocol.setMode(ProtocolMode.STATUS, true, event.getSession());
event.getSession().send(new StatusQueryPacket());
}
}
}

View file

@ -4,22 +4,106 @@ import org.spacehq.mc.auth.GameProfile;
import org.spacehq.mc.auth.UserAuthentication;
import org.spacehq.mc.auth.exception.AuthenticationException;
import org.spacehq.mc.protocol.packet.handshake.client.HandshakePacket;
import org.spacehq.mc.protocol.packet.ingame.client.*;
import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientKeepAlivePacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientRequestPacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientResourcePackStatusPacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientSettingsPacket;
import org.spacehq.mc.protocol.packet.ingame.client.ClientTabCompletePacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientChangeHeldItemPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerAbilitiesPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerRotationPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientSpectatePacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientSteerVehiclePacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientSwingArmPacket;
import org.spacehq.mc.protocol.packet.ingame.client.player.*;
import org.spacehq.mc.protocol.packet.ingame.client.window.*;
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket;
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientConfirmTransactionPacket;
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientCreativeInventoryActionPacket;
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientEnchantItemPacket;
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientWindowActionPacket;
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientUpdateSignPacket;
import org.spacehq.mc.protocol.packet.ingame.server.*;
import org.spacehq.mc.protocol.packet.ingame.server.entity.*;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.*;
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.*;
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerCombatPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerDifficultyPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerDisconnectPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerPlayerListDataPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerPlayerListEntryPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerResourcePackSendPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerRespawnPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerSetCompressionPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerStatisticsPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerSwitchCameraPacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerTabCompletePacket;
import org.spacehq.mc.protocol.packet.ingame.server.ServerTitlePacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerAnimationPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerCollectItemPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerDestroyEntitiesPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityAttachPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityEffectPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityEquipmentPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityHeadLookPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityMetadataPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityMovementPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityNBTUpdatePacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPositionPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPositionRotationPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPropertiesPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityRemoveEffectPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityRotationPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityStatusPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerChangeHeldItemPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerAbilitiesPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerUseBedPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerSetExperiencePacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerUpdateHealthPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnGlobalEntityPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnMobPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPaintingPacket;
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket;
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket;
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
import org.spacehq.mc.protocol.packet.ingame.server.window.*;
import org.spacehq.mc.protocol.packet.ingame.server.world.*;
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerCloseWindowPacket;
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket;
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket;
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket;
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket;
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerWindowPropertyPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockBreakAnimPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockValuePacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerExplosionPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMapDataPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMultiBlockChangePacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMultiChunkDataPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerOpenTileEntityEditorPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlaySoundPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerSpawnParticlePacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerSpawnPositionPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateSignPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket;
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerWorldBorderPacket;
import org.spacehq.mc.protocol.packet.login.client.EncryptionResponsePacket;
import org.spacehq.mc.protocol.packet.login.client.LoginStartPacket;
import org.spacehq.mc.protocol.packet.login.server.EncryptionRequestPacket;
@ -46,414 +130,409 @@ import java.util.UUID;
public class MinecraftProtocol extends PacketProtocol {
private ProtocolMode mode = ProtocolMode.HANDSHAKE;
private PacketHeader header = new DefaultPacketHeader();
private AESEncryption encrypt;
private ProtocolMode mode = ProtocolMode.HANDSHAKE;
private PacketHeader header = new DefaultPacketHeader();
private AESEncryption encrypt;
private GameProfile profile;
private String accessToken = "";
private ClientListener clientListener;
private GameProfile profile;
private String accessToken = "";
private ClientListener clientListener;
@SuppressWarnings("unused")
private MinecraftProtocol() {
}
@SuppressWarnings("unused")
private MinecraftProtocol() {
}
public MinecraftProtocol(ProtocolMode mode) {
if(mode != ProtocolMode.LOGIN && mode != ProtocolMode.STATUS) {
throw new IllegalArgumentException("Only login and status modes are permitted.");
}
public MinecraftProtocol(ProtocolMode mode) {
if(mode != ProtocolMode.LOGIN && mode != ProtocolMode.STATUS) {
throw new IllegalArgumentException("Only login and status modes are permitted.");
}
this.mode = mode;
if(mode == ProtocolMode.LOGIN) {
this.profile = new GameProfile((UUID) null, "Player");
}
this.mode = mode;
if(mode == ProtocolMode.LOGIN) {
this.profile = new GameProfile((UUID) null, "Player");
}
this.clientListener = new ClientListener();
}
this.clientListener = new ClientListener();
}
public MinecraftProtocol(String username) {
this(ProtocolMode.LOGIN);
this.profile = new GameProfile((UUID) null, username);
}
public MinecraftProtocol(String username) {
this(ProtocolMode.LOGIN);
this.profile = new GameProfile((UUID) null, username);
}
public MinecraftProtocol(String username, String password) throws AuthenticationException {
this(username, password, false);
}
public MinecraftProtocol(String username, String password) throws AuthenticationException {
this(username, password, false);
}
public MinecraftProtocol(String username, String using, boolean token) throws AuthenticationException {
this(username, using, token, Proxy.NO_PROXY);
}
public MinecraftProtocol(String username, String using, boolean token) throws AuthenticationException {
this(username, using, token, Proxy.NO_PROXY);
}
public MinecraftProtocol(String username, String using, boolean token, Proxy authProxy) throws AuthenticationException {
this(ProtocolMode.LOGIN);
String clientToken = UUID.randomUUID().toString();
UserAuthentication auth = new UserAuthentication(clientToken, authProxy);
auth.setUsername(username);
if(token) {
auth.setAccessToken(using);
} else {
auth.setPassword(using);
}
public MinecraftProtocol(String username, String using, boolean token, Proxy authProxy) throws AuthenticationException {
this(ProtocolMode.LOGIN);
String clientToken = UUID.randomUUID().toString();
UserAuthentication auth = new UserAuthentication(clientToken, authProxy);
auth.setUsername(username);
if(token) {
auth.setAccessToken(using);
} else {
auth.setPassword(using);
}
auth.login();
this.profile = auth.getSelectedProfile();
this.accessToken = auth.getAccessToken();
}
auth.login();
this.profile = auth.getSelectedProfile();
this.accessToken = auth.getAccessToken();
}
public MinecraftProtocol(GameProfile profile, String accessToken) {
this(ProtocolMode.LOGIN);
this.profile = profile;
this.accessToken = accessToken;
public MinecraftProtocol(GameProfile profile, String accessToken) {
this(ProtocolMode.LOGIN);
this.profile = profile;
this.accessToken = accessToken;
}
}
public GameProfile getProfile() {
return this.profile;
}
public GameProfile getProfile() {
return this.profile;
}
public String getAccessToken() {
return this.accessToken;
}
public String getAccessToken() {
return this.accessToken;
}
@Override
public boolean needsPacketSizer() {
return true;
}
@Override
public String getSRVRecordPrefix() {
return "_minecraft";
}
@Override
public boolean needsPacketEncryptor() {
return true;
}
@Override
public PacketHeader getPacketHeader() {
return this.header;
}
@Override
public PacketHeader getPacketHeader() {
return this.header;
}
@Override
public PacketEncryption getEncryption() {
return this.encrypt;
}
@Override
public PacketEncryption getEncryption() {
return this.encrypt;
}
@Override
public void newClientSession(Client client, Session session) {
if(this.profile != null) {
session.setFlag(ProtocolConstants.PROFILE_KEY, this.profile);
session.setFlag(ProtocolConstants.ACCESS_TOKEN_KEY, this.accessToken);
}
@Override
public void newClientSession(Client client, Session session) {
if(this.profile != null) {
session.setFlag(ProtocolConstants.PROFILE_KEY, this.profile);
session.setFlag(ProtocolConstants.ACCESS_TOKEN_KEY, this.accessToken);
}
this.setMode(this.mode, true, session);
session.addListener(this.clientListener);
}
this.setMode(this.mode, true, session);
session.addListener(this.clientListener);
}
@Override
public void newServerSession(Server server, Session session) {
this.setMode(ProtocolMode.HANDSHAKE, false, session);
session.addListener(new ServerListener());
}
@Override
public void newServerSession(Server server, Session session) {
this.setMode(ProtocolMode.HANDSHAKE, false, session);
session.addListener(new ServerListener());
}
protected void enableEncryption(Key key) {
try {
this.encrypt = new AESEncryption(key);
} catch(GeneralSecurityException e) {
throw new Error("Failed to enable protocol encryption.", e);
}
}
protected void enableEncryption(Key key) {
try {
this.encrypt = new AESEncryption(key);
} catch(GeneralSecurityException e) {
throw new Error("Failed to enable protocol encryption.", e);
}
}
public ProtocolMode getMode() {
return this.mode;
}
public ProtocolMode getMode() {
return this.mode;
}
protected void setMode(ProtocolMode mode, boolean client, Session session) {
this.clearPackets();
switch(mode) {
case HANDSHAKE:
if(client) {
this.initClientHandshake(session);
} else {
this.initServerHandshake(session);
}
protected void setMode(ProtocolMode mode, boolean client, Session session) {
this.clearPackets();
switch(mode) {
case HANDSHAKE:
if(client) {
this.initClientHandshake(session);
} else {
this.initServerHandshake(session);
}
break;
case LOGIN:
if(client) {
this.initClientLogin(session);
} else {
this.initServerLogin(session);
}
break;
case LOGIN:
if(client) {
this.initClientLogin(session);
} else {
this.initServerLogin(session);
}
break;
case GAME:
if(client) {
this.initClientGame(session);
} else {
this.initServerGame(session);
}
break;
case GAME:
if(client) {
this.initClientGame(session);
} else {
this.initServerGame(session);
}
break;
case STATUS:
if(client) {
this.initClientStatus(session);
} else {
this.initServerStatus(session);
}
break;
case STATUS:
if(client) {
this.initClientStatus(session);
} else {
this.initServerStatus(session);
}
break;
}
break;
}
this.mode = mode;
}
this.mode = mode;
}
private void initClientHandshake(Session session) {
this.registerOutgoing(0, HandshakePacket.class);
}
private void initClientHandshake(Session session) {
this.registerOutgoing(0, HandshakePacket.class);
}
private void initServerHandshake(Session session) {
this.registerIncoming(0, HandshakePacket.class);
}
private void initServerHandshake(Session session) {
this.registerIncoming(0, HandshakePacket.class);
}
private void initClientLogin(Session session) {
this.registerIncoming(0, LoginDisconnectPacket.class);
this.registerIncoming(1, EncryptionRequestPacket.class);
this.registerIncoming(2, LoginSuccessPacket.class);
this.registerIncoming(3, LoginSetCompressionPacket.class);
private void initClientLogin(Session session) {
this.registerIncoming(0, LoginDisconnectPacket.class);
this.registerIncoming(1, EncryptionRequestPacket.class);
this.registerIncoming(2, LoginSuccessPacket.class);
this.registerIncoming(3, LoginSetCompressionPacket.class);
this.registerOutgoing(0, LoginStartPacket.class);
this.registerOutgoing(1, EncryptionResponsePacket.class);
}
this.registerOutgoing(0, LoginStartPacket.class);
this.registerOutgoing(1, EncryptionResponsePacket.class);
}
private void initServerLogin(Session session) {
this.registerIncoming(0, LoginStartPacket.class);
this.registerIncoming(1, EncryptionResponsePacket.class);
private void initServerLogin(Session session) {
this.registerIncoming(0, LoginStartPacket.class);
this.registerIncoming(1, EncryptionResponsePacket.class);
this.registerOutgoing(0, LoginDisconnectPacket.class);
this.registerOutgoing(1, EncryptionRequestPacket.class);
this.registerOutgoing(2, LoginSuccessPacket.class);
this.registerOutgoing(3, LoginSetCompressionPacket.class);
}
this.registerOutgoing(0, LoginDisconnectPacket.class);
this.registerOutgoing(1, EncryptionRequestPacket.class);
this.registerOutgoing(2, LoginSuccessPacket.class);
this.registerOutgoing(3, LoginSetCompressionPacket.class);
}
private void initClientGame(Session session) {
this.registerIncoming(0, ServerKeepAlivePacket.class);
this.registerIncoming(1, ServerJoinGamePacket.class);
this.registerIncoming(2, ServerChatPacket.class);
this.registerIncoming(3, ServerUpdateTimePacket.class);
this.registerIncoming(4, ServerEntityEquipmentPacket.class);
this.registerIncoming(5, ServerSpawnPositionPacket.class);
this.registerIncoming(6, ServerUpdateHealthPacket.class);
this.registerIncoming(7, ServerRespawnPacket.class);
this.registerIncoming(8, ServerPlayerPositionRotationPacket.class);
this.registerIncoming(9, ServerChangeHeldItemPacket.class);
this.registerIncoming(10, ServerPlayerUseBedPacket.class);
this.registerIncoming(11, ServerAnimationPacket.class);
this.registerIncoming(12, ServerSpawnPlayerPacket.class);
this.registerIncoming(13, ServerCollectItemPacket.class);
this.registerIncoming(14, ServerSpawnObjectPacket.class);
this.registerIncoming(15, ServerSpawnMobPacket.class);
this.registerIncoming(16, ServerSpawnPaintingPacket.class);
this.registerIncoming(17, ServerSpawnExpOrbPacket.class);
this.registerIncoming(18, ServerEntityVelocityPacket.class);
this.registerIncoming(19, ServerDestroyEntitiesPacket.class);
this.registerIncoming(20, ServerEntityMovementPacket.class);
this.registerIncoming(21, ServerEntityPositionPacket.class);
this.registerIncoming(22, ServerEntityRotationPacket.class);
this.registerIncoming(23, ServerEntityPositionRotationPacket.class);
this.registerIncoming(24, ServerEntityTeleportPacket.class);
this.registerIncoming(25, ServerEntityHeadLookPacket.class);
this.registerIncoming(26, ServerEntityStatusPacket.class);
this.registerIncoming(27, ServerEntityAttachPacket.class);
this.registerIncoming(28, ServerEntityMetadataPacket.class);
this.registerIncoming(29, ServerEntityEffectPacket.class);
this.registerIncoming(30, ServerEntityRemoveEffectPacket.class);
this.registerIncoming(31, ServerSetExperiencePacket.class);
this.registerIncoming(32, ServerEntityPropertiesPacket.class);
this.registerIncoming(33, ServerChunkDataPacket.class);
this.registerIncoming(34, ServerMultiBlockChangePacket.class);
this.registerIncoming(35, ServerBlockChangePacket.class);
this.registerIncoming(36, ServerBlockValuePacket.class);
this.registerIncoming(37, ServerBlockBreakAnimPacket.class);
this.registerIncoming(38, ServerMultiChunkDataPacket.class);
this.registerIncoming(39, ServerExplosionPacket.class);
this.registerIncoming(40, ServerPlayEffectPacket.class);
this.registerIncoming(41, ServerPlaySoundPacket.class);
this.registerIncoming(42, ServerSpawnParticlePacket.class);
this.registerIncoming(43, ServerNotifyClientPacket.class);
this.registerIncoming(44, ServerSpawnGlobalEntityPacket.class);
this.registerIncoming(45, ServerOpenWindowPacket.class);
this.registerIncoming(46, ServerCloseWindowPacket.class);
this.registerIncoming(47, ServerSetSlotPacket.class);
this.registerIncoming(48, ServerWindowItemsPacket.class);
this.registerIncoming(49, ServerWindowPropertyPacket.class);
this.registerIncoming(50, ServerConfirmTransactionPacket.class);
this.registerIncoming(51, ServerUpdateSignPacket.class);
this.registerIncoming(52, ServerMapDataPacket.class);
this.registerIncoming(53, ServerUpdateTileEntityPacket.class);
this.registerIncoming(54, ServerOpenTileEntityEditorPacket.class);
this.registerIncoming(55, ServerStatisticsPacket.class);
this.registerIncoming(56, ServerPlayerListEntryPacket.class);
this.registerIncoming(57, ServerPlayerAbilitiesPacket.class);
this.registerIncoming(58, ServerTabCompletePacket.class);
this.registerIncoming(59, ServerScoreboardObjectivePacket.class);
this.registerIncoming(60, ServerUpdateScorePacket.class);
this.registerIncoming(61, ServerDisplayScoreboardPacket.class);
this.registerIncoming(62, ServerTeamPacket.class);
this.registerIncoming(63, ServerPluginMessagePacket.class);
this.registerIncoming(64, ServerDisconnectPacket.class);
this.registerIncoming(65, ServerDifficultyPacket.class);
this.registerIncoming(66, ServerCombatPacket.class);
this.registerIncoming(67, ServerSwitchCameraPacket.class);
this.registerIncoming(68, ServerWorldBorderPacket.class);
this.registerIncoming(69, ServerTitlePacket.class);
this.registerIncoming(70, ServerSetCompressionPacket.class);
this.registerIncoming(71, ServerPlayerListDataPacket.class);
this.registerIncoming(72, ServerResourcePackSendPacket.class);
this.registerIncoming(73, ServerEntityNBTUpdatePacket.class);
private void initClientGame(Session session) {
this.registerIncoming(0, ServerKeepAlivePacket.class);
this.registerIncoming(1, ServerJoinGamePacket.class);
this.registerIncoming(2, ServerChatPacket.class);
this.registerIncoming(3, ServerUpdateTimePacket.class);
this.registerIncoming(4, ServerEntityEquipmentPacket.class);
this.registerIncoming(5, ServerSpawnPositionPacket.class);
this.registerIncoming(6, ServerUpdateHealthPacket.class);
this.registerIncoming(7, ServerRespawnPacket.class);
this.registerIncoming(8, ServerPlayerPositionRotationPacket.class);
this.registerIncoming(9, ServerChangeHeldItemPacket.class);
this.registerIncoming(10, ServerPlayerUseBedPacket.class);
this.registerIncoming(11, ServerAnimationPacket.class);
this.registerIncoming(12, ServerSpawnPlayerPacket.class);
this.registerIncoming(13, ServerCollectItemPacket.class);
this.registerIncoming(14, ServerSpawnObjectPacket.class);
this.registerIncoming(15, ServerSpawnMobPacket.class);
this.registerIncoming(16, ServerSpawnPaintingPacket.class);
this.registerIncoming(17, ServerSpawnExpOrbPacket.class);
this.registerIncoming(18, ServerEntityVelocityPacket.class);
this.registerIncoming(19, ServerDestroyEntitiesPacket.class);
this.registerIncoming(20, ServerEntityMovementPacket.class);
this.registerIncoming(21, ServerEntityPositionPacket.class);
this.registerIncoming(22, ServerEntityRotationPacket.class);
this.registerIncoming(23, ServerEntityPositionRotationPacket.class);
this.registerIncoming(24, ServerEntityTeleportPacket.class);
this.registerIncoming(25, ServerEntityHeadLookPacket.class);
this.registerIncoming(26, ServerEntityStatusPacket.class);
this.registerIncoming(27, ServerEntityAttachPacket.class);
this.registerIncoming(28, ServerEntityMetadataPacket.class);
this.registerIncoming(29, ServerEntityEffectPacket.class);
this.registerIncoming(30, ServerEntityRemoveEffectPacket.class);
this.registerIncoming(31, ServerSetExperiencePacket.class);
this.registerIncoming(32, ServerEntityPropertiesPacket.class);
this.registerIncoming(33, ServerChunkDataPacket.class);
this.registerIncoming(34, ServerMultiBlockChangePacket.class);
this.registerIncoming(35, ServerBlockChangePacket.class);
this.registerIncoming(36, ServerBlockValuePacket.class);
this.registerIncoming(37, ServerBlockBreakAnimPacket.class);
this.registerIncoming(38, ServerMultiChunkDataPacket.class);
this.registerIncoming(39, ServerExplosionPacket.class);
this.registerIncoming(40, ServerPlayEffectPacket.class);
this.registerIncoming(41, ServerPlaySoundPacket.class);
this.registerIncoming(42, ServerSpawnParticlePacket.class);
this.registerIncoming(43, ServerNotifyClientPacket.class);
this.registerIncoming(44, ServerSpawnGlobalEntityPacket.class);
this.registerIncoming(45, ServerOpenWindowPacket.class);
this.registerIncoming(46, ServerCloseWindowPacket.class);
this.registerIncoming(47, ServerSetSlotPacket.class);
this.registerIncoming(48, ServerWindowItemsPacket.class);
this.registerIncoming(49, ServerWindowPropertyPacket.class);
this.registerIncoming(50, ServerConfirmTransactionPacket.class);
this.registerIncoming(51, ServerUpdateSignPacket.class);
this.registerIncoming(52, ServerMapDataPacket.class);
this.registerIncoming(53, ServerUpdateTileEntityPacket.class);
this.registerIncoming(54, ServerOpenTileEntityEditorPacket.class);
this.registerIncoming(55, ServerStatisticsPacket.class);
this.registerIncoming(56, ServerPlayerListEntryPacket.class);
this.registerIncoming(57, ServerPlayerAbilitiesPacket.class);
this.registerIncoming(58, ServerTabCompletePacket.class);
this.registerIncoming(59, ServerScoreboardObjectivePacket.class);
this.registerIncoming(60, ServerUpdateScorePacket.class);
this.registerIncoming(61, ServerDisplayScoreboardPacket.class);
this.registerIncoming(62, ServerTeamPacket.class);
this.registerIncoming(63, ServerPluginMessagePacket.class);
this.registerIncoming(64, ServerDisconnectPacket.class);
this.registerIncoming(65, ServerDifficultyPacket.class);
this.registerIncoming(66, ServerCombatPacket.class);
this.registerIncoming(67, ServerSwitchCameraPacket.class);
this.registerIncoming(68, ServerWorldBorderPacket.class);
this.registerIncoming(69, ServerTitlePacket.class);
this.registerIncoming(70, ServerSetCompressionPacket.class);
this.registerIncoming(71, ServerPlayerListDataPacket.class);
this.registerIncoming(72, ServerResourcePackSendPacket.class);
this.registerIncoming(73, ServerEntityNBTUpdatePacket.class);
this.registerOutgoing(0, ClientKeepAlivePacket.class);
this.registerOutgoing(1, ClientChatPacket.class);
this.registerOutgoing(2, ClientPlayerInteractEntityPacket.class);
this.registerOutgoing(3, ClientPlayerMovementPacket.class);
this.registerOutgoing(4, ClientPlayerPositionPacket.class);
this.registerOutgoing(5, ClientPlayerRotationPacket.class);
this.registerOutgoing(6, ClientPlayerPositionRotationPacket.class);
this.registerOutgoing(7, ClientPlayerActionPacket.class);
this.registerOutgoing(8, ClientPlayerPlaceBlockPacket.class);
this.registerOutgoing(9, ClientChangeHeldItemPacket.class);
this.registerOutgoing(10, ClientSwingArmPacket.class);
this.registerOutgoing(11, ClientPlayerStatePacket.class);
this.registerOutgoing(12, ClientSteerVehiclePacket.class);
this.registerOutgoing(13, ClientCloseWindowPacket.class);
this.registerOutgoing(14, ClientWindowActionPacket.class);
this.registerOutgoing(15, ClientConfirmTransactionPacket.class);
this.registerOutgoing(16, ClientCreativeInventoryActionPacket.class);
this.registerOutgoing(17, ClientEnchantItemPacket.class);
this.registerOutgoing(18, ClientUpdateSignPacket.class);
this.registerOutgoing(19, ClientPlayerAbilitiesPacket.class);
this.registerOutgoing(20, ClientTabCompletePacket.class);
this.registerOutgoing(21, ClientSettingsPacket.class);
this.registerOutgoing(22, ClientRequestPacket.class);
this.registerOutgoing(23, ClientPluginMessagePacket.class);
this.registerOutgoing(24, ClientSpectatePacket.class);
this.registerOutgoing(25, ClientResourcePackStatusPacket.class);
}
this.registerOutgoing(0, ClientKeepAlivePacket.class);
this.registerOutgoing(1, ClientChatPacket.class);
this.registerOutgoing(2, ClientPlayerInteractEntityPacket.class);
this.registerOutgoing(3, ClientPlayerMovementPacket.class);
this.registerOutgoing(4, ClientPlayerPositionPacket.class);
this.registerOutgoing(5, ClientPlayerRotationPacket.class);
this.registerOutgoing(6, ClientPlayerPositionRotationPacket.class);
this.registerOutgoing(7, ClientPlayerActionPacket.class);
this.registerOutgoing(8, ClientPlayerPlaceBlockPacket.class);
this.registerOutgoing(9, ClientChangeHeldItemPacket.class);
this.registerOutgoing(10, ClientSwingArmPacket.class);
this.registerOutgoing(11, ClientPlayerStatePacket.class);
this.registerOutgoing(12, ClientSteerVehiclePacket.class);
this.registerOutgoing(13, ClientCloseWindowPacket.class);
this.registerOutgoing(14, ClientWindowActionPacket.class);
this.registerOutgoing(15, ClientConfirmTransactionPacket.class);
this.registerOutgoing(16, ClientCreativeInventoryActionPacket.class);
this.registerOutgoing(17, ClientEnchantItemPacket.class);
this.registerOutgoing(18, ClientUpdateSignPacket.class);
this.registerOutgoing(19, ClientPlayerAbilitiesPacket.class);
this.registerOutgoing(20, ClientTabCompletePacket.class);
this.registerOutgoing(21, ClientSettingsPacket.class);
this.registerOutgoing(22, ClientRequestPacket.class);
this.registerOutgoing(23, ClientPluginMessagePacket.class);
this.registerOutgoing(24, ClientSpectatePacket.class);
this.registerOutgoing(25, ClientResourcePackStatusPacket.class);
}
private void initServerGame(Session session) {
this.registerIncoming(0, ClientKeepAlivePacket.class);
this.registerIncoming(1, ClientChatPacket.class);
this.registerIncoming(2, ClientPlayerInteractEntityPacket.class);
this.registerIncoming(3, ClientPlayerMovementPacket.class);
this.registerIncoming(4, ClientPlayerPositionPacket.class);
this.registerIncoming(5, ClientPlayerRotationPacket.class);
this.registerIncoming(6, ClientPlayerPositionRotationPacket.class);
this.registerIncoming(7, ClientPlayerActionPacket.class);
this.registerIncoming(8, ClientPlayerPlaceBlockPacket.class);
this.registerIncoming(9, ClientChangeHeldItemPacket.class);
this.registerIncoming(10, ClientSwingArmPacket.class);
this.registerIncoming(11, ClientPlayerStatePacket.class);
this.registerIncoming(12, ClientSteerVehiclePacket.class);
this.registerIncoming(13, ClientCloseWindowPacket.class);
this.registerIncoming(14, ClientWindowActionPacket.class);
this.registerIncoming(15, ClientConfirmTransactionPacket.class);
this.registerIncoming(16, ClientCreativeInventoryActionPacket.class);
this.registerIncoming(17, ClientEnchantItemPacket.class);
this.registerIncoming(18, ClientUpdateSignPacket.class);
this.registerIncoming(19, ClientPlayerAbilitiesPacket.class);
this.registerIncoming(20, ClientTabCompletePacket.class);
this.registerIncoming(21, ClientSettingsPacket.class);
this.registerIncoming(22, ClientRequestPacket.class);
this.registerIncoming(23, ClientPluginMessagePacket.class);
this.registerIncoming(24, ClientSpectatePacket.class);
this.registerIncoming(25, ClientResourcePackStatusPacket.class);
private void initServerGame(Session session) {
this.registerIncoming(0, ClientKeepAlivePacket.class);
this.registerIncoming(1, ClientChatPacket.class);
this.registerIncoming(2, ClientPlayerInteractEntityPacket.class);
this.registerIncoming(3, ClientPlayerMovementPacket.class);
this.registerIncoming(4, ClientPlayerPositionPacket.class);
this.registerIncoming(5, ClientPlayerRotationPacket.class);
this.registerIncoming(6, ClientPlayerPositionRotationPacket.class);
this.registerIncoming(7, ClientPlayerActionPacket.class);
this.registerIncoming(8, ClientPlayerPlaceBlockPacket.class);
this.registerIncoming(9, ClientChangeHeldItemPacket.class);
this.registerIncoming(10, ClientSwingArmPacket.class);
this.registerIncoming(11, ClientPlayerStatePacket.class);
this.registerIncoming(12, ClientSteerVehiclePacket.class);
this.registerIncoming(13, ClientCloseWindowPacket.class);
this.registerIncoming(14, ClientWindowActionPacket.class);
this.registerIncoming(15, ClientConfirmTransactionPacket.class);
this.registerIncoming(16, ClientCreativeInventoryActionPacket.class);
this.registerIncoming(17, ClientEnchantItemPacket.class);
this.registerIncoming(18, ClientUpdateSignPacket.class);
this.registerIncoming(19, ClientPlayerAbilitiesPacket.class);
this.registerIncoming(20, ClientTabCompletePacket.class);
this.registerIncoming(21, ClientSettingsPacket.class);
this.registerIncoming(22, ClientRequestPacket.class);
this.registerIncoming(23, ClientPluginMessagePacket.class);
this.registerIncoming(24, ClientSpectatePacket.class);
this.registerIncoming(25, ClientResourcePackStatusPacket.class);
this.registerOutgoing(0, ServerKeepAlivePacket.class);
this.registerOutgoing(1, ServerJoinGamePacket.class);
this.registerOutgoing(2, ServerChatPacket.class);
this.registerOutgoing(3, ServerUpdateTimePacket.class);
this.registerOutgoing(4, ServerEntityEquipmentPacket.class);
this.registerOutgoing(5, ServerSpawnPositionPacket.class);
this.registerOutgoing(6, ServerUpdateHealthPacket.class);
this.registerOutgoing(7, ServerRespawnPacket.class);
this.registerOutgoing(8, ServerPlayerPositionRotationPacket.class);
this.registerOutgoing(9, ServerChangeHeldItemPacket.class);
this.registerOutgoing(10, ServerPlayerUseBedPacket.class);
this.registerOutgoing(11, ServerAnimationPacket.class);
this.registerOutgoing(12, ServerSpawnPlayerPacket.class);
this.registerOutgoing(13, ServerCollectItemPacket.class);
this.registerOutgoing(14, ServerSpawnObjectPacket.class);
this.registerOutgoing(15, ServerSpawnMobPacket.class);
this.registerOutgoing(16, ServerSpawnPaintingPacket.class);
this.registerOutgoing(17, ServerSpawnExpOrbPacket.class);
this.registerOutgoing(18, ServerEntityVelocityPacket.class);
this.registerOutgoing(19, ServerDestroyEntitiesPacket.class);
this.registerOutgoing(20, ServerEntityMovementPacket.class);
this.registerOutgoing(21, ServerEntityPositionPacket.class);
this.registerOutgoing(22, ServerEntityRotationPacket.class);
this.registerOutgoing(23, ServerEntityPositionRotationPacket.class);
this.registerOutgoing(24, ServerEntityTeleportPacket.class);
this.registerOutgoing(25, ServerEntityHeadLookPacket.class);
this.registerOutgoing(26, ServerEntityStatusPacket.class);
this.registerOutgoing(27, ServerEntityAttachPacket.class);
this.registerOutgoing(28, ServerEntityMetadataPacket.class);
this.registerOutgoing(29, ServerEntityEffectPacket.class);
this.registerOutgoing(30, ServerEntityRemoveEffectPacket.class);
this.registerOutgoing(31, ServerSetExperiencePacket.class);
this.registerOutgoing(32, ServerEntityPropertiesPacket.class);
this.registerOutgoing(33, ServerChunkDataPacket.class);
this.registerOutgoing(34, ServerMultiBlockChangePacket.class);
this.registerOutgoing(35, ServerBlockChangePacket.class);
this.registerOutgoing(36, ServerBlockValuePacket.class);
this.registerOutgoing(37, ServerBlockBreakAnimPacket.class);
this.registerOutgoing(38, ServerMultiChunkDataPacket.class);
this.registerOutgoing(39, ServerExplosionPacket.class);
this.registerOutgoing(40, ServerPlayEffectPacket.class);
this.registerOutgoing(41, ServerPlaySoundPacket.class);
this.registerOutgoing(42, ServerSpawnParticlePacket.class);
this.registerOutgoing(43, ServerNotifyClientPacket.class);
this.registerOutgoing(44, ServerSpawnGlobalEntityPacket.class);
this.registerOutgoing(45, ServerOpenWindowPacket.class);
this.registerOutgoing(46, ServerCloseWindowPacket.class);
this.registerOutgoing(47, ServerSetSlotPacket.class);
this.registerOutgoing(48, ServerWindowItemsPacket.class);
this.registerOutgoing(49, ServerWindowPropertyPacket.class);
this.registerOutgoing(50, ServerConfirmTransactionPacket.class);
this.registerOutgoing(51, ServerUpdateSignPacket.class);
this.registerOutgoing(52, ServerMapDataPacket.class);
this.registerOutgoing(53, ServerUpdateTileEntityPacket.class);
this.registerOutgoing(54, ServerOpenTileEntityEditorPacket.class);
this.registerOutgoing(55, ServerStatisticsPacket.class);
this.registerOutgoing(56, ServerPlayerListEntryPacket.class);
this.registerOutgoing(57, ServerPlayerAbilitiesPacket.class);
this.registerOutgoing(58, ServerTabCompletePacket.class);
this.registerOutgoing(59, ServerScoreboardObjectivePacket.class);
this.registerOutgoing(60, ServerUpdateScorePacket.class);
this.registerOutgoing(61, ServerDisplayScoreboardPacket.class);
this.registerOutgoing(62, ServerTeamPacket.class);
this.registerOutgoing(63, ServerPluginMessagePacket.class);
this.registerOutgoing(64, ServerDisconnectPacket.class);
this.registerOutgoing(65, ServerDifficultyPacket.class);
this.registerOutgoing(66, ServerCombatPacket.class);
this.registerOutgoing(67, ServerSwitchCameraPacket.class);
this.registerOutgoing(68, ServerWorldBorderPacket.class);
this.registerOutgoing(69, ServerTitlePacket.class);
this.registerOutgoing(70, ServerSetCompressionPacket.class);
this.registerOutgoing(71, ServerPlayerListDataPacket.class);
this.registerOutgoing(72, ServerResourcePackSendPacket.class);
this.registerOutgoing(73, ServerEntityNBTUpdatePacket.class);
}
this.registerOutgoing(0, ServerKeepAlivePacket.class);
this.registerOutgoing(1, ServerJoinGamePacket.class);
this.registerOutgoing(2, ServerChatPacket.class);
this.registerOutgoing(3, ServerUpdateTimePacket.class);
this.registerOutgoing(4, ServerEntityEquipmentPacket.class);
this.registerOutgoing(5, ServerSpawnPositionPacket.class);
this.registerOutgoing(6, ServerUpdateHealthPacket.class);
this.registerOutgoing(7, ServerRespawnPacket.class);
this.registerOutgoing(8, ServerPlayerPositionRotationPacket.class);
this.registerOutgoing(9, ServerChangeHeldItemPacket.class);
this.registerOutgoing(10, ServerPlayerUseBedPacket.class);
this.registerOutgoing(11, ServerAnimationPacket.class);
this.registerOutgoing(12, ServerSpawnPlayerPacket.class);
this.registerOutgoing(13, ServerCollectItemPacket.class);
this.registerOutgoing(14, ServerSpawnObjectPacket.class);
this.registerOutgoing(15, ServerSpawnMobPacket.class);
this.registerOutgoing(16, ServerSpawnPaintingPacket.class);
this.registerOutgoing(17, ServerSpawnExpOrbPacket.class);
this.registerOutgoing(18, ServerEntityVelocityPacket.class);
this.registerOutgoing(19, ServerDestroyEntitiesPacket.class);
this.registerOutgoing(20, ServerEntityMovementPacket.class);
this.registerOutgoing(21, ServerEntityPositionPacket.class);
this.registerOutgoing(22, ServerEntityRotationPacket.class);
this.registerOutgoing(23, ServerEntityPositionRotationPacket.class);
this.registerOutgoing(24, ServerEntityTeleportPacket.class);
this.registerOutgoing(25, ServerEntityHeadLookPacket.class);
this.registerOutgoing(26, ServerEntityStatusPacket.class);
this.registerOutgoing(27, ServerEntityAttachPacket.class);
this.registerOutgoing(28, ServerEntityMetadataPacket.class);
this.registerOutgoing(29, ServerEntityEffectPacket.class);
this.registerOutgoing(30, ServerEntityRemoveEffectPacket.class);
this.registerOutgoing(31, ServerSetExperiencePacket.class);
this.registerOutgoing(32, ServerEntityPropertiesPacket.class);
this.registerOutgoing(33, ServerChunkDataPacket.class);
this.registerOutgoing(34, ServerMultiBlockChangePacket.class);
this.registerOutgoing(35, ServerBlockChangePacket.class);
this.registerOutgoing(36, ServerBlockValuePacket.class);
this.registerOutgoing(37, ServerBlockBreakAnimPacket.class);
this.registerOutgoing(38, ServerMultiChunkDataPacket.class);
this.registerOutgoing(39, ServerExplosionPacket.class);
this.registerOutgoing(40, ServerPlayEffectPacket.class);
this.registerOutgoing(41, ServerPlaySoundPacket.class);
this.registerOutgoing(42, ServerSpawnParticlePacket.class);
this.registerOutgoing(43, ServerNotifyClientPacket.class);
this.registerOutgoing(44, ServerSpawnGlobalEntityPacket.class);
this.registerOutgoing(45, ServerOpenWindowPacket.class);
this.registerOutgoing(46, ServerCloseWindowPacket.class);
this.registerOutgoing(47, ServerSetSlotPacket.class);
this.registerOutgoing(48, ServerWindowItemsPacket.class);
this.registerOutgoing(49, ServerWindowPropertyPacket.class);
this.registerOutgoing(50, ServerConfirmTransactionPacket.class);
this.registerOutgoing(51, ServerUpdateSignPacket.class);
this.registerOutgoing(52, ServerMapDataPacket.class);
this.registerOutgoing(53, ServerUpdateTileEntityPacket.class);
this.registerOutgoing(54, ServerOpenTileEntityEditorPacket.class);
this.registerOutgoing(55, ServerStatisticsPacket.class);
this.registerOutgoing(56, ServerPlayerListEntryPacket.class);
this.registerOutgoing(57, ServerPlayerAbilitiesPacket.class);
this.registerOutgoing(58, ServerTabCompletePacket.class);
this.registerOutgoing(59, ServerScoreboardObjectivePacket.class);
this.registerOutgoing(60, ServerUpdateScorePacket.class);
this.registerOutgoing(61, ServerDisplayScoreboardPacket.class);
this.registerOutgoing(62, ServerTeamPacket.class);
this.registerOutgoing(63, ServerPluginMessagePacket.class);
this.registerOutgoing(64, ServerDisconnectPacket.class);
this.registerOutgoing(65, ServerDifficultyPacket.class);
this.registerOutgoing(66, ServerCombatPacket.class);
this.registerOutgoing(67, ServerSwitchCameraPacket.class);
this.registerOutgoing(68, ServerWorldBorderPacket.class);
this.registerOutgoing(69, ServerTitlePacket.class);
this.registerOutgoing(70, ServerSetCompressionPacket.class);
this.registerOutgoing(71, ServerPlayerListDataPacket.class);
this.registerOutgoing(72, ServerResourcePackSendPacket.class);
this.registerOutgoing(73, ServerEntityNBTUpdatePacket.class);
}
private void initClientStatus(Session session) {
this.registerIncoming(0, StatusResponsePacket.class);
this.registerIncoming(1, StatusPongPacket.class);
private void initClientStatus(Session session) {
this.registerIncoming(0, StatusResponsePacket.class);
this.registerIncoming(1, StatusPongPacket.class);
this.registerOutgoing(0, StatusQueryPacket.class);
this.registerOutgoing(1, StatusPingPacket.class);
}
this.registerOutgoing(0, StatusQueryPacket.class);
this.registerOutgoing(1, StatusPingPacket.class);
}
private void initServerStatus(Session session) {
this.registerIncoming(0, StatusQueryPacket.class);
this.registerIncoming(1, StatusPingPacket.class);
private void initServerStatus(Session session) {
this.registerIncoming(0, StatusQueryPacket.class);
this.registerIncoming(1, StatusPingPacket.class);
this.registerOutgoing(0, StatusResponsePacket.class);
this.registerOutgoing(1, StatusPongPacket.class);
}
this.registerOutgoing(0, StatusResponsePacket.class);
this.registerOutgoing(1, StatusPongPacket.class);
}
}

View file

@ -2,24 +2,24 @@ package org.spacehq.mc.protocol;
public class ProtocolConstants {
// General Constants
public static final String GAME_VERSION = "1.8";
public static final int PROTOCOL_VERSION = 47;
// General Constants
public static final String GAME_VERSION = "1.8";
public static final int PROTOCOL_VERSION = 47;
// General Key Constants
public static final String PROFILE_KEY = "profile";
public static final String AUTH_PROXY_KEY = "auth-proxy";
// General Key Constants
public static final String PROFILE_KEY = "profile";
public static final String AUTH_PROXY_KEY = "auth-proxy";
// Client Key Constants
public static final String ACCESS_TOKEN_KEY = "access-token";
public static final String SERVER_INFO_HANDLER_KEY = "server-info-handler";
public static final String SERVER_PING_TIME_HANDLER_KEY = "server-ping-time-handler";
// Client Key Constants
public static final String ACCESS_TOKEN_KEY = "access-token";
public static final String SERVER_INFO_HANDLER_KEY = "server-info-handler";
public static final String SERVER_PING_TIME_HANDLER_KEY = "server-ping-time-handler";
// Server Key Constants
public static final String VERIFY_USERS_KEY = "verify-users";
public static final String SERVER_INFO_BUILDER_KEY = "info-builder";
public static final String SERVER_LOGIN_HANDLER_KEY = "login-handler";
public static final String PING_KEY = "ping";
public static final String SERVER_COMPRESSION_THRESHOLD = "compression-threshold";
// Server Key Constants
public static final String VERIFY_USERS_KEY = "verify-users";
public static final String SERVER_INFO_BUILDER_KEY = "info-builder";
public static final String SERVER_LOGIN_HANDLER_KEY = "login-handler";
public static final String PING_KEY = "ping";
public static final String SERVER_COMPRESSION_THRESHOLD = "compression-threshold";
}

View file

@ -2,9 +2,9 @@ package org.spacehq.mc.protocol;
public enum ProtocolMode {
HANDSHAKE,
LOGIN,
GAME,
STATUS;
HANDSHAKE,
LOGIN,
GAME,
STATUS;
}

View file

@ -37,182 +37,182 @@ import java.util.UUID;
public class ServerListener extends SessionAdapter {
private static KeyPair pair = CryptUtil.generateKeyPair();
private static KeyPair pair = CryptUtil.generateKeyPair();
private byte verifyToken[] = new byte[4];
private String serverId = "";
private String username = "";
private byte verifyToken[] = new byte[4];
private String serverId = "";
private String username = "";
private long lastPingTime = 0;
private int lastPingId = 0;
private long lastPingTime = 0;
private int lastPingId = 0;
public ServerListener() {
new Random().nextBytes(this.verifyToken);
}
public ServerListener() {
new Random().nextBytes(this.verifyToken);
}
@Override
public void connected(ConnectedEvent event) {
event.getSession().setFlag(ProtocolConstants.PING_KEY, 0);
}
@Override
public void connected(ConnectedEvent event) {
event.getSession().setFlag(ProtocolConstants.PING_KEY, 0);
}
@Override
public void packetReceived(PacketReceivedEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.HANDSHAKE) {
if(event.getPacket() instanceof HandshakePacket) {
HandshakePacket packet = event.getPacket();
switch(packet.getIntent()) {
case STATUS:
protocol.setMode(ProtocolMode.STATUS, false, event.getSession());
break;
case LOGIN:
protocol.setMode(ProtocolMode.LOGIN, false, event.getSession());
if(packet.getProtocolVersion() > ProtocolConstants.PROTOCOL_VERSION) {
event.getSession().disconnect("Outdated server! I'm still on " + ProtocolConstants.GAME_VERSION + ".");
} else if(packet.getProtocolVersion() < ProtocolConstants.PROTOCOL_VERSION) {
event.getSession().disconnect("Outdated client! Please use " + ProtocolConstants.GAME_VERSION + ".");
}
@Override
public void packetReceived(PacketReceivedEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.HANDSHAKE) {
if(event.getPacket() instanceof HandshakePacket) {
HandshakePacket packet = event.getPacket();
switch(packet.getIntent()) {
case STATUS:
protocol.setMode(ProtocolMode.STATUS, false, event.getSession());
break;
case LOGIN:
protocol.setMode(ProtocolMode.LOGIN, false, event.getSession());
if(packet.getProtocolVersion() > ProtocolConstants.PROTOCOL_VERSION) {
event.getSession().disconnect("Outdated server! I'm still on " + ProtocolConstants.GAME_VERSION + ".");
} else if(packet.getProtocolVersion() < ProtocolConstants.PROTOCOL_VERSION) {
event.getSession().disconnect("Outdated client! Please use " + ProtocolConstants.GAME_VERSION + ".");
}
break;
default:
throw new UnsupportedOperationException("Invalid client intent: " + packet.getIntent());
}
}
}
break;
default:
throw new UnsupportedOperationException("Invalid client intent: " + packet.getIntent());
}
}
}
if(protocol.getMode() == ProtocolMode.LOGIN) {
if(event.getPacket() instanceof LoginStartPacket) {
this.username = event.<LoginStartPacket>getPacket().getUsername();
boolean verify = event.getSession().hasFlag(ProtocolConstants.VERIFY_USERS_KEY) ? event.getSession().<Boolean>getFlag(ProtocolConstants.VERIFY_USERS_KEY) : true;
if(verify) {
event.getSession().send(new EncryptionRequestPacket(this.serverId, pair.getPublic(), this.verifyToken));
} else {
GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.username).getBytes()), this.username);
int threshold = event.getSession().getFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD);
event.getSession().send(new LoginSetCompressionPacket(threshold));
event.getSession().setCompressionThreshold(threshold);
event.getSession().send(new LoginSuccessPacket(profile));
event.getSession().setFlag(ProtocolConstants.PROFILE_KEY, profile);
protocol.setMode(ProtocolMode.GAME, false, event.getSession());
ServerLoginHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY);
if(handler != null) {
handler.loggedIn(event.getSession());
}
if(protocol.getMode() == ProtocolMode.LOGIN) {
if(event.getPacket() instanceof LoginStartPacket) {
this.username = event.<LoginStartPacket>getPacket().getUsername();
boolean verify = event.getSession().hasFlag(ProtocolConstants.VERIFY_USERS_KEY) ? event.getSession().<Boolean>getFlag(ProtocolConstants.VERIFY_USERS_KEY) : true;
if(verify) {
event.getSession().send(new EncryptionRequestPacket(this.serverId, pair.getPublic(), this.verifyToken));
} else {
GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.username).getBytes()), this.username);
int threshold = event.getSession().getFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD);
event.getSession().send(new LoginSetCompressionPacket(threshold));
event.getSession().setCompressionThreshold(threshold);
event.getSession().send(new LoginSuccessPacket(profile));
event.getSession().setFlag(ProtocolConstants.PROFILE_KEY, profile);
protocol.setMode(ProtocolMode.GAME, false, event.getSession());
ServerLoginHandler handler = event.getSession().getFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY);
if(handler != null) {
handler.loggedIn(event.getSession());
}
new Thread(new KeepAlive(event.getSession())).start();
}
} else if(event.getPacket() instanceof EncryptionResponsePacket) {
EncryptionResponsePacket packet = event.getPacket();
PrivateKey privateKey = pair.getPrivate();
if(!Arrays.equals(this.verifyToken, packet.getVerifyToken(privateKey))) {
throw new IllegalStateException("Invalid nonce!");
} else {
SecretKey key = packet.getSecretKey(privateKey);
protocol.enableEncryption(key);
new UserAuthThread(event.getSession(), key).start();
}
}
}
new Thread(new KeepAlive(event.getSession())).start();
}
} else if(event.getPacket() instanceof EncryptionResponsePacket) {
EncryptionResponsePacket packet = event.getPacket();
PrivateKey privateKey = pair.getPrivate();
if(!Arrays.equals(this.verifyToken, packet.getVerifyToken(privateKey))) {
throw new IllegalStateException("Invalid nonce!");
} else {
SecretKey key = packet.getSecretKey(privateKey);
protocol.enableEncryption(key);
new UserAuthThread(event.getSession(), key).start();
}
}
}
if(protocol.getMode() == ProtocolMode.STATUS) {
if(event.getPacket() instanceof StatusQueryPacket) {
ServerInfoBuilder builder = event.getSession().getFlag(ProtocolConstants.SERVER_INFO_BUILDER_KEY);
if(builder == null) {
event.getSession().disconnect("No server info builder set.");
}
if(protocol.getMode() == ProtocolMode.STATUS) {
if(event.getPacket() instanceof StatusQueryPacket) {
ServerInfoBuilder builder = event.getSession().getFlag(ProtocolConstants.SERVER_INFO_BUILDER_KEY);
if(builder == null) {
event.getSession().disconnect("No server info builder set.");
}
ServerStatusInfo info = builder.buildInfo(event.getSession());
event.getSession().send(new StatusResponsePacket(info));
} else if(event.getPacket() instanceof StatusPingPacket) {
event.getSession().send(new StatusPongPacket(event.<StatusPingPacket>getPacket().getPingTime()));
}
}
ServerStatusInfo info = builder.buildInfo(event.getSession());
event.getSession().send(new StatusResponsePacket(info));
} else if(event.getPacket() instanceof StatusPingPacket) {
event.getSession().send(new StatusPongPacket(event.<StatusPingPacket>getPacket().getPingTime()));
}
}
if(protocol.getMode() == ProtocolMode.GAME) {
if(event.getPacket() instanceof ClientKeepAlivePacket) {
ClientKeepAlivePacket packet = event.getPacket();
if(packet.getPingId() == this.lastPingId) {
long time = System.currentTimeMillis() - this.lastPingTime;
event.getSession().setFlag(ProtocolConstants.PING_KEY, time);
}
}
}
}
if(protocol.getMode() == ProtocolMode.GAME) {
if(event.getPacket() instanceof ClientKeepAlivePacket) {
ClientKeepAlivePacket packet = event.getPacket();
if(packet.getPingId() == this.lastPingId) {
long time = System.currentTimeMillis() - this.lastPingTime;
event.getSession().setFlag(ProtocolConstants.PING_KEY, time);
}
}
}
}
@Override
public void disconnecting(DisconnectingEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.LOGIN) {
event.getSession().send(new LoginDisconnectPacket(event.getReason()));
} else if(protocol.getMode() == ProtocolMode.GAME) {
event.getSession().send(new ServerDisconnectPacket(event.getReason()));
}
}
@Override
public void disconnecting(DisconnectingEvent event) {
MinecraftProtocol protocol = (MinecraftProtocol) event.getSession().getPacketProtocol();
if(protocol.getMode() == ProtocolMode.LOGIN) {
event.getSession().send(new LoginDisconnectPacket(event.getReason()));
} else if(protocol.getMode() == ProtocolMode.GAME) {
event.getSession().send(new ServerDisconnectPacket(event.getReason()));
}
}
private class UserAuthThread extends Thread {
private Session session;
private SecretKey key;
private class UserAuthThread extends Thread {
private Session session;
private SecretKey key;
public UserAuthThread(Session session, SecretKey key) {
this.key = key;
this.session = session;
}
public UserAuthThread(Session session, SecretKey key) {
this.key = key;
this.session = session;
}
@Override
public void run() {
MinecraftProtocol protocol = (MinecraftProtocol) this.session.getPacketProtocol();
try {
Proxy proxy = this.session.<Proxy>getFlag(ProtocolConstants.AUTH_PROXY_KEY);
if(proxy == null) {
proxy = Proxy.NO_PROXY;
}
@Override
public void run() {
MinecraftProtocol protocol = (MinecraftProtocol) this.session.getPacketProtocol();
try {
Proxy proxy = this.session.<Proxy>getFlag(ProtocolConstants.AUTH_PROXY_KEY);
if(proxy == null) {
proxy = Proxy.NO_PROXY;
}
String serverHash = new BigInteger(CryptUtil.getServerIdHash(serverId, pair.getPublic(), this.key)).toString(16);
SessionService service = new SessionService(proxy);
GameProfile profile = service.hasJoinedServer(new GameProfile((UUID) null, username), serverHash);
if(profile != null) {
int threshold = this.session.getFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD);
this.session.send(new LoginSetCompressionPacket(threshold));
this.session.setCompressionThreshold(threshold);
this.session.send(new LoginSuccessPacket(profile));
this.session.setFlag(ProtocolConstants.PROFILE_KEY, profile);
protocol.setMode(ProtocolMode.GAME, false, this.session);
ServerLoginHandler handler = this.session.getFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY);
if(handler != null) {
handler.loggedIn(this.session);
}
String serverHash = new BigInteger(CryptUtil.getServerIdHash(serverId, pair.getPublic(), this.key)).toString(16);
SessionService service = new SessionService(proxy);
GameProfile profile = service.hasJoinedServer(new GameProfile((UUID) null, username), serverHash);
if(profile != null) {
int threshold = this.session.getFlag(ProtocolConstants.SERVER_COMPRESSION_THRESHOLD);
this.session.send(new LoginSetCompressionPacket(threshold));
this.session.setCompressionThreshold(threshold);
this.session.send(new LoginSuccessPacket(profile));
this.session.setFlag(ProtocolConstants.PROFILE_KEY, profile);
protocol.setMode(ProtocolMode.GAME, false, this.session);
ServerLoginHandler handler = this.session.getFlag(ProtocolConstants.SERVER_LOGIN_HANDLER_KEY);
if(handler != null) {
handler.loggedIn(this.session);
}
new Thread(new KeepAlive(this.session)).start();
} else {
this.session.disconnect("Failed to verify username!");
}
} catch(AuthenticationUnavailableException e) {
this.session.disconnect("Authentication servers are down. Please try again later, sorry!");
}
}
}
new Thread(new KeepAlive(this.session)).start();
} else {
this.session.disconnect("Failed to verify username!");
}
} catch(AuthenticationUnavailableException e) {
this.session.disconnect("Authentication servers are down. Please try again later, sorry!");
}
}
}
private class KeepAlive implements Runnable {
private Session session;
private class KeepAlive implements Runnable {
private Session session;
public KeepAlive(Session session) {
this.session = session;
}
public KeepAlive(Session session) {
this.session = session;
}
@Override
public void run() {
while(this.session.isConnected()) {
lastPingTime = System.currentTimeMillis();
lastPingId = (int) lastPingTime;
this.session.send(new ServerKeepAlivePacket(lastPingId));
@Override
public void run() {
while(this.session.isConnected()) {
lastPingTime = System.currentTimeMillis();
lastPingId = (int) lastPingTime;
this.session.send(new ServerKeepAlivePacket(lastPingId));
try {
Thread.sleep(2000);
} catch(InterruptedException e) {
break;
}
}
}
}
try {
Thread.sleep(2000);
} catch(InterruptedException e) {
break;
}
}
}
}
}

View file

@ -4,6 +4,6 @@ import org.spacehq.packetlib.Session;
public interface ServerLoginHandler {
public void loggedIn(Session session);
public void loggedIn(Session session);
}

View file

@ -2,62 +2,62 @@ package org.spacehq.mc.protocol.data.game;
public class Chunk {
private ShortArray3d blocks;
private NibbleArray3d blocklight;
private NibbleArray3d skylight;
private ShortArray3d blocks;
private NibbleArray3d blocklight;
private NibbleArray3d skylight;
public Chunk(boolean skylight) {
this(new ShortArray3d(4096), new NibbleArray3d(4096), skylight ? new NibbleArray3d(4096) : null);
}
public Chunk(boolean skylight) {
this(new ShortArray3d(4096), new NibbleArray3d(4096), skylight ? new NibbleArray3d(4096) : null);
}
public Chunk(ShortArray3d blocks, NibbleArray3d blocklight, NibbleArray3d skylight) {
this.blocks = blocks;
this.blocklight = blocklight;
this.skylight = skylight;
}
public Chunk(ShortArray3d blocks, NibbleArray3d blocklight, NibbleArray3d skylight) {
this.blocks = blocks;
this.blocklight = blocklight;
this.skylight = skylight;
}
public ShortArray3d getBlocks() {
return this.blocks;
}
public ShortArray3d getBlocks() {
return this.blocks;
}
public NibbleArray3d getBlockLight() {
return this.blocklight;
}
public NibbleArray3d getBlockLight() {
return this.blocklight;
}
public NibbleArray3d getSkyLight() {
return this.skylight;
}
public NibbleArray3d getSkyLight() {
return this.skylight;
}
public boolean isEmpty() {
for(short block : this.blocks.getData()) {
if(block != 0) {
return false;
}
}
public boolean isEmpty() {
for(short block : this.blocks.getData()) {
if(block != 0) {
return false;
}
}
return true;
}
return true;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
Chunk chunk = (Chunk) o;
Chunk chunk = (Chunk) o;
if (!blocklight.equals(chunk.blocklight)) return false;
if (!blocks.equals(chunk.blocks)) return false;
if (skylight != null ? !skylight.equals(chunk.skylight) : chunk.skylight != null) return false;
if(!blocklight.equals(chunk.blocklight)) return false;
if(!blocks.equals(chunk.blocks)) return false;
if(skylight != null ? !skylight.equals(chunk.skylight) : chunk.skylight != null) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = blocks.hashCode();
result = 31 * result + blocklight.hashCode();
result = 31 * result + (skylight != null ? skylight.hashCode() : 0);
return result;
}
@Override
public int hashCode() {
int result = blocks.hashCode();
result = 31 * result + blocklight.hashCode();
result = 31 * result + (skylight != null ? skylight.hashCode() : 0);
return result;
}
}

View file

@ -4,48 +4,48 @@ import org.spacehq.mc.protocol.data.game.values.entity.MetadataType;
public class EntityMetadata {
private int id;
private MetadataType type;
private Object value;
private int id;
private MetadataType type;
private Object value;
public EntityMetadata(int id, MetadataType type, Object value) {
this.id = id;
this.type = type;
this.value = value;
}
public EntityMetadata(int id, MetadataType type, Object value) {
this.id = id;
this.type = type;
this.value = value;
}
public int getId() {
return this.id;
}
public int getId() {
return this.id;
}
public MetadataType getType() {
return this.type;
}
public MetadataType getType() {
return this.type;
}
public Object getValue() {
return this.value;
}
public Object getValue() {
return this.value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
EntityMetadata metadata = (EntityMetadata) o;
EntityMetadata metadata = (EntityMetadata) o;
if (id != metadata.id) return false;
if (type != metadata.type) return false;
if (!value.equals(metadata.value)) return false;
if(id != metadata.id) return false;
if(type != metadata.type) return false;
if(!value.equals(metadata.value)) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + type.hashCode();
result = 31 * result + value.hashCode();
return result;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + type.hashCode();
result = 31 * result + value.hashCode();
return result;
}
}

View file

@ -4,68 +4,68 @@ import org.spacehq.opennbt.tag.builtin.CompoundTag;
public class ItemStack {
private int id;
private int amount;
private int data;
private CompoundTag nbt;
private int id;
private int amount;
private int data;
private CompoundTag nbt;
public ItemStack(int id) {
this(id, 1);
}
public ItemStack(int id) {
this(id, 1);
}
public ItemStack(int id, int amount) {
this(id, amount, 0);
}
public ItemStack(int id, int amount) {
this(id, amount, 0);
}
public ItemStack(int id, int amount, int data) {
this(id, amount, data, null);
}
public ItemStack(int id, int amount, int data) {
this(id, amount, data, null);
}
public ItemStack(int id, int amount, int data, CompoundTag nbt) {
this.id = id;
this.amount = amount;
this.data = data;
this.nbt = nbt;
}
public ItemStack(int id, int amount, int data, CompoundTag nbt) {
this.id = id;
this.amount = amount;
this.data = data;
this.nbt = nbt;
}
public int getId() {
return this.id;
}
public int getId() {
return this.id;
}
public int getAmount() {
return this.amount;
}
public int getAmount() {
return this.amount;
}
public int getData() {
return this.data;
}
public int getData() {
return this.data;
}
public CompoundTag getNBT() {
return this.nbt;
}
public CompoundTag getNBT() {
return this.nbt;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
ItemStack itemStack = (ItemStack) o;
ItemStack itemStack = (ItemStack) o;
if (amount != itemStack.amount) return false;
if (data != itemStack.data) return false;
if (id != itemStack.id) return false;
if (nbt != null ? !nbt.equals(itemStack.nbt) : itemStack.nbt != null) return false;
if(amount != itemStack.amount) return false;
if(data != itemStack.data) return false;
if(id != itemStack.id) return false;
if(nbt != null ? !nbt.equals(itemStack.nbt) : itemStack.nbt != null) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + amount;
result = 31 * result + data;
result = 31 * result + (nbt != null ? nbt.hashCode() : 0);
return result;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + amount;
result = 31 * result + data;
result = 31 * result + (nbt != null ? nbt.hashCode() : 0);
return result;
}
}

View file

@ -4,65 +4,65 @@ import java.util.Arrays;
public class NibbleArray3d {
private byte[] data;
private byte[] data;
public NibbleArray3d(int size) {
this.data = new byte[size >> 1];
}
public NibbleArray3d(int size) {
this.data = new byte[size >> 1];
}
public NibbleArray3d(byte[] array) {
this.data = array;
}
public NibbleArray3d(byte[] array) {
this.data = array;
}
public byte[] getData() {
return this.data;
}
public byte[] getData() {
return this.data;
}
public int get(int x, int y, int z) {
int key = y << 8 | z << 4 | x;
int index = key >> 1;
int part = key & 1;
return part == 0 ? this.data[index] & 15 : this.data[index] >> 4 & 15;
}
public int get(int x, int y, int z) {
int key = y << 8 | z << 4 | x;
int index = key >> 1;
int part = key & 1;
return part == 0 ? this.data[index] & 15 : this.data[index] >> 4 & 15;
}
public void set(int x, int y, int z, int val) {
int key = y << 8 | z << 4 | x;
int index = key >> 1;
int part = key & 1;
if(part == 0) {
this.data[index] = (byte) (this.data[index] & 240 | val & 15);
} else {
this.data[index] = (byte) (this.data[index] & 15 | (val & 15) << 4);
}
}
public void set(int x, int y, int z, int val) {
int key = y << 8 | z << 4 | x;
int index = key >> 1;
int part = key & 1;
if(part == 0) {
this.data[index] = (byte) (this.data[index] & 240 | val & 15);
} else {
this.data[index] = (byte) (this.data[index] & 15 | (val & 15) << 4);
}
}
public void fill(int val) {
for(int index = 0; index < this.data.length << 1; index++) {
int ind = index >> 1;
int part = index & 1;
if(part == 0) {
this.data[ind] = (byte) (this.data[ind] & 240 | val & 15);
} else {
this.data[ind] = (byte) (this.data[ind] & 15 | (val & 15) << 4);
}
}
}
public void fill(int val) {
for(int index = 0; index < this.data.length << 1; index++) {
int ind = index >> 1;
int part = index & 1;
if(part == 0) {
this.data[ind] = (byte) (this.data[ind] & 240 | val & 15);
} else {
this.data[ind] = (byte) (this.data[ind] & 15 | (val & 15) << 4);
}
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
NibbleArray3d that = (NibbleArray3d) o;
NibbleArray3d that = (NibbleArray3d) o;
if (!Arrays.equals(data, that.data)) return false;
if(!Arrays.equals(data, that.data)) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return Arrays.hashCode(data);
}
@Override
public int hashCode() {
return Arrays.hashCode(data);
}
}

View file

@ -2,48 +2,48 @@ package org.spacehq.mc.protocol.data.game;
public class Position {
private int x;
private int y;
private int z;
private int x;
private int y;
private int z;
public Position(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public Position(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public int getX() {
return this.x;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getY() {
return this.y;
}
public int getZ() {
return this.z;
}
public int getZ() {
return this.z;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
Position position = (Position) o;
Position position = (Position) o;
if (x != position.x) return false;
if (y != position.y) return false;
if (z != position.z) return false;
if(x != position.x) return false;
if(y != position.y) return false;
if(z != position.z) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
}

View file

@ -1,52 +1,52 @@
package org.spacehq.mc.protocol.data.game;
public class Rotation {
private float pitch;
private float yaw;
private float roll;
private float pitch;
private float yaw;
private float roll;
public Rotation() {
this(0, 0, 0);
}
public Rotation() {
this(0, 0, 0);
}
public Rotation(float pitch, float yaw, float roll) {
this.pitch = pitch;
this.yaw = yaw;
this.roll = roll;
}
public Rotation(float pitch, float yaw, float roll) {
this.pitch = pitch;
this.yaw = yaw;
this.roll = roll;
}
public float getPitch() {
return this.pitch;
}
public float getPitch() {
return this.pitch;
}
public float getYaw() {
return this.yaw;
}
public float getYaw() {
return this.yaw;
}
public float getRoll() {
return this.roll;
}
public float getRoll() {
return this.roll;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
Rotation rotation = (Rotation) o;
Rotation rotation = (Rotation) o;
if (Float.compare(rotation.pitch, pitch) != 0) return false;
if (Float.compare(rotation.roll, roll) != 0) return false;
if (Float.compare(rotation.yaw, yaw) != 0) return false;
if(Float.compare(rotation.pitch, pitch) != 0) return false;
if(Float.compare(rotation.roll, roll) != 0) return false;
if(Float.compare(rotation.yaw, yaw) != 0) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = (pitch != +0.0f ? Float.floatToIntBits(pitch) : 0);
result = 31 * result + (yaw != +0.0f ? Float.floatToIntBits(yaw) : 0);
result = 31 * result + (roll != +0.0f ? Float.floatToIntBits(roll) : 0);
return result;
}
@Override
public int hashCode() {
int result = (pitch != +0.0f ? Float.floatToIntBits(pitch) : 0);
result = 31 * result + (yaw != +0.0f ? Float.floatToIntBits(yaw) : 0);
result = 31 * result + (roll != +0.0f ? Float.floatToIntBits(roll) : 0);
return result;
}
}

View file

@ -4,67 +4,67 @@ import java.util.Arrays;
public class ShortArray3d {
private short[] data;
private short[] data;
public ShortArray3d(int size) {
this.data = new short[size];
}
public ShortArray3d(int size) {
this.data = new short[size];
}
public ShortArray3d(short[] array) {
this.data = array;
}
public ShortArray3d(short[] array) {
this.data = array;
}
public short[] getData() {
return this.data;
}
public short[] getData() {
return this.data;
}
public int get(int x, int y, int z) {
return this.data[y << 8 | z << 4 | x] & 0xFFFF;
}
public int get(int x, int y, int z) {
return this.data[y << 8 | z << 4 | x] & 0xFFFF;
}
public void set(int x, int y, int z, int val) {
this.data[y << 8 | z << 4 | x] = (short) val;
}
public void set(int x, int y, int z, int val) {
this.data[y << 8 | z << 4 | x] = (short) val;
}
public int getBlock(int x, int y, int z) {
return this.get(x, y, z) >> 4;
}
public int getBlock(int x, int y, int z) {
return this.get(x, y, z) >> 4;
}
public void setBlock(int x, int y, int z, int block) {
this.set(x, y, z, block << 4 | this.getData(x, y, z));
}
public void setBlock(int x, int y, int z, int block) {
this.set(x, y, z, block << 4 | this.getData(x, y, z));
}
public int getData(int x, int y, int z) {
return this.get(x, y, z) & 0xF;
}
public int getData(int x, int y, int z) {
return this.get(x, y, z) & 0xF;
}
public void setData(int x, int y, int z, int data) {
this.set(x, y, z, this.getBlock(x, y, z) << 4 | data);
}
public void setData(int x, int y, int z, int data) {
this.set(x, y, z, this.getBlock(x, y, z) << 4 | data);
}
public void setBlockAndData(int x, int y, int z, int block, int data) {
this.set(x, y, z, block << 4 | data);
}
public void setBlockAndData(int x, int y, int z, int block, int data) {
this.set(x, y, z, block << 4 | data);
}
public void fill(int val) {
Arrays.fill(this.data, (short) val);
}
public void fill(int val) {
Arrays.fill(this.data, (short) val);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
ShortArray3d that = (ShortArray3d) o;
ShortArray3d that = (ShortArray3d) o;
if (!Arrays.equals(data, that.data)) return false;
if(!Arrays.equals(data, that.data)) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return Arrays.hashCode(data);
}
@Override
public int hashCode() {
return Arrays.hashCode(data);
}
}

View file

@ -7,57 +7,57 @@ import java.util.List;
public class Attribute {
private AttributeType type;
private double value;
private List<AttributeModifier> modifiers;
private AttributeType type;
private double value;
private List<AttributeModifier> modifiers;
public Attribute(AttributeType type) {
this(type, type.getDefault());
}
public Attribute(AttributeType type) {
this(type, type.getDefault());
}
public Attribute(AttributeType type, double value) {
this(type, value, new ArrayList<AttributeModifier>());
}
public Attribute(AttributeType type, double value) {
this(type, value, new ArrayList<AttributeModifier>());
}
public Attribute(AttributeType type, double value, List<AttributeModifier> modifiers) {
this.type = type;
this.value = value;
this.modifiers = modifiers;
}
public Attribute(AttributeType type, double value, List<AttributeModifier> modifiers) {
this.type = type;
this.value = value;
this.modifiers = modifiers;
}
public AttributeType getType() {
return this.type;
}
public AttributeType getType() {
return this.type;
}
public double getValue() {
return this.value;
}
public double getValue() {
return this.value;
}
public List<AttributeModifier> getModifiers() {
return new ArrayList<AttributeModifier>(this.modifiers);
}
public List<AttributeModifier> getModifiers() {
return new ArrayList<AttributeModifier>(this.modifiers);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
Attribute attribute = (Attribute) o;
Attribute attribute = (Attribute) o;
if (Double.compare(attribute.value, value) != 0) return false;
if (!modifiers.equals(attribute.modifiers)) return false;
if (type != attribute.type) return false;
if(Double.compare(attribute.value, value) != 0) return false;
if(!modifiers.equals(attribute.modifiers)) return false;
if(type != attribute.type) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = type.hashCode();
long temp = Double.doubleToLongBits(value);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + modifiers.hashCode();
return result;
}
@Override
public int hashCode() {
int result = type.hashCode();
long temp = Double.doubleToLongBits(value);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + modifiers.hashCode();
return result;
}
}

View file

@ -8,62 +8,62 @@ import java.util.UUID;
public class AttributeModifier {
private ModifierType type;
private UUID uuid;
private double amount;
private ModifierOperation operation;
private ModifierType type;
private UUID uuid;
private double amount;
private ModifierOperation operation;
public AttributeModifier(ModifierType type, double amount, ModifierOperation operation) {
this.type = type;
this.uuid = MagicValues.value(UUID.class, type);
this.amount = amount;
this.operation = operation;
}
public AttributeModifier(ModifierType type, double amount, ModifierOperation operation) {
this.type = type;
this.uuid = MagicValues.value(UUID.class, type);
this.amount = amount;
this.operation = operation;
}
public AttributeModifier(UUID uuid, double amount, ModifierOperation operation) {
this.type = MagicValues.key(ModifierType.class, uuid);
this.uuid = uuid;
this.amount = amount;
this.operation = operation;
}
public AttributeModifier(UUID uuid, double amount, ModifierOperation operation) {
this.type = MagicValues.key(ModifierType.class, uuid);
this.uuid = uuid;
this.amount = amount;
this.operation = operation;
}
public ModifierType getType() {
return this.type;
}
public ModifierType getType() {
return this.type;
}
public UUID getUUID() {
return this.uuid;
}
public UUID getUUID() {
return this.uuid;
}
public double getAmount() {
return this.amount;
}
public double getAmount() {
return this.amount;
}
public ModifierOperation getOperation() {
return this.operation;
}
public ModifierOperation getOperation() {
return this.operation;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
AttributeModifier that = (AttributeModifier) o;
AttributeModifier that = (AttributeModifier) o;
if (Double.compare(that.amount, amount) != 0) return false;
if (operation != that.operation) return false;
if (type != that.type) return false;
if(Double.compare(that.amount, amount) != 0) return false;
if(operation != that.operation) return false;
if(type != that.type) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = type.hashCode();
long temp = Double.doubleToLongBits(amount);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + operation.hashCode();
return result;
}
@Override
public int hashCode() {
int result = type.hashCode();
long temp = Double.doubleToLongBits(amount);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + operation.hashCode();
return result;
}
}

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol.data.game.values;
public enum ClientRequest {
RESPAWN,
STATS,
OPEN_INVENTORY_ACHIEVEMENT;
RESPAWN,
STATS,
OPEN_INVENTORY_ACHIEVEMENT;
}

View file

@ -2,12 +2,12 @@ package org.spacehq.mc.protocol.data.game.values;
public enum Face {
BOTTOM,
TOP,
EAST,
WEST,
NORTH,
SOUTH,
INVALID;
BOTTOM,
TOP,
EAST,
WEST,
NORTH,
SOUTH,
INVALID;
}

View file

@ -2,7 +2,7 @@ package org.spacehq.mc.protocol.data.game.values;
public enum HandshakeIntent {
STATUS,
LOGIN;
STATUS,
LOGIN;
}

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol.data.game.values;
public enum MessageType {
CHAT,
SYSTEM,
NOTIFICATION;
CHAT,
SYSTEM,
NOTIFICATION;
}

View file

@ -5,76 +5,76 @@ import org.spacehq.mc.protocol.data.game.values.entity.player.GameMode;
import org.spacehq.mc.protocol.data.message.Message;
public class PlayerListEntry {
private GameProfile profile;
private GameProfile profile;
private GameMode gameMode;
private int ping;
private Message displayName;
private GameMode gameMode;
private int ping;
private Message displayName;
public PlayerListEntry(GameProfile profile, GameMode gameMode, int ping, Message displayName) {
this.profile = profile;
this.gameMode = gameMode;
this.ping = ping;
this.displayName = displayName;
}
public PlayerListEntry(GameProfile profile, GameMode gameMode, int ping, Message displayName) {
this.profile = profile;
this.gameMode = gameMode;
this.ping = ping;
this.displayName = displayName;
}
public PlayerListEntry(GameProfile profile, GameMode gameMode) {
this.profile = profile;
this.gameMode = gameMode;
}
public PlayerListEntry(GameProfile profile, GameMode gameMode) {
this.profile = profile;
this.gameMode = gameMode;
}
public PlayerListEntry(GameProfile profile, int ping) {
this.profile = profile;
this.ping = ping;
}
public PlayerListEntry(GameProfile profile, int ping) {
this.profile = profile;
this.ping = ping;
}
public PlayerListEntry(GameProfile profile, Message displayName) {
this.profile = profile;
this.displayName = displayName;
}
public PlayerListEntry(GameProfile profile, Message displayName) {
this.profile = profile;
this.displayName = displayName;
}
public PlayerListEntry(GameProfile profile) {
this.profile = profile;
}
public PlayerListEntry(GameProfile profile) {
this.profile = profile;
}
public GameProfile getProfile() {
return this.profile;
}
public GameProfile getProfile() {
return this.profile;
}
public GameMode getGameMode() {
return this.gameMode;
}
public GameMode getGameMode() {
return this.gameMode;
}
public int getPing() {
return this.ping;
}
public int getPing() {
return this.ping;
}
public Message getDisplayName() {
return this.displayName;
}
public Message getDisplayName() {
return this.displayName;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
PlayerListEntry entry = (PlayerListEntry) o;
PlayerListEntry entry = (PlayerListEntry) o;
if (ping != entry.ping) return false;
if (displayName != null ? !displayName.equals(entry.displayName) : entry.displayName != null) return false;
if (gameMode != entry.gameMode) return false;
if (!profile.equals(entry.profile)) return false;
if(ping != entry.ping) return false;
if(displayName != null ? !displayName.equals(entry.displayName) : entry.displayName != null) return false;
if(gameMode != entry.gameMode) return false;
if(!profile.equals(entry.profile)) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = profile.hashCode();
result = 31 * result + (gameMode != null ? gameMode.hashCode() : 0);
result = 31 * result + ping;
result = 31 * result + (displayName != null ? displayName.hashCode() : 0);
return result;
}
@Override
public int hashCode() {
int result = profile.hashCode();
result = 31 * result + (gameMode != null ? gameMode.hashCode() : 0);
result = 31 * result + ping;
result = 31 * result + (displayName != null ? displayName.hashCode() : 0);
return result;
}
}

View file

@ -1,9 +1,9 @@
package org.spacehq.mc.protocol.data.game.values;
public enum PlayerListEntryAction {
ADD_PLAYER,
UPDATE_GAMEMODE,
UPDATE_LATENCY,
UPDATE_DISPLAY_NAME,
REMOVE_PLAYER;
ADD_PLAYER,
UPDATE_GAMEMODE,
UPDATE_LATENCY,
UPDATE_DISPLAY_NAME,
REMOVE_PLAYER;
}

View file

@ -1,8 +1,8 @@
package org.spacehq.mc.protocol.data.game.values;
public enum ResourcePackStatus {
SUCCESSFULLY_LOADED,
DECLINED,
FAILED_DOWNLOAD,
ACCEPTED;
SUCCESSFULLY_LOADED,
DECLINED,
FAILED_DOWNLOAD,
ACCEPTED;
}

View file

@ -1,9 +1,9 @@
package org.spacehq.mc.protocol.data.game.values;
public enum TitleAction {
TITLE,
SUBTITLE,
TIMES,
CLEAR,
RESET;
TITLE,
SUBTITLE,
TIMES,
CLEAR,
RESET;
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum Art {
KEBAB,
AZTEC,
ALBAN,
AZTEC2,
BOMB,
PLANT,
WASTELAND,
POOL,
COURBET,
SEA,
SUNSET,
CREEBET,
WANDERER,
GRAHAM,
MATCH,
BUST,
STAGE,
VOID,
SKULL_AND_ROSES,
WITHER,
FIGHTERS,
POINTER,
PIG_SCENE,
BURNING_SKULL,
SKELETON,
DONKEY_KONG;
KEBAB,
AZTEC,
ALBAN,
AZTEC2,
BOMB,
PLANT,
WASTELAND,
POOL,
COURBET,
SEA,
SUNSET,
CREEBET,
WANDERER,
GRAHAM,
MATCH,
BUST,
STAGE,
VOID,
SKULL_AND_ROSES,
WITHER,
FIGHTERS,
POINTER,
PIG_SCENE,
BURNING_SKULL,
SKELETON,
DONKEY_KONG;
}

View file

@ -2,34 +2,34 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum AttributeType {
MAX_HEALTH(20, 0, Double.MAX_VALUE),
FOLLOW_RANGE(32, 0, 2048),
KNOCKBACK_RESISTANCE(0, 0, 1),
MOVEMENT_SPEED(0.699999988079071, 0, Double.MAX_VALUE),
ATTACK_DAMAGE(2, 0, Double.MAX_VALUE),
HORSE_JUMP_STRENGTH(0.7, 0, 2),
ZOMBIE_SPAWN_REINFORCEMENTS_CHANCE(0, 0, 1);
MAX_HEALTH(20, 0, Double.MAX_VALUE),
FOLLOW_RANGE(32, 0, 2048),
KNOCKBACK_RESISTANCE(0, 0, 1),
MOVEMENT_SPEED(0.699999988079071, 0, Double.MAX_VALUE),
ATTACK_DAMAGE(2, 0, Double.MAX_VALUE),
HORSE_JUMP_STRENGTH(0.7, 0, 2),
ZOMBIE_SPAWN_REINFORCEMENTS_CHANCE(0, 0, 1);
private double def;
private double min;
private double max;
private double def;
private double min;
private double max;
private AttributeType(double def, double min, double max) {
this.def = def;
this.min = min;
this.max = max;
}
private AttributeType(double def, double min, double max) {
this.def = def;
this.min = min;
this.max = max;
}
public double getDefault() {
return this.def;
}
public double getDefault() {
return this.def;
}
public double getMin() {
return this.min;
}
public double getMin() {
return this.min;
}
public double getMax() {
return this.max;
}
public double getMax() {
return this.max;
}
}

View file

@ -2,28 +2,28 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum Effect {
SPEED,
SLOWNESS,
DIG_SPEED,
DIG_SLOWNESS,
DAMAGE_BOOST,
HEAL,
DAMAGE,
JUMP_BOOST,
CONFUSION,
REGENERATION,
RESISTANCE,
FIRE_RESISTANCE,
WATER_BREATHING,
INVISIBILITY,
BLINDNESS,
NIGHT_VISION,
HUNGER,
WEAKNESS,
POISON,
WITHER_EFFECT,
HEALTH_BOOST,
ABSORPTION,
SATURATION;
SPEED,
SLOWNESS,
DIG_SPEED,
DIG_SLOWNESS,
DAMAGE_BOOST,
HEAL,
DAMAGE,
JUMP_BOOST,
CONFUSION,
REGENERATION,
RESISTANCE,
FIRE_RESISTANCE,
WATER_BREATHING,
INVISIBILITY,
BLINDNESS,
NIGHT_VISION,
HUNGER,
WEAKNESS,
POISON,
WITHER_EFFECT,
HEALTH_BOOST,
ABSORPTION,
SATURATION;
}

View file

@ -2,27 +2,27 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum EntityStatus {
HURT_OR_MINECART_SPAWNER_DELAY_RESET,
LIVING_HURT,
DEAD,
IRON_GOLEM_THROW,
TAMING,
TAMED,
WOLF_SHAKING,
FINISHED_EATING,
SHEEP_GRAZING_OR_TNT_CART_EXPLODING,
IRON_GOLEM_ROSE,
VILLAGER_HEARTS,
VILLAGER_ANGRY,
VILLAGER_HAPPY,
WITCH_MAGIC_PARTICLES,
ZOMBIE_VILLAGER_SHAKING,
FIREWORK_EXPLODING,
ANIMAL_HEARTS,
RESET_SQUID_ROTATION,
EXPLOSION_PARTICLE,
GUARDIAN_SOUND,
ENABLE_REDUCED_DEBUG,
DISABLE_REDUCED_DEBUG;
HURT_OR_MINECART_SPAWNER_DELAY_RESET,
LIVING_HURT,
DEAD,
IRON_GOLEM_THROW,
TAMING,
TAMED,
WOLF_SHAKING,
FINISHED_EATING,
SHEEP_GRAZING_OR_TNT_CART_EXPLODING,
IRON_GOLEM_ROSE,
VILLAGER_HEARTS,
VILLAGER_ANGRY,
VILLAGER_HAPPY,
WITCH_MAGIC_PARTICLES,
ZOMBIE_VILLAGER_SHAKING,
FIREWORK_EXPLODING,
ANIMAL_HEARTS,
RESET_SQUID_ROTATION,
EXPLOSION_PARTICLE,
GUARDIAN_SOUND,
ENABLE_REDUCED_DEBUG,
DISABLE_REDUCED_DEBUG;
}

View file

@ -2,40 +2,40 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public class FallingBlockData implements ObjectData {
private int id;
private int metadata;
private int id;
private int metadata;
public FallingBlockData(int id, int metadata) {
this.id = id;
this.metadata = metadata;
}
public FallingBlockData(int id, int metadata) {
this.id = id;
this.metadata = metadata;
}
public int getId() {
return this.id;
}
public int getId() {
return this.id;
}
public int getMetadata() {
return this.metadata;
}
public int getMetadata() {
return this.metadata;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
FallingBlockData that = (FallingBlockData) o;
FallingBlockData that = (FallingBlockData) o;
if (id != that.id) return false;
if (metadata != that.metadata) return false;
if(id != that.id) return false;
if(metadata != that.metadata) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + metadata;
return result;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + metadata;
return result;
}
}

View file

@ -2,6 +2,6 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum GlobalEntityType {
LIGHTNING_BOLT;
LIGHTNING_BOLT;
}

View file

@ -2,9 +2,9 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum HangingDirection implements ObjectData {
SOUTH,
WEST,
NORTH,
EAST;
SOUTH,
WEST,
NORTH,
EAST;
}

View file

@ -2,13 +2,13 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum MetadataType {
BYTE,
SHORT,
INT,
FLOAT,
STRING,
ITEM,
POSITION,
ROTATION;
BYTE,
SHORT,
INT,
FLOAT,
STRING,
ITEM,
POSITION,
ROTATION;
}

View file

@ -2,12 +2,12 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum MinecartType implements ObjectData {
NORMAL,
CHEST,
POWERED,
TNT,
MOB_SPAWNER,
HOPPER,
COMMAND_BLOCK;
NORMAL,
CHEST,
POWERED,
TNT,
MOB_SPAWNER,
HOPPER,
COMMAND_BLOCK;
}

View file

@ -2,38 +2,38 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum MobType {
ARMOR_STAND,
CREEPER,
SKELETON,
SPIDER,
GIANT_ZOMBIE,
ZOMBIE,
SLIME,
GHAST,
ZOMBIE_PIGMAN,
ENDERMAN,
CAVE_SPIDER,
SILVERFISH,
BLAZE,
MAGMA_CUBE,
ENDER_DRAGON,
WITHER,
BAT,
WITCH,
ENDERMITE,
GUARDIAN,
PIG,
SHEEP,
COW,
CHICKEN,
SQUID,
WOLF,
MOOSHROOM,
SNOWMAN,
OCELOT,
IRON_GOLEM,
HORSE,
RABBIT,
VILLAGER;
ARMOR_STAND,
CREEPER,
SKELETON,
SPIDER,
GIANT_ZOMBIE,
ZOMBIE,
SLIME,
GHAST,
ZOMBIE_PIGMAN,
ENDERMAN,
CAVE_SPIDER,
SILVERFISH,
BLAZE,
MAGMA_CUBE,
ENDER_DRAGON,
WITHER,
BAT,
WITCH,
ENDERMITE,
GUARDIAN,
PIG,
SHEEP,
COW,
CHICKEN,
SQUID,
WOLF,
MOOSHROOM,
SNOWMAN,
OCELOT,
IRON_GOLEM,
HORSE,
RABBIT,
VILLAGER;
}

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum ModifierOperation {
ADD,
ADD_MULTIPLIED,
MULTIPLY;
ADD,
ADD_MULTIPLIED,
MULTIPLY;
}

View file

@ -2,17 +2,17 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum ModifierType {
CREATURE_FLEE_SPEED_BONUS,
ENDERMAN_ATTACK_SPEED_BOOST,
SPRINT_SPEED_BOOST,
PIGZOMBIE_ATTACK_SPEED_BOOST,
WITCH_DRINKING_SPEED_PENALTY,
ZOMBIE_BABY_SPEED_BOOST,
ITEM_MODIFIER,
SPEED_POTION_MODIFIER,
HEALTH_BOOST_POTION_MODIFIER,
SLOW_POTION_MODIFIER,
STRENGTH_POTION_MODIFIER,
WEAKNESS_POTION_MODIFIER;
CREATURE_FLEE_SPEED_BONUS,
ENDERMAN_ATTACK_SPEED_BOOST,
SPRINT_SPEED_BOOST,
PIGZOMBIE_ATTACK_SPEED_BOOST,
WITCH_DRINKING_SPEED_PENALTY,
ZOMBIE_BABY_SPEED_BOOST,
ITEM_MODIFIER,
SPEED_POTION_MODIFIER,
HEALTH_BOOST_POTION_MODIFIER,
SLOW_POTION_MODIFIER,
STRENGTH_POTION_MODIFIER,
WEAKNESS_POTION_MODIFIER;
}

View file

@ -2,27 +2,27 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public enum ObjectType {
BOAT,
ITEM,
MINECART,
PRIMED_TNT,
ENDER_CRYSTAL,
ARROW,
SNOWBALL,
EGG,
GHAST_FIREBALL,
BLAZE_FIREBALL,
ENDER_PEARL,
WITHER_HEAD_PROJECTILE,
FALLING_BLOCK,
ITEM_FRAME,
EYE_OF_ENDER,
POTION,
FALLING_DRAGON_EGG,
EXP_BOTTLE,
FIREWORK_ROCKET,
LEASH_KNOT,
ARMOR_STAND,
FISH_HOOK;
BOAT,
ITEM,
MINECART,
PRIMED_TNT,
ENDER_CRYSTAL,
ARROW,
SNOWBALL,
EGG,
GHAST_FIREBALL,
BLAZE_FIREBALL,
ENDER_PEARL,
WITHER_HEAD_PROJECTILE,
FALLING_BLOCK,
ITEM_FRAME,
EYE_OF_ENDER,
POTION,
FALLING_DRAGON_EGG,
EXP_BOTTLE,
FIREWORK_ROCKET,
LEASH_KNOT,
ARMOR_STAND,
FISH_HOOK;
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public class ProjectileData implements ObjectData {
private int ownerId;
private int ownerId;
public ProjectileData(int ownerId) {
this.ownerId = ownerId;
}
public ProjectileData(int ownerId) {
this.ownerId = ownerId;
}
public int getOwnerId() {
return this.ownerId;
}
public int getOwnerId() {
return this.ownerId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
ProjectileData that = (ProjectileData) o;
ProjectileData that = (ProjectileData) o;
if (ownerId != that.ownerId) return false;
if(ownerId != that.ownerId) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return ownerId;
}
@Override
public int hashCode() {
return ownerId;
}
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.entity;
public class SplashPotionData implements ObjectData {
private int potionData;
private int potionData;
public SplashPotionData(int potionData) {
this.potionData = potionData;
}
public SplashPotionData(int potionData) {
this.potionData = potionData;
}
public int getPotionData() {
return this.potionData;
}
public int getPotionData() {
return this.potionData;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
SplashPotionData that = (SplashPotionData) o;
SplashPotionData that = (SplashPotionData) o;
if (potionData != that.potionData) return false;
if(potionData != that.potionData) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return potionData;
}
@Override
public int hashCode() {
return potionData;
}
}

View file

@ -2,11 +2,11 @@ package org.spacehq.mc.protocol.data.game.values.entity.player;
public enum Animation {
SWING_ARM,
DAMAGE,
LEAVE_BED,
EAT_FOOD,
CRITICAL_HIT,
ENCHANTMENT_CRITICAL_HIT;
SWING_ARM,
DAMAGE,
LEAVE_BED,
EAT_FOOD,
CRITICAL_HIT,
ENCHANTMENT_CRITICAL_HIT;
}

View file

@ -2,16 +2,16 @@ package org.spacehq.mc.protocol.data.game.values.entity.player;
public enum BlockBreakStage {
STAGE_1,
STAGE_2,
STAGE_3,
STAGE_4,
STAGE_5,
STAGE_6,
STAGE_7,
STAGE_8,
STAGE_9,
STAGE_10,
RESET;
STAGE_1,
STAGE_2,
STAGE_3,
STAGE_4,
STAGE_5,
STAGE_6,
STAGE_7,
STAGE_8,
STAGE_9,
STAGE_10,
RESET;
}

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol.data.game.values.entity.player;
public enum CombatState {
ENTER_COMBAT,
END_COMBAT,
ENTITY_DEAD;
ENTER_COMBAT,
END_COMBAT,
ENTITY_DEAD;
}

View file

@ -4,9 +4,9 @@ import org.spacehq.mc.protocol.data.game.values.world.notify.ClientNotificationV
public enum GameMode implements ClientNotificationValue {
SURVIVAL,
CREATIVE,
ADVENTURE,
SPECTATOR;
SURVIVAL,
CREATIVE,
ADVENTURE,
SPECTATOR;
}

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol.data.game.values.entity.player;
public enum InteractAction {
INTERACT,
ATTACK,
INTERACT_AT;
INTERACT,
ATTACK,
INTERACT_AT;
}

View file

@ -2,11 +2,11 @@ package org.spacehq.mc.protocol.data.game.values.entity.player;
public enum PlayerAction {
START_DIGGING,
CANCEL_DIGGING,
FINISH_DIGGING,
DROP_ITEM_STACK,
DROP_ITEM,
RELEASE_USE_ITEM;
START_DIGGING,
CANCEL_DIGGING,
FINISH_DIGGING,
DROP_ITEM_STACK,
DROP_ITEM,
RELEASE_USE_ITEM;
}

View file

@ -2,12 +2,12 @@ package org.spacehq.mc.protocol.data.game.values.entity.player;
public enum PlayerState {
START_SNEAKING,
STOP_SNEAKING,
LEAVE_BED,
START_SPRINTING,
STOP_SPRINTING,
RIDING_JUMP,
OPEN_INVENTORY;
START_SNEAKING,
STOP_SNEAKING,
LEAVE_BED,
START_SPRINTING,
STOP_SPRINTING,
RIDING_JUMP,
OPEN_INVENTORY;
}

View file

@ -2,10 +2,10 @@ package org.spacehq.mc.protocol.data.game.values.entity.player;
public enum PositionElement {
X,
Y,
Z,
PITCH,
YAW;
X,
Y,
Z,
PITCH,
YAW;
}

View file

@ -2,9 +2,9 @@ package org.spacehq.mc.protocol.data.game.values.scoreboard;
public enum NameTagVisibility {
ALWAYS,
NEVER,
HIDE_FOR_OTHER_TEAMS,
HIDE_FOR_OWN_TEAM;
ALWAYS,
NEVER,
HIDE_FOR_OTHER_TEAMS,
HIDE_FOR_OWN_TEAM;
}

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol.data.game.values.scoreboard;
public enum ObjectiveAction {
ADD,
REMOVE,
UPDATE;
ADD,
REMOVE,
UPDATE;
}

View file

@ -2,7 +2,7 @@ package org.spacehq.mc.protocol.data.game.values.scoreboard;
public enum ScoreType {
INTEGER,
HEARTS;
INTEGER,
HEARTS;
}

View file

@ -2,7 +2,7 @@ package org.spacehq.mc.protocol.data.game.values.scoreboard;
public enum ScoreboardAction {
ADD_OR_UPDATE,
REMOVE;
ADD_OR_UPDATE,
REMOVE;
}

View file

@ -2,25 +2,25 @@ package org.spacehq.mc.protocol.data.game.values.scoreboard;
public enum ScoreboardPosition {
PLAYER_LIST,
SIDEBAR,
BELOW_NAME,
PLAYER_LIST,
SIDEBAR,
BELOW_NAME,
SIDEBAR_TEAM_BLACK,
SIDEBAR_TEAM_DARK_BLUE,
SIDEBAR_TEAM_DARK_GREEN,
SIDEBAR_TEAM_DARK_AQUA,
SIDEBAR_TEAM_DARK_RED,
SIDEBAR_TEAM_DARK_PURPLE,
SIDEBAR_TEAM_GOLD,
SIDEBAR_TEAM_GRAY,
SIDEBAR_TEAM_DARK_GRAY,
SIDEBAR_TEAM_BLUE,
SIDEBAR_TEAM_GREEN,
SIDEBAR_TEAM_AQUA,
SIDEBAR_TEAM_RED,
SIDEBAR_TEAM_LIGHT_PURPLE,
SIDEBAR_TEAM_YELLOW,
SIDEBAR_TEAM_WHITE;
SIDEBAR_TEAM_BLACK,
SIDEBAR_TEAM_DARK_BLUE,
SIDEBAR_TEAM_DARK_GREEN,
SIDEBAR_TEAM_DARK_AQUA,
SIDEBAR_TEAM_DARK_RED,
SIDEBAR_TEAM_DARK_PURPLE,
SIDEBAR_TEAM_GOLD,
SIDEBAR_TEAM_GRAY,
SIDEBAR_TEAM_DARK_GRAY,
SIDEBAR_TEAM_BLUE,
SIDEBAR_TEAM_GREEN,
SIDEBAR_TEAM_AQUA,
SIDEBAR_TEAM_RED,
SIDEBAR_TEAM_LIGHT_PURPLE,
SIDEBAR_TEAM_YELLOW,
SIDEBAR_TEAM_WHITE;
}

View file

@ -2,10 +2,10 @@ package org.spacehq.mc.protocol.data.game.values.scoreboard;
public enum TeamAction {
CREATE,
REMOVE,
UPDATE,
ADD_PLAYER,
REMOVE_PLAYER;
CREATE,
REMOVE,
UPDATE,
ADD_PLAYER,
REMOVE_PLAYER;
}

View file

@ -2,22 +2,22 @@ package org.spacehq.mc.protocol.data.game.values.scoreboard;
public enum TeamColor {
NONE,
BLACK,
DARK_BLUE,
DARK_GREEN,
DARK_AQUA,
DARK_RED,
DARK_PURPLE,
GOLD,
GRAY,
DARK_GRAY,
BLUE,
GREEN,
AQUA,
RED,
LIGHT_PURPLE,
YELLOW,
WHITE;
NONE,
BLACK,
DARK_BLUE,
DARK_GREEN,
DARK_AQUA,
DARK_RED,
DARK_PURPLE,
GOLD,
GRAY,
DARK_GRAY,
BLUE,
GREEN,
AQUA,
RED,
LIGHT_PURPLE,
YELLOW,
WHITE;
}

View file

@ -2,8 +2,8 @@ package org.spacehq.mc.protocol.data.game.values.setting;
public enum ChatVisibility {
FULL,
SYSTEM,
HIDDEN;
FULL,
SYSTEM,
HIDDEN;
}

View file

@ -2,9 +2,9 @@ package org.spacehq.mc.protocol.data.game.values.setting;
public enum Difficulty {
PEACEFUL,
EASY,
NORMAL,
HARD;
PEACEFUL,
EASY,
NORMAL,
HARD;
}

View file

@ -2,12 +2,12 @@ package org.spacehq.mc.protocol.data.game.values.setting;
public enum SkinPart {
CAPE,
JACKET,
LEFT_SLEEVE,
RIGHT_SLEEVE,
LEFT_PANTS_LEG,
RIGHT_PANTS_LEG,
HAT;
CAPE,
JACKET,
LEFT_SLEEVE,
RIGHT_SLEEVE,
LEFT_PANTS_LEG,
RIGHT_PANTS_LEG,
HAT;
}

View file

@ -2,37 +2,37 @@ package org.spacehq.mc.protocol.data.game.values.statistic;
public enum Achievement implements Statistic {
OPEN_INVENTORY,
GET_WOOD,
MAKE_WORKBENCH,
MAKE_PICKAXE,
MAKE_FURNACE,
GET_IRON,
MAKE_HOE,
MAKE_BREAD,
MAKE_CAKE,
MAKE_IRON_PICKAXE,
COOK_FISH,
RIDE_MINECART_1000_BLOCKS,
MAKE_SWORD,
KILL_ENEMY,
KILL_COW,
FLY_PIG,
SNIPE_SKELETON,
GET_DIAMONDS,
GIVE_DIAMONDS,
ENTER_PORTAL,
ATTACKED_BY_GHAST,
GET_BLAZE_ROD,
MAKE_POTION,
GO_TO_THE_END,
DEFEAT_ENDER_DRAGON,
DEAL_18_OR_MORE_DAMAGE,
MAKE_BOOKCASE,
BREED_COW,
SPAWN_WITHER,
KILL_WITHER,
MAKE_FULL_BEACON,
EXPLORE_ALL_BIOMES;
OPEN_INVENTORY,
GET_WOOD,
MAKE_WORKBENCH,
MAKE_PICKAXE,
MAKE_FURNACE,
GET_IRON,
MAKE_HOE,
MAKE_BREAD,
MAKE_CAKE,
MAKE_IRON_PICKAXE,
COOK_FISH,
RIDE_MINECART_1000_BLOCKS,
MAKE_SWORD,
KILL_ENEMY,
KILL_COW,
FLY_PIG,
SNIPE_SKELETON,
GET_DIAMONDS,
GIVE_DIAMONDS,
ENTER_PORTAL,
ATTACKED_BY_GHAST,
GET_BLAZE_ROD,
MAKE_POTION,
GO_TO_THE_END,
DEFEAT_ENDER_DRAGON,
DEAL_18_OR_MORE_DAMAGE,
MAKE_BOOKCASE,
BREED_COW,
SPAWN_WITHER,
KILL_WITHER,
MAKE_FULL_BEACON,
EXPLORE_ALL_BIOMES;
}

View file

@ -2,14 +2,14 @@ package org.spacehq.mc.protocol.data.game.values.statistic;
public class BreakBlockStatistic implements Statistic {
private int id;
private int id;
public BreakBlockStatistic(int id) {
this.id = id;
}
public BreakBlockStatistic(int id) {
this.id = id;
}
public int getId() {
return this.id;
}
public int getId() {
return this.id;
}
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.statistic;
public class BreakItemStatistic implements Statistic {
private int id;
private int id;
public BreakItemStatistic(int id) {
this.id = id;
}
public BreakItemStatistic(int id) {
this.id = id;
}
public int getId() {
return this.id;
}
public int getId() {
return this.id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
BreakItemStatistic that = (BreakItemStatistic) o;
BreakItemStatistic that = (BreakItemStatistic) o;
if (id != that.id) return false;
if(id != that.id) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return id;
}
@Override
public int hashCode() {
return id;
}
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.statistic;
public class CraftItemStatistic implements Statistic {
private int id;
private int id;
public CraftItemStatistic(int id) {
this.id = id;
}
public CraftItemStatistic(int id) {
this.id = id;
}
public int getId() {
return this.id;
}
public int getId() {
return this.id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
CraftItemStatistic that = (CraftItemStatistic) o;
CraftItemStatistic that = (CraftItemStatistic) o;
if (id != that.id) return false;
if(id != that.id) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return id;
}
@Override
public int hashCode() {
return id;
}
}

View file

@ -2,28 +2,28 @@ package org.spacehq.mc.protocol.data.game.values.statistic;
public enum GenericStatistic implements Statistic {
TIMES_LEFT_GAME,
MINUTES_PLAYED,
BLOCKS_WALKED,
BLOCKS_SWAM,
BLOCKS_FALLEN,
BLOCKS_CLIMBED,
BLOCKS_FLOWN,
BLOCKS_DOVE,
BLOCKS_TRAVELLED_IN_MINECART,
BLOCKS_TRAVELLED_IN_BOAT,
BLOCKS_RODE_ON_PIG,
BLOCKS_RODE_ON_HORSE,
TIMES_JUMPED,
TIMES_DROPPED_ITEMS,
TIMES_DEALT_DAMAGE,
DAMAGE_TAKEN,
DEATHS,
MOB_KILLS,
ANIMALS_BRED,
PLAYERS_KILLED,
FISH_CAUGHT,
JUNK_FISHED,
TREASURE_FISHED;
TIMES_LEFT_GAME,
MINUTES_PLAYED,
BLOCKS_WALKED,
BLOCKS_SWAM,
BLOCKS_FALLEN,
BLOCKS_CLIMBED,
BLOCKS_FLOWN,
BLOCKS_DOVE,
BLOCKS_TRAVELLED_IN_MINECART,
BLOCKS_TRAVELLED_IN_BOAT,
BLOCKS_RODE_ON_PIG,
BLOCKS_RODE_ON_HORSE,
TIMES_JUMPED,
TIMES_DROPPED_ITEMS,
TIMES_DEALT_DAMAGE,
DAMAGE_TAKEN,
DEATHS,
MOB_KILLS,
ANIMALS_BRED,
PLAYERS_KILLED,
FISH_CAUGHT,
JUNK_FISHED,
TREASURE_FISHED;
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.statistic;
public class UseItemStatistic implements Statistic {
private int id;
private int id;
public UseItemStatistic(int id) {
this.id = id;
}
public UseItemStatistic(int id) {
this.id = id;
}
public int getId() {
return this.id;
}
public int getId() {
return this.id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
UseItemStatistic that = (UseItemStatistic) o;
UseItemStatistic that = (UseItemStatistic) o;
if (id != that.id) return false;
if(id != that.id) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return id;
}
@Override
public int hashCode() {
return id;
}
}

View file

@ -3,7 +3,7 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum ClickItemParam implements WindowActionParam {
LEFT_CLICK,
RIGHT_CLICK;
LEFT_CLICK,
RIGHT_CLICK;
}

View file

@ -3,6 +3,6 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum CreativeGrabParam implements WindowActionParam {
GRAB;
GRAB;
}

View file

@ -3,9 +3,9 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum DropItemParam implements WindowActionParam {
DROP_FROM_SELECTED,
DROP_SELECTED_STACK,
LEFT_CLICK_OUTSIDE_NOT_HOLDING,
RIGHT_CLICK_OUTSIDE_NOT_HOLDING;
DROP_FROM_SELECTED,
DROP_SELECTED_STACK,
LEFT_CLICK_OUTSIDE_NOT_HOLDING,
RIGHT_CLICK_OUTSIDE_NOT_HOLDING;
}

View file

@ -3,6 +3,6 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum FillStackParam implements WindowActionParam {
FILL;
FILL;
}

View file

@ -3,14 +3,14 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum MoveToHotbarParam implements WindowActionParam {
SLOT_1,
SLOT_2,
SLOT_3,
SLOT_4,
SLOT_5,
SLOT_6,
SLOT_7,
SLOT_8,
SLOT_9;
SLOT_1,
SLOT_2,
SLOT_3,
SLOT_4,
SLOT_5,
SLOT_6,
SLOT_7,
SLOT_8,
SLOT_9;
}

View file

@ -3,7 +3,7 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum ShiftClickItemParam implements WindowActionParam {
LEFT_CLICK,
RIGHT_CLICK;
LEFT_CLICK,
RIGHT_CLICK;
}

View file

@ -3,11 +3,11 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum SpreadItemParam implements WindowActionParam {
LEFT_MOUSE_BEGIN_DRAG,
LEFT_MOUSE_ADD_SLOT,
LEFT_MOUSE_END_DRAG,
RIGHT_MOUSE_BEGIN_DRAG,
RIGHT_MOUSE_ADD_SLOT,
RIGHT_MOUSE_END_DRAG;
LEFT_MOUSE_BEGIN_DRAG,
LEFT_MOUSE_ADD_SLOT,
LEFT_MOUSE_END_DRAG,
RIGHT_MOUSE_BEGIN_DRAG,
RIGHT_MOUSE_ADD_SLOT,
RIGHT_MOUSE_END_DRAG;
}

View file

@ -2,12 +2,12 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum WindowAction {
CLICK_ITEM,
SHIFT_CLICK_ITEM,
MOVE_TO_HOTBAR_SLOT,
CREATIVE_GRAB_MAX_STACK,
DROP_ITEM,
SPREAD_ITEM,
FILL_STACK;
CLICK_ITEM,
SHIFT_CLICK_ITEM,
MOVE_TO_HOTBAR_SLOT,
CREATIVE_GRAB_MAX_STACK,
DROP_ITEM,
SPREAD_ITEM,
FILL_STACK;
}

View file

@ -2,18 +2,18 @@ package org.spacehq.mc.protocol.data.game.values.window;
public enum WindowType {
GENERIC_INVENTORY,
ANVIL,
BEACON,
BREWING_STAND,
CHEST,
CRAFTING_TABLE,
DISPENSER,
DROPPER,
ENCHANTING_TABLE,
FURNACE,
HOPPER,
VILLAGER,
HORSE;
GENERIC_INVENTORY,
ANVIL,
BEACON,
BREWING_STAND,
CHEST,
CRAFTING_TABLE,
DISPENSER,
DROPPER,
ENCHANTING_TABLE,
FURNACE,
HOPPER,
VILLAGER,
HORSE;
}

View file

@ -27,25 +27,29 @@ public enum EnchantmentTableProperty implements WindowProperty {
/**
* The enchantment for slot 1.
*
* @see #getEnchantment(int, int)
*/
ENCHANTMENT_SLOT_1,
/**
* The enchantment for slot 2.
*
* @see #getEnchantment(int, int)
*/
ENCHANTMENT_SLOT_2,
/**
* The enchantment for slot 3.
*
* @see #getEnchantment(int, int)
*/
ENCHANTMENT_SLOT_3;
/**
* Packs enchantment type and level into one integer as used for the ENCHANTMENT_SLOT_X properties.
* @param type Id of the enchantment
*
* @param type Id of the enchantment
* @param level Level of the enchantment
* @return Packed value
* @see #getEnchantmentType(int)
@ -57,6 +61,7 @@ public enum EnchantmentTableProperty implements WindowProperty {
/**
* Unpacks the enchantment type from one integer as used for the ENCHANTMENT_SLOT_X properties.
*
* @param enchantmentInfo Packed value
* @return Id of the enchantment
* @see #getEnchantment(int, int)
@ -67,6 +72,7 @@ public enum EnchantmentTableProperty implements WindowProperty {
/**
* Unpacks the enchantment level from one integer as used for the ENCHANTMENT_SLOT_X properties.
*
* @param enchantmentInfo Packed value
* @return Level of the enchantment
* @see #getEnchantment(int, int)

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.world;
public class CustomSound implements Sound {
private String name;
private String name;
public CustomSound(String name) {
this.name = name;
}
public CustomSound(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public String getName() {
return this.name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
CustomSound that = (CustomSound) o;
CustomSound that = (CustomSound) o;
if (!name.equals(that.name)) return false;
if(!name.equals(that.name)) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public int hashCode() {
return name.hashCode();
}
}

View file

@ -2,208 +2,208 @@ package org.spacehq.mc.protocol.data.game.values.world;
public enum GenericSound implements Sound {
CLICK,
FIZZ,
FIRE_AMBIENT,
IGNITE_FIRE,
WATER_AMBIENT,
LAVA_AMBIENT,
LAVA_POP,
HARP,
BASS_DRUM,
SNARE_DRUM,
HI_HAT,
DOUBLE_BASS,
PISTON_EXTEND,
PISTON_RETRACT,
PORTAL_AMBIENT,
TNT_PRIMED,
BOW_HIT,
COLLECT_ITEM,
COLLECT_EXP,
SUCCESSFUL_HIT,
FIREWORK_BLAST,
FIREWORK_LARGE_BLAST,
FIREWORK_FAR_BLAST,
FIREWORK_FAR_LARGE_BLAST,
FIREWORK_TWINKLE,
FIREWORK_FAR_TWINKLE,
RAIN_AMBIENT,
WITHER_SPAWN,
ENDER_DRAGON_DEATH,
FIRE_PROJECTILE,
DOOR_OPEN,
DOOR_CLOSE,
GHAST_CHARGE,
GHAST_FIRE,
POUND_WOODEN_DOOR,
POUND_METAL_DOOR,
BREAK_WOODEN_DOOR,
WITHER_SHOOT,
BAT_TAKE_OFF,
INFECT_VILLAGER,
DISINFECT_VILLAGER,
ANVIL_BREAK,
ANVIL_USE,
ANVIL_LAND,
BREAK_SPLASH_POTION,
THORNS_DAMAGE,
EXPLOSION,
CAVE_AMBIENT,
OPEN_CHEST,
CLOSE_CHEST,
DIG_STONE,
DIG_WOOD,
DIG_GRAVEL,
DIG_GRASS,
DIG_CLOTH,
DIG_SAND,
DIG_SNOW,
DIG_GLASS,
ANVIL_STEP,
LADDER_STEP,
STONE_STEP,
WOOD_STEP,
GRAVEL_STEP,
GRASS_STEP,
CLOTH_STEP,
SAND_STEP,
SNOW_STEP,
BURP,
SADDLE_HORSE,
ENDER_DRAGON_FLAP_WINGS,
THUNDER_AMBIENT,
LAUNCH_FIREWORKS,
CREEPER_PRIMED,
ENDERMAN_STARE,
ENDERMAN_TELEPORT,
IRON_GOLEM_THROW,
IRON_GOLEM_WALK,
ZOMBIE_PIGMAN_ANGRY,
SILVERFISH_STEP,
SKELETON_STEP,
SPIDER_STEP,
ZOMBIE_STEP,
ZOMBIE_CURE,
CHICKEN_LAY_EGG,
CHICKEN_STEP,
COW_STEP,
HORSE_EATING,
HORSE_LAND,
HORSE_WEAR_ARMOR,
HORSE_GALLOP,
HORSE_BREATHE,
HORSE_WOOD_STEP,
HORSE_SOFT_STEP,
HORSE_JUMP,
SHEAR_SHEEP,
PIG_STEP,
SHEEP_STEP,
VILLAGER_YES,
VILLAGER_NO,
WOLF_STEP,
WOLF_SHAKE,
DRINK,
EAT,
LEVEL_UP,
FISH_HOOK_SPLASH,
ITEM_BREAK,
SWIM,
SPLASH,
HURT,
DEATH,
BIG_FALL,
SMALL_FALL,
MOB_SWIM,
MOB_SPLASH,
PLAYER_SWIM,
PLAYER_SPLASH,
ENDER_DRAGON_GROWL,
WITHER_IDLE,
BLAZE_BREATHE,
ENDERMAN_SCREAM,
ENDERMAN_IDLE,
GHAST_MOAN,
ZOMBIE_PIGMAN_IDLE,
SILVERFISH_IDLE,
SKELETON_IDLE,
SPIDER_IDLE,
WITCH_IDLE,
ZOMBIE_IDLE,
BAT_IDLE,
CHICKEN_IDLE,
COW_IDLE,
HORSE_IDLE,
DONKEY_IDLE,
ZOMBIE_HORSE_IDLE,
SKELETON_HORSE_IDLE,
OCELOT_PURR,
OCELOT_PURR_MEOW,
OCELOT_MEOW,
PIG_IDLE,
SHEEP_IDLE,
VILLAGER_HAGGLE,
VILLAGER_IDLE,
WOLF_GROWL,
WOLF_PANT,
WOLF_WHINE,
WOLF_BARK,
MOB_BIG_FALL,
MOB_SMALL_FALL,
PLAYER_BIG_FALL,
PLAYER_SMALL_FALL,
ENDER_DRAGON_HURT,
WITHER_HURT,
WITHER_DEATH,
BLAZE_HURT,
BLAZE_DEATH,
CREEPER_HURT,
CREEPER_DEATH,
ENDERMAN_HURT,
ENDERMAN_DEATH,
GHAST_HURT,
GHAST_DEATH,
IRON_GOLEM_HURT,
IRON_GOLEM_DEATH,
MOB_HURT,
MOB_DEATH,
ZOMBIE_PIGMAN_HURT,
ZOMBIE_PIGMAN_DEATH,
SILVERFISH_HURT,
SILVERFISH_DEATH,
SKELETON_HURT,
SKELETON_DEATH,
SLIME,
BIG_SLIME,
SPIDER_DEATH,
WITCH_HURT,
WITCH_DEATH,
ZOMBIE_HURT,
ZOMBIE_DEATH,
PLAYER_HURT,
PLAYER_DEATH,
WOLF_HURT,
WOLF_DEATH,
VILLAGER_HURT,
VILLAGER_DEATH,
PIG_DEATH,
OCELOT_HURT,
HORSE_HURT,
DONKEY_HURT,
ZOMBIE_HORSE_HURT,
SKELETON_HORSE_HURT,
HORSE_DEATH,
DONKEY_DEATH,
ZOMBIE_HORSE_DEATH,
SKELETON_HORSE_DEATH,
COW_HURT,
CHICKEN_HURT,
BAT_HURT,
BAT_DEATH,
RABBIT_IDLE,
RABBIT_HOP,
RABBIT_HURT,
RABBIT_DEATH,
MOB_ATTACK;
CLICK,
FIZZ,
FIRE_AMBIENT,
IGNITE_FIRE,
WATER_AMBIENT,
LAVA_AMBIENT,
LAVA_POP,
HARP,
BASS_DRUM,
SNARE_DRUM,
HI_HAT,
DOUBLE_BASS,
PISTON_EXTEND,
PISTON_RETRACT,
PORTAL_AMBIENT,
TNT_PRIMED,
BOW_HIT,
COLLECT_ITEM,
COLLECT_EXP,
SUCCESSFUL_HIT,
FIREWORK_BLAST,
FIREWORK_LARGE_BLAST,
FIREWORK_FAR_BLAST,
FIREWORK_FAR_LARGE_BLAST,
FIREWORK_TWINKLE,
FIREWORK_FAR_TWINKLE,
RAIN_AMBIENT,
WITHER_SPAWN,
ENDER_DRAGON_DEATH,
FIRE_PROJECTILE,
DOOR_OPEN,
DOOR_CLOSE,
GHAST_CHARGE,
GHAST_FIRE,
POUND_WOODEN_DOOR,
POUND_METAL_DOOR,
BREAK_WOODEN_DOOR,
WITHER_SHOOT,
BAT_TAKE_OFF,
INFECT_VILLAGER,
DISINFECT_VILLAGER,
ANVIL_BREAK,
ANVIL_USE,
ANVIL_LAND,
BREAK_SPLASH_POTION,
THORNS_DAMAGE,
EXPLOSION,
CAVE_AMBIENT,
OPEN_CHEST,
CLOSE_CHEST,
DIG_STONE,
DIG_WOOD,
DIG_GRAVEL,
DIG_GRASS,
DIG_CLOTH,
DIG_SAND,
DIG_SNOW,
DIG_GLASS,
ANVIL_STEP,
LADDER_STEP,
STONE_STEP,
WOOD_STEP,
GRAVEL_STEP,
GRASS_STEP,
CLOTH_STEP,
SAND_STEP,
SNOW_STEP,
BURP,
SADDLE_HORSE,
ENDER_DRAGON_FLAP_WINGS,
THUNDER_AMBIENT,
LAUNCH_FIREWORKS,
CREEPER_PRIMED,
ENDERMAN_STARE,
ENDERMAN_TELEPORT,
IRON_GOLEM_THROW,
IRON_GOLEM_WALK,
ZOMBIE_PIGMAN_ANGRY,
SILVERFISH_STEP,
SKELETON_STEP,
SPIDER_STEP,
ZOMBIE_STEP,
ZOMBIE_CURE,
CHICKEN_LAY_EGG,
CHICKEN_STEP,
COW_STEP,
HORSE_EATING,
HORSE_LAND,
HORSE_WEAR_ARMOR,
HORSE_GALLOP,
HORSE_BREATHE,
HORSE_WOOD_STEP,
HORSE_SOFT_STEP,
HORSE_JUMP,
SHEAR_SHEEP,
PIG_STEP,
SHEEP_STEP,
VILLAGER_YES,
VILLAGER_NO,
WOLF_STEP,
WOLF_SHAKE,
DRINK,
EAT,
LEVEL_UP,
FISH_HOOK_SPLASH,
ITEM_BREAK,
SWIM,
SPLASH,
HURT,
DEATH,
BIG_FALL,
SMALL_FALL,
MOB_SWIM,
MOB_SPLASH,
PLAYER_SWIM,
PLAYER_SPLASH,
ENDER_DRAGON_GROWL,
WITHER_IDLE,
BLAZE_BREATHE,
ENDERMAN_SCREAM,
ENDERMAN_IDLE,
GHAST_MOAN,
ZOMBIE_PIGMAN_IDLE,
SILVERFISH_IDLE,
SKELETON_IDLE,
SPIDER_IDLE,
WITCH_IDLE,
ZOMBIE_IDLE,
BAT_IDLE,
CHICKEN_IDLE,
COW_IDLE,
HORSE_IDLE,
DONKEY_IDLE,
ZOMBIE_HORSE_IDLE,
SKELETON_HORSE_IDLE,
OCELOT_PURR,
OCELOT_PURR_MEOW,
OCELOT_MEOW,
PIG_IDLE,
SHEEP_IDLE,
VILLAGER_HAGGLE,
VILLAGER_IDLE,
WOLF_GROWL,
WOLF_PANT,
WOLF_WHINE,
WOLF_BARK,
MOB_BIG_FALL,
MOB_SMALL_FALL,
PLAYER_BIG_FALL,
PLAYER_SMALL_FALL,
ENDER_DRAGON_HURT,
WITHER_HURT,
WITHER_DEATH,
BLAZE_HURT,
BLAZE_DEATH,
CREEPER_HURT,
CREEPER_DEATH,
ENDERMAN_HURT,
ENDERMAN_DEATH,
GHAST_HURT,
GHAST_DEATH,
IRON_GOLEM_HURT,
IRON_GOLEM_DEATH,
MOB_HURT,
MOB_DEATH,
ZOMBIE_PIGMAN_HURT,
ZOMBIE_PIGMAN_DEATH,
SILVERFISH_HURT,
SILVERFISH_DEATH,
SKELETON_HURT,
SKELETON_DEATH,
SLIME,
BIG_SLIME,
SPIDER_DEATH,
WITCH_HURT,
WITCH_DEATH,
ZOMBIE_HURT,
ZOMBIE_DEATH,
PLAYER_HURT,
PLAYER_DEATH,
WOLF_HURT,
WOLF_DEATH,
VILLAGER_HURT,
VILLAGER_DEATH,
PIG_DEATH,
OCELOT_HURT,
HORSE_HURT,
DONKEY_HURT,
ZOMBIE_HORSE_HURT,
SKELETON_HORSE_HURT,
HORSE_DEATH,
DONKEY_DEATH,
ZOMBIE_HORSE_DEATH,
SKELETON_HORSE_DEATH,
COW_HURT,
CHICKEN_HURT,
BAT_HURT,
BAT_DEATH,
RABBIT_IDLE,
RABBIT_HOP,
RABBIT_HURT,
RABBIT_DEATH,
MOB_ATTACK;
}

View file

@ -1,60 +1,60 @@
package org.spacehq.mc.protocol.data.game.values.world;
public enum Particle {
EXPLOSION_NORMAL,
EXPLOSION_LARGE,
EXPLOSION_HUGE,
FIREWORKS_SPARK,
WATER_BUBBLE,
WATER_SPLASH,
WATER_WAKE,
SUSPENDED,
SUSPENDED_DEPTH,
CRIT,
CRIT_MAGIC,
SMOKE_NORMAL,
SMOKE_LARGE,
SPELL,
SPELL_INSTANT,
SPELL_MOB,
SPELL_MOB_AMBIENT,
SPELL_WITCH,
DRIP_WATER,
DRIP_LAVA,
VILLAGER_ANGRY,
VILLAGER_HAPPY,
TOWN_AURA,
NOTE,
PORTAL,
ENCHANTMENT_TABLE,
FLAME,
LAVA,
FOOTSTEP,
CLOUD,
REDSTONE,
SNOWBALL,
SNOW_SHOVEL,
SLIME,
HEART,
BARRIER,
ICON_CRACK(2),
BLOCK_CRACK(1),
BLOCK_DUST(1),
WATER_DROP,
ITEM_TAKE,
MOB_APPEARANCE;
EXPLOSION_NORMAL,
EXPLOSION_LARGE,
EXPLOSION_HUGE,
FIREWORKS_SPARK,
WATER_BUBBLE,
WATER_SPLASH,
WATER_WAKE,
SUSPENDED,
SUSPENDED_DEPTH,
CRIT,
CRIT_MAGIC,
SMOKE_NORMAL,
SMOKE_LARGE,
SPELL,
SPELL_INSTANT,
SPELL_MOB,
SPELL_MOB_AMBIENT,
SPELL_WITCH,
DRIP_WATER,
DRIP_LAVA,
VILLAGER_ANGRY,
VILLAGER_HAPPY,
TOWN_AURA,
NOTE,
PORTAL,
ENCHANTMENT_TABLE,
FLAME,
LAVA,
FOOTSTEP,
CLOUD,
REDSTONE,
SNOWBALL,
SNOW_SHOVEL,
SLIME,
HEART,
BARRIER,
ICON_CRACK(2),
BLOCK_CRACK(1),
BLOCK_DUST(1),
WATER_DROP,
ITEM_TAKE,
MOB_APPEARANCE;
private int dataLength;
private int dataLength;
private Particle() {
this(0);
}
private Particle() {
this(0);
}
private Particle(int dataLength) {
this.dataLength = dataLength;
}
private Particle(int dataLength) {
this.dataLength = dataLength;
}
public int getDataLength() {
return this.dataLength;
}
public int getDataLength() {
return this.dataLength;
}
}

View file

@ -1,10 +1,10 @@
package org.spacehq.mc.protocol.data.game.values.world;
public enum WorldBorderAction {
SET_SIZE,
LERP_SIZE,
SET_CENTER,
INITIALIZE,
SET_WARNING_TIME,
SET_WARNING_BLOCKS;
SET_SIZE,
LERP_SIZE,
SET_CENTER,
INITIALIZE,
SET_WARNING_TIME,
SET_WARNING_BLOCKS;
}

View file

@ -2,12 +2,12 @@ package org.spacehq.mc.protocol.data.game.values.world;
public enum WorldType {
DEFAULT,
FLAT,
LARGE_BIOMES,
AMPLIFIED,
CUSTOMIZED,
DEBUG,
DEFAULT_1_1;
DEFAULT,
FLAT,
LARGE_BIOMES,
AMPLIFIED,
CUSTOMIZED,
DEBUG,
DEFAULT_1_1;
}

View file

@ -4,40 +4,40 @@ import org.spacehq.mc.protocol.data.game.Position;
public class BlockChangeRecord {
private Position position;
private int block;
private Position position;
private int block;
public BlockChangeRecord(Position position, int block) {
this.position = position;
this.block = block;
}
public BlockChangeRecord(Position position, int block) {
this.position = position;
this.block = block;
}
public Position getPosition() {
return this.position;
}
public Position getPosition() {
return this.position;
}
public int getBlock() {
return this.block;
}
public int getBlock() {
return this.block;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
BlockChangeRecord record = (BlockChangeRecord) o;
BlockChangeRecord record = (BlockChangeRecord) o;
if (block != record.block) return false;
if (!position.equals(record.position)) return false;
if(block != record.block) return false;
if(!position.equals(record.position)) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = position.hashCode();
result = 31 * result + block;
return result;
}
@Override
public int hashCode() {
int result = position.hashCode();
result = 31 * result + block;
return result;
}
}

View file

@ -2,48 +2,48 @@ package org.spacehq.mc.protocol.data.game.values.world.block;
public class ExplodedBlockRecord {
private int x;
private int y;
private int z;
private int x;
private int y;
private int z;
public ExplodedBlockRecord(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public ExplodedBlockRecord(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public int getX() {
return this.x;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getY() {
return this.y;
}
public int getZ() {
return this.z;
}
public int getZ() {
return this.z;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
ExplodedBlockRecord that = (ExplodedBlockRecord) o;
ExplodedBlockRecord that = (ExplodedBlockRecord) o;
if (x != that.x) return false;
if (y != that.y) return false;
if (z != that.z) return false;
if(x != that.x) return false;
if(y != that.y) return false;
if(z != that.z) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
}

View file

@ -2,11 +2,11 @@ package org.spacehq.mc.protocol.data.game.values.world.block;
public enum UpdatedTileType {
MOB_SPAWNER,
COMMAND_BLOCK,
BEACON,
SKULL,
FLOWER_POT,
BANNER;
MOB_SPAWNER,
COMMAND_BLOCK,
BEACON,
SKULL,
FLOWER_POT,
BANNER;
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public class ChestValue implements BlockValue {
private int viewers;
private int viewers;
public ChestValue(int viewers) {
this.viewers = viewers;
}
public ChestValue(int viewers) {
this.viewers = viewers;
}
public int getViewers() {
return this.viewers;
}
public int getViewers() {
return this.viewers;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
ChestValue that = (ChestValue) o;
ChestValue that = (ChestValue) o;
if (viewers != that.viewers) return false;
if(viewers != that.viewers) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return viewers;
}
@Override
public int hashCode() {
return viewers;
}
}

View file

@ -2,6 +2,6 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public enum ChestValueType implements BlockValueType {
VIEWING_PLAYER_COUNT;
VIEWING_PLAYER_COUNT;
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public class GenericBlockValue implements BlockValue {
private int value;
private int value;
public GenericBlockValue(int value) {
this.value = value;
}
public GenericBlockValue(int value) {
this.value = value;
}
public int getValue() {
return this.value;
}
public int getValue() {
return this.value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
GenericBlockValue that = (GenericBlockValue) o;
GenericBlockValue that = (GenericBlockValue) o;
if (value != that.value) return false;
if(value != that.value) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return value;
}
@Override
public int hashCode() {
return value;
}
}

View file

@ -2,6 +2,6 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public enum GenericBlockValueType implements BlockValueType {
GENERIC;
GENERIC;
}

View file

@ -2,6 +2,6 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public enum MobSpawnerValueType implements BlockValueType {
RESET_DELAY;
RESET_DELAY;
}

View file

@ -2,35 +2,35 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public class NoteBlockValue implements BlockValue {
private int pitch;
private int pitch;
public NoteBlockValue(int pitch) {
if(pitch < 0 || pitch > 24) {
throw new IllegalArgumentException("Pitch must be between 0 and 24.");
}
public NoteBlockValue(int pitch) {
if(pitch < 0 || pitch > 24) {
throw new IllegalArgumentException("Pitch must be between 0 and 24.");
}
this.pitch = pitch;
}
this.pitch = pitch;
}
public int getPitch() {
return this.pitch;
}
public int getPitch() {
return this.pitch;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
NoteBlockValue that = (NoteBlockValue) o;
NoteBlockValue that = (NoteBlockValue) o;
if (pitch != that.pitch) return false;
if(pitch != that.pitch) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return pitch;
}
@Override
public int hashCode() {
return pitch;
}
}

View file

@ -2,10 +2,10 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public enum NoteBlockValueType implements BlockValueType {
HARP,
DOUBLE_BASS,
SNARE_DRUM,
HI_HAT,
BASS_DRUM;
HARP,
DOUBLE_BASS,
SNARE_DRUM,
HI_HAT,
BASS_DRUM;
}

View file

@ -2,11 +2,11 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public enum PistonValue implements BlockValue {
DOWN,
UP,
SOUTH,
WEST,
NORTH,
EAST;
DOWN,
UP,
SOUTH,
WEST,
NORTH,
EAST;
}

View file

@ -2,7 +2,7 @@ package org.spacehq.mc.protocol.data.game.values.world.block.value;
public enum PistonValueType implements BlockValueType {
PUSHING,
PULLING;
PUSHING,
PULLING;
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.world.effect;
public class BreakBlockEffectData implements WorldEffectData {
private int blockId;
private int blockId;
public BreakBlockEffectData(int blockId) {
this.blockId = blockId;
}
public BreakBlockEffectData(int blockId) {
this.blockId = blockId;
}
public int getBlockId() {
return this.blockId;
}
public int getBlockId() {
return this.blockId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
BreakBlockEffectData that = (BreakBlockEffectData) o;
BreakBlockEffectData that = (BreakBlockEffectData) o;
if (blockId != that.blockId) return false;
if(blockId != that.blockId) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return blockId;
}
@Override
public int hashCode() {
return blockId;
}
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.world.effect;
public class BreakPotionEffectData implements WorldEffectData {
private int potionId;
private int potionId;
public BreakPotionEffectData(int potionId) {
this.potionId = potionId;
}
public BreakPotionEffectData(int potionId) {
this.potionId = potionId;
}
public int getPotionId() {
return this.potionId;
}
public int getPotionId() {
return this.potionId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
BreakPotionEffectData that = (BreakPotionEffectData) o;
BreakPotionEffectData that = (BreakPotionEffectData) o;
if (potionId != that.potionId) return false;
if(potionId != that.potionId) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return potionId;
}
@Override
public int hashCode() {
return potionId;
}
}

View file

@ -2,31 +2,31 @@ package org.spacehq.mc.protocol.data.game.values.world.effect;
public class HardLandingEffectData implements WorldEffectData {
private int damagingDistance;
private int damagingDistance;
public HardLandingEffectData(int damagingDistance) {
this.damagingDistance = damagingDistance;
}
public HardLandingEffectData(int damagingDistance) {
this.damagingDistance = damagingDistance;
}
public int getDamagingDistance() {
return this.damagingDistance;
}
public int getDamagingDistance() {
return this.damagingDistance;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
HardLandingEffectData that = (HardLandingEffectData) o;
HardLandingEffectData that = (HardLandingEffectData) o;
if (damagingDistance != that.damagingDistance) return false;
if(damagingDistance != that.damagingDistance) return false;
return true;
}
return true;
}
@Override
public int hashCode() {
return damagingDistance;
}
@Override
public int hashCode() {
return damagingDistance;
}
}

View file

@ -2,12 +2,12 @@ package org.spacehq.mc.protocol.data.game.values.world.effect;
public enum ParticleEffect implements WorldEffect {
SMOKE,
BREAK_BLOCK,
BREAK_SPLASH_POTION,
BREAK_EYE_OF_ENDER,
MOB_SPAWN,
BONEMEAL_GROW,
HARD_LANDING_DUST;
SMOKE,
BREAK_BLOCK,
BREAK_SPLASH_POTION,
BREAK_EYE_OF_ENDER,
MOB_SPAWN,
BONEMEAL_GROW,
HARD_LANDING_DUST;
}

Some files were not shown because too many files have changed in this diff Show more