/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.google.gson.JsonObject
* com.mojang.brigadier.arguments.ArgumentType
*/
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.commands.synchronization.ArgumentTypeInfo;
import net.minecraft.network.FriendlyByteBuf;
public class SingletonArgumentInfo>
implements ArgumentTypeInfo {
private final Template template;
private SingletonArgumentInfo(Function constructor) {
this.template = new Template(constructor);
}
public static > SingletonArgumentInfo contextFree(Supplier constructor) {
return new SingletonArgumentInfo(context -> (ArgumentType)constructor.get());
}
public static > SingletonArgumentInfo contextAware(Function constructor) {
return new SingletonArgumentInfo(constructor);
}
@Override
public void serializeToNetwork(Template template, FriendlyByteBuf out) {
}
@Override
public void serializeToJson(Template template, JsonObject out) {
}
@Override
public Template deserializeFromNetwork(FriendlyByteBuf in) {
return this.template;
}
@Override
public Template unpack(A argument) {
return this.template;
}
public final class Template
implements ArgumentTypeInfo.Template {
private final Function constructor;
public Template(Function constructor) {
this.constructor = constructor;
}
@Override
public A instantiate(CommandBuildContext context) {
return (ArgumentType)this.constructor.apply(context);
}
@Override
public ArgumentTypeInfo type() {
return SingletonArgumentInfo.this;
}
}
}