Dieser Commit ist enthalten in:
Ursprung
4f24fe862d
Commit
afb7f1c698
@ -1 +1 @@
|
||||
Subproject commit aa70f423d87e9f6534ad2dd1f20a5122179c423f
|
||||
Subproject commit e52e9c5ccd8ef9b87ce06d4eeeaaa4044afa89b5
|
@ -36,11 +36,6 @@ import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class SchematicData {
|
||||
|
||||
static {
|
||||
new SqlTypeMapper<>(PipedInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("PipedInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
|
||||
new SqlTypeMapper<>(ByteArrayInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("ByteArrayInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
|
||||
}
|
||||
|
||||
public static Clipboard clipboardFromStream(InputStream is, boolean schemFormat) {
|
||||
try {
|
||||
return WorldEditWrapper.impl.getClipboard(is, schemFormat);
|
||||
@ -49,42 +44,20 @@ public class SchematicData {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Statement updateDatabase = new Statement("UPDATE SchematicNode SET NodeData = ?, NodeFormat = ? WHERE NodeId = ?");
|
||||
private static final Statement selSchemData = new Statement("SELECT NodeData FROM SchematicNode WHERE NodeId = ?");
|
||||
|
||||
private final SchematicNode node;
|
||||
private final NodeData data;
|
||||
|
||||
public SchematicData(SchematicNode node) {
|
||||
this.node = node;
|
||||
this.data = NodeData.get(node);
|
||||
if(node.isDir())
|
||||
throw new SecurityException("Node is Directory");
|
||||
}
|
||||
|
||||
public InputStream schemData() throws IOException {
|
||||
try {
|
||||
return selSchemData.select(rs -> {
|
||||
rs.next();
|
||||
Blob schemData = rs.getBlob("NodeData");
|
||||
if(schemData == null) {
|
||||
throw new SecurityException("SchemData is null");
|
||||
}
|
||||
try {
|
||||
return new GZIPInputStream(schemData.getBinaryStream());
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("SchemData is wrong", e);
|
||||
}
|
||||
}, node.getId());
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Clipboard load() throws IOException, NoClipboardException {
|
||||
return WorldEditWrapper.impl.getClipboard(schemData(), node.getSchemFormat());
|
||||
return WorldEditWrapper.impl.getClipboard(data.schemData(), data.getNodeFormat());
|
||||
}
|
||||
|
||||
public void loadToPlayer(Player player) throws IOException, NoClipboardException {
|
||||
WorldEditWrapper.impl.setPlayerClipboard(player, schemData(), node.getSchemFormat());
|
||||
WorldEditWrapper.impl.setPlayerClipboard(player, data.schemData(), data.getNodeFormat());
|
||||
}
|
||||
|
||||
public void saveFromPlayer(Player player) throws IOException, NoClipboardException {
|
||||
@ -92,16 +65,11 @@ public class SchematicData {
|
||||
}
|
||||
|
||||
public void saveFromPlayer(Player player, boolean newFormat) throws IOException, NoClipboardException {
|
||||
saveFromStream(WorldEditWrapper.impl.getPlayerClipboard(player, newFormat), newFormat);
|
||||
data.saveFromStream(WorldEditWrapper.impl.getPlayerClipboard(player, newFormat), newFormat);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void saveFromBytes(byte[] bytes, boolean newFormat) {
|
||||
saveFromStream(new ByteArrayInputStream(bytes), newFormat);
|
||||
}
|
||||
|
||||
public void saveFromStream(InputStream blob, boolean newFormat) {
|
||||
updateDatabase.update(blob, newFormat, node.getId());
|
||||
node.setNodeFormat(newFormat);
|
||||
data.saveFromStream(new ByteArrayInputStream(bytes), newFormat);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren