com.sk89q.worldedit.cli.data.FileRegistries Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of FastAsyncWorldEdit-CLI Show documentation
Show all versions of FastAsyncWorldEdit-CLI Show documentation
Blazingly fast Minecraft world manipulation for artists, builders and everyone else.
The newest version!
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.sk89q.worldedit.cli.data;
import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.cli.CLIWorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.util.io.ResourceLoader;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
public class FileRegistries {
private final CLIWorldEdit app;
private final Gson gson = new GsonBuilder().create();
private DataFile dataFile;
public FileRegistries(CLIWorldEdit app) {
this.app = app;
}
public void loadDataFiles() {
ResourceLoader resourceLoader = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.CONFIGURATION)
.getResourceLoader();
try {
URL url = resourceLoader.getResource(FileRegistries.class, app.getPlatform().getDataVersion() + ".json");
this.dataFile = gson.fromJson(Resources.toString(url, StandardCharsets.UTF_8), DataFile.class);
} catch (IOException e) {
throw new RuntimeException(
"The provided file is not compatible with this version of WorldEdit-CLI. Please update or report this.");
}
}
public DataFile getDataFile() {
return this.dataFile;
}
public static class BlockManifest {
public String defaultstate;
public Map properties;
}
public static class BlockProperty {
public List values;
public String type;
}
public static class DataFile {
public Map> itemtags;
public Map> blocktags;
public Map> entitytags;
public List items;
public List entities;
public List biomes;
public Map blocks;
}
}