diff --git a/ReadMe.md b/ReadMe.md index 3201942b6..6f6420012 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -31,10 +31,10 @@ Minosoft is an open source minecraft client, written from scratch in java. It ai ## Rendering Rendering is developed and maintained by Lukas Eisenhauer. It is very WIP, but it works. See !8 for more details. -![Rendering](doc/img/rendering.png) +![Rendering](doc/img/rendering.png) The current result of rendering (taken in 739f861bf62341698abcd58386c353a4831f4818). -![Rendering](doc/img/rendering_hypixel.png) +![Rendering](doc/img/rendering_hypixel.png) The Hypixel prototype lobby (taken in 91ab431004fa1ae132a1eb1115550f84c27f48f8). ## Launcher diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/MappingsLoadingException.java b/src/main/java/de/bixilon/minosoft/data/mappings/MappingsLoadingException.java new file mode 100644 index 000000000..77fc02e74 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/mappings/MappingsLoadingException.java @@ -0,0 +1,35 @@ +/* + * Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.data.mappings; + +public class MappingsLoadingException extends Exception { + public MappingsLoadingException() { + } + + public MappingsLoadingException(String message) { + super(message); + } + + public MappingsLoadingException(String message, Throwable cause) { + super(message, cause); + } + + public MappingsLoadingException(Throwable cause) { + super(cause); + } + + public MappingsLoadingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/main/ServerListCell.java b/src/main/java/de/bixilon/minosoft/gui/main/ServerListCell.java index d26780091..4da172cb5 100644 --- a/src/main/java/de/bixilon/minosoft/gui/main/ServerListCell.java +++ b/src/main/java/de/bixilon/minosoft/gui/main/ServerListCell.java @@ -187,7 +187,7 @@ public class ServerListCell extends ListCell implements Initializable { version.setStyle("-fx-text-fill: red;"); optionsConnect.setDisable(true); canConnect = false; - setErrorMotd(String.format("%s", server.getLastPing().getLastConnectionException().getLocalizedMessage())); + setErrorMotd(String.format("%s: %s", server.getLastPing().getLastConnectionException().getClass().getCanonicalName(), server.getLastPing().getLastConnectionException().getLocalizedMessage())); } })); } diff --git a/src/main/java/de/bixilon/minosoft/protocol/network/Connection.java b/src/main/java/de/bixilon/minosoft/protocol/network/Connection.java index 7cf5a3573..5de6560f3 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/network/Connection.java +++ b/src/main/java/de/bixilon/minosoft/protocol/network/Connection.java @@ -17,6 +17,7 @@ import de.bixilon.minosoft.Minosoft; import de.bixilon.minosoft.data.Player; import de.bixilon.minosoft.data.VelocityHandler; import de.bixilon.minosoft.data.mappings.CustomMapping; +import de.bixilon.minosoft.data.mappings.MappingsLoadingException; import de.bixilon.minosoft.data.mappings.recipes.Recipes; import de.bixilon.minosoft.data.mappings.versions.Version; import de.bixilon.minosoft.data.mappings.versions.Versions; @@ -160,7 +161,7 @@ public class Connection { } catch (IOException e) { Log.printException(e, LogLevels.DEBUG); Log.fatal(String.format("Could not load mapping for %s. This version seems to be unsupported!", version)); - lastException = new RuntimeException(String.format("Mappings could not be loaded: %s", e.getLocalizedMessage())); + lastException = new MappingsLoadingException("Mappings could not be loaded", e); setConnectionState(ConnectionStates.FAILED_NO_RETRY); } } diff --git a/src/main/java/de/bixilon/minosoft/protocol/network/socket/SocketNetwork.java b/src/main/java/de/bixilon/minosoft/protocol/network/socket/SocketNetwork.java index 61ce17ae4..63f7e1a1e 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/network/socket/SocketNetwork.java +++ b/src/main/java/de/bixilon/minosoft/protocol/network/socket/SocketNetwork.java @@ -192,24 +192,20 @@ public class SocketNetwork implements Network { try { packet = connection.getPacketByCommand(connection.getConnectionState(), inPacketBuffer.getCommand()); if (packet == null) { - Log.fatal(String.format("Packet mapping does not contain a packet with id 0x%x. The server sends bullshit or your versions.json broken!", inPacketBuffer.getCommand())); disconnect(); - lastException = new RuntimeException(String.format("Invalid packet 0x%x", inPacketBuffer.getCommand())); + lastException = new UnknownPacketException(String.format("Invalid packet 0x%x", inPacketBuffer.getCommand())); throw lastException; } Class clazz = packet.getClazz(); if (clazz == null) { - Log.warn(String.format("[IN] Received unknown packet (id=0x%x, name=%s, length=%d, dataLength=%d, version=%s, state=%s)", inPacketBuffer.getCommand(), packet, inPacketBuffer.getLength(), inPacketBuffer.getBytesLeft(), connection.getVersion(), connection.getConnectionState())); - continue; + throw new UnknownPacketException(String.format("Unknown packet (id=0x%x, name=%s, length=%d, dataLength=%d, version=%s, state=%s)", inPacketBuffer.getCommand(), packet, inPacketBuffer.getLength(), inPacketBuffer.getBytesLeft(), connection.getVersion(), connection.getConnectionState())); } try { ClientboundPacket packetInstance = clazz.getConstructor().newInstance(); boolean success = packetInstance.read(inPacketBuffer); if (inPacketBuffer.getBytesLeft() > 0 || !success) { - // warn not all data used - Log.warn(String.format("[IN] Could not parse packet %s (used=%d, available=%d, total=%d, success=%s)", packet, inPacketBuffer.getPosition(), inPacketBuffer.getBytesLeft(), inPacketBuffer.getLength(), success)); - continue; + throw new PacketParseException(String.format("Could not parse packet %s (used=%d, available=%d, total=%d, success=%s)", packet, inPacketBuffer.getPosition(), inPacketBuffer.getBytesLeft(), inPacketBuffer.getLength(), success)); } //set special settings to avoid miss timing issues diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketParseException.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketParseException.java new file mode 100644 index 000000000..0f5d39e2b --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketParseException.java @@ -0,0 +1,35 @@ +/* + * Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.protocol.protocol; + +public class PacketParseException extends Exception { + public PacketParseException() { + } + + public PacketParseException(String message) { + super(message); + } + + public PacketParseException(String message, Throwable cause) { + super(message, cause); + } + + public PacketParseException(Throwable cause) { + super(cause); + } + + public PacketParseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/UnknownPacketException.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/UnknownPacketException.java new file mode 100644 index 000000000..55ca2d637 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/UnknownPacketException.java @@ -0,0 +1,35 @@ +/* + * Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.protocol.protocol; + +public class UnknownPacketException extends Exception { + public UnknownPacketException() { + } + + public UnknownPacketException(String message) { + super(message); + } + + public UnknownPacketException(String message, Throwable cause) { + super(message, cause); + } + + public UnknownPacketException(Throwable cause) { + super(cause); + } + + public UnknownPacketException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +}