SteamWar/SpigotCore
Archiviert
13
0

Pr Stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaos 2022-02-09 19:53:43 +01:00
Ursprung e8357c1c60
Commit bc1f268022
4 geänderte Dateien mit 12 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -115,11 +115,6 @@ public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper {
} }
} }
@Override
public File getWorldEditSchematicFolder() {
return WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getWorkingDirectoryFile(WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getConfiguration().saveDir);
}
private static class MCEditSchematicReader extends NBTSchematicReader { private static class MCEditSchematicReader extends NBTSchematicReader {
private final NBTInputStream inputStream; private final NBTInputStream inputStream;

Datei anzeigen

@ -88,11 +88,6 @@ public class WorldEditWrapper8 implements WorldEditWrapper.IWorldEditWrapper {
return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData()); return new SchematicReader(new NBTInputStream(is)).read(WorldEdit.getInstance().getServer().getWorlds().get(0).getWorldData());
} }
@Override
public File getWorldEditSchematicFolder() {
return WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getWorkingDirectoryFile(WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getConfiguration().saveDir);
}
private static class SpongeSchematicReader implements ClipboardReader { private static class SpongeSchematicReader implements ClipboardReader {
private final NBTInputStream inputStream; private final NBTInputStream inputStream;

Datei anzeigen

@ -18,7 +18,9 @@ public class WorldEditWrapper {
InputStream getPlayerClipboard(Player player, boolean schemFormat); InputStream getPlayerClipboard(Player player, boolean schemFormat);
void setPlayerClipboard(Player player, InputStream is, boolean schemFormat); void setPlayerClipboard(Player player, InputStream is, boolean schemFormat);
Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException; Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException;
File getWorldEditSchematicFolder(); default File getWorldEditSchematicFolder() {
return WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getWorkingDirectoryFile(WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getConfiguration().saveDir);
}
} }
static WorldEditPlugin getWorldEditPlugin() { static WorldEditPlugin getWorldEditPlugin() {

Datei anzeigen

@ -25,10 +25,7 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.ByteArrayOutputStream; import java.io.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
@ -38,8 +35,13 @@ import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.GZIPInputStream;
public class StandaloneProvider implements Provider { public class StandaloneProvider implements Provider {
public StandaloneProvider() {
nodesToPath.put(-1, schematicDir.toPath());
}
@Override @Override
public BauweltMember getBauMember(int ownerID, int memberID) { public BauweltMember getBauMember(int ownerID, int memberID) {
OfflinePlayer player = Bukkit.getOfflinePlayer(SteamwarUser.get(memberID).getUUID()); OfflinePlayer player = Bukkit.getOfflinePlayer(SteamwarUser.get(memberID).getUUID());
@ -206,10 +208,6 @@ public class StandaloneProvider implements Provider {
private final Map<Integer, List<SchematicNode>> nodesByParent = new HashMap<>(); private final Map<Integer, List<SchematicNode>> nodesByParent = new HashMap<>();
private final Map<Integer, Path> nodesToPath = new HashMap<>(); private final Map<Integer, Path> nodesToPath = new HashMap<>();
{
nodesToPath.put(-1, schematicDir.toPath());
}
private List<SchematicNode> mapDir(Integer id) { private List<SchematicNode> mapDir(Integer id) {
try (Stream<Path> stream = Files.list(id==null?schematicDir.toPath():nodesToPath.get(id))) { try (Stream<Path> stream = Files.list(id==null?schematicDir.toPath():nodesToPath.get(id))) {
List<SchematicNode> list = stream.map(path -> { List<SchematicNode> list = stream.map(path -> {
@ -342,22 +340,18 @@ public class StandaloneProvider implements Provider {
@Override @Override
public InputStream getSchematicData(SchematicNode node) throws IOException { public InputStream getSchematicData(SchematicNode node) throws IOException {
return Files.newInputStream(nodesToPath.get(node.getId())); return new GZIPInputStream(Files.newInputStream(nodesToPath.get(node.getId())));
} }
@Override @Override
public void saveSchematicNode(SchematicNode node, InputStream blob, boolean newFormat) { public void saveSchematicNode(SchematicNode node, InputStream blob, boolean newFormat) {
try { try (FileOutputStream stream = new FileOutputStream(nodesToPath.get(node.getId()).toFile())) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bucket = new byte[1024]; byte[] bucket = new byte[1024];
int nReadBytes; int nReadBytes;
while((nReadBytes = blob.read(bucket, 0, bucket.length)) !=-1){ while((nReadBytes = blob.read(bucket, 0, bucket.length)) !=-1){
byteArrayOutputStream.write(bucket, 0, nReadBytes); stream.write(bucket, 0, nReadBytes);
} }
byte[] bytes = byteArrayOutputStream.toByteArray();
Files.write(nodesToPath.get(node.getId()), bytes, StandardOpenOption.TRUNCATE_EXISTING);
} catch (IOException e) { } catch (IOException e) {
throw new SecurityException(e); throw new SecurityException(e);
} }