Skip to content

Commit

Permalink
[Flavor] Fix tests failing
Browse files Browse the repository at this point in the history
  • Loading branch information
ScribbleTAS committed Dec 18, 2024
1 parent 96a2ad4 commit fa4754a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static abstract class PlaybackFileCommandExtension implements Registerabl
protected final Path tempDir;

public PlaybackFileCommandExtension() {
this(null);
this((Path) null);
}

/**
Expand All @@ -69,13 +69,18 @@ public PlaybackFileCommandExtension() {
* @param tempFolderName The name of the temp folder
*/
public PlaybackFileCommandExtension(String tempFolderName) {
if (tempFolderName == null) {
this(TASmodClient.tasfiledirectory.resolve("temp").resolve(tempFolderName));
}

public PlaybackFileCommandExtension(Path tempDirectory) {
if (tempDirectory == null) {
tempDir = null;
return;
}
this.tempDir = TASmodClient.tasfiledirectory.resolve("temp").resolve(tempFolderName);

tempDir = tempDirectory;
try {
AbstractDataFile.createDirectory(tempDir);
AbstractDataFile.createDirectory(tempDirectory);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Path;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.List;
Expand Down Expand Up @@ -40,12 +41,22 @@ public class DesyncMonitorFileCommandExtension extends PlaybackFileCommandExtens
private MonitorContainer currentValues;

public DesyncMonitorFileCommandExtension() {
super("monitoring");
this("monitoring");
}

public DesyncMonitorFileCommandExtension(String tempDirName) {
super(tempDirName);
this.monitorContainer = new BigArrayList<MonitorContainer>(tempDir.toString());
// Is enabled by default
enabled = true;
}

public DesyncMonitorFileCommandExtension(Path tempDir) {
super(tempDir);
this.monitorContainer = new BigArrayList<>(tempDir.toString());
enabled = true;
}

@Override
public String getExtensionName() {
return "tasmod_desyncMonitor@v1";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.minecrafttas.tasmod.playback.filecommands.builtin;

import java.io.IOException;
import java.nio.file.Path;

import com.dselent.bigarraylist.BigArrayList;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
Expand All @@ -16,7 +17,17 @@ public class LabelFileCommandExtension extends PlaybackFileCommandExtension {
BigArrayList<PlaybackFileCommandContainer> label = new BigArrayList<>();

public LabelFileCommandExtension() {
super("label");
this("label");
}

public LabelFileCommandExtension(String tempDirName) {
super(tempDirName);
this.label = new BigArrayList<>(tempDir.toString());
enabled = true;
}

public LabelFileCommandExtension(Path tempDir) {
super(tempDir);
this.label = new BigArrayList<>(tempDir.toString());
enabled = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.minecrafttas.tasmod.playback.filecommands.builtin;

import java.io.IOException;
import java.nio.file.Path;

import com.dselent.bigarraylist.BigArrayList;
import com.minecrafttas.tasmod.TASmod;
Expand All @@ -18,11 +19,21 @@ public class OptionsFileCommandExtension extends PlaybackFileCommandExtension {
BigArrayList<PlaybackFileCommandContainer> hud;

public OptionsFileCommandExtension() {
super("hud");
this("hud");
}

public OptionsFileCommandExtension(String tempDirName) {
super(tempDirName);
hud = new BigArrayList<>(tempDir.toString());
enabled = true;
}

public OptionsFileCommandExtension(Path tempDir) {
super(tempDir);
this.hud = new BigArrayList<>(tempDir.toString());
enabled = true;
}

@Override
public String getExtensionName() {
return "tasmod_options@v1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -73,7 +75,9 @@ void beforeEach() {
creditsMetadata.setValue(CreditFields.Author, "Scribal");
creditsMetadataExtension.onLoad(creditsMetadata);

TASmodAPIRegistry.PLAYBACK_FILE_COMMAND.register(new LabelFileCommandExtension(), new DesyncMonitorFileCommandExtension(), new OptionsFileCommandExtension());
Path temp = Paths.get("src/test/resources/temp");

TASmodAPIRegistry.PLAYBACK_FILE_COMMAND.register(new LabelFileCommandExtension(temp), new DesyncMonitorFileCommandExtension(temp), new OptionsFileCommandExtension(temp));

TASmodAPIRegistry.PLAYBACK_METADATA.register(creditsMetadataExtension, startpositionMetadataExtension);
}
Expand Down

0 comments on commit fa4754a

Please sign in to comment.