Paper config files

== AT ==
public org.spigotmc.SpigotWorldConfig getBoolean(Ljava/lang/String;Z)Z
public org.spigotmc.SpigotWorldConfig getDouble(Ljava/lang/String;)D
public org.spigotmc.SpigotWorldConfig getDouble(Ljava/lang/String;D)D
public org.spigotmc.SpigotWorldConfig getInt(Ljava/lang/String;)I
public org.spigotmc.SpigotWorldConfig getInt(Ljava/lang/String;I)I
public org.spigotmc.SpigotWorldConfig getList(Ljava/lang/String;Ljava/lang/Object;)Ljava/util/List;
public org.spigotmc.SpigotWorldConfig getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
public net.minecraft.server.dedicated.DedicatedServerProperties reload(Lnet/minecraft/core/RegistryAccess;Ljava/util/Properties;Ljoptsimple/OptionSet;)Lnet/minecraft/server/dedicated/DedicatedServerProperties;
public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES
This commit is contained in:
Jake Potrebic
2022-06-08 22:20:16 -07:00
parent e954a5a260
commit 769119f918
81 changed files with 4997 additions and 103 deletions

View File

@@ -0,0 +1,30 @@
package io.papermc.paper.configuration.constraint;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.lang.reflect.Type;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE, ElementType.PARAMETER})
public @interface Constraint {
Class<? extends org.spongepowered.configurate.objectmapping.meta.Constraint<?>> value();
class Factory implements org.spongepowered.configurate.objectmapping.meta.Constraint.Factory<Constraint, Object> {
@SuppressWarnings("unchecked")
@Override
public org.spongepowered.configurate.objectmapping.meta.Constraint<Object> make(final Constraint data, final Type type) {
try {
final Constructor<? extends org.spongepowered.configurate.objectmapping.meta.Constraint<?>> constructor = data.value().getDeclaredConstructor();
constructor.trySetAccessible();
return (org.spongepowered.configurate.objectmapping.meta.Constraint<Object>) constructor.newInstance();
} catch (final ReflectiveOperationException e) {
throw new RuntimeException("Could not create constraint", e);
}
}
}
}

View File

@@ -0,0 +1,43 @@
package io.papermc.paper.configuration.constraint;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Type;
import org.jspecify.annotations.Nullable;
import org.spongepowered.configurate.objectmapping.meta.Constraint;
import org.spongepowered.configurate.serialize.SerializationException;
public final class Constraints {
private Constraints() {
}
public static final class Positive implements Constraint<Number> {
@Override
public void validate(@Nullable Number value) throws SerializationException {
if (value != null && value.doubleValue() <= 0) {
throw new SerializationException(value + " should be positive");
}
}
}
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Min {
int value();
final class Factory implements Constraint.Factory<Min, Number> {
@Override
public Constraint<Number> make(Min data, Type type) {
return value -> {
if (value != null && value.intValue() < data.value()) {
throw new SerializationException(value + " is less than the min " + data.value());
}
};
}
}
}
}