Fix replay in 1.21 -> RPlayer needs fixing before
All checks were successful
SteamWarCI Build successful
All checks were successful
SteamWarCI Build successful
This commit is contained in:
@@ -27,9 +27,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.*;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@@ -120,7 +118,12 @@ public class WorldeditWrapper14 implements WorldeditWrapper {
|
||||
|
||||
@Override
|
||||
public Clipboard loadChar(String charName) throws IOException {
|
||||
return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem"))))).read();
|
||||
File file = new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem");
|
||||
Clipboard clipboard;
|
||||
try (ClipboardReader reader = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file))) {
|
||||
clipboard = reader.read();
|
||||
}
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,6 +50,18 @@ tasks.register<FightServer>("WarGear20") {
|
||||
config = "WarGear20.yml"
|
||||
}
|
||||
|
||||
tasks.register<FightServer>("HalloweenWS") {
|
||||
group = "run"
|
||||
description = "Run a Halloween 1.21 Fight Replay Server"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":FightSystem:shadowJar")
|
||||
template = "HalloweenWS"
|
||||
worldName = "arenas/Lucifus"
|
||||
config = "HalloweenWS.yml"
|
||||
replay = 179786
|
||||
jar = "/jars/paper-1.21.6.jar"
|
||||
}
|
||||
|
||||
tasks.register<FightServer>("WarGear21") {
|
||||
group = "run"
|
||||
description = "Run a WarGear 1.21 Fight Server"
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV2;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@@ -37,7 +36,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.enginehub.linbus.stream.LinBinaryIO;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WorldEditWrapper21 implements WorldEditWrapper {
|
||||
|
||||
@@ -68,12 +71,58 @@ public class WorldEditWrapper21 implements WorldEditWrapper {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
public Clipboard getClipboard(InputStream is, NodeData.SchematicFormat schemFormat) throws IOException {
|
||||
return switch (schemFormat) {
|
||||
case MCEDIT -> new MCEditSchematicReader(new NBTInputStream(is)).read();
|
||||
case SPONGE_V2 -> new SpongeSchematicV2Reader(LinBinaryIO.read(new DataInputStream(is))).read();
|
||||
case SPONGE_V3 -> new SpongeSchematicV3Reader(LinBinaryIO.read(new DataInputStream(is))).read();
|
||||
};
|
||||
public Clipboard getClipboard(InputStream is, NodeData.SchematicFormat ignored) throws IOException {
|
||||
ResetableInputStream ris = new ResetableInputStream(is);
|
||||
for (NodeData.SchematicFormat schemFormat : NodeData.SchematicFormat.values()) {
|
||||
try {
|
||||
Clipboard clipboard = switch (schemFormat) {
|
||||
case MCEDIT -> new MCEditSchematicReader(new NBTInputStream(ris)).read();
|
||||
case SPONGE_V2 -> new SpongeSchematicV2Reader(LinBinaryIO.read(new DataInputStream(ris))).read();
|
||||
case SPONGE_V3 -> new SpongeSchematicV3Reader(LinBinaryIO.read(new DataInputStream(ris))).read();
|
||||
};
|
||||
ris.close();
|
||||
return clipboard;
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
ris.reset();
|
||||
}
|
||||
throw new IOException("No clipboard found");
|
||||
}
|
||||
|
||||
private class ResetableInputStream extends InputStream {
|
||||
|
||||
private InputStream inputStream;
|
||||
private int pointer = 0;
|
||||
private List<Integer> list = new ArrayList<>();
|
||||
|
||||
public ResetableInputStream(InputStream in) {
|
||||
this.inputStream = in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (pointer >= list.size()) {
|
||||
int data = inputStream.read();
|
||||
list.add(data);
|
||||
pointer++;
|
||||
return data;
|
||||
}
|
||||
int data = list.get(pointer);
|
||||
pointer++;
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
pointer = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
list.clear();
|
||||
pointer = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user