From 59fcaf6ee9d93e4b541279195fdca29da22147f4 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 24 Aug 2021 14:37:56 +0200 Subject: [PATCH] Reenable BCLIb-Version warning --- .../handler/autosync/HelloClient.java | 20 +++++++++---------- .../ru/bclib/gui/screens/ProgressScreen.java | 2 +- .../gui/screens/WarnBCLibVersionMismatch.java | 8 ++++---- .../resources/assets/bclib/lang/en_us.json | 6 +++--- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/main/java/ru/bclib/api/dataexchange/handler/autosync/HelloClient.java b/src/main/java/ru/bclib/api/dataexchange/handler/autosync/HelloClient.java index d98d5600..7cc49493 100644 --- a/src/main/java/ru/bclib/api/dataexchange/handler/autosync/HelloClient.java +++ b/src/main/java/ru/bclib/api/dataexchange/handler/autosync/HelloClient.java @@ -317,10 +317,10 @@ public class HelloClient extends DataHandler.FromServer { final String localBclibVersion = getBCLibVersion(); BCLib.LOGGER.info("Received Hello from Server. (client=" + localBclibVersion + ", server=" + bclibVersion + ")"); - // if (DataFixerAPI.getModVersion(localBclibVersion) != DataFixerAPI.getModVersion(bclibVersion)){ - // showBCLibError(client); - // return; - // } + if (ModUtil.convertModVersion(localBclibVersion) != ModUtil.convertModVersion(bclibVersion)){ + showBCLibError(client); + return; + } final List filesToRequest = new ArrayList<>(2); final List filesToRemove = new ArrayList<>(2); @@ -344,12 +344,10 @@ public class HelloClient extends DataHandler.FromServer { protected void showBCLibError(Minecraft client) { BCLib.LOGGER.error("BCLib differs on client and server."); client.setScreen(new WarnBCLibVersionMismatch((download) -> { - Minecraft.getInstance() - .setScreen((Screen) null); if (download) { - requestBCLibDownload((hadErrors) -> { - client.stop(); - }); + requestBCLibDownload(); + + this.onCloseSyncFilesScreen(); } })); } @@ -426,9 +424,9 @@ public class HelloClient extends DataHandler.FromServer { } } - private void requestBCLibDownload(Consumer whenFinished) { + private void requestBCLibDownload() { BCLib.LOGGER.warning("Starting download of BCLib"); - whenFinished.accept(true); + requestFileDownloads(List.of(new AutoSyncID.ForModFileRequest(BCLib.MOD_ID, bclibVersion))); } @Environment(EnvType.CLIENT) diff --git a/src/main/java/ru/bclib/gui/screens/ProgressScreen.java b/src/main/java/ru/bclib/gui/screens/ProgressScreen.java index dd8f79d5..6bceda3c 100644 --- a/src/main/java/ru/bclib/gui/screens/ProgressScreen.java +++ b/src/main/java/ru/bclib/gui/screens/ProgressScreen.java @@ -109,7 +109,7 @@ public class ProgressScreen extends GridScreen implements ProgressListener { private ProgressLogoRender progressImage; private int currentProgress = 0; public boolean shouldCloseOnEsc() { - return true; + return false; } public Component getProgressComponent(){ diff --git a/src/main/java/ru/bclib/gui/screens/WarnBCLibVersionMismatch.java b/src/main/java/ru/bclib/gui/screens/WarnBCLibVersionMismatch.java index dfe9cfd4..05b48c4d 100644 --- a/src/main/java/ru/bclib/gui/screens/WarnBCLibVersionMismatch.java +++ b/src/main/java/ru/bclib/gui/screens/WarnBCLibVersionMismatch.java @@ -10,13 +10,13 @@ import ru.bclib.gui.gridlayout.GridRow; import ru.bclib.gui.gridlayout.GridScreen; @Environment(EnvType.CLIENT) -public class WarnBCLibVersionMismatch extends GridScreen { +public class WarnBCLibVersionMismatch extends BCLibScreen { private final Component description; private final Listener listener; public WarnBCLibVersionMismatch(Listener listener) { - super(new TranslatableComponent("bclib.datafixer.bclibmissmatch.title")); + super(new TranslatableComponent("title.bclib.bclibmissmatch")); - this.description = new TranslatableComponent("bclib.datafixer.bclibmissmatch.message"); + this.description = new TranslatableComponent("message.bclib.bclibmissmatch"); this.listener = listener; } @@ -24,7 +24,7 @@ public class WarnBCLibVersionMismatch extends GridScreen { final int BUTTON_HEIGHT = 20; grid.addRow().addMessage(this.description, this.font, Alignment.CENTER); - + grid.addSpacerRow(20); GridRow row = grid.addRow(); row.addFiller(); row.addButton(CommonComponents.GUI_NO, BUTTON_HEIGHT, this.font, (button) -> { diff --git a/src/main/resources/assets/bclib/lang/en_us.json b/src/main/resources/assets/bclib/lang/en_us.json index c63eb74b..cd85ae87 100644 --- a/src/main/resources/assets/bclib/lang/en_us.json +++ b/src/main/resources/assets/bclib/lang/en_us.json @@ -1,12 +1,12 @@ { "message.bclib.anvil_damage": "§cDamage", "bclib.datafixer.backupWarning.title": "Guardian detected an incompatible World", - "bclib.datafixer.backupWarning.message": "The Guardian detected, that the internals of the following Mods did change since this world was last played.\n\nWe can automatically change the world for you. If you continue without applying the changes the world may not load correct. Before you continue, you should create a Backup.", + "bclib.datafixer.backupWarning.message": "The Guardian detected, that the internals som installed Mods did change since this world was last played.\n\nWe can automatically change the world for you. If you continue without applying the changes the world may not load correct. Before you continue, you should create a Backup.", "bclib.datafixer.backupWarning.backup": "Create Backup before applying Fixes", "bclib.datafixer.backupWarning.nofixes": "Continue Without Fixes", "bclib.datafixer.backupWarning.fix": "Apply Fixes", - "bclib.datafixer.bclibmissmatch.title": "Version Mismatch", - "bclib.datafixer.bclibmissmatch.message": "The Version of BCLib on the server and this client do not match. This will cause problems when playing.\n\nDo you want to automatically download the BCLib-Version from the server. You will need to manually delete the old version from your Mods Directory.", + "title.bclib.bclibmissmatch": "Version Mismatch", + "message.bclib.bclibmissmatch": "The Version of BCLib on the server and this client do not match. This will cause problems when playing.\n\nDo you want to automatically download the BCLib-Version from the server? \n\nBCLib will move the old version into a subdirectory of your Mods-Folder and before installing the new one.", "title.bclib.syncfiles": "Mismatching Data", "message.bclib.syncfiles": "Some Content on the Server does not match the versions on the client.\nDo you want to replace the selected content with the data from the server?", "message.bclib.syncfiles.mods": "Synchronize Mods",