Make sure the replay is stopped if the main menu is opened (fixes #95)
This commit is contained in:
@@ -195,6 +195,10 @@ public class ReplayModReplay {
|
|||||||
replayHandler = new ReplayHandler(replayFile, true);
|
replayHandler = new ReplayHandler(replayFile, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forcefullyStopReplay() {
|
||||||
|
replayHandler = null;
|
||||||
|
}
|
||||||
|
|
||||||
public ReplayMod getCore() {
|
public ReplayMod getCore() {
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
private static final int BUTTON_EXIT_SERVER = 1;
|
private static final int BUTTON_EXIT_SERVER = 1;
|
||||||
private static final int BUTTON_ACHIEVEMENTS = 5;
|
private static final int BUTTON_ACHIEVEMENTS = 5;
|
||||||
@@ -102,6 +104,20 @@ public class GuiHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mod.getReplayHandler() != null) {
|
||||||
|
// Something went terribly wrong and we ended up in the main menu with the replay still active.
|
||||||
|
// To prevent players from joining live servers and using the CameraEntity, try to stop the replay now.
|
||||||
|
try {
|
||||||
|
mod.getReplayHandler().endReplay();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.error("Trying to stop broken replay: ", e);
|
||||||
|
} finally {
|
||||||
|
if (mod.getReplayHandler() != null) {
|
||||||
|
mod.forcefullyStopReplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<GuiButton> buttonList = event.buttonList;
|
List<GuiButton> buttonList = event.buttonList;
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.gui.width / 2 - 100,
|
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.gui.width / 2 - 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user