Configurable xp orb merge group count (#12503)
This commit is contained in:
@@ -62,7 +62,8 @@ public abstract class Configurations<G, W> {
|
||||
protected ObjectMapper.Factory.Builder createObjectMapper() {
|
||||
return ObjectMapper.factoryBuilder()
|
||||
.addConstraint(Constraint.class, new Constraint.Factory())
|
||||
.addConstraint(Constraints.Min.class, Number.class, new Constraints.Min.Factory());
|
||||
.addConstraint(Constraints.Min.class, Number.class, new Constraints.Min.Factory())
|
||||
.addConstraint(Constraints.Max.class, Number.class, new Constraints.Max.Factory());
|
||||
}
|
||||
|
||||
protected YamlConfigurationLoader.Builder createLoaderBuilder() {
|
||||
|
||||
@@ -356,6 +356,9 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public IntOr.Default compressionLevel = IntOr.Default.USE_DEFAULT;
|
||||
@Comment("Defines the leniency distance added on the server to the interaction range of a player when validating interact packets.")
|
||||
public DoubleOr.Default clientInteractionLeniencyDistance = DoubleOr.Default.USE_DEFAULT;
|
||||
@Comment("Defines how many orbs groups can exist in an area.")
|
||||
@Constraints.Min(1)
|
||||
public IntOr.Default xpOrbGroupsPerArea = IntOr.Default.USE_DEFAULT;
|
||||
}
|
||||
|
||||
public BlockUpdates blockUpdates;
|
||||
|
||||
@@ -40,4 +40,22 @@ public final class Constraints {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Max {
|
||||
int value();
|
||||
|
||||
final class Factory implements Constraint.Factory<Max, Number> {
|
||||
@Override
|
||||
public Constraint<Number> make(Max data, Type type) {
|
||||
return value -> {
|
||||
if (value != null && value.intValue() > data.value()) {
|
||||
throw new SerializationException(value + " is greater than the max " + data.value());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user