ed56673Merge branch '1.8' into 1.8.991573d9Update jGui, ReplayStudio and Translationsd71358bAdd confirmation dialog before overwriting path presets (fixes #65)1a55983Move addCallback method from integration test Utils to main Utils18c5bcdBe more cooperative with other mods on the ingame menu (fixes #42)c054fe8Register keys for simplepathing only once (fixes #63)f13297cFix default interpolator handling in keyframe gui and after loading (fixes #64)391f304Show error popup if entity tracker fails to load0e0eaaaFix entity tracker being set even if it failed loading (fixes #50)a34bbbcFix NPE when spectating a player without a camera entity60879fbChange local class to be an inner class because Srg2Source breaks with itdfafbecLoad translations from github repo, only reload language not all resource packs8a6ec51Add missing tooltips to player overview and various missing chat messages5677fc5Re-add warning to replay editor748a91eFix missing tooltips on fav/like/dislike buttons in replay centeree24866Fix upload replay button not being updated when name/tags changedba085cMove translations into separate repo3f0e3e7Fix NPE when receiving Replay|Restrict messages (fixes #16 GH)40e1d85Fix crash when saving the last keyframe in the edit gui (fixes #61)03aada1Update Mixin to 0.6.8 (fixes #9 GH)0c1dc65Fix interpolator being lost when moving keyframe to the end (fixes #62)fcbbbc9Add integration test. Run with ./gradlew runIntegrationTestfe6ded0Fix movement of keyframe via GuiEditKeyframe not updating selected keyframef58fa8fFix Login GUI not respecting other GUIs opened on startup4fc3a31Fix OpenEye being installed into working dir instead of mcDataDir
144 lines
4.9 KiB
Java
144 lines
4.9 KiB
Java
package com.replaymod.online;
|
|
|
|
import com.replaymod.core.ReplayMod;
|
|
import com.replaymod.online.api.ApiClient;
|
|
import com.replaymod.online.gui.GuiLoginPrompt;
|
|
import com.replaymod.online.gui.GuiReplayDownloading;
|
|
import com.replaymod.online.gui.GuiSaveModifiedReplay;
|
|
import com.replaymod.online.handler.GuiHandler;
|
|
import com.replaymod.replay.ReplayModReplay;
|
|
import com.replaymod.replay.events.ReplayCloseEvent;
|
|
import com.replaymod.replaystudio.replay.ReplayFile;
|
|
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
|
import com.replaymod.replaystudio.studio.ReplayStudio;
|
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
import net.minecraftforge.common.config.Configuration;
|
|
import net.minecraftforge.fml.common.Mod;
|
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
import static net.minecraft.client.Minecraft.getMinecraft;
|
|
|
|
@Mod(modid = ReplayModOnline.MOD_ID,
|
|
version = "@MOD_VERSION@",
|
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
|
useMetadata = true)
|
|
public class ReplayModOnline {
|
|
public static final String MOD_ID = "replaymod-online";
|
|
|
|
@Mod.Instance(MOD_ID)
|
|
public static ReplayModOnline instance;
|
|
|
|
private ReplayMod core;
|
|
|
|
private ReplayModReplay replayModule;
|
|
|
|
private Logger logger;
|
|
|
|
private ApiClient apiClient;
|
|
|
|
/**
|
|
* In case the currently opened replay gets modified, the resulting replay file is saved to this location.
|
|
* Usually a file within the normal replays folder with a unique name.
|
|
* When the replay is closed, the user is asked whether they want to give it a proper name.
|
|
*/
|
|
private File currentReplayOutputFile;
|
|
|
|
@Mod.EventHandler
|
|
public void preInit(FMLPreInitializationEvent event) {
|
|
logger = event.getModLog();
|
|
core = ReplayMod.instance;
|
|
replayModule = ReplayModReplay.instance;
|
|
|
|
core.getSettingsRegistry().register(Setting.class);
|
|
|
|
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
|
|
ConfigurationAuthData authData = new ConfigurationAuthData(config);
|
|
apiClient = new ApiClient(authData);
|
|
authData.load(apiClient);
|
|
}
|
|
|
|
@Mod.EventHandler
|
|
public void init(FMLInitializationEvent event) {
|
|
if (!getDownloadsFolder().exists()){
|
|
if (!getDownloadsFolder().mkdirs()) {
|
|
logger.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
|
}
|
|
}
|
|
|
|
new GuiHandler(this).register();
|
|
MinecraftForge.EVENT_BUS.register(this);
|
|
}
|
|
|
|
@Mod.EventHandler
|
|
public void postInit(FMLPostInitializationEvent event) {
|
|
// Initial login prompt
|
|
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
|
if (!isLoggedIn()) {
|
|
core.runLater(() -> new GuiLoginPrompt(apiClient, GuiScreen.wrap(getMinecraft().currentScreen), null, false).display());
|
|
}
|
|
}
|
|
}
|
|
|
|
public ReplayMod getCore() {
|
|
return core;
|
|
}
|
|
|
|
public ReplayModReplay getReplayModule() {
|
|
return replayModule;
|
|
}
|
|
|
|
public Logger getLogger() {
|
|
return logger;
|
|
}
|
|
|
|
public ApiClient getApiClient() {
|
|
return apiClient;
|
|
}
|
|
|
|
public boolean isLoggedIn() {
|
|
return apiClient.isLoggedIn();
|
|
}
|
|
|
|
public File getDownloadsFolder() {
|
|
String path = core.getSettingsRegistry().get(Setting.DOWNLOAD_PATH);
|
|
return new File(path.startsWith("./") ? getMinecraft().mcDataDir : null, path);
|
|
}
|
|
|
|
public File getDownloadedFile(int id) {
|
|
return new File(getDownloadsFolder(), id + ".mcpr");
|
|
}
|
|
|
|
public boolean hasDownloaded(int id) {
|
|
return getDownloadedFile(id).exists();
|
|
}
|
|
|
|
public void startReplay(int id, String name, GuiScreen onDownloadCancelled) throws IOException {
|
|
File file = getDownloadedFile(id);
|
|
if (file.exists()) {
|
|
currentReplayOutputFile = new File(core.getReplayFolder(), System.currentTimeMillis() + ".mcpr");
|
|
ReplayFile replayFile = new ZipReplayFile(new ReplayStudio(), file, currentReplayOutputFile);
|
|
replayModule.startReplay(replayFile);
|
|
} else {
|
|
new GuiReplayDownloading(onDownloadCancelled, this, id, name).display();
|
|
}
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void onReplayClosed(ReplayCloseEvent.Post event) {
|
|
if (currentReplayOutputFile != null) {
|
|
if (currentReplayOutputFile.exists()) { // Replay was modified, ask user for new name
|
|
new GuiSaveModifiedReplay(currentReplayOutputFile).display();
|
|
}
|
|
currentReplayOutputFile = null;
|
|
}
|
|
}
|
|
}
|