package com.hypixel.hytale.builtin.hytalegenerator.assets.scanners;
import com.hypixel.hytale.builtin.hytalegenerator.scanners.Scanner;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.logger.HytaleLogger;
import javax.annotation.Nonnull;
public class ImportedScannerAsset extends ScannerAsset {
public static final BuilderCodec<ImportedScannerAsset> CODEC;
private String name = "";
public ImportedScannerAsset() {
}
public Scanner build(@Nonnull ScannerAsset.Argument argument) {
if (super.skip()) {
return Scanner.noScanner();
} else if (this.name != null && !this.name.isEmpty()) {
ScannerAsset exportedAsset = ScannerAsset.getExportedAsset(this.name);
return exportedAsset == null ? Scanner.noScanner() : exportedAsset.build(argument);
} else {
((HytaleLogger.Api)HytaleLogger.getLogger().atWarning()).log("An exported Pattern with the name does not exist: " + this.name);
return Scanner.noScanner();
}
}
static {
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(ImportedScannerAsset.class, ImportedScannerAsset::new, ScannerAsset.ABSTRACT_CODEC).append(new KeyedCodec("Name", Codec.STRING, false), (t, k) -> t.name = k, (k) -> k.name).add()).build();
}
}