-
Notifications
You must be signed in to change notification settings - Fork 27
Add DayZ workshop mod updates #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JustABiologist
wants to merge
4
commits into
Osiris-Team:master
Choose a base branch
from
JustABiologist:bounty/dayz-mod-update-215
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
92d094e
Add DayZ workshop mod updates
JustABiologist b6604e2
Generalize Steam Workshop mod updater
JustABiologist 39f93ce
Integrate Steam Workshop mods into updater flow
JustABiologist 2c6f735
Check Steam Workshop metadata before updating mods
JustABiologist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModDownloadTask.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright (c) 2024 Osiris-Team. | ||
| * All rights reserved. | ||
| * | ||
| * This software is copyrighted work, licensed under the terms | ||
| * of the MIT-License. Consult the "LICENSE" file for details. | ||
| */ | ||
|
|
||
| package com.osiris.autoplug.client.tasks.updater.mods; | ||
|
|
||
| import com.osiris.autoplug.client.tasks.updater.search.SearchResult; | ||
|
|
||
| interface ModDownloadTask { | ||
| void start(); | ||
|
|
||
| boolean isAlive(); | ||
|
|
||
| String getPlName(); | ||
|
|
||
| SearchResult getSearchResult(); | ||
|
|
||
| boolean isDownloadSuccessful(); | ||
|
|
||
| boolean isInstallSuccessful(); | ||
| } |
102 changes: 102 additions & 0 deletions
102
src/main/java/com/osiris/autoplug/client/tasks/updater/mods/SteamWorkshopMod.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* | ||
| * Copyright (c) 2024 Osiris-Team. | ||
| * All rights reserved. | ||
| * | ||
| * This software is copyrighted work, licensed under the terms | ||
| * of the MIT-License. Consult the "LICENSE" file for details. | ||
| */ | ||
|
|
||
| package com.osiris.autoplug.client.tasks.updater.mods; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileNotFoundException; | ||
| import java.io.IOException; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.nio.file.Files; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Comparator; | ||
| import java.util.List; | ||
|
|
||
| public class SteamWorkshopMod extends MinecraftMod { | ||
| private final File directory; | ||
| private String publishedId; | ||
| private final String timestamp; | ||
|
|
||
| public SteamWorkshopMod(File directory, String name, String publishedId) { | ||
| this(directory, name, publishedId, null); | ||
| } | ||
|
|
||
| public SteamWorkshopMod(File directory, String name, String publishedId, String timestamp) { | ||
| super(directory.getAbsolutePath(), name, timestamp != null ? timestamp : publishedId, "Steam Workshop", null, null, null); | ||
| this.directory = directory; | ||
| this.publishedId = publishedId; | ||
| this.timestamp = timestamp; | ||
| } | ||
|
|
||
| public File getDirectory() { | ||
| return directory; | ||
| } | ||
|
|
||
| public String getPublishedId() { | ||
| return publishedId; | ||
| } | ||
|
|
||
| public void setPublishedId(String publishedId) { | ||
| this.publishedId = publishedId; | ||
| if (getVersion() == null) | ||
| setVersion(publishedId); | ||
| } | ||
|
|
||
| public String getTimestamp() { | ||
| return timestamp; | ||
| } | ||
|
|
||
| @NotNull | ||
| public static List<SteamWorkshopMod> findIn(File dir) throws IOException { | ||
| if (!dir.exists()) throw new FileNotFoundException("Directory does not exist: " + dir); | ||
| List<SteamWorkshopMod> mods = new ArrayList<>(); | ||
| File[] files = dir.listFiles(); | ||
| if (files == null) return mods; | ||
| Arrays.sort(files, Comparator.comparing(File::getName)); | ||
| for (File file : files) { | ||
| if (!file.isDirectory()) continue; | ||
| File metaFile = new File(file, "meta.cpp"); | ||
| if (metaFile.exists()) | ||
| mods.add(readFromMeta(file, metaFile)); | ||
| } | ||
| return mods; | ||
| } | ||
|
|
||
| static SteamWorkshopMod readFromMeta(File modDir, File metaFile) throws IOException { | ||
| String name = modDir.getName(); | ||
| String publishedId = null; | ||
| String timestamp = null; | ||
| for (String line : Files.readAllLines(metaFile.toPath(), StandardCharsets.UTF_8)) { | ||
| String trimmedLine = line.trim(); | ||
| if (trimmedLine.isEmpty() || trimmedLine.startsWith("//")) continue; | ||
|
|
||
| int equalsIndex = trimmedLine.indexOf('='); | ||
| if (equalsIndex < 0) continue; | ||
|
|
||
| String key = trimmedLine.substring(0, equalsIndex).trim(); | ||
| String value = trimmedLine.substring(equalsIndex + 1).trim(); | ||
| int semicolonIndex = value.indexOf(';'); | ||
| if (semicolonIndex < 0) continue; | ||
| value = value.substring(0, semicolonIndex).trim(); | ||
| if (value.startsWith("\"") && value.endsWith("\"") && value.length() >= 2) | ||
| value = value.substring(1, value.length() - 1); | ||
|
|
||
| if (key.equals("name")) name = value; | ||
| if (key.equals("publishedid")) publishedId = value; | ||
| if (key.equals("timestamp")) timestamp = value; | ||
| } | ||
|
|
||
| if (publishedId == null || !publishedId.matches("\\d+")) | ||
| throw new IOException("Failed to read publishedid from " + metaFile); | ||
|
|
||
| return new SteamWorkshopMod(modDir, name, publishedId, timestamp); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need to move this block into the loop below