Uncompressed schem api
Dieser Commit ist enthalten in:
Ursprung
6202a78f41
Commit
c032baf879
@ -54,7 +54,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
@ -111,9 +110,9 @@ class Schematic_14 {
|
|||||||
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
||||||
try {
|
try {
|
||||||
if(schemFormat){
|
if(schemFormat){
|
||||||
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read();
|
return new SpongeSchematicReader(new NBTInputStream(is)).read();
|
||||||
}else{
|
}else{
|
||||||
return new MCEditSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read();
|
return new MCEditSchematicReader(new NBTInputStream(is)).read();
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new NoClipboardException();
|
throw new NoClipboardException();
|
||||||
|
@ -32,6 +32,7 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.io.SchematicReader;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
import com.sk89q.worldedit.world.registry.WorldData;
|
||||||
@ -47,7 +48,6 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
|
|
||||||
class Schematic_8 {
|
class Schematic_8 {
|
||||||
private Schematic_8(){}
|
private Schematic_8(){}
|
||||||
@ -88,9 +88,9 @@ class Schematic_8 {
|
|||||||
|
|
||||||
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
static Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
|
||||||
if(schemFormat)
|
if(schemFormat)
|
||||||
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is))).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
return new SpongeSchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
||||||
else
|
else
|
||||||
return ClipboardFormat.SCHEMATIC.getReader(is).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WorldEditPlugin getWorldEditPlugin() {
|
private static WorldEditPlugin getWorldEditPlugin() {
|
||||||
|
@ -32,6 +32,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class Schematic {
|
public class Schematic {
|
||||||
|
|
||||||
@ -189,7 +190,7 @@ public class Schematic {
|
|||||||
Blob schemData = rs.getBlob("SchemData");
|
Blob schemData = rs.getBlob("SchemData");
|
||||||
if(schemData == null)
|
if(schemData == null)
|
||||||
throw new IOException("SchemData is null");
|
throw new IOException("SchemData is null");
|
||||||
return schemData.getBinaryStream();
|
return new GZIPInputStream(schemData.getBinaryStream());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
@ -205,18 +206,9 @@ public class Schematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadToPlayer(Player player) throws IOException, NoClipboardException {
|
public void loadToPlayer(Player player) throws IOException, NoClipboardException {
|
||||||
ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = ?", schemID);
|
InputStream is = schemData();
|
||||||
try {
|
|
||||||
rs.next();
|
|
||||||
Blob blob = rs.getBlob("SchemData");
|
|
||||||
if(blob == null)
|
|
||||||
throw new NoClipboardException();
|
|
||||||
InputStream is = blob.getBinaryStream();
|
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> Schematic_8.setPlayerClipboard(player, is, schemFormat), 8),
|
VersionedRunnable.call(new VersionedRunnable(() -> Schematic_8.setPlayerClipboard(player, is, schemFormat), 8),
|
||||||
new VersionedRunnable(() -> Schematic_14.setPlayerClipboard(player, is, schemFormat), 14));
|
new VersionedRunnable(() -> Schematic_14.setPlayerClipboard(player, is, schemFormat), 14));
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveOldFormatFromPlayer(Player player) throws IOException, NoClipboardException {
|
public void saveOldFormatFromPlayer(Player player) throws IOException, NoClipboardException {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren