Compare commits
8 Commits
1.1.8+1.16
...
master
Author | SHA1 | Date |
---|---|---|
TheBrokenRail | 0bc2eb8b07 | |
TheBrokenRail | 37fe78675e | |
TheBrokenRail | 64d94e4d68 | |
Samekichi | a58350f0ce | |
TheBrokenRail | 0a2afee6ee | |
TheBrokenRail | 47ac38726f | |
Guntram Blohm | bed078867d | |
TheBrokenRail | 1d4494d905 |
|
@ -1,5 +1,14 @@
|
|||
# Changelog
|
||||
|
||||
**1.1.11**
|
||||
* Add Translations
|
||||
|
||||
**1.1.10**
|
||||
* Improve
|
||||
|
||||
**1.1.9**
|
||||
* Add ```modupdater``` Entry-Point
|
||||
|
||||
**1.1.8**
|
||||
* Strict Minecraft Version Checking by Default
|
||||
* Print Message To Log Showing All Scanned Mods
|
||||
|
|
|
@ -15,5 +15,18 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
stage('Publish') {
|
||||
when {
|
||||
expression {
|
||||
return sh(returnStdout: true, script: 'git tag --contains').trim().length() > 0
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh './gradlew publish'
|
||||
withCredentials([string(credentialsId: 'curseforge_key', variable: 'CURSEFORGE_KEY')]) {
|
||||
sh './gradlew -Pcurseforge.api_key="${CURSEFORGE_KEY}" curseforge'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,4 +124,16 @@ In strict mode it only marks a file as compatibleif the Minecraft version is ide
|
|||
}
|
||||
}
|
||||
```
|
||||
In loose mode, it will also mark a file as compatible if it has the same release target.
|
||||
In loose mode, it will also mark a file as compatible if it has the same release target.
|
||||
|
||||
## Custom Version Compatibility Checking
|
||||
You can also specify the ```modupdater``` entry-point as a ```ModUpdaterEntryPoint``` to check if a version is compatible with the current MC version.
|
||||
```gradle
|
||||
repositories {
|
||||
maven { url 'https://maven.thebrokenrail.com' }
|
||||
}
|
||||
dependencies {
|
||||
modCompileOnly 'com.thebrokenrail:modupdater:VERSION'
|
||||
// VERSION = "<Mod Version>+<MC Version>", for example "1.2.4+20w12a"
|
||||
}
|
||||
```
|
16
build.gradle
16
build.gradle
|
@ -1,6 +1,7 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '0.4-SNAPSHOT'
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
compileJava {
|
||||
|
@ -99,4 +100,19 @@ if (project.hasProperty('curseforge.api_key')) {
|
|||
forgeGradleIntegration = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url '/data/maven'
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,17 +2,17 @@
|
|||
org.gradle.jvmargs = -Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
minecraft_version = 1.16.1
|
||||
minecraft_version = 1.16.2-rc2
|
||||
curseforge_id = 391583
|
||||
simple_minecraft_version = 1.16.1
|
||||
simple_minecraft_version = 1.16.2
|
||||
yarn_build = 1
|
||||
fabric_loader_version = 0.8.8+build.202
|
||||
fabric_loader_version = 0.9.1+build.205
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.1.8
|
||||
mod_version = 1.1.11
|
||||
maven_group = com.thebrokenrail
|
||||
|
||||
# Dependencies
|
||||
fabric_api_version = 0.13.1+build.370-1.16
|
||||
modmenu_version = 1.12.2+build.16
|
||||
fabric_api_version = 0.17.2+build.396-1.16
|
||||
modmenu_version = 1.14.6+build.31
|
||||
moshi_version = 1.9.2
|
||||
|
|
|
@ -6,7 +6,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
public interface UpdateStrategy {
|
||||
@Nullable
|
||||
ModUpdate run(ConfigObject obj, String oldVersion, String name);
|
||||
ModUpdate run(ConfigObject obj, String oldVersion, String name, String id);
|
||||
|
||||
default boolean isStrict(ConfigObject obj) {
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package com.thebrokenrail.modupdater.api.entrypoint;
|
||||
|
||||
public interface ModUpdaterEntryPoint {
|
||||
boolean isVersionCompatible(String version);
|
||||
}
|
|
@ -26,7 +26,7 @@ public class ModUpdaterCommand {
|
|||
ModUpdate[] updates = ModUpdater.getUpdates();
|
||||
assert updates != null;
|
||||
for (ModUpdate update : updates) {
|
||||
context.getSource().sendFeedback(new LiteralText(update.text).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, update.downloadURL)).setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands." + ModUpdater.NAMESPACE + ".hover")))), false);
|
||||
context.getSource().sendFeedback(new LiteralText(update.text).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, update.downloadURL)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("commands." + ModUpdater.NAMESPACE + ".hover")))), false);
|
||||
}
|
||||
return updates.length;
|
||||
}))
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.thebrokenrail.modupdater.api.UpdateStrategy;
|
|||
import com.thebrokenrail.modupdater.data.ModUpdate;
|
||||
import com.thebrokenrail.modupdater.util.Util;
|
||||
import net.fabricmc.loader.api.SemanticVersion;
|
||||
import net.fabricmc.loader.util.version.VersionParsingException;
|
||||
import net.fabricmc.loader.api.VersionParsingException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
@ -33,7 +33,7 @@ public class CurseForgeStrategy implements UpdateStrategy {
|
|||
|
||||
@Override
|
||||
@Nullable
|
||||
public ModUpdate run(ConfigObject obj, String oldVersion, String name) {
|
||||
public ModUpdate run(ConfigObject obj, String oldVersion, String name, String id) {
|
||||
int projectID;
|
||||
try {
|
||||
projectID = obj.getInt("projectID");
|
||||
|
@ -65,7 +65,7 @@ public class CurseForgeStrategy implements UpdateStrategy {
|
|||
String versionStr;
|
||||
GameVersion version = Util.getMinecraftVersion();
|
||||
if (version.isStable()) {
|
||||
versionStr = version.getName();
|
||||
versionStr = version.getId();
|
||||
} else {
|
||||
versionStr = version.getReleaseTarget() + "-Snapshot";
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class CurseForgeStrategy implements UpdateStrategy {
|
|||
for (CurseForgeFile file : files) {
|
||||
if (Util.isFileCompatible(file.fileName)) {
|
||||
String fileVersion = Util.getVersionFromFileName(file.fileName);
|
||||
if ((Arrays.asList(file.gameVersion).contains(versionStr) && strict) || Util.isVersionCompatible(fileVersion, strict)) {
|
||||
if ((Arrays.asList(file.gameVersion).contains(versionStr) && !strict) || Util.isVersionCompatible(id, fileVersion, strict)) {
|
||||
if (newestFile != null) {
|
||||
String newestFileVersion = Util.getVersionFromFileName(newestFile.fileName);
|
||||
try {
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.thebrokenrail.modupdater.api.UpdateStrategy;
|
|||
import com.thebrokenrail.modupdater.data.ModUpdate;
|
||||
import com.thebrokenrail.modupdater.util.Util;
|
||||
import net.fabricmc.loader.api.SemanticVersion;
|
||||
import net.fabricmc.loader.util.version.VersionParsingException;
|
||||
import net.fabricmc.loader.api.VersionParsingException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
@ -35,7 +35,7 @@ public class GitHubReleasesStrategy implements UpdateStrategy {
|
|||
|
||||
@Override
|
||||
@Nullable
|
||||
public ModUpdate run(ConfigObject obj, String oldVersion, String name) {
|
||||
public ModUpdate run(ConfigObject obj, String oldVersion, String name, String id) {
|
||||
String owner;
|
||||
String repo;
|
||||
try {
|
||||
|
@ -73,7 +73,7 @@ public class GitHubReleasesStrategy implements UpdateStrategy {
|
|||
for (GitHubReleaseAsset asset : release.assets) {
|
||||
if (Util.isFileCompatible(asset.name)) {
|
||||
String fileVersion = Util.getVersionFromFileName(asset.name);
|
||||
if (Util.isVersionCompatible(fileVersion, strict)) {
|
||||
if (Util.isVersionCompatible(id, fileVersion, strict)) {
|
||||
if (newestFile != null) {
|
||||
try {
|
||||
if (SemanticVersion.parse(fileVersion).compareTo(SemanticVersion.parse(fileVersion)) > 0) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public class JSONStrategy implements UpdateStrategy {
|
|||
|
||||
@Override
|
||||
@Nullable
|
||||
public ModUpdate run(ConfigObject obj, String oldVersion, String name) {
|
||||
public ModUpdate run(ConfigObject obj, String oldVersion, String name, String id) {
|
||||
String url;
|
||||
try {
|
||||
url = obj.getString("url");
|
||||
|
@ -61,7 +61,7 @@ public class JSONStrategy implements UpdateStrategy {
|
|||
return null;
|
||||
}
|
||||
|
||||
String version = Util.getMinecraftVersion().getName();
|
||||
String version = Util.getMinecraftVersion().getId();
|
||||
if (map.containsKey(version)) {
|
||||
LatestVersionEntry entry = map.get(version);
|
||||
if (!oldVersion.equals(entry.version)) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.thebrokenrail.modupdater.api.UpdateStrategy;
|
|||
import com.thebrokenrail.modupdater.data.ModUpdate;
|
||||
import com.thebrokenrail.modupdater.util.Util;
|
||||
import net.fabricmc.loader.api.SemanticVersion;
|
||||
import net.fabricmc.loader.util.version.VersionParsingException;
|
||||
import net.fabricmc.loader.api.VersionParsingException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
@ -40,7 +40,7 @@ public class MavenStrategy implements UpdateStrategy {
|
|||
|
||||
@Override
|
||||
@Nullable
|
||||
public ModUpdate run(ConfigObject obj, String oldVersion, String name) {
|
||||
public ModUpdate run(ConfigObject obj, String oldVersion, String name, String id) {
|
||||
String repository;
|
||||
String group;
|
||||
String artifact;
|
||||
|
@ -87,7 +87,7 @@ public class MavenStrategy implements UpdateStrategy {
|
|||
Node node = versions.item(i);
|
||||
|
||||
String version = node.getTextContent();
|
||||
if (Util.isVersionCompatible(version, strict)) {
|
||||
if (Util.isVersionCompatible(id, version, strict)) {
|
||||
if (newestVersion != null) {
|
||||
try {
|
||||
if (SemanticVersion.parse(version).compareTo(SemanticVersion.parse(newestVersion)) > 0) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class UpdateStrategyRunner {
|
|||
|
||||
scan.accept(name);
|
||||
|
||||
return strategyObj.run(obj, oldVersion, name);
|
||||
return strategyObj.run(obj, oldVersion, name, metadata.getId());
|
||||
}
|
||||
|
||||
public static ModUpdate[] checkAllModsForUpdates() {
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.thebrokenrail.modupdater.util;
|
||||
|
||||
import com.mojang.bridge.game.GameVersion;
|
||||
import com.thebrokenrail.modupdater.ModUpdater;
|
||||
import com.thebrokenrail.modupdater.api.ConfigObject;
|
||||
import com.thebrokenrail.modupdater.api.entrypoint.ModUpdaterEntryPoint;
|
||||
import com.thebrokenrail.modupdater.api.impl.ConfigObjectHardcoded;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
|
||||
import net.minecraft.MinecraftVersion;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -12,6 +15,7 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -71,16 +75,23 @@ public class Util {
|
|||
if (parts.length > 1) {
|
||||
return String.format("%s.%s", parts[0], parts[1]);
|
||||
} else {
|
||||
return minecraftVersion.getName();
|
||||
return minecraftVersion.getId();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isVersionCompatible(String versionStr, char prefix, boolean strict) {
|
||||
updateMinecraftVersion();
|
||||
return versionStr.endsWith(prefix + minecraftVersionSemantic) || versionStr.endsWith(prefix + minecraftVersion.getName()) || (!strict && (versionStr.endsWith(prefix + minecraftVersion.getReleaseTarget()) || versionStr.endsWith(prefix + getMajorVersion())));
|
||||
return versionStr.endsWith(prefix + minecraftVersionSemantic) || versionStr.endsWith(prefix + minecraftVersion.getId()) || (!strict && (versionStr.endsWith(prefix + minecraftVersion.getReleaseTarget()) || versionStr.endsWith(prefix + getMajorVersion())));
|
||||
}
|
||||
|
||||
public static boolean isVersionCompatible(String versionStr, boolean strict) {
|
||||
public static boolean isVersionCompatible(String id, String versionStr, boolean strict) {
|
||||
List<EntrypointContainer<ModUpdaterEntryPoint>> list = FabricLoader.getInstance().getEntrypointContainers(ModUpdater.NAMESPACE, ModUpdaterEntryPoint.class);
|
||||
for (EntrypointContainer<ModUpdaterEntryPoint> container : list) {
|
||||
if (container.getProvider().getMetadata().getId().equals(id)) {
|
||||
return container.getEntrypoint().isVersionCompatible(versionStr);
|
||||
}
|
||||
}
|
||||
|
||||
return isVersionCompatible(versionStr, '+', strict) || isVersionCompatible(versionStr, '-', strict);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"gui.modupdater.title": "可用的模组更新",
|
||||
"gui.modupdater.download": "下载",
|
||||
"gui.modupdater.refresh": "刷新",
|
||||
"gui.modupdater.loading": "加载中...",
|
||||
"commands.modupdater.not_loaded": "模组更新加载时无法进行其它操作",
|
||||
"commands.modupdater.refresh_start": "刷新模组更新列表中",
|
||||
"commands.modupdater.hover": "点击下载",
|
||||
"commands.modupdater.list_title": "可用的模组更新:"
|
||||
}
|
Reference in New Issue