From 90fb17b89f21e3d4b714155b7ee977f9f3bf1299 Mon Sep 17 00:00:00 2001 From: Logan Darklock Date: Sat, 31 Aug 2019 07:36:23 -0700 Subject: [PATCH] Told Proguard not to touch things it doesn't understand --- scripts/proguard.pro | 5 +++++ .../utils/command/exception/CommandUnhandledException.java | 1 + .../api/utils/command/helpers/arguments/ArgConsumer.java | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 4ac0f723..53ab195d 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -17,6 +17,11 @@ -keep class baritone.api.** { *; } # this is the keep api +# Proguard does not know the commands framework better than I do +# It needs its empty constructors and simple names to work correctly +-keep class baritone.api.utils.command.** { *; } +-keepclasseswithmembernames class baritone.api.utils.command.** { *; } + # service provider needs these class names -keep class baritone.BaritoneProvider -keep class baritone.api.IBaritoneProvider diff --git a/src/api/java/baritone/api/utils/command/exception/CommandUnhandledException.java b/src/api/java/baritone/api/utils/command/exception/CommandUnhandledException.java index 849ace18..dba4513e 100644 --- a/src/api/java/baritone/api/utils/command/exception/CommandUnhandledException.java +++ b/src/api/java/baritone/api/utils/command/exception/CommandUnhandledException.java @@ -63,6 +63,7 @@ public class CommandUnhandledException extends CommandErrorMessageException { // line = line.replaceFirst("\\(([^)]+)\\)$", "\n\t . $1"); line = line.replaceFirst("\\([^:]+:(\\d+)\\)$", ":$1"); + line = line.replaceFirst("\\(Unknown Source\\)$", ""); lines.set(i, line); } } diff --git a/src/api/java/baritone/api/utils/command/helpers/arguments/ArgConsumer.java b/src/api/java/baritone/api/utils/command/helpers/arguments/ArgConsumer.java index e050239c..9cec8d1f 100644 --- a/src/api/java/baritone/api/utils/command/helpers/arguments/ArgConsumer.java +++ b/src/api/java/baritone/api/utils/command/helpers/arguments/ArgConsumer.java @@ -214,9 +214,9 @@ public class ArgConsumer { public T getDatatype(Class datatype) { try { return datatype.getConstructor(ArgConsumer.class).newInstance(this); - } catch (RuntimeException e) { + } catch (InvocationTargetException e) { throw new CommandInvalidTypeException(has() ? peek() : consumed(), datatype.getSimpleName()); - } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { + } catch (NoSuchMethodException | IllegalAccessException | InstantiationException e) { throw new CommandUnhandledException(e); } }