mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Clean up and format code.
This commit is contained in:
parent
688e043825
commit
dae57d1090
229 changed files with 1402 additions and 2402 deletions
|
@ -2,10 +2,10 @@ package com.github.steveice10.mc.protocol.test;
|
|||
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.ServerLoginHandler;
|
||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.WorldType;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.github.steveice10.mc.protocol;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.login.client.LoginStartPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginDisconnectPacket;
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.auth.exception.request.InvalidCredentialsException;
|
||||
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
||||
|
@ -18,7 +16,9 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDisconnectPa
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerSetCompressionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.client.EncryptionResponsePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.client.LoginStartPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.EncryptionRequestPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginDisconnectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginSetCompressionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginSuccessPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.status.client.StatusPingPacket;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol;
|
||||
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
||||
import com.github.steveice10.mc.auth.service.AuthenticationService;
|
||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
||||
import com.github.steveice10.mc.protocol.packet.handshake.client.HandshakePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
||||
|
@ -84,6 +89,10 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.Serve
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPaintingPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerCloseWindowPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket;
|
||||
|
@ -109,20 +118,11 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUnload
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerWorldBorderPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.client.EncryptionResponsePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.client.LoginStartPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.EncryptionRequestPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginDisconnectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginSetCompressionPacket;
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
||||
import com.github.steveice10.mc.auth.service.AuthenticationService;
|
||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
||||
import com.github.steveice10.mc.protocol.packet.handshake.client.HandshakePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.client.EncryptionResponsePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.EncryptionRequestPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginSuccessPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.status.client.StatusPingPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.status.client.StatusQueryPacket;
|
||||
|
@ -155,12 +155,12 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
}
|
||||
|
||||
public MinecraftProtocol(SubProtocol subProtocol) {
|
||||
if (subProtocol != SubProtocol.LOGIN && subProtocol != SubProtocol.STATUS) {
|
||||
if(subProtocol != SubProtocol.LOGIN && subProtocol != SubProtocol.STATUS) {
|
||||
throw new IllegalArgumentException("Only login and status modes are permitted.");
|
||||
}
|
||||
|
||||
this.subProtocol = subProtocol;
|
||||
if (subProtocol == SubProtocol.LOGIN) {
|
||||
if(subProtocol == SubProtocol.LOGIN) {
|
||||
this.profile = new GameProfile((UUID) null, "Player");
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
String clientToken = UUID.randomUUID().toString();
|
||||
AuthenticationService auth = new AuthenticationService(clientToken, authProxy);
|
||||
auth.setUsername(username);
|
||||
if (token) {
|
||||
if(token) {
|
||||
auth.setAccessToken(using);
|
||||
} else {
|
||||
auth.setPassword(using);
|
||||
|
@ -225,7 +225,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
|
||||
@Override
|
||||
public void newClientSession(Client client, Session session) {
|
||||
if (this.profile != null) {
|
||||
if(this.profile != null) {
|
||||
session.setFlag(MinecraftConstants.PROFILE_KEY, this.profile);
|
||||
session.setFlag(MinecraftConstants.ACCESS_TOKEN_KEY, this.accessToken);
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
protected void enableEncryption(Key key) {
|
||||
try {
|
||||
this.encrypt = new AESEncryption(key);
|
||||
} catch (GeneralSecurityException e) {
|
||||
} catch(GeneralSecurityException e) {
|
||||
throw new Error("Failed to enable protocol encryption.", e);
|
||||
}
|
||||
}
|
||||
|
@ -254,9 +254,9 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
|
||||
protected void setSubProtocol(SubProtocol subProtocol, boolean client, Session session) {
|
||||
this.clearPackets();
|
||||
switch (subProtocol) {
|
||||
switch(subProtocol) {
|
||||
case HANDSHAKE:
|
||||
if (client) {
|
||||
if(client) {
|
||||
this.initClientHandshake(session);
|
||||
} else {
|
||||
this.initServerHandshake(session);
|
||||
|
@ -264,7 +264,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
|
||||
break;
|
||||
case LOGIN:
|
||||
if (client) {
|
||||
if(client) {
|
||||
this.initClientLogin(session);
|
||||
} else {
|
||||
this.initServerLogin(session);
|
||||
|
@ -272,7 +272,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
|
||||
break;
|
||||
case GAME:
|
||||
if (client) {
|
||||
if(client) {
|
||||
this.initClientGame(session);
|
||||
} else {
|
||||
this.initServerGame(session);
|
||||
|
@ -280,7 +280,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
|
||||
break;
|
||||
case STATUS:
|
||||
if (client) {
|
||||
if(client) {
|
||||
this.initClientStatus(session);
|
||||
} else {
|
||||
this.initServerStatus(session);
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package com.github.steveice10.mc.protocol;
|
||||
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
||||
import com.github.steveice10.mc.auth.service.SessionService;
|
||||
import com.github.steveice10.mc.protocol.data.SubProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.data.status.PlayerInfo;
|
||||
import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
|
||||
import com.github.steveice10.mc.protocol.data.status.VersionInfo;
|
||||
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder;
|
||||
import com.github.steveice10.mc.protocol.packet.handshake.client.HandshakePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDisconnectPacket;
|
||||
|
@ -19,11 +24,6 @@ import com.github.steveice10.mc.protocol.packet.status.client.StatusQueryPacket;
|
|||
import com.github.steveice10.mc.protocol.packet.status.server.StatusPongPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.status.server.StatusResponsePacket;
|
||||
import com.github.steveice10.mc.protocol.util.CryptUtil;
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
||||
import com.github.steveice10.mc.auth.service.SessionService;
|
||||
import com.github.steveice10.mc.protocol.data.status.PlayerInfo;
|
||||
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
|
||||
import com.github.steveice10.packetlib.event.session.DisconnectingEvent;
|
||||
|
@ -182,7 +182,7 @@ public class ServerListener extends SessionAdapter {
|
|||
}
|
||||
|
||||
int threshold;
|
||||
if (this.session.hasFlag(MinecraftConstants.SERVER_COMPRESSION_THRESHOLD)) {
|
||||
if(this.session.hasFlag(MinecraftConstants.SERVER_COMPRESSION_THRESHOLD)) {
|
||||
threshold = this.session.getFlag(MinecraftConstants.SERVER_COMPRESSION_THRESHOLD);
|
||||
} else {
|
||||
threshold = 256;
|
||||
|
|
|
@ -5,35 +5,51 @@ import com.github.steveice10.mc.protocol.data.game.BossBarColor;
|
|||
import com.github.steveice10.mc.protocol.data.game.BossBarDivision;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.data.game.MessageType;
|
||||
import com.github.steveice10.mc.protocol.data.game.PlayerListEntryAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.ResourcePackStatus;
|
||||
import com.github.steveice10.mc.protocol.data.game.TitleAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.UnlockRecipesAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.EntityStatus;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.EquipmentSlot;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.AttributeType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierOperation;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Animation;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.BlockBreakStage;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.CombatState;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PositionElement;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.GlobalEntityType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.MobType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.object.HangingDirection;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.object.MinecartType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.ObjectiveAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreType;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardPosition;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.GenericStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.AdvancementTabAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.ClickItemParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.CraftingBookDataType;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.CreativeGrabParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.DropItemParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.FillStackParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.MoveToHotbarParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.ShiftClickItemParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.SpreadItemParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowAction;
|
||||
|
@ -53,31 +69,15 @@ import com.github.steveice10.mc.protocol.data.game.world.block.value.MobSpawnerV
|
|||
import com.github.steveice10.mc.protocol.data.game.world.block.value.NoteBlockValueType;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.value.PistonValue;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.value.PistonValueType;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.effect.ParticleEffect;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.effect.SmokeEffectData;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.effect.SoundEffect;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.map.MapIconType;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.notify.ClientNotification;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.notify.DemoMessageValue;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.notify.EnterCreditsValue;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.sound.SoundCategory;
|
||||
import com.github.steveice10.mc.protocol.data.game.PlayerListEntryAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.TitleAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.EntityStatus;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.CombatState;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.GlobalEntityType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.MobType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.object.MinecartType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.ObjectiveAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.DropItemParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.FillStackParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.MoveToHotbarParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.effect.ParticleEffect;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.notify.ClientNotification;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.sound.SoundCategory;
|
||||
import com.github.steveice10.mc.protocol.data.handshake.HandshakeIntent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1043,7 +1043,7 @@ public class MagicValues {
|
|||
if(!values.containsKey(key)) {
|
||||
values.put(key, new ArrayList<Object>());
|
||||
} else if(overwrite) {
|
||||
for(Iterator<Object> it = values.get(key).iterator(); it.hasNext();) {
|
||||
for(Iterator<Object> it = values.get(key).iterator(); it.hasNext(); ) {
|
||||
if(value.getClass().isAssignableFrom(it.next().getClass())) {
|
||||
it.remove();
|
||||
}
|
||||
|
@ -1053,7 +1053,7 @@ public class MagicValues {
|
|||
values.get(key).add(value);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public static <T> T key(Class<T> keyType, Object value) {
|
||||
for(Object key : values.keySet()) {
|
||||
if(keyType.isAssignableFrom(key.getClass())) {
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.github.steveice10.mc.protocol.data.game;
|
|||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PlayerListEntry {
|
||||
private GameProfile profile;
|
||||
|
@ -56,20 +58,23 @@ public class PlayerListEntry {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof PlayerListEntry && this.profile.equals(((PlayerListEntry) o).profile) && this.gameMode == ((PlayerListEntry) o).gameMode && this.ping == ((PlayerListEntry) o).ping && (this.displayName != null ? this.displayName.equals(((PlayerListEntry) o).displayName) : ((PlayerListEntry) o).displayName == null);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof PlayerListEntry)) return false;
|
||||
|
||||
PlayerListEntry that = (PlayerListEntry) o;
|
||||
return Objects.equals(this.profile, that.profile) &&
|
||||
this.gameMode == that.gameMode &&
|
||||
this.ping == that.ping &&
|
||||
Objects.equals(this.displayName, that.displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.profile.hashCode();
|
||||
result = 31 * result + (this.gameMode != null ? this.gameMode.hashCode() : 0);
|
||||
result = 31 * result + this.ping;
|
||||
result = 31 * result + (this.displayName != null ? this.displayName.hashCode() : 0);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.profile, this.gameMode, this.ping, this.displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.github.steveice10.mc.protocol.data.game.advancement;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -48,8 +48,9 @@ public class Advancement {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Advancement)) return false;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof Advancement)) return false;
|
||||
|
||||
Advancement that = (Advancement) o;
|
||||
return Objects.equals(this.id, that.id) &&
|
||||
Objects.equals(this.parentId, that.parentId) &&
|
||||
|
@ -60,21 +61,15 @@ public class Advancement {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, parentId, displayData, criteria, requirements);
|
||||
return Objects.hash(this.id, this.parentId, this.displayData, this.criteria, this.requirements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
|
||||
public static class DisplayData {
|
||||
public enum FrameType {
|
||||
TASK,
|
||||
CHALLENGE,
|
||||
GOAL;
|
||||
}
|
||||
|
||||
private Message title;
|
||||
private Message description;
|
||||
private ItemStack icon;
|
||||
|
@ -83,7 +78,6 @@ public class Advancement {
|
|||
private boolean hidden;
|
||||
private String backgroundTexture;
|
||||
private float posX, posY;
|
||||
|
||||
public DisplayData(Message title, Message description, ItemStack icon, FrameType frameType,
|
||||
boolean showToast, boolean hidden, float posX, float posY) {
|
||||
this.title = title;
|
||||
|
@ -140,8 +134,9 @@ public class Advancement {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof DisplayData)) return false;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof DisplayData)) return false;
|
||||
|
||||
DisplayData that = (DisplayData) o;
|
||||
return this.showToast == that.showToast &&
|
||||
this.hidden == that.hidden &&
|
||||
|
@ -156,12 +151,18 @@ public class Advancement {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(title, description, icon, frameType, showToast, hidden, backgroundTexture, posX, posY);
|
||||
return ObjectUtil.hashCode(this.title, this.description, this.icon, this.frameType, this.showToast, this.hidden, this.backgroundTexture, this.posX, this.posY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
|
||||
public enum FrameType {
|
||||
TASK,
|
||||
CHALLENGE,
|
||||
GOAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.github.steveice10.mc.protocol.data.game.chunk;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||
import com.github.steveice10.mc.protocol.util.NetUtil;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
||||
|
@ -9,6 +10,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockStorage {
|
||||
private static final BlockState AIR = new BlockState(0, 0);
|
||||
|
@ -39,6 +41,18 @@ public class BlockStorage {
|
|||
this.storage = new FlexibleStorage(this.bitsPerEntry, in.readLongs(in.readVarInt()));
|
||||
}
|
||||
|
||||
private static int index(int x, int y, int z) {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
|
||||
private static BlockState rawToState(int raw) {
|
||||
return new BlockState(raw >> 4, raw & 0xF);
|
||||
}
|
||||
|
||||
private static int stateToRaw(BlockState state) {
|
||||
return (state.getId() << 4) | (state.getData() & 0xF);
|
||||
}
|
||||
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeByte(this.bitsPerEntry);
|
||||
|
||||
|
@ -106,28 +120,24 @@ public class BlockStorage {
|
|||
return true;
|
||||
}
|
||||
|
||||
private static int index(int x, int y, int z) {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
|
||||
private static BlockState rawToState(int raw) {
|
||||
return new BlockState(raw >> 4, raw & 0xF);
|
||||
}
|
||||
|
||||
private static int stateToRaw(BlockState state) {
|
||||
return (state.getId() << 4) | (state.getData() & 0xF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof BlockStorage && this.bitsPerEntry == ((BlockStorage) o).bitsPerEntry && this.states.equals(((BlockStorage) o).states) && this.storage.equals(((BlockStorage) o).storage);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof BlockStorage)) return false;
|
||||
|
||||
BlockStorage that = (BlockStorage) o;
|
||||
return this.bitsPerEntry == that.bitsPerEntry &&
|
||||
Objects.equals(this.states, that.states) &&
|
||||
Objects.equals(this.storage, that.storage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.bitsPerEntry;
|
||||
result = 31 * result + this.states.hashCode();
|
||||
result = 31 * result + this.storage.hashCode();
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.bitsPerEntry, this.states, this.storage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.chunk;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Chunk {
|
||||
private BlockStorage blocks;
|
||||
private NibbleArray3d blocklight;
|
||||
|
@ -33,14 +37,22 @@ public class Chunk {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof Chunk && this.blocks.equals(((Chunk) o).blocks) && this.blocklight.equals(((Chunk) o).blocklight) && ((this.skylight == null && (((Chunk) o).skylight == null)) || (this.skylight != null && this.skylight.equals(((Chunk) o).skylight))));
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof Chunk)) return false;
|
||||
|
||||
Chunk that = (Chunk) o;
|
||||
return Objects.equals(this.blocks, that.blocks) &&
|
||||
Objects.equals(this.blocklight, that.blocklight) &&
|
||||
Objects.equals(this.skylight, that.skylight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.blocks.hashCode();
|
||||
result = 31 * result + this.blocklight.hashCode();
|
||||
result = 31 * result + (this.skylight != null ? this.skylight.hashCode() : 0);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.blocks, this.blocklight, this.skylight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.chunk;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Column {
|
||||
private int x;
|
||||
private int z;
|
||||
|
@ -74,4 +77,27 @@ public class Column {
|
|||
public boolean hasSkylight() {
|
||||
return this.skylight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof Column)) return false;
|
||||
|
||||
Column that = (Column) o;
|
||||
return this.x == that.x &&
|
||||
this.z == that.z &&
|
||||
Arrays.equals(this.chunks, that.chunks) &&
|
||||
Arrays.equals(this.biomeData, that.biomeData) &&
|
||||
Arrays.equals(this.tileEntities, that.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectUtil.hashCode(this.x, this.z, this.chunks, this.biomeData, this.tileEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.chunk;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FlexibleStorage {
|
||||
|
@ -24,6 +26,21 @@ public class FlexibleStorage {
|
|||
this.maxEntryValue = (1L << this.bitsPerEntry) - 1;
|
||||
}
|
||||
|
||||
private static int roundToNearest(int value, int roundTo) {
|
||||
if(roundTo == 0) {
|
||||
return 0;
|
||||
} else if(value == 0) {
|
||||
return roundTo;
|
||||
} else {
|
||||
if(value < 0) {
|
||||
roundTo *= -1;
|
||||
}
|
||||
|
||||
int remainder = value % roundTo;
|
||||
return remainder != 0 ? value + roundTo - remainder : value;
|
||||
}
|
||||
}
|
||||
|
||||
public long[] getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
@ -73,32 +90,25 @@ public class FlexibleStorage {
|
|||
}
|
||||
}
|
||||
|
||||
private static int roundToNearest(int value, int roundTo) {
|
||||
if(roundTo == 0) {
|
||||
return 0;
|
||||
} else if(value == 0) {
|
||||
return roundTo;
|
||||
} else {
|
||||
if(value < 0) {
|
||||
roundTo *= -1;
|
||||
}
|
||||
|
||||
int remainder = value % roundTo;
|
||||
return remainder != 0 ? value + roundTo - remainder : value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof FlexibleStorage && Arrays.equals(this.data, ((FlexibleStorage) o).data) && this.bitsPerEntry == ((FlexibleStorage) o).bitsPerEntry && this.size == ((FlexibleStorage) o).size && this.maxEntryValue == ((FlexibleStorage) o).maxEntryValue);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof FlexibleStorage)) return false;
|
||||
|
||||
FlexibleStorage that = (FlexibleStorage) o;
|
||||
return Arrays.equals(this.data, that.data) &&
|
||||
this.bitsPerEntry == that.bitsPerEntry &&
|
||||
this.size == that.size &&
|
||||
this.maxEntryValue == that.maxEntryValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Arrays.hashCode(this.data);
|
||||
result = 31 * result + this.bitsPerEntry;
|
||||
result = 31 * result + this.size;
|
||||
result = 31 * result + (int) this.maxEntryValue;
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.data, this.bitsPerEntry, this.size, this.maxEntryValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.chunk;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
||||
|
@ -61,11 +62,20 @@ public class NibbleArray3d {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof NibbleArray3d && Arrays.equals(this.data, ((NibbleArray3d) o).data));
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof NibbleArray3d)) return false;
|
||||
|
||||
NibbleArray3d that = (NibbleArray3d) o;
|
||||
return Arrays.equals(this.data, that.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity;
|
||||
|
||||
public enum Effect {
|
||||
|
||||
SPEED,
|
||||
SLOWNESS,
|
||||
DIG_SPEED,
|
||||
|
@ -29,5 +28,4 @@ public enum Effect {
|
|||
LEVITATION,
|
||||
LUCK,
|
||||
BAD_LUCK;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.attribute;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Attribute {
|
||||
|
||||
private AttributeType type;
|
||||
private double value;
|
||||
private List<AttributeModifier> modifiers;
|
||||
|
@ -40,28 +40,21 @@ public class Attribute {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof Attribute)) return false;
|
||||
|
||||
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;
|
||||
|
||||
return true;
|
||||
Attribute that = (Attribute) o;
|
||||
return this.type == that.type &&
|
||||
this.value == that.value &&
|
||||
Objects.equals(this.modifiers, that.modifiers);
|
||||
}
|
||||
|
||||
@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;
|
||||
return ObjectUtil.hashCode(this.type, this.value, this.modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.attribute;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AttributeModifier {
|
||||
|
||||
private ModifierType type;
|
||||
private UUID uuid;
|
||||
private double amount;
|
||||
|
@ -53,24 +54,22 @@ public class AttributeModifier {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof AttributeModifier)) return false;
|
||||
|
||||
AttributeModifier that = (AttributeModifier) o;
|
||||
|
||||
if(Double.compare(that.amount, amount) != 0) return false;
|
||||
if(operation != that.operation) return false;
|
||||
if(!type.equals(that.type)) return false;
|
||||
|
||||
return true;
|
||||
return this.type == that.type &&
|
||||
Objects.equals(this.uuid, that.uuid) &&
|
||||
this.amount == that.amount &&
|
||||
this.operation == that.operation;
|
||||
}
|
||||
|
||||
@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;
|
||||
return ObjectUtil.hashCode(this.type, this.uuid, this.amount, this.operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.attribute;
|
||||
|
||||
public enum AttributeType {
|
||||
|
||||
GENERIC_MAX_HEALTH(20, 0, 1024),
|
||||
GENERIC_FOLLOW_RANGE(32, 0, 2048),
|
||||
GENERIC_KNOCKBACK_RESISTANCE(0, 0, 1),
|
||||
|
@ -36,5 +35,4 @@ public enum AttributeType {
|
|||
public double getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.attribute;
|
||||
|
||||
public enum ModifierOperation {
|
||||
|
||||
ADD,
|
||||
ADD_MULTIPLIED,
|
||||
MULTIPLY;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.metadata;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class EntityMetadata {
|
||||
private int id;
|
||||
|
@ -27,19 +29,22 @@ public class EntityMetadata {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof EntityMetadata && this.id == ((EntityMetadata) o).id && this.type == ((EntityMetadata) o).type && this.value.equals(((EntityMetadata) o).value));
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof EntityMetadata)) return false;
|
||||
|
||||
EntityMetadata that = (EntityMetadata) o;
|
||||
return this.id == that.id &&
|
||||
this.type == that.type &&
|
||||
Objects.equals(this.value, that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.id;
|
||||
result = 31 * result + this.type.hashCode();
|
||||
result = 31 * result + this.value.hashCode();
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.id, this.type, this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.metadata;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ItemStack {
|
||||
private int id;
|
||||
private int amount;
|
||||
|
@ -45,15 +48,23 @@ public class ItemStack {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof ItemStack && this.id == ((ItemStack) o).id && this.amount == ((ItemStack) o).amount && this.data == ((ItemStack) o).data && ((this.nbt != null && ((ItemStack) o).nbt != null) || (this.nbt != null && this.nbt.equals(((ItemStack) o).nbt))));
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof ItemStack)) return false;
|
||||
|
||||
ItemStack that = (ItemStack) o;
|
||||
return this.id == that.id &&
|
||||
this.amount == that.amount &&
|
||||
this.data == that.data &&
|
||||
Objects.equals(this.nbt, that.nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.id;
|
||||
result = 31 * result + this.amount;
|
||||
result = 31 * result + this.data;
|
||||
result = 31 * result + (this.nbt != null ? this.nbt.hashCode() : 0);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.id, this.amount, this.data, this.nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.metadata;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class Position {
|
||||
private int x;
|
||||
|
@ -27,19 +27,22 @@ public class Position {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof Position && this.x == ((Position) o).x && this.y == ((Position) o).y && this.z == ((Position) o).z);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof Position)) return false;
|
||||
|
||||
Position that = (Position) o;
|
||||
return this.x == that.x &&
|
||||
this.y == that.y &&
|
||||
this.z == that.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.x;
|
||||
result = 31 * result + this.y;
|
||||
result = 31 * result + this.z;
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.metadata;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class Rotation {
|
||||
private float pitch;
|
||||
private float yaw;
|
||||
|
@ -29,14 +31,22 @@ public class Rotation {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof Rotation && Float.compare(this.pitch, ((Rotation) o).pitch) == 0 && Float.compare(this.yaw, ((Rotation) o).yaw) == 0 && Float.compare(this.roll, ((Rotation) o).roll) == 0);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof Rotation)) return false;
|
||||
|
||||
Rotation that = (Rotation) o;
|
||||
return this.pitch == that.pitch &&
|
||||
this.yaw == that.yaw &&
|
||||
this.roll == that.roll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Float.floatToIntBits(this.pitch);
|
||||
result = 31 * result + Float.floatToIntBits(this.yaw);
|
||||
result = 31 * result + Float.floatToIntBits(this.roll);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.pitch, this.yaw, this.roll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.player;
|
||||
|
||||
public enum Animation {
|
||||
|
||||
SWING_ARM,
|
||||
DAMAGE,
|
||||
LEAVE_BED,
|
||||
EAT_FOOD,
|
||||
CRITICAL_HIT,
|
||||
ENCHANTMENT_CRITICAL_HIT;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.player;
|
||||
|
||||
public enum BlockBreakStage {
|
||||
|
||||
STAGE_1,
|
||||
STAGE_2,
|
||||
STAGE_3,
|
||||
|
@ -13,5 +12,4 @@ public enum BlockBreakStage {
|
|||
STAGE_9,
|
||||
STAGE_10,
|
||||
RESET;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.player;
|
||||
|
||||
public enum CombatState {
|
||||
|
||||
ENTER_COMBAT,
|
||||
END_COMBAT,
|
||||
ENTITY_DEAD;
|
||||
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@ package com.github.steveice10.mc.protocol.data.game.entity.player;
|
|||
import com.github.steveice10.mc.protocol.data.game.world.notify.ClientNotificationValue;
|
||||
|
||||
public enum GameMode implements ClientNotificationValue {
|
||||
|
||||
SURVIVAL,
|
||||
CREATIVE,
|
||||
ADVENTURE,
|
||||
SPECTATOR;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.player;
|
||||
|
||||
public enum InteractAction {
|
||||
|
||||
INTERACT,
|
||||
ATTACK,
|
||||
INTERACT_AT;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.player;
|
||||
|
||||
public enum PlayerAction {
|
||||
|
||||
START_DIGGING,
|
||||
CANCEL_DIGGING,
|
||||
FINISH_DIGGING,
|
||||
|
@ -9,5 +8,4 @@ public enum PlayerAction {
|
|||
DROP_ITEM,
|
||||
RELEASE_USE_ITEM,
|
||||
SWAP_HANDS;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.player;
|
||||
|
||||
public enum PositionElement {
|
||||
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
PITCH,
|
||||
YAW;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type;
|
||||
|
||||
public enum GlobalEntityType {
|
||||
|
||||
LIGHTNING_BOLT;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type;
|
||||
|
||||
public enum PaintingType {
|
||||
|
||||
KEBAB,
|
||||
AZTEC,
|
||||
ALBAN,
|
||||
|
@ -28,5 +27,4 @@ public enum PaintingType {
|
|||
BURNING_SKULL,
|
||||
SKELETON,
|
||||
DONKEY_KONG;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type.object;
|
||||
|
||||
public class FallingBlockData implements ObjectData {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class FallingBlockData implements ObjectData {
|
||||
private int id;
|
||||
private int metadata;
|
||||
|
||||
|
@ -21,21 +22,20 @@ public class FallingBlockData implements ObjectData {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof FallingBlockData)) return false;
|
||||
|
||||
FallingBlockData that = (FallingBlockData) o;
|
||||
|
||||
if(id != that.id) return false;
|
||||
if(metadata != that.metadata) return false;
|
||||
|
||||
return true;
|
||||
return this.id == that.id &&
|
||||
this.metadata == that.metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + metadata;
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.id, this.metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type.object;
|
||||
|
||||
public enum HangingDirection implements ObjectData {
|
||||
|
||||
SOUTH,
|
||||
WEST,
|
||||
NORTH,
|
||||
EAST;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type.object;
|
||||
|
||||
public enum MinecartType implements ObjectData {
|
||||
|
||||
NORMAL,
|
||||
CHEST,
|
||||
POWERED,
|
||||
|
@ -9,5 +8,4 @@ public enum MinecartType implements ObjectData {
|
|||
MOB_SPAWNER,
|
||||
HOPPER,
|
||||
COMMAND_BLOCK;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type.object;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class ProjectileData implements ObjectData {
|
||||
private int ownerId;
|
||||
|
||||
|
@ -13,11 +15,20 @@ public class ProjectileData implements ObjectData {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || (o instanceof ProjectileData && this.ownerId == ((ProjectileData) o).ownerId);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof ProjectileData)) return false;
|
||||
|
||||
ProjectileData that = (ProjectileData) o;
|
||||
return this.ownerId == that.ownerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.ownerId;
|
||||
return ObjectUtil.hashCode(this.ownerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type.object;
|
||||
|
||||
public class SplashPotionData implements ObjectData {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class SplashPotionData implements ObjectData {
|
||||
private int potionData;
|
||||
|
||||
public SplashPotionData(int potionData) {
|
||||
|
@ -15,18 +16,19 @@ public class SplashPotionData implements ObjectData {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof SplashPotionData)) return false;
|
||||
|
||||
SplashPotionData that = (SplashPotionData) o;
|
||||
|
||||
if(potionData != that.potionData) return false;
|
||||
|
||||
return true;
|
||||
return this.potionData == that.potionData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return potionData;
|
||||
return ObjectUtil.hashCode(this.potionData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.scoreboard;
|
||||
|
||||
public enum NameTagVisibility {
|
||||
|
||||
ALWAYS,
|
||||
NEVER,
|
||||
HIDE_FOR_OTHER_TEAMS,
|
||||
HIDE_FOR_OWN_TEAM;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.scoreboard;
|
||||
|
||||
public enum ObjectiveAction {
|
||||
|
||||
ADD,
|
||||
REMOVE,
|
||||
UPDATE;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.scoreboard;
|
||||
|
||||
public enum ScoreType {
|
||||
|
||||
INTEGER,
|
||||
HEARTS;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.scoreboard;
|
||||
|
||||
public enum ScoreboardAction {
|
||||
|
||||
ADD_OR_UPDATE,
|
||||
REMOVE;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.scoreboard;
|
||||
|
||||
public enum ScoreboardPosition {
|
||||
|
||||
PLAYER_LIST,
|
||||
SIDEBAR,
|
||||
BELOW_NAME,
|
||||
|
@ -22,5 +21,4 @@ public enum ScoreboardPosition {
|
|||
SIDEBAR_TEAM_LIGHT_PURPLE,
|
||||
SIDEBAR_TEAM_YELLOW,
|
||||
SIDEBAR_TEAM_WHITE;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.scoreboard;
|
||||
|
||||
public enum TeamAction {
|
||||
|
||||
CREATE,
|
||||
REMOVE,
|
||||
UPDATE,
|
||||
ADD_PLAYER,
|
||||
REMOVE_PLAYER;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.scoreboard;
|
||||
|
||||
public enum TeamColor {
|
||||
|
||||
NONE,
|
||||
BLACK,
|
||||
DARK_BLUE,
|
||||
|
@ -19,5 +18,4 @@ public enum TeamColor {
|
|||
LIGHT_PURPLE,
|
||||
YELLOW,
|
||||
WHITE;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.setting;
|
||||
|
||||
public enum ChatVisibility {
|
||||
|
||||
FULL,
|
||||
SYSTEM,
|
||||
HIDDEN;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.setting;
|
||||
|
||||
public enum Difficulty {
|
||||
|
||||
PEACEFUL,
|
||||
EASY,
|
||||
NORMAL,
|
||||
HARD;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.setting;
|
||||
|
||||
public enum SkinPart {
|
||||
|
||||
CAPE,
|
||||
JACKET,
|
||||
LEFT_SLEEVE,
|
||||
|
@ -9,5 +8,4 @@ public enum SkinPart {
|
|||
LEFT_PANTS_LEG,
|
||||
RIGHT_PANTS_LEG,
|
||||
HAT;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class BreakBlockStatistic implements Statistic {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BreakBlockStatistic implements Statistic {
|
||||
private String id;
|
||||
|
||||
public BreakBlockStatistic(String id) {
|
||||
|
@ -15,18 +18,19 @@ public class BreakBlockStatistic implements Statistic {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof BreakBlockStatistic)) return false;
|
||||
|
||||
BreakBlockStatistic that = (BreakBlockStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equals(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
return ObjectUtil.hashCode(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class BreakItemStatistic implements Statistic {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BreakItemStatistic implements Statistic {
|
||||
private String id;
|
||||
|
||||
public BreakItemStatistic(String id) {
|
||||
|
@ -15,18 +18,19 @@ public class BreakItemStatistic implements Statistic {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof BreakItemStatistic)) return false;
|
||||
|
||||
BreakItemStatistic that = (BreakItemStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equals(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
return ObjectUtil.hashCode(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class CraftItemStatistic implements Statistic {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CraftItemStatistic implements Statistic {
|
||||
private String id;
|
||||
|
||||
public CraftItemStatistic(String id) {
|
||||
|
@ -15,18 +18,19 @@ public class CraftItemStatistic implements Statistic {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof CraftItemStatistic)) return false;
|
||||
|
||||
CraftItemStatistic that = (CraftItemStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equals(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
return ObjectUtil.hashCode(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class DropItemStatistic implements Statistic {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DropItemStatistic implements Statistic {
|
||||
private String id;
|
||||
|
||||
public DropItemStatistic(String id) {
|
||||
|
@ -15,18 +18,19 @@ public class DropItemStatistic implements Statistic {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof DropItemStatistic)) return false;
|
||||
|
||||
DropItemStatistic that = (DropItemStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equals(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
return ObjectUtil.hashCode(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public enum GenericStatistic implements Statistic {
|
||||
|
||||
CAKE_SLICES_EATEN,
|
||||
TIMES_CAULDRON_FILLED,
|
||||
TIMES_CAULDRON_USED,
|
||||
|
@ -52,5 +51,4 @@ public enum GenericStatistic implements Statistic {
|
|||
ANIMALS_BRED,
|
||||
PLAYERS_KILLED,
|
||||
FISH_CAUGHT;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class KillEntityStatistic implements Statistic {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class KillEntityStatistic implements Statistic {
|
||||
private String id;
|
||||
|
||||
public KillEntityStatistic(String id) {
|
||||
|
@ -15,18 +18,19 @@ public class KillEntityStatistic implements Statistic {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof KillEntityStatistic)) return false;
|
||||
|
||||
KillEntityStatistic that = (KillEntityStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equals(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
return ObjectUtil.hashCode(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class KilledByEntityStatistic implements Statistic {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class KilledByEntityStatistic implements Statistic {
|
||||
private String id;
|
||||
|
||||
public KilledByEntityStatistic(String id) {
|
||||
|
@ -15,18 +18,19 @@ public class KilledByEntityStatistic implements Statistic {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof KilledByEntityStatistic)) return false;
|
||||
|
||||
KilledByEntityStatistic that = (KilledByEntityStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equals(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
return ObjectUtil.hashCode(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class PickupItemStatistic implements Statistic {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PickupItemStatistic implements Statistic {
|
||||
private String id;
|
||||
|
||||
public PickupItemStatistic(String id) {
|
||||
|
@ -15,18 +18,19 @@ public class PickupItemStatistic implements Statistic {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof PickupItemStatistic)) return false;
|
||||
|
||||
PickupItemStatistic that = (PickupItemStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equals(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
return ObjectUtil.hashCode(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class UseItemStatistic implements Statistic {
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class UseItemStatistic implements Statistic {
|
||||
private String id;
|
||||
|
||||
public UseItemStatistic(String id) {
|
||||
|
@ -15,18 +18,19 @@ public class UseItemStatistic implements Statistic {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!(o instanceof UseItemStatistic)) return false;
|
||||
|
||||
UseItemStatistic that = (UseItemStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equals(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
return ObjectUtil.hashCode(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
|
||||
public enum ClickItemParam implements WindowActionParam {
|
||||
|
||||
LEFT_CLICK,
|
||||
RIGHT_CLICK;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
|
||||
public enum CreativeGrabParam implements WindowActionParam {
|
||||
|
||||
GRAB;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
|
||||
public enum DropItemParam implements WindowActionParam {
|
||||
|
||||
DROP_FROM_SELECTED,
|
||||
DROP_SELECTED_STACK,
|
||||
LEFT_CLICK_OUTSIDE_NOT_HOLDING,
|
||||
RIGHT_CLICK_OUTSIDE_NOT_HOLDING;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
|
||||
public enum FillStackParam implements WindowActionParam {
|
||||
|
||||
FILL;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
|
||||
public enum MoveToHotbarParam implements WindowActionParam {
|
||||
|
||||
SLOT_1,
|
||||
SLOT_2,
|
||||
SLOT_3,
|
||||
|
@ -12,5 +10,4 @@ public enum MoveToHotbarParam implements WindowActionParam {
|
|||
SLOT_7,
|
||||
SLOT_8,
|
||||
SLOT_9;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
|
||||
public enum ShiftClickItemParam implements WindowActionParam {
|
||||
|
||||
LEFT_CLICK,
|
||||
RIGHT_CLICK;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.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;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
public enum WindowAction {
|
||||
|
||||
CLICK_ITEM,
|
||||
SHIFT_CLICK_ITEM,
|
||||
MOVE_TO_HOTBAR_SLOT,
|
||||
|
@ -9,5 +8,4 @@ public enum WindowAction {
|
|||
DROP_ITEM,
|
||||
SPREAD_ITEM,
|
||||
FILL_STACK;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
public enum WindowType {
|
||||
|
||||
GENERIC_INVENTORY,
|
||||
ANVIL,
|
||||
BEACON,
|
||||
|
@ -16,5 +15,4 @@ public enum WindowType {
|
|||
VILLAGER,
|
||||
SHULKER_BOX,
|
||||
HORSE;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ package com.github.steveice10.mc.protocol.data.game.window.property;
|
|||
* Window properties of an enchantment table.
|
||||
*/
|
||||
public enum EnchantmentTableProperty implements WindowProperty {
|
||||
|
||||
/**
|
||||
* Level of the enchantment in slot 1.
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,6 @@ package com.github.steveice10.mc.protocol.data.game.window.property;
|
|||
* Window properties of a furnace.
|
||||
*/
|
||||
public enum FurnaceProperty {
|
||||
|
||||
/**
|
||||
* Number of ticks left before the current fuel runs out.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window.property;
|
||||
|
||||
public interface WindowProperty {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.block;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockChangeRecord {
|
||||
private Position position;
|
||||
|
@ -21,13 +24,21 @@ public class BlockChangeRecord {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof BlockChangeRecord && this.position.equals(((BlockChangeRecord) o).position) && this.block.equals(((BlockChangeRecord) o).block);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof BlockChangeRecord)) return false;
|
||||
|
||||
BlockChangeRecord that = (BlockChangeRecord) o;
|
||||
return Objects.equals(this.position, that.position) &&
|
||||
Objects.equals(this.block, that.block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.position.hashCode();
|
||||
result = 31 * result + this.block.hashCode();
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.position, this.block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.block;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class BlockState {
|
||||
private int id;
|
||||
private int data;
|
||||
|
@ -19,13 +21,21 @@ public class BlockState {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof BlockState && this.id == ((BlockState) o).id && this.data == ((BlockState) o).data;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof BlockState)) return false;
|
||||
|
||||
BlockState that = (BlockState) o;
|
||||
return this.id == that.id &&
|
||||
this.data == that.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.id;
|
||||
result = 31 * result + this.data;
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.id, this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.block;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class ExplodedBlockRecord {
|
||||
private int x;
|
||||
private int y;
|
||||
|
@ -25,14 +27,22 @@ public class ExplodedBlockRecord {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ExplodedBlockRecord && this.x == ((ExplodedBlockRecord) o).x && this.y == ((ExplodedBlockRecord) o).y && this.z == ((ExplodedBlockRecord) o).z;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof ExplodedBlockRecord)) return false;
|
||||
|
||||
ExplodedBlockRecord that = (ExplodedBlockRecord) o;
|
||||
return this.x == that.x &&
|
||||
this.y == that.y &&
|
||||
this.z == that.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.x;
|
||||
result = 31 * result + this.y;
|
||||
result = 31 * result + this.z;
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.block.value;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class ChestValue implements BlockValue {
|
||||
private int viewers;
|
||||
|
||||
|
@ -13,11 +15,20 @@ public class ChestValue implements BlockValue {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ChestValue && this.viewers == ((ChestValue) o).viewers;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof ChestValue)) return false;
|
||||
|
||||
ChestValue that = (ChestValue) o;
|
||||
return this.viewers == that.viewers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.viewers;
|
||||
return ObjectUtil.hashCode(this.viewers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.block.value;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class GenericBlockValue implements BlockValue {
|
||||
private int value;
|
||||
|
||||
|
@ -13,11 +15,20 @@ public class GenericBlockValue implements BlockValue {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof GenericBlockValue && this.value == ((GenericBlockValue) o).value;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof GenericBlockValue)) return false;
|
||||
|
||||
GenericBlockValue that = (GenericBlockValue) o;
|
||||
return this.value == that.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.value;
|
||||
return ObjectUtil.hashCode(this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.block.value;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class NoteBlockValue implements BlockValue {
|
||||
private int pitch;
|
||||
|
||||
|
@ -17,11 +19,20 @@ public class NoteBlockValue implements BlockValue {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof NoteBlockValue && this.pitch == ((NoteBlockValue) o).pitch;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof NoteBlockValue)) return false;
|
||||
|
||||
NoteBlockValue that = (NoteBlockValue) o;
|
||||
return this.pitch == that.pitch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.pitch;
|
||||
return ObjectUtil.hashCode(this.pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.effect;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class BonemealGrowEffectData implements WorldEffectData {
|
||||
private int particleCount;
|
||||
|
||||
|
@ -13,11 +15,20 @@ public class BonemealGrowEffectData implements WorldEffectData {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof BonemealGrowEffectData && this.particleCount == ((BonemealGrowEffectData) o).particleCount;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof BonemealGrowEffectData)) return false;
|
||||
|
||||
BonemealGrowEffectData that = (BonemealGrowEffectData) o;
|
||||
return this.particleCount == that.particleCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.particleCount;
|
||||
return ObjectUtil.hashCode(this.particleCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.effect;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BreakBlockEffectData implements WorldEffectData {
|
||||
private BlockState blockState;
|
||||
|
@ -15,11 +18,20 @@ public class BreakBlockEffectData implements WorldEffectData {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof BreakBlockEffectData && this.blockState.equals(((BreakBlockEffectData) o).blockState);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof BreakBlockEffectData)) return false;
|
||||
|
||||
BreakBlockEffectData that = (BreakBlockEffectData) o;
|
||||
return Objects.equals(this.blockState, that.blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.blockState.hashCode();
|
||||
return ObjectUtil.hashCode(this.blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.effect;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class BreakPotionEffectData implements WorldEffectData {
|
||||
private int potionId;
|
||||
|
||||
|
@ -13,11 +15,20 @@ public class BreakPotionEffectData implements WorldEffectData {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof BreakPotionEffectData && this.potionId == ((BreakPotionEffectData) o).potionId;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof BreakPotionEffectData)) return false;
|
||||
|
||||
BreakPotionEffectData that = (BreakPotionEffectData) o;
|
||||
return this.potionId == that.potionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.potionId;
|
||||
return ObjectUtil.hashCode(this.potionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.effect;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class RecordEffectData implements WorldEffectData {
|
||||
private int recordId;
|
||||
|
||||
|
@ -13,11 +15,20 @@ public class RecordEffectData implements WorldEffectData {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof RecordEffectData && this.recordId == ((RecordEffectData) o).recordId;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof RecordEffectData)) return false;
|
||||
|
||||
RecordEffectData that = (RecordEffectData) o;
|
||||
return this.recordId == that.recordId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.recordId;
|
||||
return ObjectUtil.hashCode(this.recordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.map;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MapData {
|
||||
|
@ -39,16 +41,24 @@ public class MapData {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof MapData && this.columns == ((MapData) o).columns && this.rows == ((MapData) o).rows && this.x == ((MapData) o).x && this.y == ((MapData) o).y && Arrays.equals(this.data, ((MapData) o).data);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof MapData)) return false;
|
||||
|
||||
MapData that = (MapData) o;
|
||||
return this.columns == that.columns &&
|
||||
this.rows == that.rows &&
|
||||
this.x == that.x &&
|
||||
this.y == that.y &&
|
||||
Arrays.equals(this.data, that.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.columns;
|
||||
result = 31 * result + this.rows;
|
||||
result = 31 * result + this.x;
|
||||
result = 31 * result + this.y;
|
||||
result = 31 * result + Arrays.hashCode(this.data);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.columns, this.rows, this.x, this.y, this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.map;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class MapIcon {
|
||||
private int centerX;
|
||||
private int centerZ;
|
||||
|
@ -31,15 +33,23 @@ public class MapIcon {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof MapIcon && this.centerX == ((MapIcon) o).centerX && this.centerZ == ((MapIcon) o).centerZ && this.iconType == ((MapIcon) o).iconType && this.iconRotation == ((MapIcon) o).iconRotation;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof MapIcon)) return false;
|
||||
|
||||
MapIcon that = (MapIcon) o;
|
||||
return this.centerX == that.centerX &&
|
||||
this.centerZ == that.centerZ &&
|
||||
this.iconType == that.iconType &&
|
||||
this.iconRotation == that.iconRotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.centerX;
|
||||
result = 31 * result + this.centerZ;
|
||||
result = 31 * result + this.iconRotation;
|
||||
result = 31 * result + (this.iconType != null ? this.iconType.hashCode() : 0);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.centerX, this.centerZ, this.iconType, this.iconRotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.notify;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class RainStrengthValue implements ClientNotificationValue {
|
||||
private float strength;
|
||||
|
||||
|
@ -21,11 +23,20 @@ public class RainStrengthValue implements ClientNotificationValue {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof RainStrengthValue && Float.compare(this.strength, ((RainStrengthValue) o).strength) == 0;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof RainStrengthValue)) return false;
|
||||
|
||||
RainStrengthValue that = (RainStrengthValue) o;
|
||||
return Float.compare(this.strength, that.strength) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.strength != +0.0f ? Float.floatToIntBits(this.strength) : 0;
|
||||
return ObjectUtil.hashCode(this.strength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.notify;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
public class ThunderStrengthValue implements ClientNotificationValue {
|
||||
private float strength;
|
||||
|
||||
|
@ -21,11 +23,20 @@ public class ThunderStrengthValue implements ClientNotificationValue {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ThunderStrengthValue && Float.compare(this.strength, ((ThunderStrengthValue) o).strength) == 0;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof ThunderStrengthValue)) return false;
|
||||
|
||||
ThunderStrengthValue that = (ThunderStrengthValue) o;
|
||||
return Float.compare(this.strength, that.strength) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.strength != +0.0f ? Float.floatToIntBits(this.strength) : 0;
|
||||
return ObjectUtil.hashCode(this.strength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.sound;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CustomSound implements Sound {
|
||||
private String name;
|
||||
|
||||
|
@ -13,11 +17,20 @@ public class CustomSound implements Sound {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof CustomSound && this.name.equals(((CustomSound) o).name);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof CustomSound)) return false;
|
||||
|
||||
CustomSound that = (CustomSound) o;
|
||||
return Objects.equals(this.name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
return ObjectUtil.hashCode(this.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,6 @@ public enum ChatColor {
|
|||
WHITE,
|
||||
RESET;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public static ChatColor byName(String name) {
|
||||
name = name.toLowerCase();
|
||||
for(ChatColor color : values()) {
|
||||
|
@ -34,4 +29,9 @@ public enum ChatColor {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,6 @@ public enum ChatFormat {
|
|||
ITALIC,
|
||||
OBFUSCATED;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public static ChatFormat byName(String name) {
|
||||
name = name.toLowerCase();
|
||||
for(ChatFormat format : values()) {
|
||||
|
@ -22,4 +17,9 @@ public enum ChatFormat {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
|
@ -6,11 +6,6 @@ public enum ClickAction {
|
|||
OPEN_URL,
|
||||
OPEN_FILE;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public static ClickAction byName(String name) {
|
||||
name = name.toLowerCase();
|
||||
for(ClickAction action : values()) {
|
||||
|
@ -21,4 +16,9 @@ public enum ClickAction {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.message;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ClickEvent implements Cloneable {
|
||||
private ClickAction action;
|
||||
private String value;
|
||||
|
@ -24,13 +28,21 @@ public class ClickEvent implements Cloneable {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ClickEvent && this.action == ((ClickEvent) o).action && this.value.equals(((ClickEvent) o).value);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof ClickEvent)) return false;
|
||||
|
||||
ClickEvent that = (ClickEvent) o;
|
||||
return this.action == that.action &&
|
||||
Objects.equals(this.value, that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.action.hashCode();
|
||||
result = 31 * result + this.value.hashCode();
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.action, this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,6 @@ public enum HoverAction {
|
|||
SHOW_ACHIEVEMENT,
|
||||
SHOW_ENTITY;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public static HoverAction byName(String name) {
|
||||
name = name.toLowerCase();
|
||||
for(HoverAction action : values()) {
|
||||
|
@ -21,4 +16,9 @@ public enum HoverAction {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.message;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class HoverEvent implements Cloneable {
|
||||
private HoverAction action;
|
||||
private Message value;
|
||||
|
@ -24,13 +28,21 @@ public class HoverEvent implements Cloneable {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof HoverEvent && this.action == ((HoverEvent) o).action && this.value.equals(((HoverEvent) o).value);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof HoverEvent)) return false;
|
||||
|
||||
HoverEvent that = (HoverEvent) o;
|
||||
return this.action == that.action &&
|
||||
Objects.equals(this.value, that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.action.hashCode();
|
||||
result = 31 * result + this.value.hashCode();
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.action, this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.github.steveice10.mc.protocol.data.message;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class KeybindMessage extends Message {
|
||||
private String keybind;
|
||||
|
||||
|
@ -38,11 +41,21 @@ public class KeybindMessage extends Message {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof KeybindMessage && super.equals(o) && this.keybind.equals(((KeybindMessage) o).keybind);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof KeybindMessage)) return false;
|
||||
|
||||
KeybindMessage that = (KeybindMessage) o;
|
||||
return super.equals(o) &&
|
||||
Objects.equals(this.keybind, that.keybind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() * 31 + keybind.hashCode();
|
||||
return ObjectUtil.hashCode(super.hashCode(), this.keybind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.message;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
@ -7,126 +8,12 @@ import com.google.gson.JsonParser;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class Message implements Cloneable {
|
||||
private MessageStyle style = new MessageStyle();
|
||||
private List<Message> extra = new ArrayList<Message>();
|
||||
|
||||
public abstract String getText();
|
||||
|
||||
public String getFullText() {
|
||||
StringBuilder build = new StringBuilder(this.getText());
|
||||
for(Message msg : this.extra) {
|
||||
build.append(msg.getFullText());
|
||||
}
|
||||
|
||||
return build.toString();
|
||||
}
|
||||
|
||||
public MessageStyle getStyle() {
|
||||
return this.style;
|
||||
}
|
||||
|
||||
public List<Message> getExtra() {
|
||||
return new ArrayList<Message>(this.extra);
|
||||
}
|
||||
|
||||
public Message setStyle(MessageStyle style) {
|
||||
this.style = style;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message setExtra(List<Message> extra) {
|
||||
this.extra = new ArrayList<Message>(extra);
|
||||
for(Message msg : this.extra) {
|
||||
msg.getStyle().setParent(this.style);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message addExtra(Message message) {
|
||||
this.extra.add(message);
|
||||
message.getStyle().setParent(this.style);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message removeExtra(Message message) {
|
||||
this.extra.remove(message);
|
||||
message.getStyle().setParent(null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message clearExtra() {
|
||||
for(Message msg : this.extra) {
|
||||
msg.getStyle().setParent(null);
|
||||
}
|
||||
|
||||
this.extra.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getFullText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Message clone();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Message && this.style.equals(((Message) o).style) && this.extra.equals(((Message) o).extra);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.style.hashCode();
|
||||
result = 31 * result + this.extra.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toJsonString() {
|
||||
return this.toJson().toString();
|
||||
}
|
||||
|
||||
public JsonElement toJson() {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("color", this.style.getColor().toString());
|
||||
for(ChatFormat format : this.style.getFormats()) {
|
||||
json.addProperty(format.toString(), true);
|
||||
}
|
||||
|
||||
if(this.style.getClickEvent() != null) {
|
||||
JsonObject click = new JsonObject();
|
||||
click.addProperty("action", this.style.getClickEvent().getAction().toString());
|
||||
click.addProperty("value", this.style.getClickEvent().getValue());
|
||||
json.add("clickEvent", click);
|
||||
}
|
||||
|
||||
if(this.style.getHoverEvent() != null) {
|
||||
JsonObject hover = new JsonObject();
|
||||
hover.addProperty("action", this.style.getHoverEvent().getAction().toString());
|
||||
hover.add("value", this.style.getHoverEvent().getValue().toJson());
|
||||
json.add("hoverEvent", hover);
|
||||
}
|
||||
|
||||
if(this.style.getInsertion() != null) {
|
||||
json.addProperty("insertion", this.style.getInsertion());
|
||||
}
|
||||
|
||||
if(this.extra.size() > 0) {
|
||||
JsonArray extra = new JsonArray();
|
||||
for(Message msg : this.extra) {
|
||||
extra.add(msg.toJson());
|
||||
}
|
||||
|
||||
json.add("extra", extra);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static Message fromString(String str) {
|
||||
try {
|
||||
return fromJson(new JsonParser().parse(str));
|
||||
|
@ -159,7 +46,7 @@ public abstract class Message implements Cloneable {
|
|||
}
|
||||
|
||||
msg = new TranslationMessage(json.get("translate").getAsString(), with);
|
||||
} else if (json.has("keybind")) {
|
||||
} else if(json.has("keybind")) {
|
||||
msg = new KeybindMessage(json.get("keybind").getAsString());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown message type in json: " + json.toString());
|
||||
|
@ -211,4 +98,122 @@ public abstract class Message implements Cloneable {
|
|||
throw new IllegalArgumentException("Cannot convert " + e.getClass().getSimpleName() + " to a message.");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String getText();
|
||||
|
||||
public String getFullText() {
|
||||
StringBuilder build = new StringBuilder(this.getText());
|
||||
for(Message msg : this.extra) {
|
||||
build.append(msg.getFullText());
|
||||
}
|
||||
|
||||
return build.toString();
|
||||
}
|
||||
|
||||
public MessageStyle getStyle() {
|
||||
return this.style;
|
||||
}
|
||||
|
||||
public Message setStyle(MessageStyle style) {
|
||||
this.style = style;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Message> getExtra() {
|
||||
return new ArrayList<Message>(this.extra);
|
||||
}
|
||||
|
||||
public Message setExtra(List<Message> extra) {
|
||||
this.extra = new ArrayList<Message>(extra);
|
||||
for(Message msg : this.extra) {
|
||||
msg.getStyle().setParent(this.style);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message addExtra(Message message) {
|
||||
this.extra.add(message);
|
||||
message.getStyle().setParent(this.style);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message removeExtra(Message message) {
|
||||
this.extra.remove(message);
|
||||
message.getStyle().setParent(null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message clearExtra() {
|
||||
for(Message msg : this.extra) {
|
||||
msg.getStyle().setParent(null);
|
||||
}
|
||||
|
||||
this.extra.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Message clone();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof Message)) return false;
|
||||
|
||||
Message that = (Message) o;
|
||||
return Objects.equals(this.style, that.style) &&
|
||||
Objects.equals(this.extra, that.extra);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectUtil.hashCode(this.style, this.extra);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getFullText();
|
||||
}
|
||||
|
||||
public String toJsonString() {
|
||||
return this.toJson().toString();
|
||||
}
|
||||
|
||||
public JsonElement toJson() {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("color", this.style.getColor().toString());
|
||||
for(ChatFormat format : this.style.getFormats()) {
|
||||
json.addProperty(format.toString(), true);
|
||||
}
|
||||
|
||||
if(this.style.getClickEvent() != null) {
|
||||
JsonObject click = new JsonObject();
|
||||
click.addProperty("action", this.style.getClickEvent().getAction().toString());
|
||||
click.addProperty("value", this.style.getClickEvent().getValue());
|
||||
json.add("clickEvent", click);
|
||||
}
|
||||
|
||||
if(this.style.getHoverEvent() != null) {
|
||||
JsonObject hover = new JsonObject();
|
||||
hover.addProperty("action", this.style.getHoverEvent().getAction().toString());
|
||||
hover.add("value", this.style.getHoverEvent().getValue().toJson());
|
||||
json.add("hoverEvent", hover);
|
||||
}
|
||||
|
||||
if(this.style.getInsertion() != null) {
|
||||
json.addProperty("insertion", this.style.getInsertion());
|
||||
}
|
||||
|
||||
if(this.extra.size() > 0) {
|
||||
JsonArray extra = new JsonArray();
|
||||
for(Message msg : this.extra) {
|
||||
extra.add(msg.toJson());
|
||||
}
|
||||
|
||||
json.add("extra", extra);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.message;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MessageStyle implements Cloneable {
|
||||
private static final MessageStyle DEFAULT = new MessageStyle();
|
||||
|
@ -21,33 +24,57 @@ public class MessageStyle implements Cloneable {
|
|||
return this.color;
|
||||
}
|
||||
|
||||
public MessageStyle setColor(ChatColor color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ChatFormat> getFormats() {
|
||||
return new ArrayList<ChatFormat>(this.formats);
|
||||
}
|
||||
|
||||
public MessageStyle setFormats(List<ChatFormat> formats) {
|
||||
this.formats = new ArrayList<ChatFormat>(formats);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClickEvent getClickEvent() {
|
||||
return this.click;
|
||||
}
|
||||
|
||||
public MessageStyle setClickEvent(ClickEvent event) {
|
||||
this.click = event;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HoverEvent getHoverEvent() {
|
||||
return this.hover;
|
||||
}
|
||||
|
||||
public MessageStyle setHoverEvent(HoverEvent event) {
|
||||
this.hover = event;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getInsertion() {
|
||||
return this.insertion;
|
||||
}
|
||||
|
||||
public MessageStyle setInsertion(String insertion) {
|
||||
this.insertion = insertion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageStyle getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public MessageStyle setColor(ChatColor color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
protected MessageStyle setParent(MessageStyle parent) {
|
||||
if(parent == null) {
|
||||
parent = DEFAULT;
|
||||
}
|
||||
|
||||
public MessageStyle setFormats(List<ChatFormat> formats) {
|
||||
this.formats = new ArrayList<ChatFormat>(formats);
|
||||
this.parent = parent;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -66,35 +93,6 @@ public class MessageStyle implements Cloneable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public MessageStyle setClickEvent(ClickEvent event) {
|
||||
this.click = event;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageStyle setHoverEvent(HoverEvent event) {
|
||||
this.hover = event;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageStyle setInsertion(String insertion) {
|
||||
this.insertion = insertion;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected MessageStyle setParent(MessageStyle parent) {
|
||||
if(parent == null) {
|
||||
parent = DEFAULT;
|
||||
}
|
||||
|
||||
this.parent = parent;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MessageStyle{color=" + this.color + ",formats=" + this.formats + ",clickEvent=" + this.click + ",hoverEvent=" + this.hover + ",insertion=" + this.insertion + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageStyle clone() {
|
||||
return new MessageStyle().setParent(this.parent).setColor(this.color).setFormats(this.formats).setClickEvent(this.click != null ? this.click.clone() : null).setHoverEvent(this.hover != null ? this.hover.clone() : null).setInsertion(this.insertion);
|
||||
|
@ -102,17 +100,25 @@ public class MessageStyle implements Cloneable {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof MessageStyle && this.color == ((MessageStyle) o).color && this.formats.equals(((MessageStyle) o).formats) && (this.click != null ? this.click.equals(((MessageStyle) o).click) : ((MessageStyle) o).click == null) && (this.hover != null ? this.hover.equals(((MessageStyle) o).hover) : ((MessageStyle) o).hover == null) && (this.insertion != null ? this.insertion.equals(((MessageStyle) o).insertion) : ((MessageStyle) o).insertion == null) && this.parent.equals(((MessageStyle) o).parent);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof MessageStyle)) return false;
|
||||
|
||||
MessageStyle that = (MessageStyle) o;
|
||||
return this.color == that.color &&
|
||||
Objects.equals(this.formats, that.formats) &&
|
||||
Objects.equals(this.click, that.click) &&
|
||||
Objects.equals(this.hover, that.hover) &&
|
||||
Objects.equals(this.insertion, that.insertion) &&
|
||||
Objects.equals(this.parent, that.parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.color.hashCode();
|
||||
result = 31 * result + this.formats.hashCode();
|
||||
result = 31 * result + (this.click != null ? this.click.hashCode() : 0);
|
||||
result = 31 * result + (this.hover != null ? this.hover.hashCode() : 0);
|
||||
result = 31 * result + (this.insertion != null ? this.insertion.hashCode() : 0);
|
||||
result = 31 * result + this.parent.hashCode();
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.color, this.formats, this.click, this.hover, this.insertion, this.parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
package com.github.steveice10.mc.protocol.data.message;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class TextMessage extends Message {
|
||||
private String text;
|
||||
|
||||
|
@ -39,13 +42,21 @@ public class TextMessage extends Message {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof TextMessage && super.equals(o) && this.text.equals(((TextMessage) o).text);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof TextMessage)) return false;
|
||||
|
||||
TextMessage that = (TextMessage) o;
|
||||
return super.equals(o) &&
|
||||
Objects.equals(this.text, that.text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + this.text.hashCode();
|
||||
return result;
|
||||
return ObjectUtil.hashCode(super.hashCode(), this.text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.github.steveice10.mc.protocol.data.message;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TranslationMessage extends Message {
|
||||
private String translationKey;
|
||||
|
@ -72,14 +74,22 @@ public class TranslationMessage extends Message {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof TranslationMessage && super.equals(o) && this.translationKey.equals(((TranslationMessage) o).translationKey) && Arrays.deepEquals(this.translationParams, ((TranslationMessage) o).translationParams);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof TranslationMessage)) return false;
|
||||
|
||||
TranslationMessage that = (TranslationMessage) o;
|
||||
return super.equals(o) &&
|
||||
Objects.equals(this.translationKey, that.translationKey) &&
|
||||
Arrays.equals(this.translationParams, that.translationParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + this.translationKey.hashCode();
|
||||
result = 31 * result + Arrays.deepHashCode(this.translationParams);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(super.hashCode(), this.translationKey, this.translationParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.status;
|
||||
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -29,14 +30,22 @@ public class PlayerInfo {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof PlayerInfo && this.max == ((PlayerInfo) o).max && this.online == ((PlayerInfo) o).online && Arrays.deepEquals(this.players, ((PlayerInfo) o).players);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof PlayerInfo)) return false;
|
||||
|
||||
PlayerInfo that = (PlayerInfo) o;
|
||||
return this.max == that.max &&
|
||||
this.online == that.online &&
|
||||
Arrays.equals(this.players, that.players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.max;
|
||||
result = 31 * result + this.online;
|
||||
result = 31 * result + Arrays.deepHashCode(this.players);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.max, this.online, this.players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.github.steveice10.mc.protocol.data.status;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ServerStatusInfo {
|
||||
private VersionInfo version;
|
||||
|
@ -35,15 +37,23 @@ public class ServerStatusInfo {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ServerStatusInfo && this.version.equals(((ServerStatusInfo) o).version) && this.players.equals(((ServerStatusInfo) o).players) && this.description.equals(((ServerStatusInfo) o).description) && (this.icon != null ? this.icon.equals(((ServerStatusInfo) o).icon) : ((ServerStatusInfo) o).icon == null);
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof ServerStatusInfo)) return false;
|
||||
|
||||
ServerStatusInfo that = (ServerStatusInfo) o;
|
||||
return Objects.equals(this.version, that.version) &&
|
||||
Objects.equals(this.players, that.players) &&
|
||||
Objects.equals(this.description, that.description) &&
|
||||
Objects.equals(this.icon, that.icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.version.hashCode();
|
||||
result = 31 * result + this.players.hashCode();
|
||||
result = 31 * result + this.description.hashCode();
|
||||
result = 31 * result + (this.icon != null ? this.icon.hashCode() : 0);
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.version, this.players, this.description, this.icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.github.steveice10.mc.protocol.data.status;
|
||||
|
||||
import com.github.steveice10.mc.protocol.MinecraftConstants;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class VersionInfo {
|
||||
|
||||
public static final VersionInfo CURRENT = new VersionInfo(MinecraftConstants.GAME_VERSION, MinecraftConstants.PROTOCOL_VERSION);
|
||||
|
||||
private String name;
|
||||
|
@ -24,13 +26,21 @@ public class VersionInfo {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof VersionInfo && this.name.equals(((VersionInfo) o).name) && this.protocol == ((VersionInfo) o).protocol;
|
||||
if(this == o) return true;
|
||||
if(!(o instanceof VersionInfo)) return false;
|
||||
|
||||
VersionInfo that = (VersionInfo) o;
|
||||
return Objects.equals(this.name, that.name) &&
|
||||
this.protocol == that.protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.name.hashCode();
|
||||
result = 31 * result + this.protocol;
|
||||
return result;
|
||||
return ObjectUtil.hashCode(this.name, this.protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.github.steveice10.mc.protocol.data.status.handler;
|
|||
import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
|
||||
|
||||
public interface ServerInfoHandler {
|
||||
public void handle(Session session, ServerStatusInfo info);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.github.steveice10.mc.protocol.packet;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
public abstract class MinecraftPacket implements Packet {
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ObjectUtil.toString(this);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,14 @@
|
|||
package com.github.steveice10.mc.protocol.packet.handshake.client;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.handshake.HandshakeIntent;
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HandshakePacket implements Packet {
|
||||
|
||||
public class HandshakePacket extends MinecraftPacket {
|
||||
private int protocolVersion;
|
||||
private String hostname;
|
||||
private int port;
|
||||
|
@ -63,9 +61,4 @@ public class HandshakePacket implements Packet {
|
|||
public boolean isPriority() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.client;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ClientChatPacket implements Packet {
|
||||
|
||||
public class ClientChatPacket extends MinecraftPacket {
|
||||
private String message;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -32,14 +30,4 @@ public class ClientChatPacket implements Packet {
|
|||
public void write(NetOutput out) throws IOException {
|
||||
out.writeString(this.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.client;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ClientKeepAlivePacket implements Packet {
|
||||
|
||||
public class ClientKeepAlivePacket extends MinecraftPacket {
|
||||
private int id;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -32,14 +30,4 @@ public class ClientKeepAlivePacket implements Packet {
|
|||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(this.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue