From 615db152ee07c6cbcde60659d016b848d9692cf6 Mon Sep 17 00:00:00 2001 From: Mgazul Date: Wed, 21 Aug 2024 00:37:25 +0800 Subject: [PATCH] Mohist libraries offline mode #3311 --- README.md | 6 +- build.gradle | 80 +++++++- gradle.properties | 5 +- mohistlauncher/build.gradle | 2 - .../main/java/com/mohistmc/MohistMCStart.java | 3 + .../java/com/mohistmc/action/ZipTree.java | 33 ++++ .../mohistmc/feature/DefaultLibraries.java | 9 - .../com/mohistmc/libraries/Libraries.java | 43 +++++ .../libraries/LibrariesDownloadQueue.java | 182 ++++++++++++++++++ .../java/com/mohistmc/util/JarManifests.java | 37 ++++ .../main/resources/lang/message.properties | 3 +- .../resources/lang/message_ru_RU.properties | 1 - .../resources/lang/message_zh_CN.properties | 3 +- .../resources/lang/message_zh_TW.properties | 2 +- .../src/main/resources/libraries.txt | 6 +- mohistplugins/src/main/resources/plugin.yml | 4 +- 16 files changed, 386 insertions(+), 33 deletions(-) create mode 100644 mohistlauncher/src/main/java/com/mohistmc/action/ZipTree.java create mode 100644 mohistlauncher/src/main/java/com/mohistmc/libraries/Libraries.java create mode 100644 mohistlauncher/src/main/java/com/mohistmc/libraries/LibrariesDownloadQueue.java create mode 100644 mohistlauncher/src/main/java/com/mohistmc/util/JarManifests.java diff --git a/README.md b/README.md index 33b06e725f..6fce5b43b2 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.codemc.io%2Fjob%2FMohistMC%2Fjob%2FMohist-1.20.1)](https://ci.codemc.io/job/MohistMC/job/Mohist-1.20.1) [![](https://img.shields.io/github/stars/MohistMC/Mohist.svg?label=Stars&logo=github)](https://github.com/MohistMC/Mohist/stargazers) -[![](https://img.shields.io/badge/Forge-1.20.1--47.3.5-brightgreen.svg?colorB=26303d&logo=Conda-Forge)](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.20.1.html) -[![](https://img.shields.io/badge/NeoForge-1.20.1--47.1.79-brightgreen.svg?colorB=26303d)](https://neoforged.net/) +[![](https://img.shields.io/badge/Forge-1.20.1--47.3.6-brightgreen.svg?colorB=26303d&logo=Conda-Forge)](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.20.1.html) +[![](https://img.shields.io/badge/NeoForge-1.20.1--47.1.106-brightgreen.svg?colorB=26303d)](https://neoforged.net/) [![](https://img.shields.io/badge/JDK-17.0.10-brightgreen.svg?colorB=469C00&logo=java)](https://www.azul.com/downloads/?version=java-17-lts#zulu) [![](https://img.shields.io/badge/Gradle-8.3-brightgreen.svg?colorB=469C00&logo=gradle)](https://docs.gradle.org/8.3/release-notes.html) [![](https://img.shields.io/bstats/servers/6762?label=bStats)](https://bstats.org/plugin/server-implementation/Mohist/6762) @@ -21,7 +21,7 @@ Progress ------ -- [x] Rectify Forge([**361e99805**](https://github.com/MinecraftForge/MinecraftForge/commit/361e99805)) +- [x] Rectify Forge([**25bc8679b**](https://github.com/MinecraftForge/MinecraftForge/commit/25bc8679b)) - [x] Rectify NeoForge([**e7ac32353**](https://github.com/neoforged/NeoForge/commit/e7ac32353)) - [x] Start patch * [x] Bukkit([**997de31d**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/997de31d)) diff --git a/build.gradle b/build.gradle index de2ac0adeb..5d339fa9a9 100644 --- a/build.gradle +++ b/build.gradle @@ -16,9 +16,9 @@ plugins { id 'com.github.ben-manes.versions' version '0.46.0' id 'net.minecraftforge.gradleutils' version '[2.2,2.3)' id 'eclipse' - id 'de.undercouch.download' version '5.4.0' - id 'net.minecraftforge.gradle.patcher' version '[6.0.11,6.2)' apply false - id 'net.minecraftforge.gradle.mcp' version '[6.0.11,6.2)' apply false + id 'de.undercouch.download' version '5.6.0' + id 'net.minecraftforge.gradle.patcher' version '[6.0.16,6.2)' apply false + id 'net.minecraftforge.gradle.mcp' version '[6.0.16,6.2)' apply false } init() //Init all our extension methods! @@ -152,6 +152,30 @@ project(':clean') { } } +def mohistDeps = { + mohist "com.nothome:javaxdelta:2.0.1" + mohist "com.github.jponge:lzma-java:1.3" + mohist "commons-collections:commons-collections:3.2.2" + mohist "com.opencsv:opencsv:4.4" + mohist "de.siegmar:fastcsv:2.0.0" + mohist "net.minecraftforge:installertools:1.4.1" + mohist 'net.minecraftforge:binarypatcher:1.1.1' + mohist "net.minecraftforge:JarJarFileSystems:0.3.19" + mohist "net.minecraftforge:ForgeAutoRenamingTool:0.1.22:all" + mohist "net.minecraftforge:srgutils:0.5.4" + mohist "net.minecraftforge:jarsplitter:1.1.4" + mohist 'com.google.errorprone:error_prone_annotations:2.1.3' + mohist 'org.apache.commons:commons-text:1.3' + mohist 'org.apache.commons:commons-collections4:4.2' + mohist 'commons-beanutils:commons-beanutils:1.9.3' + mohist "trove:trove:1.0.2" + mohist "org.codehaus.mojo:animal-sniffer-annotations:1.14" + mohist "com.google.j2objc:j2objc-annotations:1.1" + mohist "cpw.mods:bootstraplauncher:1.1.2" + mohist "com.google.code.findbugs:jsr305:3.0.2" + mohist 'org.checkerframework:checker-qual:2.0.0' +} + def sharedDeps = { moduleonly "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}" moduleonly "org.ow2.asm:asm:${ASM_VERSION}" @@ -162,7 +186,7 @@ def sharedDeps = { moduleonly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}" moduleonly "net.minecraftforge:JarJarFileSystems:${JARJAR_VERSION}" - installer "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}" + compileOnly "cpw.mods:securejarhandler:${SECUREJARHANDLER_VERSION}" // Mmohist TODO installer "org.ow2.asm:asm:${ASM_VERSION}" installer "org.ow2.asm:asm-commons:${ASM_VERSION}" installer "org.ow2.asm:asm-tree:${ASM_VERSION}" @@ -234,7 +258,6 @@ def sharedDeps = { installer "com.mohistmc:eventbus:${EVENTBUS_VERSION}" installer 'com.ibm.icu:icu4j:71.1' // Forge 1.20.1 - compileOnly 'me.clip:placeholderapi:2.11.5' installer 'com.google.guava:failureaccess:1.0.1' @@ -417,6 +440,10 @@ project(':mohist') { // Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it. transitive = false } + mohist { + // Don't pull all libraries, if we're missing something, add it to the installer list so the installer knows to download it. + transitive = false + } moduleonly api.extendsFrom(installer) } @@ -426,6 +453,13 @@ project(':mohist') { into 'libraries' } + task downloadMultipleFiles(type: Download) { + src([ + 'https://maven.mohistmc.com/libraries/1.20.1/mohist/libraries.zip' + ]) + dest layout.buildDirectory.dir("libraries") + } + dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' testImplementation 'org.junit.vintage:junit-vintage-engine:5.+' @@ -439,6 +473,7 @@ project(':mohist') { runtimeOnly "cpw.mods:bootstraplauncher:${BOOTSTRAPLAUNCHER_VERSION}" } dependencies sharedDeps + dependencies mohistDeps patcher { excs.from file("$rootDir/src/main/resources/forge.exc") @@ -541,7 +576,7 @@ project(':mohist') { 'Specification-Vendor' : 'SpigotMC', 'Specification-Version' : '1.20.1', 'Implementation-Title' : 'Spigot', - 'Implementation-Version': bukkit_version + '-' + craftbukkit_version + '-' + spigot_version + '-' + neoforge_version , + 'Implementation-Version': bukkit_version + '-' + craftbukkit_version + '-' + spigot_version + '-' + neoforge_version, 'Implementation-Vendor' : 'SpigotMC' ] as LinkedHashMap ] @@ -685,7 +720,29 @@ project(':mohist') { } } - task mohistJar(type: Jar, dependsOn: [genServerBinPatches, project(':mohistlauncher').tasks.jar]) { + task packageLibraries(type: Zip, dependsOn: [downloadMultipleFiles]) { + archiveFileName = 'libraries.zip' + destinationDirectory = file("build/distributions") + outputs.upToDateWhen { + false // TODO: Not 100% sure how to make this task re-run when libraries are changed... + } + + configurations.mohist.resolvedConfiguration.resolvedArtifacts.collect { + def moduleVersion = it.moduleVersion + from (it.file) { + into ("${moduleVersion.id.group.replace('.', '/')}/${moduleVersion.id.name}/${moduleVersion.id.version}/") + } + } + + configurations.installer.resolvedConfiguration.resolvedArtifacts.collect { + def moduleVersion = it.moduleVersion + from (it.file) { + into ("${moduleVersion.id.group.replace('.', '/')}/${moduleVersion.id.name}/${moduleVersion.id.version}/") + } + } + } + + task mohistJar(type: Jar, dependsOn: [packageLibraries, genServerBinPatches, project(':mohistlauncher').tasks.jar]) { archiveClassifier = 'server' archiveExtension = 'jar' archiveBaseName = 'mohist' @@ -697,6 +754,7 @@ project(':mohist') { 'libraries/' + getMavenPath(rootProject.tasks.findByPath(':fmlloader:jar')), "libraries/net/minecraft/server/${MC_VERSION}-${MCP_VERSION}/server-${MC_VERSION}-${MCP_VERSION}-extra.jar", "libraries/cpw/mods/bootstraplauncher/1.1.2/bootstraplauncher-1.1.2.jar", + "libraries/cpw/mods/securejarhandler/mohist-2.1.11/securejarhandler-mohist-2.1.11.jar", "libraries/net/minecraftforge/installertools/1.4.1/installertools-1.4.1.jar", "libraries/io/netty/netty-transport-native-epoll/4.1.82.Final/netty-transport-native-epoll-4.1.82.Final-linux-x86_64.jar", "libraries/io/netty/netty-transport-native-epoll/4.1.82.Final/netty-transport-native-epoll-4.1.82.Final-linux-aarch_64.jar" @@ -760,6 +818,14 @@ project(':mohist') { into "" } + from(zipTree(packageLibraries.outputs.getFiles().asPath)) { + into 'META-INF/libraries' + } + + from(zipTree(downloadMultipleFiles.outputs.getFiles().asPath)) { + into 'META-INF/libraries' + } + from(rootProject.file('server_files/version.txt')) { filter(ReplaceTokens, tokens: [VERSION: MOHIST_VERSION]) rename { 'versions/mohist.txt' } diff --git a/gradle.properties b/gradle.properties index de306e3204..85e223c75c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,8 +7,9 @@ org.gradle.daemon=false bukkit_version=997de31d craftbukkit_version=ddc9a2dad spigot_version=d2eba2c8 -forge_version=47.3.5 -neoforge_version=47.1.105 +forge_version=47.3.6 +neoforge_version=47.1.106 +mohist_group_id=com.mohistmc #systemProp.http.proxyHost=127.0.0.1 #systemProp.http.proxyPort=7890 diff --git a/mohistlauncher/build.gradle b/mohistlauncher/build.gradle index 60014261e4..9d1a883441 100644 --- a/mohistlauncher/build.gradle +++ b/mohistlauncher/build.gradle @@ -20,7 +20,6 @@ dependencies { implementation 'com.mohistmc:i18n:0.6' implementation 'com.mohistmc:json:0.5' implementation 'com.mohistmc:tools:0.5.1' - implementation 'com.mohistmc:libraries:0.5' implementation "cpw.mods:bootstraplauncher:1.1.2" implementation 'me.tongfei:progressbar:0.10.0' implementation 'org.jline:jline:3.25.1' @@ -32,7 +31,6 @@ shadowJar { include(dependency('com.mohistmc:i18n')) include(dependency('com.mohistmc:json')) include(dependency('com.mohistmc:tools')) - include(dependency('com.mohistmc:libraries')) include(dependency('me.tongfei:progressbar')) include(dependency('org.jline:jline')) } diff --git a/mohistlauncher/src/main/java/com/mohistmc/MohistMCStart.java b/mohistlauncher/src/main/java/com/mohistmc/MohistMCStart.java index 4bebfb2de2..1f2f1fc8fb 100644 --- a/mohistlauncher/src/main/java/com/mohistmc/MohistMCStart.java +++ b/mohistlauncher/src/main/java/com/mohistmc/MohistMCStart.java @@ -18,6 +18,7 @@ package com.mohistmc; +import com.mohistmc.action.ZipTree; import com.mohistmc.action.v_1_20_1; import com.mohistmc.config.MohistConfigUtil; import com.mohistmc.feature.AutoDeleteMods; @@ -77,6 +78,8 @@ public static void main(String[] args) throws Exception { UpdateUtils.versionCheck(); } + ZipTree.init(); + if (MohistConfigUtil.INSTALLATIONFINISHED() && MohistConfigUtil.CHECK_LIBRARIES()) { DefaultLibraries.run(); } diff --git a/mohistlauncher/src/main/java/com/mohistmc/action/ZipTree.java b/mohistlauncher/src/main/java/com/mohistmc/action/ZipTree.java new file mode 100644 index 0000000000..f55135d4d2 --- /dev/null +++ b/mohistlauncher/src/main/java/com/mohistmc/action/ZipTree.java @@ -0,0 +1,33 @@ +package com.mohistmc.action; + +import com.mohistmc.MohistMCStart; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class ZipTree { + + public static void init() throws IOException { + InputStream is = MohistMCStart.class.getClassLoader().getResourceAsStream("META-INF/libraries"); + getFileContent(is); + } + + public static void getFileContent(Object fileInPath) throws IOException { + BufferedReader br = null; + if (fileInPath == null) { + return; + } + if (fileInPath instanceof String) { + br = new BufferedReader(new FileReader((String) fileInPath)); + } else if (fileInPath instanceof InputStream) { + br = new BufferedReader(new InputStreamReader((InputStream) fileInPath)); + } + String line; + while ((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + } +} diff --git a/mohistlauncher/src/main/java/com/mohistmc/feature/DefaultLibraries.java b/mohistlauncher/src/main/java/com/mohistmc/feature/DefaultLibraries.java index 8e2ee208b1..6ecb8866af 100644 --- a/mohistlauncher/src/main/java/com/mohistmc/feature/DefaultLibraries.java +++ b/mohistlauncher/src/main/java/com/mohistmc/feature/DefaultLibraries.java @@ -31,21 +31,12 @@ public class DefaultLibraries { public static void run() { - String config = MohistConfigUtil.LIBRARIES_DOWNLOADSOURCE(); - String ds = System.getProperty("downloadsource") == null ? config : System.getProperty("downloadsource"); - String downloadSource = config; - if (!Objects.equals(config, ds) && ConnectionUtil.isValid(ds)) { - downloadSource = ds; - } - LibrariesDownloadQueue queue = LibrariesDownloadQueue.create() .inputStream(DefaultLibraries.class.getClassLoader().getResourceAsStream("libraries.txt")) - .downloadSource(downloadSource) .build(); System.out.println(I18n.as("libraries.checking.start")); if (queue.needDownload()) { - System.out.println(I18n.as("libraries.downloadsource", queue.downloadSource.name())); System.out.println(I18n.as("libraries.global.percentage")); queue.progressBar(); for (Libraries libraries : queue.need_download) { diff --git a/mohistlauncher/src/main/java/com/mohistmc/libraries/Libraries.java b/mohistlauncher/src/main/java/com/mohistmc/libraries/Libraries.java new file mode 100644 index 0000000000..d811084f51 --- /dev/null +++ b/mohistlauncher/src/main/java/com/mohistmc/libraries/Libraries.java @@ -0,0 +1,43 @@ +/* + * Mohist - MohistMC + * Copyright (C) 2018-2024. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.mohistmc.libraries; + +import com.mohistmc.tools.MD5Util; +import java.io.File; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Libraries { + + String path; + String md5; + long size; + boolean installer; + + public static Libraries from(String line) { + String[] parts = line.split("\\|"); + return new Libraries(parts[0], parts[1], Long.parseLong(parts[2]), Boolean.parseBoolean(parts[3])); + } + + public static Libraries from(File file) { + return new Libraries(file.getAbsolutePath(), MD5Util.get(file), file.length(), false); + } +} diff --git a/mohistlauncher/src/main/java/com/mohistmc/libraries/LibrariesDownloadQueue.java b/mohistlauncher/src/main/java/com/mohistmc/libraries/LibrariesDownloadQueue.java new file mode 100644 index 0000000000..79f4aab3bd --- /dev/null +++ b/mohistlauncher/src/main/java/com/mohistmc/libraries/LibrariesDownloadQueue.java @@ -0,0 +1,182 @@ +/* + * Mohist - MohistMC + * Copyright (C) 2018-2024. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.mohistmc.libraries; + +import com.mohistmc.MohistMCStart; +import com.mohistmc.tools.ConnectionUtil; +import com.mohistmc.tools.FileUtils; +import com.mohistmc.tools.MD5Util; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import lombok.ToString; +import me.tongfei.progressbar.ProgressBar; +import me.tongfei.progressbar.ProgressBarBuilder; +import me.tongfei.progressbar.ProgressBarStyle; + +@ToString +public class LibrariesDownloadQueue { + + @ToString.Exclude + public final Set allLibraries = new HashSet<>(); + @ToString.Exclude + private final Set fail = new HashSet<>(); + @ToString.Exclude + public InputStream inputStream = null; + @ToString.Exclude + public Set need_download = new LinkedHashSet<>(); + @ToString.Exclude + public Set installer = new LinkedHashSet<>(); + public List installerTourls = new ArrayList<>(); + + public String parentDirectory = "libraries"; + public String systemProperty = null; + public boolean debug = false; + + + public static LibrariesDownloadQueue create() { + return new LibrariesDownloadQueue(); + } + + /** + * Set the input stream for the list that needs to be downloaded + * + * @param inputStream The input stream of the target file + * @return Returns the current real column + */ + public LibrariesDownloadQueue inputStream(InputStream inputStream) { + this.inputStream = inputStream; + return this; + } + + /** + * Set the file download directory + * + * @param parentDirectory The path to which the file is downloaded + * @return Returns the current real column + */ + public LibrariesDownloadQueue parentDirectory(String parentDirectory) { + this.parentDirectory = parentDirectory; + return this; + } + + /** + * Construct the final column + * + * @return Construct the final column + */ + public LibrariesDownloadQueue build() { + init(); + return this; + } + + /** + * Download in the form of a progress bar + */ + public void progressBar() { + if (needDownload()) { + ProgressBarBuilder builder = new ProgressBarBuilder().setTaskName("") + .setStyle(ProgressBarStyle.ASCII) + .setUpdateIntervalMillis(100) + .setInitialMax(need_download.size()); + try (ProgressBar pb = builder.build()) { + for (Libraries lib : need_download) { + File file = new File(parentDirectory, lib.path); + file.getParentFile().mkdirs(); + String url = "META-INF/" + file.getPath(); + if (copyFileFromJar(file, url.replaceAll("\\\\", "/"), lib)) { + debug("downloadFile: OK"); + fail.remove(lib); + } else { + debug("downloadFile: No " + url); + fail.add(lib); + } + pb.step(); + } + } + } + if (!fail.isEmpty()) { + progressBar(); + } + } + + protected boolean copyFileFromJar(File file, String pathInJar, Libraries lib) { + InputStream is = MohistMCStart.class.getClassLoader().getResourceAsStream(pathInJar); + + if (!file.exists() || !MD5Util.get(file).equals(lib.getMd5()) || file.length() <= 1) { + file.getParentFile().mkdirs(); + if (is != null) { + try { + file.createNewFile(); + Files.copy(is, file.toPath(), StandardCopyOption.REPLACE_EXISTING); + return true; + } catch (IOException ignored) { + } + } else { + System.out.println("[Mohist] The file " + file.getPath()+ " doesn't exists in the Mohist jar !"); + return false; + } + } + return true; + } + + public boolean needDownload() { + for (Libraries libraries : allLibraries) { + File lib = new File(parentDirectory, libraries.path); + if (lib.exists() && Objects.equals(MD5Util.get(lib), libraries.md5)) { + continue; + } + need_download.add(libraries); + } + return !need_download.isEmpty(); + } + + private void init() { + try { + BufferedReader b = new BufferedReader(new InputStreamReader(inputStream)); + for (String line = b.readLine(); line != null; line = b.readLine()) { + Libraries libraries = Libraries.from(line); + allLibraries.add(libraries); + if (libraries.isInstaller()) { + File file = new File(parentDirectory, libraries.getPath()); + URL url = file.toURI().toURL(); + installer.add(libraries); + installerTourls.add(url); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void debug(String log) { + if (debug) System.out.println(log + "\n"); + } +} diff --git a/mohistlauncher/src/main/java/com/mohistmc/util/JarManifests.java b/mohistlauncher/src/main/java/com/mohistmc/util/JarManifests.java new file mode 100644 index 0000000000..4939025c3a --- /dev/null +++ b/mohistlauncher/src/main/java/com/mohistmc/util/JarManifests.java @@ -0,0 +1,37 @@ +package com.mohistmc.util; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Collections; +import java.util.Map; +import java.util.WeakHashMap; +import java.util.jar.Manifest; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +@ApiStatus.Internal +public final class JarManifests { + private JarManifests() { + } + + private static final Map MANIFESTS = Collections.synchronizedMap(new WeakHashMap<>()); + + public static @Nullable Manifest manifest(final @NotNull Class clazz) { + return MANIFESTS.computeIfAbsent(clazz.getClassLoader(), classLoader -> { + final String classLocation = "/" + clazz.getName().replace(".", "/") + ".class"; + final URL resource = clazz.getResource(classLocation); + if (resource == null) { + return null; + } + final String classFilePath = resource.toString().replace("\\", "/"); + final String archivePath = classFilePath.substring(0, classFilePath.length() - classLocation.length()); + try (final InputStream stream = new URL(archivePath + "/META-INF/MANIFEST.MF").openStream()) { + return new Manifest(stream); + } catch (final IOException ex) { + return null; + } + }); + } +} diff --git a/mohistlauncher/src/main/resources/lang/message.properties b/mohistlauncher/src/main/resources/lang/message.properties index ab814b044f..53803342b2 100644 --- a/mohistlauncher/src/main/resources/lang/message.properties +++ b/mohistlauncher/src/main/resources/lang/message.properties @@ -1,5 +1,4 @@ libraries.checking.start=Checking libraries, please wait... -libraries.downloadsource=DownloadSource: %s libraries.check.end=All libraries are nice :)! download.file=Downloading file %s with size %s download.file.ok=Download finished for %s ! @@ -12,7 +11,7 @@ installation.finished=Finished the installation verification process! eula=You need to agree to the EULA to continue launching the server. Enter 'true' to agree eula_notrue=Invalid input, please enter 'true'. eula.text=By changing the setting below to true you are indicating your agreement to our EULA (%s). -libraries.global.percentage=Download percentage: +libraries.global.percentage=Complete progress: update.check=Update in check... update.stopcheck=If you don't want to enable update check, set check_update in mohist-config/mohist.yml to false update.latest=No update found, latest version: (%s) current version: (%s) diff --git a/mohistlauncher/src/main/resources/lang/message_ru_RU.properties b/mohistlauncher/src/main/resources/lang/message_ru_RU.properties index 19334f6f6b..2a63cd0868 100644 --- a/mohistlauncher/src/main/resources/lang/message_ru_RU.properties +++ b/mohistlauncher/src/main/resources/lang/message_ru_RU.properties @@ -11,7 +11,6 @@ installation.finished=Процесс проверки установки зав eula=Вы должны согласиться с Пользовательским Соглашением, чтобы запустить сервер. Введите true чтобы продолжить. eula.text=Заменой этого параметра вы подтверждаете своё согласие с нашим Пользовательским Соглашением (%s). update.check=Проверка обновлений... -libraries.global.percentage=download percentage: update.stopcheck=Если вы хотите отключить проверку обновлений, то установите check_update в файле banner-config/banner.yml на false update.latest=Обновление не найдено, последняя версия: (%s) текущая версия: (%s) update.detect=Последняя версия banner - %s, а у вас %s. Последняя версия была собрана %s. Вам следует обновиться, чтобы исправить последние ошибки! diff --git a/mohistlauncher/src/main/resources/lang/message_zh_CN.properties b/mohistlauncher/src/main/resources/lang/message_zh_CN.properties index d4e9fcc5a0..88804309ce 100644 --- a/mohistlauncher/src/main/resources/lang/message_zh_CN.properties +++ b/mohistlauncher/src/main/resources/lang/message_zh_CN.properties @@ -1,5 +1,4 @@ libraries.checking.start=检查库文件中,请稍等... -libraries.downloadsource=下载源: %s libraries.check.end=库文件检查完成,未发现问题 :) download.file=下载文件 %s ,大小 %s download.file.ok=下载文件 %s 完成 @@ -12,7 +11,7 @@ installation.finished=安装验证已完成! eula=你需要同意EULA才能继续启动服务器。输入'true'同意 eula_notrue=输入无效,请输入'true'。 eula.text=将下面的值改为“true”即代表你同意EULA(%s) -libraries.global.percentage=下载进度: +libraries.global.percentage=补全进度: update.check=检查更新中... update.stopcheck=如果不想启用更新检查,在mohist-config/mohist.yml中设置“check_update”为“false” update.latest=未发现更新。最新版本:(%s),当前版本:(%s) diff --git a/mohistlauncher/src/main/resources/lang/message_zh_TW.properties b/mohistlauncher/src/main/resources/lang/message_zh_TW.properties index 828d417bda..deabac62e3 100644 --- a/mohistlauncher/src/main/resources/lang/message_zh_TW.properties +++ b/mohistlauncher/src/main/resources/lang/message_zh_TW.properties @@ -10,7 +10,7 @@ installation.mcpfilemissing=[Mohist] 無法完成安裝:MCP配置文件不存 installation.finished=安裝驗證已完成! eula=你需要同意EULA才能繼續啟動服務器。輸入“true”同意 eula.text=將下面的值改為“true”即代表你同意EULA(%s) -libraries.global.percentage=下載進度: +libraries.global.percentage=補全進度: update.check=檢查更新中... update.stopcheck=如果不想啟用更新檢查,在mohist-config/mohist.yml中設置“check_update”為“false” update.latest=未發現更新。最新版本:(%s),當前版本:(%s) diff --git a/mohistlauncher/src/main/resources/libraries.txt b/mohistlauncher/src/main/resources/libraries.txt index 32e0f34f96..32c32802a3 100644 --- a/mohistlauncher/src/main/resources/libraries.txt +++ b/mohistlauncher/src/main/resources/libraries.txt @@ -19,7 +19,7 @@ com/opencsv/opencsv/4.4/opencsv-4.4.jar|0a370fa0055d9d2840599332bd5cbf47|167167| commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3.jar|4a105c9d029a7edc6f2b16567d37eab6|246174|false commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar|f54a8510f834a1a57166970bfc982e94|588337|false commons-io/commons-io/2.11.0/commons-io-2.11.0.jar|3b4b7ccfaeceeac240b804839ee1a1ca|327135|true -commons-lang/commons-lang/2.6-mohist/commons-lang-2.6-mohist.jar|755f5cdb5de00d072215340e8370daff|280341|false +commons-lang/commons-lang/2.6-mohist/commons-lang-2.6-mohist.jar|e261ab6b71d587e735053eeaf5c2c7dc|280341|false commons-logging/commons-logging/1.2/commons-logging-1.2.jar|040b4b4d8eac886f6b4a2a3bd2f31b00|61829|false commons-codec/commons-codec/1.16.0/commons-codec-1.16.0.jar|6e26920fa7228891980890cce06b718c|360738|false cpw/mods/bootstraplauncher/1.1.2/bootstraplauncher-1.1.2.jar|48f5255aa337344c467c0150d347813d|8284|false @@ -43,10 +43,10 @@ jline/jline/2.14.6/jline-2.14.6.jar|480423551649bc6980b43f09e4717272|268780|fals net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar|bd2e5bc6b4b020c2d9a6e17a8e9bcef1|1879325|false net/java/dev/jna/jna-platform/5.13.0/jna-platform-5.13.0.jar|7cc7af47ad1f151faa57ef0624b2f271|1363209|false net/jodah/typetools/0.6.3/typetools-0.6.3.jar|d4a375bf382f726cf1a650ccb38a736c|18281|false -net/md-5/bungeecord-chat/1.20-R0.1/bungeecord-chat-1.20-R0.1.jar|3cb2b3d6961602639dd16c7e9356f652|148951|false +net/md-5/bungeecord-chat/1.20-R0.1/bungeecord-chat-1.20-R0.1.jar|24d8090241f49602bd924e2f4e7eca05|148951|false net/md-5/SpecialSource/1.11.2/SpecialSource-1.11.2.jar|adcca168c7f61188d6bf90c809d6eef1|89094|false net/minecraft/server/1.20.1/server-1.20.1.jar|308f4d8ff0c2019bccba141616e10c32|47791053|false -net/minecraft/server/1.20.1-20230612.114412/server-1.20.1-20230612.114412-mappings.txt|5e3c901c75851369f7034bc796df8f69|6154194|false +net/minecraft/server/1.20.1-20230612.114412/server-1.20.1-20230612.114412-mappings.txt|8fbaeb28c33dee3cc751d29c461aea0b|6154194|false net/minecraftforge/accesstransformers/8.0.4/accesstransformers-8.0.4.jar|f0d3533f9437ba4428eaee9f28f7ecd9|77756|false net/minecraftforge/binarypatcher/1.1.1/binarypatcher-1.1.1.jar|499620533414c0aa11c105615f3cf7f6|21892|true net/minecraftforge/coremods/5.1.6/coremods-5.1.6.jar|4b4fe7e512819804660d621bf11c7381|24124|false diff --git a/mohistplugins/src/main/resources/plugin.yml b/mohistplugins/src/main/resources/plugin.yml index c616f07ee0..f9a171a5af 100644 --- a/mohistplugins/src/main/resources/plugin.yml +++ b/mohistplugins/src/main/resources/plugin.yml @@ -1,4 +1,6 @@ name: Mohist version: 1.20.1 main: com.mohistmc.plugins.Main -api-version: "1.20" \ No newline at end of file +api-version: "1.20" + +softdepend: [PlaceholderAPI] \ No newline at end of file