12
0

Full (untested) implementation

Dieser Commit ist enthalten in:
Lixfel 2020-02-22 15:09:42 +01:00
Ursprung 4a9a678a63
Commit 8ac38aff31
3 geänderte Dateien mit 1801 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,43 @@
package de.steamwar.sql;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
class IDConverter {
private IDConverter(){}
static Map<String, BlockTypeID> getMap(){
Map<String, BlockTypeID> ids = new HashMap<>();
YamlConfiguration legacy = YamlConfiguration.loadConfiguration(new InputStreamReader(Objects.requireNonNull(IDConverter.class.getClassLoader().getResourceAsStream("legacy.yml"))));
for(String blockNum : legacy.getKeys(false)){
String[] block = blockNum.split(":");
String blockString = legacy.getString(blockNum);
ids.put(blockString, new BlockTypeID(Integer.parseInt(block[0]), Byte.parseByte(block[1])));
if(blockString.contains("["))
ids.put(blockString.split("\\[")[0], new BlockTypeID(Integer.parseInt(block[0]), (byte)0));
}
return ids;
}
static class BlockTypeID{
private final int blockId;
private final byte dataId;
private BlockTypeID(int blockId, byte dataId) {
this.blockId = blockId;
this.dataId = dataId;
}
int getBlockId() {
return blockId;
}
byte getDataId() {
return dataId;
}
}
}

Datei anzeigen

@ -17,7 +17,6 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.registry.WorldData;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import javax.annotation.Nullable;
@ -71,6 +70,7 @@ class Schematic_8 {
}
public static class SpongeSchematicReader implements ClipboardReader {
private final NBTInputStream inputStream;
private int schematicVersion = -1;
@ -105,6 +105,8 @@ class Schematic_8 {
@SuppressWarnings("deprecation")
private BlockArrayClipboard readSchematic(CompoundTag schematicTag) throws IOException {
final Map<String, IDConverter.BlockTypeID> ids = IDConverter.getMap();
Map<String, Tag> schematic = schematicTag.getValue();
int width = (requireTag(schematic, "Width", ShortTag.class)).getValue();
int height = (requireTag(schematic, "Height", ShortTag.class)).getValue();
@ -152,14 +154,16 @@ class Schematic_8 {
String palettePart = (String)iterator.next();
id = requireTag(paletteObject, palettePart, IntTag.class).getValue();
String matName = palettePart.split(":")[1].split("\\[")[0];
Material material = Material.getMaterial(matName);
if(material == null){
state = new BaseBlock(0); //AIR
continue;
IDConverter.BlockTypeID blockID = ids.get(palettePart);
if(blockID == null){
blockID = ids.get(palettePart.split("\\[")[0]);
}
state = new BaseBlock(material.getId());
if(blockID == null){
state = new BaseBlock(0); //AIR
}else{
state = new BaseBlock(blockID.getBlockId(), blockID.getDataId());
}
}
byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();

1747
SpigotCore_8/src/legacy.yml Normale Datei

Datei-Diff unterdrückt, da er zu groß ist Diff laden