Get online module compiling on 1.13
This commit is contained in:
@@ -7,6 +7,7 @@ import com.replaymod.core.gui.RestoreReplayGui;
|
|||||||
import com.replaymod.core.handler.MainMenuHandler;
|
import com.replaymod.core.handler.MainMenuHandler;
|
||||||
import com.replaymod.core.utils.OpenGLUtils;
|
import com.replaymod.core.utils.OpenGLUtils;
|
||||||
import com.replaymod.core.versions.MCVer;
|
import com.replaymod.core.versions.MCVer;
|
||||||
|
import com.replaymod.online.ReplayModOnline;
|
||||||
import com.replaymod.recording.ReplayModRecording;
|
import com.replaymod.recording.ReplayModRecording;
|
||||||
import com.replaymod.render.ReplayModRender;
|
import com.replaymod.render.ReplayModRender;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
@@ -164,7 +165,9 @@ public class ReplayMod implements Module {
|
|||||||
// Register all RM modules
|
// Register all RM modules
|
||||||
modules.add(this);
|
modules.add(this);
|
||||||
modules.add(new ReplayModRecording(this));
|
modules.add(new ReplayModRecording(this));
|
||||||
modules.add(new ReplayModReplay(this));
|
ReplayModReplay replayModule = new ReplayModReplay(this);
|
||||||
|
modules.add(replayModule);
|
||||||
|
modules.add(new ReplayModOnline(this, replayModule));
|
||||||
modules.add(new ReplayModRender(this));
|
modules.add(new ReplayModRender(this));
|
||||||
modules.add(new ReplayModSimplePathing(this));
|
modules.add(new ReplayModSimplePathing(this));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.replaymod.online;
|
package com.replaymod.online;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import com.replaymod.core.versions.MCVer;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ public class AuthenticationHash {
|
|||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
|
||||||
public AuthenticationHash() {
|
public AuthenticationHash() {
|
||||||
username = Minecraft.getMinecraft().getSession().getUsername();
|
username = MCVer.getMinecraft().getSession().getUsername();
|
||||||
currentTime = System.currentTimeMillis();
|
currentTime = System.currentTimeMillis();
|
||||||
randomLong = random.nextLong();
|
randomLong = random.nextLong();
|
||||||
hash = getAuthenticationHash();
|
hash = getAuthenticationHash();
|
||||||
|
|||||||
@@ -1,63 +1,65 @@
|
|||||||
package com.replaymod.online;
|
//#if MC<11300
|
||||||
|
//$$ package com.replaymod.online;
|
||||||
import com.replaymod.online.api.ApiClient;
|
//$$
|
||||||
import com.replaymod.online.api.AuthData;
|
//$$ import com.replaymod.online.api.ApiClient;
|
||||||
import com.replaymod.online.api.replay.holders.AuthConfirmation;
|
//$$ import com.replaymod.online.api.AuthData;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
//$$ import com.replaymod.online.api.replay.holders.AuthConfirmation;
|
||||||
import net.minecraftforge.common.config.Property;
|
//$$ import net.minecraftforge.common.config.Configuration;
|
||||||
|
//$$ import net.minecraftforge.common.config.Property;
|
||||||
/**
|
//$$
|
||||||
* Auth data stored in a {@link Configuration}.
|
//$$ /**
|
||||||
*/
|
//$$ * Auth data stored in a {@link Configuration}.
|
||||||
public class ConfigurationAuthData implements AuthData {
|
//$$ */
|
||||||
|
//$$ public class ConfigurationAuthData implements AuthData {
|
||||||
private final Configuration config;
|
//$$
|
||||||
private String userName;
|
//$$ private final Configuration config;
|
||||||
private String authKey;
|
//$$ private String userName;
|
||||||
|
//$$ private String authKey;
|
||||||
public ConfigurationAuthData(Configuration config) {
|
//$$
|
||||||
this.config = config;
|
//$$ public ConfigurationAuthData(Configuration config) {
|
||||||
}
|
//$$ this.config = config;
|
||||||
|
//$$ }
|
||||||
/**
|
//$$
|
||||||
* Loads the data from the configuration and checks for its validity.
|
//$$ /**
|
||||||
* If the data is invalid, it is removed from the config.
|
//$$ * Loads the data from the configuration and checks for its validity.
|
||||||
* @param apiClient Api client used for validating the auth data
|
//$$ * If the data is invalid, it is removed from the config.
|
||||||
*/
|
//$$ * @param apiClient Api client used for validating the auth data
|
||||||
public void load(ApiClient apiClient) {
|
//$$ */
|
||||||
Property property = config.get("authkey", "authkey", (String) null);
|
//$$ public void load(ApiClient apiClient) {
|
||||||
if (property != null) {
|
//$$ Property property = config.get("authkey", "authkey", (String) null);
|
||||||
String authKey = property.getString();
|
//$$ if (property != null) {
|
||||||
AuthConfirmation result = apiClient.checkAuthkey(authKey);
|
//$$ String authKey = property.getString();
|
||||||
if (result != null) {
|
//$$ AuthConfirmation result = apiClient.checkAuthkey(authKey);
|
||||||
this.authKey = authKey;
|
//$$ if (result != null) {
|
||||||
this.userName = result.getUsername();
|
//$$ this.authKey = authKey;
|
||||||
} else {
|
//$$ this.userName = result.getUsername();
|
||||||
setData(null, null);
|
//$$ } else {
|
||||||
}
|
//$$ setData(null, null);
|
||||||
}
|
//$$ }
|
||||||
}
|
//$$ }
|
||||||
|
//$$ }
|
||||||
@Override
|
//$$
|
||||||
public String getUserName() {
|
//$$ @Override
|
||||||
return userName;
|
//$$ public String getUserName() {
|
||||||
}
|
//$$ return userName;
|
||||||
|
//$$ }
|
||||||
@Override
|
//$$
|
||||||
public String getAuthKey() {
|
//$$ @Override
|
||||||
return authKey;
|
//$$ public String getAuthKey() {
|
||||||
}
|
//$$ return authKey;
|
||||||
|
//$$ }
|
||||||
@Override
|
//$$
|
||||||
public void setData(String userName, String authKey) {
|
//$$ @Override
|
||||||
this.userName = userName;
|
//$$ public void setData(String userName, String authKey) {
|
||||||
this.authKey = authKey;
|
//$$ this.userName = userName;
|
||||||
|
//$$ this.authKey = authKey;
|
||||||
config.removeCategory(config.getCategory("authkey"));
|
//$$
|
||||||
if (authKey != null) {
|
//$$ config.removeCategory(config.getCategory("authkey"));
|
||||||
// Note: .get() actually creates the entry with the default value if it doesn't exist
|
//$$ if (authKey != null) {
|
||||||
config.get("authkey", "authkey", authKey);
|
//$$ // Note: .get() actually creates the entry with the default value if it doesn't exist
|
||||||
}
|
//$$ config.get("authkey", "authkey", authKey);
|
||||||
config.save();
|
//$$ }
|
||||||
}
|
//$$ config.save();
|
||||||
}
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|||||||
68
src/main/java/com/replaymod/online/PlainFileAuthData.java
Normal file
68
src/main/java/com/replaymod/online/PlainFileAuthData.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
package com.replaymod.online;
|
||||||
|
|
||||||
|
import com.replaymod.online.api.ApiClient;
|
||||||
|
import com.replaymod.online.api.AuthData;
|
||||||
|
import com.replaymod.online.api.replay.holders.AuthConfirmation;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auth data stored in a plain text file.
|
||||||
|
*/
|
||||||
|
public class PlainFileAuthData implements AuthData {
|
||||||
|
private final Path path;
|
||||||
|
private String userName;
|
||||||
|
private String authKey;
|
||||||
|
|
||||||
|
public PlainFileAuthData(Path path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the data from the JSON file and checks for its validity.
|
||||||
|
* If the data is invalid, the JSON file is removed.
|
||||||
|
* @param apiClient Api client used for validating the auth data
|
||||||
|
*/
|
||||||
|
public void load(ApiClient apiClient) throws IOException {
|
||||||
|
String authKey;
|
||||||
|
try {
|
||||||
|
authKey = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||||
|
} catch (FileNotFoundException ignored) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AuthConfirmation result = apiClient.checkAuthkey(authKey);
|
||||||
|
if (result != null) {
|
||||||
|
this.authKey = authKey;
|
||||||
|
this.userName = result.getUsername();
|
||||||
|
} else {
|
||||||
|
Files.deleteIfExists(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAuthKey() {
|
||||||
|
return authKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setData(String userName, String authKey) {
|
||||||
|
this.userName = userName;
|
||||||
|
this.authKey = authKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Files.write(path, authKey.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE_NEW);
|
||||||
|
} catch (IOException e) {
|
||||||
|
ReplayModOnline.LOGGER.error("Saving auth data:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.replaymod.online;
|
package com.replaymod.online;
|
||||||
|
|
||||||
|
import com.replaymod.core.Module;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.online.api.ApiClient;
|
import com.replaymod.online.api.ApiClient;
|
||||||
|
import com.replaymod.online.api.AuthData;
|
||||||
import com.replaymod.online.gui.GuiLoginPrompt;
|
import com.replaymod.online.gui.GuiLoginPrompt;
|
||||||
import com.replaymod.online.gui.GuiReplayDownloading;
|
import com.replaymod.online.gui.GuiReplayDownloading;
|
||||||
import com.replaymod.online.gui.GuiSaveModifiedReplay;
|
import com.replaymod.online.gui.GuiSaveModifiedReplay;
|
||||||
@@ -12,48 +15,36 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
|||||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
import net.minecraftforge.fml.common.Mod;
|
//#if MC>=11300
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
//#else
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
//$$ import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
//#endif
|
||||||
//#else
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.Mod;
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import static com.replaymod.core.versions.MCVer.*;
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
import static net.minecraft.client.Minecraft.getMinecraft;
|
|
||||||
|
|
||||||
@Mod(modid = ReplayModOnline.MOD_ID,
|
public class ReplayModOnline implements Module {
|
||||||
version = "@MOD_VERSION@",
|
{ instance = this; }
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
//#if MC>=10800
|
|
||||||
clientSideOnly = true,
|
|
||||||
//#endif
|
|
||||||
useMetadata = true)
|
|
||||||
public class ReplayModOnline {
|
|
||||||
public static final String MOD_ID = "replaymod-online";
|
|
||||||
|
|
||||||
@Mod.Instance(MOD_ID)
|
|
||||||
public static ReplayModOnline instance;
|
public static ReplayModOnline instance;
|
||||||
|
|
||||||
private ReplayMod core;
|
private ReplayMod core;
|
||||||
|
|
||||||
private ReplayModReplay replayModule;
|
private ReplayModReplay replayModule;
|
||||||
|
|
||||||
public static Logger LOGGER;
|
public static Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
@@ -64,22 +55,31 @@ public class ReplayModOnline {
|
|||||||
*/
|
*/
|
||||||
private File currentReplayOutputFile;
|
private File currentReplayOutputFile;
|
||||||
|
|
||||||
@Mod.EventHandler
|
public ReplayModOnline(ReplayMod core, ReplayModReplay replayModule) {
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
this.core = core;
|
||||||
LOGGER = event.getModLog();
|
this.replayModule = replayModule;
|
||||||
core = ReplayMod.instance;
|
|
||||||
replayModule = ReplayModReplay.instance;
|
|
||||||
|
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
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
|
@Override
|
||||||
public void init(FMLInitializationEvent event) {
|
public void initClient() {
|
||||||
|
Path path = MCVer.mcDataDir(MCVer.getMinecraft()).toPath().resolve("config/replaymod-online.token");
|
||||||
|
PlainFileAuthData authData = new PlainFileAuthData(path);
|
||||||
|
apiClient = new ApiClient(authData);
|
||||||
|
if (Files.notExists(path)) {
|
||||||
|
AuthData oldAuthData = loadOldAuthData();
|
||||||
|
if (oldAuthData != null) {
|
||||||
|
authData.setData(oldAuthData.getUserName(), oldAuthData.getAuthKey());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
authData.load(apiClient);
|
||||||
|
} catch (IOException e) {
|
||||||
|
ReplayModOnline.LOGGER.error("Loading auth data:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!getDownloadsFolder().exists()){
|
if (!getDownloadsFolder().exists()){
|
||||||
if (!getDownloadsFolder().mkdirs()) {
|
if (!getDownloadsFolder().mkdirs()) {
|
||||||
LOGGER.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
LOGGER.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
||||||
@@ -88,10 +88,7 @@ public class ReplayModOnline {
|
|||||||
|
|
||||||
new GuiHandler(this).register();
|
new GuiHandler(this).register();
|
||||||
FML_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
|
||||||
public void postInit(FMLPostInitializationEvent event) {
|
|
||||||
// Initial login prompt
|
// Initial login prompt
|
||||||
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
||||||
if (!isLoggedIn()) {
|
if (!isLoggedIn()) {
|
||||||
@@ -103,6 +100,23 @@ public class ReplayModOnline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads old auth data from the legacy Configuration system and stores it in the new json file.
|
||||||
|
* Always returns null on 1.13+ where the Configuration system has been removed.
|
||||||
|
*/
|
||||||
|
private AuthData loadOldAuthData() {
|
||||||
|
//#if MC<11300
|
||||||
|
//$$ Path path = MCVer.mcDataDir(MCVer.getMinecraft()).toPath().resolve("config/replaymod-online.cfg");
|
||||||
|
//$$ Configuration config = new Configuration(path.toFile());
|
||||||
|
//$$ ConfigurationAuthData authData = new ConfigurationAuthData(config);
|
||||||
|
//$$ authData.load(new ApiClient(authData));
|
||||||
|
//$$ if (authData.getAuthKey() != null) {
|
||||||
|
//$$ return authData;
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public ReplayMod getCore() {
|
public ReplayMod getCore() {
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
@@ -125,7 +139,7 @@ public class ReplayModOnline {
|
|||||||
|
|
||||||
public File getDownloadsFolder() {
|
public File getDownloadsFolder() {
|
||||||
String path = core.getSettingsRegistry().get(Setting.DOWNLOAD_PATH);
|
String path = core.getSettingsRegistry().get(Setting.DOWNLOAD_PATH);
|
||||||
return new File(path.startsWith("./") ? getMinecraft().mcDataDir : null, path);
|
return new File(path.startsWith("./") ? mcDataDir(getMinecraft()) : null, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getDownloadedFile(int id) {
|
public File getDownloadedFile(int id) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.google.gson.JsonParseException;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.online.AuthenticationHash;
|
import com.replaymod.online.AuthenticationHash;
|
||||||
import com.replaymod.online.api.replay.ReplayModApiMethods;
|
import com.replaymod.online.api.replay.ReplayModApiMethods;
|
||||||
import com.replaymod.online.api.replay.SearchQuery;
|
import com.replaymod.online.api.replay.SearchQuery;
|
||||||
@@ -30,7 +31,7 @@ import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
|
|||||||
|
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
private static final Minecraft mc = MCVer.getMinecraft();
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
private static final JsonParser jsonParser = new JsonParser();
|
private static final JsonParser jsonParser = new JsonParser();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ public enum MinecraftVersion {
|
|||||||
MC_1_11_2("Minecraft 1.11.2", "1.11.2"),
|
MC_1_11_2("Minecraft 1.11.2", "1.11.2"),
|
||||||
MC_1_12("Minecraft 1.12", "1.12"),
|
MC_1_12("Minecraft 1.12", "1.12"),
|
||||||
MC_1_12_1("Minecraft 1.12.1", "1.12.1"),
|
MC_1_12_1("Minecraft 1.12.1", "1.12.1"),
|
||||||
MC_1_12_2("Minecraft 1.12.2", "1.12.2");
|
MC_1_12_2("Minecraft 1.12.2", "1.12.2"),
|
||||||
|
MC_1_13_2("Minecraft 1.13.2", "1.13.2");
|
||||||
|
|
||||||
private String niceName, apiName;
|
private String niceName, apiName;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.replaymod.online.gui;
|
package com.replaymod.online.gui;
|
||||||
|
|
||||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||||
import com.replaymod.core.versions.MCVer;
|
|
||||||
import com.replaymod.online.api.ApiClient;
|
import com.replaymod.online.api.ApiClient;
|
||||||
import com.replaymod.online.api.ApiException;
|
import com.replaymod.online.api.ApiException;
|
||||||
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
||||||
@@ -13,9 +12,9 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
|||||||
import de.johni0702.minecraft.gui.utils.Consumers;
|
import de.johni0702.minecraft.gui.utils.Consumers;
|
||||||
import de.johni0702.minecraft.gui.utils.Utils;
|
import de.johni0702.minecraft.gui.utils.Utils;
|
||||||
import com.replaymod.core.utils.Patterns;
|
import com.replaymod.core.utils.Patterns;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import org.lwjgl.util.Dimension;
|
|
||||||
import org.lwjgl.util.ReadableColor;
|
|
||||||
|
|
||||||
import static com.replaymod.core.versions.MCVer.*;
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
|||||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.lwjgl.util.Dimension;
|
|
||||||
import org.lwjgl.util.ReadableDimension;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -462,7 +462,7 @@ public class GuiReplayCenter extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReadableDimension calcMinSize(GuiContainer<?> container) {
|
public ReadableDimension calcMinSize(GuiContainer<?> container) {
|
||||||
return new org.lwjgl.util.Dimension(300, thumbnail.getMinSize().getHeight());
|
return new Dimension(300, thumbnail.getMinSize().getHeight());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,14 @@ import de.johni0702.minecraft.gui.function.Typeable;
|
|||||||
import de.johni0702.minecraft.gui.layout.GridLayout;
|
import de.johni0702.minecraft.gui.layout.GridLayout;
|
||||||
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
import org.lwjgl.util.ReadablePoint;
|
//#if MC>=11300
|
||||||
|
import com.replaymod.core.versions.MCVer.Keyboard;
|
||||||
|
//#else
|
||||||
|
//$$ import org.lwjgl.input.Keyboard;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -33,13 +33,16 @@ import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
|||||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.util.ReportedException;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
//#if MC>=11300
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.settings.GameSettings;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -47,6 +50,7 @@ import java.io.IOException;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.newReportedException;
|
||||||
import static java.util.Arrays.stream;
|
import static java.util.Arrays.stream;
|
||||||
|
|
||||||
public class GuiUploadReplay extends GuiScreen {
|
public class GuiUploadReplay extends GuiScreen {
|
||||||
@@ -130,7 +134,7 @@ public class GuiUploadReplay extends GuiScreen {
|
|||||||
metaData = replayFile.getMetaData();
|
metaData = replayFile.getMetaData();
|
||||||
optThumbnail = replayFile.getThumb();
|
optThumbnail = replayFile.getThumb();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ReportedException(CrashReport.makeCrashReport(e, "Read replay file " + file.getName()));
|
throw newReportedException(CrashReport.makeCrashReport(e, "Read replay file " + file.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply to gui
|
// Apply to gui
|
||||||
@@ -147,7 +151,11 @@ public class GuiUploadReplay extends GuiScreen {
|
|||||||
// Get name of key used for thumbnail creation
|
// Get name of key used for thumbnail creation
|
||||||
KeyBindingRegistry registry = mod.getCore().getKeyBindingRegistry();
|
KeyBindingRegistry registry = mod.getCore().getKeyBindingRegistry();
|
||||||
KeyBinding keyBinding = registry.getKeyBindings().get("replaymod.input.thumbnail");
|
KeyBinding keyBinding = registry.getKeyBindings().get("replaymod.input.thumbnail");
|
||||||
String keyName = keyBinding == null ? "???" : GameSettings.getKeyDisplayString(keyBinding.getKeyCode());
|
//#if MC>=11300
|
||||||
|
String keyName = keyBinding == null ? "???" : keyBinding.func_197978_k();
|
||||||
|
//#else
|
||||||
|
//$$ String keyName = keyBinding == null ? "???" : GameSettings.getKeyDisplayString(keyBinding.getKeyCode());
|
||||||
|
//#endif
|
||||||
|
|
||||||
// No thumbnail, show default thumbnail and hint on how to create one
|
// No thumbnail, show default thumbnail and hint on how to create one
|
||||||
thumbnail.setTexture(Utils.DEFAULT_THUMBNAIL);
|
thumbnail.setTexture(Utils.DEFAULT_THUMBNAIL);
|
||||||
|
|||||||
@@ -15,7 +15,12 @@ import net.minecraft.client.resources.I18n;
|
|||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
|
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
//#if MC>=11300
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
//#endif
|
||||||
//#else
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
//#endif
|
//#endif
|
||||||
@@ -45,8 +50,15 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, getGui(event).width / 2 - 100,
|
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, getGui(event).width / 2 - 100,
|
||||||
getGui(event).height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
getGui(event).height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter")) {
|
||||||
getButtonList(event).add(button);
|
//#if MC>=11300
|
||||||
|
@Override
|
||||||
|
public void onClick(double mouseX, double mouseY) {
|
||||||
|
onButton(new GuiScreenEvent.ActionPerformedEvent.Pre(getGui(event), this, new ArrayList<>()));
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
|
};
|
||||||
|
addButton(event, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -276,7 +276,6 @@ sourceSets {
|
|||||||
exclude 'com/replaymod/compat'
|
exclude 'com/replaymod/compat'
|
||||||
exclude 'com/replaymod/editor'
|
exclude 'com/replaymod/editor'
|
||||||
exclude 'com/replaymod/extras'
|
exclude 'com/replaymod/extras'
|
||||||
exclude 'com/replaymod/online'
|
|
||||||
exclude 'com/replaymod/restrictions'
|
exclude 'com/replaymod/restrictions'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user