diff options
Diffstat (limited to 'src')
7 files changed, 28 insertions, 15 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index c048ce1b..4cda4590 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -809,7 +809,7 @@ public class NEUOverlay extends Gui { /** * Handles the mouse input, cancelling the forge event if a NEU gui element is clicked. */ - public boolean mouseInput() { + public synchronized boolean mouseInput() { if (disabled) { return false; } @@ -1479,7 +1479,7 @@ public class NEUOverlay extends Gui { * Returns an index-able array containing the elements in searchedItems. * Whenever searchedItems is updated in updateSearch(), the array is recreated here. */ - public List<JsonObject> getSearchedItems() { + public synchronized List<JsonObject> getSearchedItems() { if (searchedItems == null) { updateSearch(); return new ArrayList<>(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/UpdateCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/UpdateCommand.java index 4cf8a62c..36443b27 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/UpdateCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/UpdateCommand.java @@ -86,7 +86,7 @@ public class UpdateCommand extends ClientCommandBase { neu.autoUpdater.scheduleDownload(); break; case "updatemodes": - sender.addChatMessage(new ChatComponentText("§e[NEU] §bTo ensure we do not accidentally corrupt your mod folder, we can only offer support for autoupdates on system with certain capabilities for file deletions (specifically linux), or systems that have SkyClient Updater installed. Updating NEU through SCU and through NEUs autoupdate with the SCU compatibility enabled behaves potentially different, so we suggest turning off NEU updates in SCU if you want to use NEU specific update features (such as betas and faster access to hotfixes).")); + sender.addChatMessage(new ChatComponentText("§e[NEU] §bTo ensure we do not accidentally corrupt your mod folder, we can only offer support for autoupdates on system with certain capabilities for file deletions (specifically unix systems). You can still manually update your files")); break; default: displayHelp(sender); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java index ff36b092..7869225d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/AutoUpdater.java @@ -75,7 +75,7 @@ public class AutoUpdater { if (SystemUtils.IS_OS_UNIX) { return new LinuxBasedUpdater(this, url); } - if (Loader.isModLoaded("skyblockclientupdater")) { + if (Loader.isModLoaded("skyblockclientupdater") && SCUCompatUpdater.IS_ENABLED) { return SCUCompatUpdater.tryCreate(this, url); } return null; @@ -165,6 +165,7 @@ public class AutoUpdater { } neu.displayLinks(updateJson, firstWidth); NotificationHandler.displayNotification(Arrays.asList( + "", "§eThere is a new version of NotEnoughUpdates available.", "§eCheck the chat for more information" ), true); @@ -249,7 +250,8 @@ public class AutoUpdater { return validateMcModInfo(jsonArray); } } catch (IOException | JsonSyntaxException e) { - return false; + e.printStackTrace(); } + return false; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/SCUCompatUpdater.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/SCUCompatUpdater.java index 3e68fcd0..3cb600cb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/SCUCompatUpdater.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/SCUCompatUpdater.java @@ -45,6 +45,8 @@ import java.util.List; * */ public class SCUCompatUpdater extends UpdateLoader { + public static final boolean IS_ENABLED = false; + private SCUCompatUpdater(AutoUpdater updater, URL url) { super(updater, url); } @@ -58,7 +60,7 @@ public class SCUCompatUpdater extends UpdateLoader { public void deleteFiles(List<File> toDelete) { try { for (File f : toDelete) - ReflectionHolder.deleteFileOnShutdownHandle.invoke(f, ""); + ReflectionHolder.deleteFileOnShutdownHandle.invoke(ReflectionHolder.updateCheckerInstance, f, ""); } catch (Throwable e) { e.printStackTrace(); updater.logProgress("Invoking SCU failed. Check the log for more info."); @@ -89,8 +91,10 @@ public class SCUCompatUpdater extends UpdateLoader { } public static UpdateLoader tryCreate(AutoUpdater updater, URL url) { - if (!ReflectionHolder.isSCUFullyPresent) + if (!ReflectionHolder.isSCUFullyPresent) { updater.logProgress("§cFound Skyclient Updater Mod, however our hooks did not function properly."); + return null; + } return new SCUCompatUpdater(updater, url); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java index d358533e..1a1a8504 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java @@ -128,9 +128,12 @@ abstract class UpdateLoader { state = State.FAILED; } deleteFiles(toDelete); - if (state != State.FAILED) + if (state != State.FAILED) { state = State.INSTALLED; - updater.logProgress("Update successful. Thank you for your time."); + updater.logProgress("Update successful. Thank you for your time."); + return; + } + updater.logProgress("§cFailure to delete some files. Please delte the old NEU version manually from your mods folder."); } public abstract void deleteFiles(List<File> toDelete); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/NetUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/NetUtils.java index 251a2b3a..b09dd839 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/NetUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/NetUtils.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; -import java.net.URLConnection; import java.nio.file.Files; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; @@ -36,9 +35,8 @@ public class NetUtils { public static CompletableFuture<File> downloadAsync(URL httpURL, File outputFile) { return CompletableFuture.supplyAsync(() -> { try { - URLConnection urlConnection = httpURL.openConnection(); try ( - InputStream from = urlConnection.getInputStream(); + InputStream from = httpURL.openStream(); OutputStream to = Files.newOutputStream(outputFile.toPath()); ) { IOUtils.copyLarge(from, to); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index f45b840c..71f62273 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -873,6 +873,8 @@ public class Utils { String... lore ) { NBTTagCompound tag = itemStack.getTagCompound(); + if (tag == null) + tag = new NBTTagCompound(); NBTTagCompound display = tag.getCompoundTag("display"); NBTTagList Lore = new NBTTagList(); @@ -1936,9 +1938,13 @@ public class Utils { public static void showOutdatedRepoNotification() { NotificationHandler.displayNotification(Lists.newArrayList( EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", - EnumChatFormatting.RED + "Data used for many NEU features is not up to date, this should normally not be the case.", - EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + EnumChatFormatting.RED +" and restart your game" + - " to see if that fixes the issue.", EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + "discord.gg/moulberry" + + EnumChatFormatting.RED + + "Data used for many NEU features is not up to date, this should normally not be the case.", + EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + + EnumChatFormatting.RED + " and restart your game" + + " to see if that fixes the issue.", + EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + + "discord.gg/moulberry" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" ), |