Removed MarkerKeyframe and replaced it with generic type of Keyframe using the new Marker POJO
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import eu.crushedpixel.replaymod.assets.AssetRepository;
|
||||
import eu.crushedpixel.replaymod.assets.CustomObjectRepository;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
import eu.crushedpixel.replaymod.holders.KeyframeSet;
|
||||
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
||||
import eu.crushedpixel.replaymod.holders.Marker;
|
||||
import eu.crushedpixel.replaymod.holders.PlayerVisibility;
|
||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||
@@ -16,10 +18,8 @@ import org.apache.commons.compress.archivers.zip.ZipFile;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public class ReplayFile extends ZipFile {
|
||||
|
||||
@@ -135,17 +135,20 @@ public class ReplayFile extends ZipFile {
|
||||
return getEntry(ENTRY_MARKERS);
|
||||
}
|
||||
|
||||
public Supplier<MarkerKeyframe[]> markers() {
|
||||
return new Supplier<MarkerKeyframe[]>() {
|
||||
public Supplier<List<Keyframe<Marker>>> markers() {
|
||||
return new Supplier<List<Keyframe<Marker>>>() {
|
||||
@Override
|
||||
public MarkerKeyframe[] get() {
|
||||
public List<Keyframe<Marker>> get() {
|
||||
try {
|
||||
ZipArchiveEntry entry = markersEntry();
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(entry)));
|
||||
return new Gson().fromJson(reader, MarkerKeyframe[].class);
|
||||
|
||||
Type keyframeType = new TypeToken<ArrayList<Keyframe<Marker>>>(){}.getType();
|
||||
|
||||
return new Gson().fromJson(reader, keyframeType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package eu.crushedpixel.replaymod.utils;
|
||||
import com.google.gson.Gson;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.assets.CustomObjectRepository;
|
||||
import eu.crushedpixel.replaymod.holders.KeyframeSet;
|
||||
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
||||
import eu.crushedpixel.replaymod.holders.PlayerVisibility;
|
||||
import eu.crushedpixel.replaymod.holders.*;
|
||||
import eu.crushedpixel.replaymod.recording.PacketSerializer;
|
||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -53,7 +50,7 @@ public class ReplayFileIO {
|
||||
return files;
|
||||
}
|
||||
|
||||
public static void writeReplayFile(File replayFile, File tempFile, ReplayMetaData metaData, Set<MarkerKeyframe> markers,
|
||||
public static void writeReplayFile(File replayFile, File tempFile, ReplayMetaData metaData, Set<Keyframe<Marker>> markers,
|
||||
Map<String, File> resourcePacks, Map<Integer, String> resourcePackRequests) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
@@ -82,7 +79,7 @@ public class ReplayFileIO {
|
||||
zos.putNextEntry(new ZipEntry(ReplayFile.ENTRY_MARKERS));
|
||||
|
||||
pw = new PrintWriter(zos);
|
||||
pw.write(new Gson().toJson(markers.toArray(new MarkerKeyframe[markers.size()])));
|
||||
pw.write(new Gson().toJson(markers.toArray(new Keyframe[markers.size()])));
|
||||
pw.flush();
|
||||
zos.closeEntry();
|
||||
}
|
||||
@@ -166,7 +163,7 @@ public class ReplayFileIO {
|
||||
write((Object) metaData, file);
|
||||
}
|
||||
|
||||
public static void write(MarkerKeyframe[] markers, File file) throws IOException {
|
||||
public static void write(Keyframe<Marker>[] markers, File file) throws IOException {
|
||||
write((Object) markers, file);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user