package net.minecraft.commands.synchronization;
import com.google.gson.JsonObject;
import com.mojang.brigadier.arguments.ArgumentType;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.network.FriendlyByteBuf;
public class SingletonArgumentInfo> implements ArgumentTypeInfo.Template> {
private final SingletonArgumentInfo.Template template;
private SingletonArgumentInfo(Function constructor) {
this.template = new SingletonArgumentInfo.Template(constructor);
}
public static > SingletonArgumentInfo contextFree(Supplier argumentTypeSupplier) {
return new SingletonArgumentInfo<>(commandBuildContext -> (ArgumentType)argumentTypeSupplier.get());
}
public static > SingletonArgumentInfo contextAware(Function argumentType) {
return new SingletonArgumentInfo<>(argumentType);
}
public void serializeToNetwork(SingletonArgumentInfo.Template template, FriendlyByteBuf friendlyByteBuf) {
}
public void serializeToJson(SingletonArgumentInfo.Template template, JsonObject jsonObject) {
}
public SingletonArgumentInfo.Template deserializeFromNetwork(FriendlyByteBuf friendlyByteBuf) {
return this.template;
}
public SingletonArgumentInfo.Template unpack(A argumentType) {
return this.template;
}
public final class Template implements net.minecraft.commands.synchronization.ArgumentTypeInfo.Template {
private final Function constructor;
public Template(final Function constructor) {
this.constructor = constructor;
}
@Override
public A instantiate(CommandBuildContext context) {
return (A)this.constructor.apply(context);
}
@Override
public ArgumentTypeInfo type() {
return SingletonArgumentInfo.this;
}
}
}