Fix Fox disguise type not saving the color properly as reported by rosa on discord

This commit is contained in:
libraryaddict 2023-04-08 10:25:55 +12:00
parent fe0628753f
commit fa90946089
4 changed files with 10 additions and 2 deletions

View File

@ -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);

View File

@ -41,7 +41,6 @@ public class PlayerWatcher extends LivingWatcher {
((PlayerDisguise) getDisguise()).setNameVisible(nameVisible);
}
@RandomDefaultValue
public String getName() {
return ((PlayerDisguise) getDisguise()).getName();
}

View File

@ -7,8 +7,11 @@ import java.lang.annotation.Target;
/**
* Created by libraryaddict on 31/12/2019.
* <p>
* This annotation should only be used on setter methods
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface RandomDefaultValue {
}

View File

@ -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)) {