From eaa426dd6626946aaec37ce135a702df1ed82de6 Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 20 Sep 2019 09:51:57 -0500 Subject: [PATCH] Fix poor usage of Cloneable Because super.clone() isn't being called, the idea of "Cloneable" isn't upheld. --- .../helpers/arguments/ArgConsumer.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) 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 219e3645..f0d5139f 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 @@ -54,7 +54,7 @@ import java.util.stream.Stream; * handlers can do their job and log the error to chat. * */ -public class ArgConsumer implements Cloneable { +public class ArgConsumer { /** * The list of arguments in this ArgConsumer @@ -410,7 +410,7 @@ public class ArgConsumer implements Cloneable { * @see IDatatype */ public T peekDatatype(Class datatype) { - return clone().getDatatype(datatype); + return copy().getDatatype(datatype); } /** @@ -427,7 +427,7 @@ public class ArgConsumer implements Cloneable { * @see IDatatype */ public T peekDatatypeOrNull(Class datatype) { - return clone().getDatatypeOrNull(datatype); + return copy().getDatatypeOrNull(datatype); } /** @@ -445,7 +445,7 @@ public class ArgConsumer implements Cloneable { * @see IDatatypePost */ public > T peekDatatypePost(Class datatype, O original) { - return clone().getDatatypePost(datatype, original); + return copy().getDatatypePost(datatype, original); } /** @@ -464,7 +464,7 @@ public class ArgConsumer implements Cloneable { * @see IDatatypePost */ public > T peekDatatypePostOrDefault(Class datatype, O original, T def) { - return clone().getDatatypePostOrDefault(datatype, original, def); + return copy().getDatatypePostOrDefault(datatype, original, def); } /** @@ -500,7 +500,7 @@ public class ArgConsumer implements Cloneable { * @see IDatatypeFor */ public > T peekDatatypeFor(Class datatype) { - return clone().peekDatatypeFor(datatype); + return copy().peekDatatypeFor(datatype); } /** @@ -519,7 +519,7 @@ public class ArgConsumer implements Cloneable { * @see IDatatypeFor */ public > T peekDatatypeForOrDefault(Class datatype, T def) { - return clone().peekDatatypeForOrDefault(datatype, def); + return copy().peekDatatypeForOrDefault(datatype, def); } /** @@ -975,12 +975,10 @@ public class ArgConsumer implements Cloneable { } /** - * @return A clone of this {@link ArgConsumer}. It has the same arguments (both consumed and not), but does not + * @return A copy of this {@link ArgConsumer}. It has the same arguments (both consumed and not), but does not * affect or mutate this instance. Useful for the various {@code peek} functions */ - @SuppressWarnings("MethodDoesntCallSuperMethod") - @Override - public ArgConsumer clone() { + public ArgConsumer copy() { return new ArgConsumer(args, consumed); }