From dae83d0e3619fea82383a1d5ba2256a46f0d63ab Mon Sep 17 00:00:00 2001 From: KennyTV Date: Thu, 2 Jul 2020 11:08:59 +0200 Subject: [PATCH 1/2] Wrap exceptions in remappers to InformativeEx --- .../myles/ViaVersion/api/protocol/Protocol.java | 7 ++++--- .../ViaVersion/api/remapper/PacketRemapper.java | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java index 280836879..c6f9c5b6a 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java @@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.platform.providers.ViaProviders; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.exception.CancelException; +import us.myles.ViaVersion.exception.InformativeException; import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.State; @@ -417,9 +418,9 @@ public abstract class Protocol The new return type. */ public void map(ValueTransformer transformer) { - if (transformer.getInputType() == null) throw new IllegalArgumentException("Use map(Type, ValueTransformer) for value transformers without specified input type!"); + if (transformer.getInputType() == null) { + throw new IllegalArgumentException("Use map(Type, ValueTransformer) for value transformers without specified input type!"); + } map(transformer.getInputType(), transformer); } @@ -116,7 +119,8 @@ public abstract class PacketRemapper { * Remap a packet wrapper * * @param packetWrapper The wrapper to remap - * @throws Exception Throws if it fails to write / read to the packet. + * @throws InformativeException if it fails to write / read to the packet + * @throws CancelException if the packet should be cancelled */ public void remap(PacketWrapper packetWrapper) throws Exception { try { @@ -130,6 +134,14 @@ public abstract class PacketRemapper { } catch (InformativeException e) { e.addSource(this.getClass()); throw e; + } catch (CancelException e) { + // Pass through CancelExceptions + throw e; + } catch (Exception e) { + // Wrap other exceptions during packet handling + InformativeException ex = new InformativeException(e); + ex.addSource(this.getClass()); + throw ex; } } } From 01d534391d8249ecb9f9b5443153c6e1aa12d270 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Thu, 23 Jul 2020 10:56:54 -0300 Subject: [PATCH 2/2] Remove "API" from name in fabric.mod.json --- fabric/src/main/resources/fabric.mod.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 8b2d96470..7426e3f73 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "viaversion", - "name": "ViaVersion API", + "name": "ViaVersion", "version": "${project.version}", "description": "${project.description}", "license": "MIT", @@ -28,4 +28,4 @@ "custom": { "modmenu:api": true } -} \ No newline at end of file +}