mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
More custom exceptions
This commit is contained in:
parent
ae685e9068
commit
e24b657c3f
@ -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.
|
||||
|
||||

|
||||

|
||||
The current result of rendering (taken in 739f861bf62341698abcd58386c353a4831f4818).
|
||||
|
||||

|
||||

|
||||
The Hypixel prototype lobby (taken in 91ab431004fa1ae132a1eb1115550f84c27f48f8).
|
||||
|
||||
## Launcher
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
@ -187,7 +187,7 @@ public class ServerListCell extends ListCell<Server> 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()));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<? extends ClientboundPacket> 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
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user