// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.prefab;

import com.hypixel.hytale.server.core.asset.AssetModule;
import javax.annotation.Nullable;
import com.hypixel.hytale.assetstore.AssetPack;
import javax.annotation.Nonnull;
import java.nio.file.Path;

record PrefabEntry(@Nonnull Path path, @Nonnull Path relativePath, @Nullable AssetPack pack, @Nonnull String displayName) {
    public PrefabEntry(@Nonnull final Path path, @Nonnull final Path relativePath, @Nullable final AssetPack pack) {
        this(path, relativePath, pack, buildDisplayName(relativePath, pack));
    }
    
    public boolean isFromBasePack() {
        return this.pack != null && this.pack.equals(AssetModule.get().getBaseAssetPack());
    }
    
    public boolean isFromAssetPack() {
        return this.pack != null;
    }
    
    @Nonnull
    public String getPackName() {
        return (this.pack != null) ? this.pack.getName() : "Server";
    }
    
    @Nonnull
    public String getFileName() {
        return this.path.getFileName().toString();
    }
    
    @Nonnull
    public String getDisplayNameWithPack() {
        if (this.pack == null || this.isFromBasePack()) {
            return this.getFileName();
        }
        return "[" + this.pack.getName() + "] " + this.getFileName();
    }
    
    @Nonnull
    private static String buildDisplayName(@Nonnull final Path relativePath, @Nullable final AssetPack pack) {
        final String fileName = relativePath.getFileName().toString();
        if (pack == null || pack.equals(AssetModule.get().getBaseAssetPack())) {
            return fileName;
        }
        return "[" + pack.getName() + "] " + fileName;
    }
    
    @Nonnull
    public Path path() {
        return this.path;
    }
    
    @Nonnull
    public Path relativePath() {
        return this.relativePath;
    }
    
    @Nullable
    public AssetPack pack() {
        return this.pack;
    }
    
    @Nonnull
    public String displayName() {
        return this.displayName;
    }
}
