1.0.2
All checks were successful
ModUpdater/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-06-24 10:02:31 -04:00
parent 29f76f0881
commit c1e0737d70
8 changed files with 35 additions and 19 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
**1.0.2**
* Improve Errors
* Improve GUI
**1.0.1** **1.0.1**
* New Icon * New Icon

View File

@ -1,6 +1,8 @@
# ModUpdater # ModUpdater
A simple Minecraft mod updater. A simple Minecraft mod updater.
**NOTE:** This is only able to scan mods that have opted-in!
## Mod Users ## Mod Users
Go to the Mod Menu and click the configure icon for ModUpdater. Go to the Mod Menu and click the configure icon for ModUpdater.

View File

@ -9,7 +9,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.8.8+build.202 fabric_loader_version = 0.8.8+build.202
# Mod Properties # Mod Properties
mod_version = 1.0.1 mod_version = 1.0.2
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
# Dependencies # Dependencies

View File

@ -11,7 +11,7 @@ public class ModUpdater implements ModInitializer {
private static final String LOGGER_NAME = "ModUpdater"; private static final String LOGGER_NAME = "ModUpdater";
private static Logger getLogger() { public static Logger getLogger() {
return LogManager.getLogger(LOGGER_NAME); return LogManager.getLogger(LOGGER_NAME);
} }

View File

@ -33,13 +33,13 @@ public class ModUpdateScreen extends Screen {
int paddingX = 5; int paddingX = 5;
int doneX = width / 2 - buttonWidth - paddingX; int doneX = width / 2 - buttonWidth - paddingX;
int downloadX = width / 2 + paddingX; int downloadX = width / 2 + paddingX;
download = addButton(new ButtonWidget(downloadX, height - 38, buttonWidth, 20, new TranslatableText("gui." + ModUpdater.NAMESPACE + ".download"), buttonWidget -> { download = addButton(new ButtonWidget(downloadX, height - 30, buttonWidth, 20, new TranslatableText("gui." + ModUpdater.NAMESPACE + ".download"), buttonWidget -> {
if (list.getSelected() != null) { if (list.getSelected() != null) {
Util.getOperatingSystem().open(list.getSelected().update.downloadURL); Util.getOperatingSystem().open(list.getSelected().update.downloadURL);
} }
})); }));
download.active = false; download.active = false;
addButton(new ButtonWidget(doneX, height - 38, buttonWidth, 20, ScreenTexts.DONE, buttonWidget -> { addButton(new ButtonWidget(doneX, height - 30, buttonWidth, 20, ScreenTexts.DONE, buttonWidget -> {
assert client != null; assert client != null;
client.openScreen(parent); client.openScreen(parent);
})); }));
@ -58,7 +58,7 @@ public class ModUpdateScreen extends Screen {
private final ModUpdateScreen screen; private final ModUpdateScreen screen;
private ModUpdateListWidget(MinecraftClient client, ModUpdateScreen screen) { private ModUpdateListWidget(MinecraftClient client, ModUpdateScreen screen) {
super(client, screen.width, screen.height, 32, screen.height - 65 + 4, 18); super(client, screen.width, screen.height, 32, screen.height - 40, 18);
this.screen = screen; this.screen = screen;
for (ModUpdate update : ModUpdater.getUpdates()) { for (ModUpdate update : ModUpdater.getUpdates()) {
@ -68,12 +68,12 @@ public class ModUpdateScreen extends Screen {
@Override @Override
public int getRowWidth() { public int getRowWidth() {
return width - 20; return width - 40;
} }
@Override @Override
protected int getScrollbarPositionX() { protected int getScrollbarPositionX() {
return super.getScrollbarPositionX() + 30; return width - 14;
} }
private int getWidth() { private int getWidth() {
@ -116,7 +116,8 @@ public class ModUpdateScreen extends Screen {
@Override @Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
screen.textRenderer.drawWithShadow(matrices, update.text, (float) (parent.getWidth() / 2 - screen.textRenderer.getWidth(update.text) / 2), (float) (y + 1), 16777215, true); String text = screen.textRenderer.trimToWidth(update.text, parent.getRowWidth() - 6);
screen.textRenderer.drawWithShadow(matrices, text, (float) (parent.getWidth() / 2 - screen.textRenderer.getWidth(text) / 2), (float) (y + 3), 16777215, true);
} }
@Override @Override

View File

@ -41,7 +41,7 @@ class CurseForgeStrategy implements ModUpdateStrategy {
try { try {
files = jsonAdapter.fromJson(data); files = jsonAdapter.fromJson(data);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); ModUpdater.getLogger().warn("Unable To Access CurseForge: " + name);
return null; return null;
} }

View File

@ -38,7 +38,7 @@ public class MavenStrategy implements ModUpdateStrategy {
SAXReader reader = new SAXReader(); SAXReader reader = new SAXReader();
doc = reader.read(new URL(mavenRoot + "/maven-metadata.xml")); doc = reader.read(new URL(mavenRoot + "/maven-metadata.xml"));
} catch (MalformedURLException | DocumentException e) { } catch (MalformedURLException | DocumentException e) {
ModUpdater.invalidModUpdaterConfig(name); ModUpdater.getLogger().warn("Unable To Access Maven Repository: " + name);
return null; return null;
} }

View File

@ -5,15 +5,24 @@ import java.util.Map;
public class HardcodedData { public class HardcodedData {
public static ConfigObject getData(String modID) { public static ConfigObject getData(String modID) {
if ("fabric".equals(modID)) { switch (modID) {
case "fabric": {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("strategy", "maven"); map.put("strategy", "maven");
map.put("repository", "https://maven.fabricmc.net"); map.put("repository", "https://maven.fabricmc.net");
map.put("group", "net.fabricmc.fabric-api"); map.put("group", "net.fabricmc.fabric-api");
map.put("artifact", "fabric-api"); map.put("artifact", "fabric-api");
return new ConfigObject.ConfigObjectHardcoded(map); return new ConfigObject.ConfigObjectHardcoded(map);
} else { }
case "modmenu": {
Map<String, Object> map = new HashMap<>();
map.put("strategy", "curseforge");
map.put("projectID", 308702);
return new ConfigObject.ConfigObjectHardcoded(map);
}
default: {
return null; return null;
} }
} }
} }
}