Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Fix version checking and add failed language string
Dieser Commit ist enthalten in:
Ursprung
ad751ecb5b
Commit
b0e291edc4
@ -33,6 +33,9 @@ import org.geysermc.connector.utils.FileUtils;
|
|||||||
import org.geysermc.connector.utils.LanguageUtils;
|
import org.geysermc.connector.utils.LanguageUtils;
|
||||||
import org.geysermc.connector.utils.WebUtils;
|
import org.geysermc.connector.utils.WebUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class VersionCommand extends GeyserCommand {
|
public class VersionCommand extends GeyserCommand {
|
||||||
@ -56,9 +59,9 @@ public class VersionCommand extends GeyserCommand {
|
|||||||
Properties gitProp = new Properties();
|
Properties gitProp = new Properties();
|
||||||
gitProp.load(FileUtils.getResource("git.properties"));
|
gitProp.load(FileUtils.getResource("git.properties"));
|
||||||
|
|
||||||
String buildXML = WebUtils.getBody("https://ci.nukkitx.com/job/GeyserMC/job/Geyser/job/" + gitProp.getProperty("git.branch") + "/lastSuccessfulBuild/api/xml?xpath=//master/buildNumber");
|
String buildXML = WebUtils.getBody("https://ci.nukkitx.com/job/GeyserMC/job/Geyser/job/" + URLEncoder.encode(gitProp.getProperty("git.branch"), StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber");
|
||||||
if (buildXML.startsWith("<buildNumber>")) {
|
if (buildXML.startsWith("<buildNumber>")) {
|
||||||
int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?buildNumber>", ""));
|
int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim());
|
||||||
int buildNum = Integer.parseInt(gitProp.getProperty("git.build.number"));
|
int buildNum = Integer.parseInt(gitProp.getProperty("git.build.number"));
|
||||||
if (latestBuildNum != buildNum) {
|
if (latestBuildNum != buildNum) {
|
||||||
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.commands.version.no_updates"));
|
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.commands.version.no_updates"));
|
||||||
@ -66,10 +69,11 @@ public class VersionCommand extends GeyserCommand {
|
|||||||
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.commands.version.outdated", (latestBuildNum - buildNum), "http://ci.geysermc.org/"));
|
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.commands.version.outdated", (latestBuildNum - buildNum), "http://ci.geysermc.org/"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError();
|
throw new AssertionError("buildNumber missing");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (IOException | AssertionError | NumberFormatException e) {
|
||||||
sender.sendMessage("Failed to check for updates");
|
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.commands.version.failed"), e);
|
||||||
|
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.commands.version.failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c199011b6c131b195e94d4785abbc3dd73ca19cd
|
Subproject commit fc8f930a238a375c7e3be6e5c7ea1720b61d0cca
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren