From 2a7542aeb8a7d9fee93c58f906646407a03949ee Mon Sep 17 00:00:00 2001 From: johni0702 Date: Thu, 6 Oct 2016 13:30:14 +0200 Subject: [PATCH 1/4] Update jGui Never use decimal point regardless of user locale (fixes #13) Make popups disable user input and show the mouse when opened on an overlay (fixes #11) Fix de-focusing of text fields when focusing another text field (fixes #14) --- jGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jGui b/jGui index 9c1d2dfc..fc13c5f7 160000 --- a/jGui +++ b/jGui @@ -1 +1 @@ -Subproject commit 9c1d2dfc1c9ea4b4f6f15fcd06b22ba48e835a87 +Subproject commit fc13c5f73c0ad214108f9575839d20449c2ceb00 From 9de63ce9b1008aec662d15f47aa6678e761f46c9 Mon Sep 17 00:00:00 2001 From: johni0702 Date: Thu, 6 Oct 2016 17:56:25 +0200 Subject: [PATCH 2/4] Add gradle tasks for automating the release process --- build.gradle | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/build.gradle b/build.gradle index 3ed543b1..ee010da1 100755 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import groovy.json.JsonOutput + import java.util.zip.ZipInputStream buildscript { @@ -195,4 +197,85 @@ setupDecompWorkspace.dependsOn copySrg setupDevWorkspace.dependsOn copySrg project.tasks.idea.dependsOn copySrg +def generateVersionsJson() { + // List all tags + def stdout = new ByteArrayOutputStream() + project.exec { + commandLine 'git', 'for-each-ref', '--sort=taggerdate', '--format=%(refname:short)', 'refs/tags' + standardOutput = stdout + } + def versions = stdout.toString().tokenize('\n').reverse() + def mcVersions = versions.collect {it.substring(0, it.indexOf('-'))}.unique().reverse() + + def root = [ + homepage: 'https://www.replaymod.com/download/', + promos: [:] + ] + mcVersions.forEach { mcVersion -> + def mcVersionRoot = [:] + def latest + def recommended + versions.forEach { + def (thisMcVersion, modVersion, preVersion) = it.tokenize('-') + if (thisMcVersion == mcVersion) { + mcVersionRoot[it] = "See https://github.com/ReplayMod/ReplayMod/releases/$it" + if (latest == null) latest = it + if (preVersion == null) { + if (recommended == null) recommended = it + } + } + } + root[mcVersion] = mcVersionRoot + root.promos[mcVersion + '-latest'] = latest + if (recommended != null) { + root.promos[mcVersion + '-recommended'] = recommended + } + } + root +} + +task doRelease() { + doLast { + // Parse version + def version = project.releaseVersion as String + if (project.version.endsWith('*')) { + throw new InvalidUserDataException('Git working tree is dirty. Make sure to commit all changes.') + } + def (mcVersion, modVersion, preVersion) = version.tokenize('-') + preVersion = preVersion != null && preVersion.startsWith('b') ? preVersion.substring(1) : null + + // Create new tag + if (preVersion != null) { + project.exec { + commandLine 'git', 'tag', + '-m', "Pre-release $preVersion of $modVersion for Minecraft $mcVersion", + "$mcVersion-$modVersion-b$preVersion" + } + } else { + project.exec { + commandLine 'git', 'tag', + '-m', "Release $modVersion for Minecraft $mcVersion", + "$mcVersion-$modVersion" + } + } + + // Switch to master branch to update versions.json + project.exec { commandLine 'git', 'checkout', 'master' } + + // Generate versions.json content + def versionsRoot = generateVersionsJson() + def versionsJson = JsonOutput.prettyPrint(JsonOutput.toJson(versionsRoot)) + + // Write versions.json + new File('versions.json').write(versionsJson) + + // Commit changes + project.exec { commandLine 'git', 'add', 'versions.json' } + project.exec { commandLine 'git', 'commit', '-m', "Update versions.json for $version" } + + // Return to previous branch + project.exec { commandLine 'git', 'checkout', '-' } + } +} + defaultTasks 'build' From 45191daad482d7d2a3ea8bc310bac3281d09810d Mon Sep 17 00:00:00 2001 From: johni0702 Date: Fri, 7 Oct 2016 22:55:58 +0200 Subject: [PATCH 3/4] Add GUI that offers the user to install OpenEye --- .../com/replaymod/extras/OpenEyeExtra.java | 142 ++++++++++++++++++ .../com/replaymod/extras/ReplayModExtras.java | 1 + .../assets/replaymod/lang/en_US.lang | 12 +- 3 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/replaymod/extras/OpenEyeExtra.java diff --git a/src/main/java/com/replaymod/extras/OpenEyeExtra.java b/src/main/java/com/replaymod/extras/OpenEyeExtra.java new file mode 100644 index 00000000..600db9ad --- /dev/null +++ b/src/main/java/com/replaymod/extras/OpenEyeExtra.java @@ -0,0 +1,142 @@ +package com.replaymod.extras; + +import com.replaymod.core.ReplayMod; +import com.replaymod.core.Setting; +import de.johni0702.minecraft.gui.container.AbstractGuiScreen; +import de.johni0702.minecraft.gui.container.GuiContainer; +import de.johni0702.minecraft.gui.container.GuiPanel; +import de.johni0702.minecraft.gui.container.GuiScreen; +import de.johni0702.minecraft.gui.element.GuiButton; +import de.johni0702.minecraft.gui.element.GuiLabel; +import de.johni0702.minecraft.gui.function.Tickable; +import de.johni0702.minecraft.gui.layout.CustomLayout; +import de.johni0702.minecraft.gui.layout.HorizontalLayout; +import de.johni0702.minecraft.gui.layout.VerticalLayout; +import de.johni0702.minecraft.gui.popup.AbstractGuiPopup; +import de.johni0702.minecraft.gui.utils.Colors; +import net.minecraftforge.fml.common.Loader; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.FileOutputStream; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.FileChannel; +import java.nio.channels.ReadableByteChannel; + +public class OpenEyeExtra implements Extra { + private static final String DOWNLOAD_URL = "https://www.replaymod.com/dl/openeye/" + Loader.MC_VERSION; + private static final Setting ASK_FOR_OPEN_EYE = new Setting<>("advanced", "askForOpenEye", null, true); + + private ReplayMod mod; + + @Override + public void register(ReplayMod mod) throws Exception { + this.mod = mod; + mod.getSettingsRegistry().register(ASK_FOR_OPEN_EYE); + + if (!Loader.isModLoaded("OpenEye") && mod.getSettingsRegistry().get(ASK_FOR_OPEN_EYE)) { + mod.runLater(() -> new OfferGui(GuiScreen.wrap(mod.getMinecraft().currentScreen)).display()); + } + } + + private class OfferGui extends AbstractGuiScreen { + public final GuiScreen parent; + public final GuiPanel textPanel = new GuiPanel().setLayout(new VerticalLayout().setSpacing(3)) + .addElements(new VerticalLayout.Data(0.5), + new GuiLabel().setI18nText("replaymod.gui.offeropeneye1"), + new GuiLabel().setI18nText("replaymod.gui.offeropeneye2"), + new GuiLabel().setI18nText("replaymod.gui.offeropeneye3"), + new GuiLabel().setI18nText("replaymod.gui.offeropeneye4"), + new GuiLabel().setI18nText("replaymod.gui.offeropeneye5"), + new GuiLabel().setI18nText("replaymod.gui.offeropeneye6"), + new GuiLabel().setI18nText("replaymod.gui.offeropeneye7"), + new GuiLabel().setI18nText("replaymod.gui.offeropeneye8")); + public final GuiPanel buttonPanel = new GuiPanel() + .setLayout(new HorizontalLayout(HorizontalLayout.Alignment.CENTER).setSpacing(5)); + public final GuiPanel contentPanel = new GuiPanel(this).setLayout(new VerticalLayout().setSpacing(20)) + .addElements(new VerticalLayout.Data(0.5), textPanel, buttonPanel); + public final GuiButton yesButton = new GuiButton(buttonPanel).setSize(150, 20).setI18nLabel("gui.yes"); + public final GuiButton noButton = new GuiButton(buttonPanel).setSize(150, 20).setI18nLabel("gui.no"); + + public OfferGui(GuiScreen parent) { + this.parent = parent; + + yesButton.onClick(() -> { + GuiPopup popup = new GuiPopup(OfferGui.this); + new Thread(() -> { + try { + File targetFile = new File("mods/" + Loader.MC_VERSION, "OpenEye.jar"); + FileUtils.forceMkdir(targetFile.getParentFile()); + + ReadableByteChannel in = Channels.newChannel(new URL(DOWNLOAD_URL).openStream()); + FileChannel out = new FileOutputStream(targetFile).getChannel(); + out.transferFrom(in, 0, Long.MAX_VALUE); + } catch (Throwable e) { + e.printStackTrace(); + } finally { + mod.runLater(() -> { + popup.close(); + parent.display(); + }); + } + }).start(); + }); + noButton.onClick(() -> { + mod.getSettingsRegistry().set(ASK_FOR_OPEN_EYE, false); + mod.getSettingsRegistry().save(); + parent.display(); + }); + + setLayout(new CustomLayout() { + @Override + protected void layout(OfferGui container, int width, int height) { + pos(contentPanel, width / 2 - width(contentPanel) / 2, height / 2 - height(contentPanel) / 2); + } + }); + } + + @Override + protected OfferGui getThis() { + return this; + } + } + + private static final class GuiPopup extends AbstractGuiPopup { + GuiPopup(GuiContainer container) { + super(container); + popup.addElements(null, new GuiIndicator().setColor(Colors.BLACK)); + setBackgroundColor(Colors.DARK_TRANSPARENT); + open(); + } + + @Override + public void close() { + super.close(); + } + + @Override + protected GuiPopup getThis() { + return this; + } + + private static final class GuiIndicator extends GuiLabel implements Tickable { + private int tick; + + @Override + public void tick() { + tick++; + setText(new String[]{ + "Ooooo", + "oOooo", + "ooOoo", + "oooOo", + "ooooO", + "oooOo", + "ooOoo", + "oOooo", + }[tick / 5 % 8]); + } + } + } +} diff --git a/src/main/java/com/replaymod/extras/ReplayModExtras.java b/src/main/java/com/replaymod/extras/ReplayModExtras.java index b56c26ac..54a7eca4 100644 --- a/src/main/java/com/replaymod/extras/ReplayModExtras.java +++ b/src/main/java/com/replaymod/extras/ReplayModExtras.java @@ -29,6 +29,7 @@ public class ReplayModExtras { FullBrightness.class, HotkeyButtons.class, LocalizationExtra.class, + OpenEyeExtra.class, VersionChecker.class ); diff --git a/src/main/resources/assets/replaymod/lang/en_US.lang b/src/main/resources/assets/replaymod/lang/en_US.lang index bee76354..1c660296 100644 --- a/src/main/resources/assets/replaymod/lang/en_US.lang +++ b/src/main/resources/assets/replaymod/lang/en_US.lang @@ -496,4 +496,14 @@ replaymod.gui.modwarning.id=Mod Id: replaymod.gui.modwarning.missing=Missing Mods replaymod.gui.modwarning.version=Different Mod Versions replaymod.gui.modwarning.version.expected=Expected -replaymod.gui.modwarning.version.found=Found \ No newline at end of file +replaymod.gui.modwarning.version.found=Found + +#OpenEye +replaymod.gui.offeropeneye1=Do you want to install OpenEye? +replaymod.gui.offeropeneye2=OpenEye is a mod that collects anonymous information +replaymod.gui.offeropeneye3=about the mods being run and any crashes that happen. +replaymod.gui.offeropeneye4= +replaymod.gui.offeropeneye5=OpenEye can be disabled at any time and is completely optional. +replaymod.gui.offeropeneye6=More information is available at https://openeye.openmods.info/faq +replaymod.gui.offeropeneye7=Clicking Yes will download OpenEye and place it in your mods folder. +replaymod.gui.offeropeneye8=It will then be active the next time you start Minecraft. \ No newline at end of file From a804d6b8a3dc784348ea18360cdaea097fe36c7b Mon Sep 17 00:00:00 2001 From: johni0702 Date: Sun, 16 Oct 2016 11:16:20 +0200 Subject: [PATCH 4/4] Properly register replay restrictions plugin channel --- src/main/java/com/replaymod/recording/ReplayModRecording.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/replaymod/recording/ReplayModRecording.java b/src/main/java/com/replaymod/recording/ReplayModRecording.java index 63df4cfc..093a7441 100644 --- a/src/main/java/com/replaymod/recording/ReplayModRecording.java +++ b/src/main/java/com/replaymod/recording/ReplayModRecording.java @@ -1,6 +1,7 @@ package com.replaymod.recording; import com.replaymod.core.ReplayMod; +import com.replaymod.core.utils.Restrictions; import com.replaymod.recording.handler.ConnectionEventHandler; import com.replaymod.recording.packet.PacketListener; import net.minecraftforge.fml.common.FMLCommonHandler; @@ -8,6 +9,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.EventBus; +import net.minecraftforge.fml.common.network.NetworkRegistry; import org.apache.logging.log4j.Logger; import org.lwjgl.input.Keyboard; @@ -44,5 +46,7 @@ public class ReplayModRecording { public void init(FMLInitializationEvent event) { EventBus bus = FMLCommonHandler.instance().bus(); bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core)); + + NetworkRegistry.INSTANCE.newSimpleChannel(Restrictions.PLUGIN_CHANNEL); } }