39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
package com.songoda.epicheads.cache.legacy;
|
|
|
|
import com.songoda.epicheads.cache.CacheFile;
|
|
import com.songoda.epicheads.cache.CacheHead;
|
|
import com.songoda.epicheads.config.DefaultsConfigFile;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.Arrays;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class CacheFileConverter {
|
|
|
|
public static CacheFile convertToCacheFile(String name, LegacyCacheConfig config) {
|
|
Set<String> addons = new HashSet<>(config.getAddons());
|
|
addons.add("original");
|
|
List<CacheHead> heads = config.getHeads().stream().map(CacheFileConverter::convertToCacheHead).collect(Collectors.toList());
|
|
return new CacheFile(name, addons, heads);
|
|
}
|
|
|
|
public static CacheHead convertToCacheHead(LegacyCachedHead head) {
|
|
int id = head.getId();
|
|
String name = head.getName();
|
|
String texture = head.getTexture();
|
|
String category = head.getCategory();
|
|
List<String> tags = Arrays.asList(head.getTags());
|
|
double cost = head.getCost();
|
|
return new CacheHead(id, name, category, texture, tags, cost);
|
|
}
|
|
|
|
public static void convertResource(String name, String resource, File file) throws IOException {
|
|
LegacyCacheConfig addon = new LegacyCacheConfig(new DefaultsConfigFile(resource));
|
|
convertToCacheFile(name, addon).write(file);
|
|
}
|
|
|
|
} |