fix(weaver-pojo-attributes-ext)!: Rename values to value for more consistency

This commit is contained in:
2025-11-08 21:29:30 +01:00
parent 577039923b
commit bf6cd05a63
5 changed files with 9 additions and 9 deletions

View File

@@ -20,9 +20,9 @@ public class TweedCoatBridgeTestModConfig {
@Validator(value = WeavableNumberRangeValidator.class, config = "-10=..=10") @Validator(value = WeavableNumberRangeValidator.class, config = "-10=..=10")
private int integerInRange = -5; private int integerInRange = -5;
@Attribute(key = TweedCoatAttributes.BACKGROUND_TEXTURE, values = "textures/block/green_terracotta.png") @Attribute(key = TweedCoatAttributes.BACKGROUND_TEXTURE, value = "textures/block/green_terracotta.png")
private Greeting serverGreeting = new Greeting("Hello server!", "Server"); private Greeting serverGreeting = new Greeting("Hello server!", "Server");
@Attribute(key = TweedCoatAttributes.BACKGROUND_TEXTURE, values = "textures/block/red_terracotta.png") @Attribute(key = TweedCoatAttributes.BACKGROUND_TEXTURE, value = "textures/block/red_terracotta.png")
private Greeting clientGreeting = new Greeting("Hello client!", "Client"); private Greeting clientGreeting = new Greeting("Hello client!", "Client");
@CompoundWeaving @CompoundWeaving

View File

@@ -13,7 +13,7 @@ import lombok.Data;
@Data @Data
public class TestModConfig { public class TestModConfig {
private String helloStart = "Minecraft"; private String helloStart = "Minecraft";
@Attribute(key = "scope", values = "game") @Attribute(key = "scope", value = "game")
private String helloInGame = "Game"; private String helloInGame = "Game";
private String helloEnd = "!"; private String helloEnd = "!";
} }

View File

@@ -11,5 +11,5 @@ import java.lang.annotation.*;
@Repeatable(Attributes.class) @Repeatable(Attributes.class)
public @interface Attribute { public @interface Attribute {
String key(); String key();
String[] values(); String[] value();
} }

View File

@@ -32,7 +32,7 @@ public class AttributesPojoWeavingProcessor implements TweedPojoWeavingExtension
@Override @Override
public <T> void afterWeaveEntry(ActualType<T> valueType, ConfigEntry<T> configEntry, WeavingContext context) { public <T> void afterWeaveEntry(ActualType<T> valueType, ConfigEntry<T> configEntry, WeavingContext context) {
val attributeAnnotations = context.annotations().getAnnotationsByType(Attribute.class); val attributeAnnotations = context.annotations().getAnnotationsByType(Attribute.class);
val attributes = collectAttributesFromAnnotations(attributeAnnotations, Attribute::key, Attribute::values); val attributes = collectAttributesFromAnnotations(attributeAnnotations, Attribute::key, Attribute::value);
attributes.forEach((key, values) -> attributesExtension.setAttribute(configEntry, key, values)); attributes.forEach((key, values) -> attributesExtension.setAttribute(configEntry, key, values));
val attributeDefaultAnnotations = context.annotations().getAnnotationsByType(AttributeDefault.class); val attributeDefaultAnnotations = context.annotations().getAnnotationsByType(AttributeDefault.class);

View File

@@ -72,19 +72,19 @@ class AttributesPojoWeavingProcessorTest {
@PojoWeavingExtension(AttributesPojoWeavingProcessor.class) @PojoWeavingExtension(AttributesPojoWeavingProcessor.class)
@CompoundWeaving @CompoundWeaving
public static class Config { public static class Config {
@Attribute(key = "scope", values = "game") @Attribute(key = "scope", value = "game")
public String string; public String string;
@Attribute(key = "color", values = "green") @Attribute(key = "color", value = "green")
public SubConfig sub1; public SubConfig sub1;
@AttributeDefault(key = "color", defaultValue = "green") @AttributeDefault(key = "color", defaultValue = "green")
@AttributeDefault(key = "scope", defaultValue = "game") @AttributeDefault(key = "scope", defaultValue = "game")
@Attribute(key = "scope", values = "world") @Attribute(key = "scope", value = "world")
public SubConfig sub2; public SubConfig sub2;
} }
@CompoundWeaving @CompoundWeaving
public static class SubConfig { public static class SubConfig {
@Attribute(key = "color", values = "red") @Attribute(key = "color", value = "red")
public String a; public String a;
public String b; public String b;
} }