diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java index ffff927e..7a68426e 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java @@ -47,11 +47,11 @@ public class FoxWatcher extends AgeableWatcher { setFoxFlag(32, value); } - @RandomDefaultValue public Fox.Type getType() { return Fox.Type.values()[getData(MetaIndex.FOX_TYPE)]; } + @RandomDefaultValue public void setType(Fox.Type type) { setData(MetaIndex.FOX_TYPE, type.ordinal()); sendData(MetaIndex.FOX_TYPE); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java index 25febd83..c4508c4b 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java @@ -41,7 +41,6 @@ public class PlayerWatcher extends LivingWatcher { ((PlayerDisguise) getDisguise()).setNameVisible(nameVisible); } - @RandomDefaultValue public String getName() { return ((PlayerDisguise) getDisguise()).getName(); } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/parser/RandomDefaultValue.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/parser/RandomDefaultValue.java index c88bab6f..431a03ba 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/parser/RandomDefaultValue.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/parser/RandomDefaultValue.java @@ -7,8 +7,11 @@ import java.lang.annotation.Target; /** * Created by libraryaddict on 31/12/2019. + *
+ * This annotation should only be used on setter methods */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface RandomDefaultValue { + } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java index dd120a77..c43c5627 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java @@ -170,6 +170,12 @@ public class CompileMethods { info.setReturnType(method.getReturnType().getName()); info.setRandomDefault(method.isAnnotationPresent(RandomDefaultValue.class)); + if (info.isRandomDefault() && !"void".equals(info.getReturnType())) { + throw new IllegalStateException( + "@RandomDefaultValue is intended for use only on setter methods, " + info.getMethod() + " on " + c.getSimpleName() + + " does not met this criteria!"); + } + String s = new Gson().toJson(info); if (methods.contains(s)) {