forked from HMCL-dev/HMCL
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/prs-base' into prs
- Loading branch information
Showing
18 changed files
with
201 additions
and
199 deletions.
There are no files selected for viewing
This file contains 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
2 changes: 1 addition & 1 deletion
2
...t/burningtnt/hmclprs/impl/FinalValue.java → ...va/net/burningtnt/hmclprs/FinalValue.java
This file contains 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
145 changes: 0 additions & 145 deletions
145
HMCL/src/main/java/net/burningtnt/hmclprs/PRCollection.java
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
HMCL/src/main/java/net/burningtnt/hmclprs/hooks/EntryPoint.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
HMCL/src/main/java/net/burningtnt/hmclprs/hooks/PRCollectionBootstrap.java
This file contains 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,58 @@ | ||
package net.burningtnt.hmclprs.hooks; | ||
|
||
import net.burningtnt.hmclprs.Constants; | ||
import net.burningtnt.hmclprs.patch.Inject; | ||
import net.burningtnt.hmclprs.patch.Redirect; | ||
import net.burningtnt.hmclprs.patch.ValueMutation; | ||
|
||
import javax.swing.*; | ||
|
||
public final class PRCollectionBootstrap { | ||
private PRCollectionBootstrap() { | ||
} | ||
|
||
@Inject | ||
public static void onApplicationLaunch() { | ||
if (Constants.SHOULD_DISPLAY_LAUNCH_WARNING && JOptionPane.showConfirmDialog( | ||
null, Constants.getWarningBody(), Constants.getWarningTitle(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE | ||
) != JOptionPane.OK_OPTION) { | ||
System.exit(1); | ||
} | ||
} | ||
|
||
@ValueMutation | ||
public static String onInitApplicationName(String name) { | ||
return name + Constants.PR_COLLECTION_SUFFIX; | ||
} | ||
|
||
@ValueMutation | ||
public static String onInitApplicationFullName(String fullName) { | ||
Constants.DEFAULT_FULL_NAME.setValue(fullName); | ||
return fullName + Constants.PR_COLLECTION_SUFFIX; | ||
} | ||
|
||
@ValueMutation | ||
public static String onInitApplicationVersion(String version) { | ||
Constants.DEFAULT_VERSION.setValue(version); | ||
return version + Constants.PR_COLLECTION_SUFFIX; | ||
} | ||
|
||
@Redirect | ||
public static String onInitApplicationTitle() { | ||
return Constants.DEFAULT_FULL_NAME.getValue() + " v" + Constants.DEFAULT_VERSION.getValue() + Constants.PR_COLLECTION_SUFFIX; | ||
} | ||
|
||
@Redirect | ||
public static String onInitApplicationPublishURL() { | ||
return Constants.HOME_PAGE; | ||
} | ||
|
||
@Redirect | ||
public static String onInitApplicationDefaultUpdateLink() { | ||
return Constants.UPDATE_LINK; | ||
} | ||
|
||
@Inject | ||
public static void importRef(Class<?> clazz) { | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
HMCL/src/main/java/net/burningtnt/hmclprs/hooks/PRCollectionRuntime.java
This file contains 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,92 @@ | ||
package net.burningtnt.hmclprs.hooks; | ||
|
||
import javafx.collections.ObservableList; | ||
import javafx.scene.Node; | ||
import javafx.scene.layout.VBox; | ||
import net.burningtnt.hmclprs.Constants; | ||
import net.burningtnt.hmclprs.patch.Inject; | ||
import net.burningtnt.hmclprs.patch.Redirect; | ||
import net.burningtnt.hmclprs.patch.ValueMutation; | ||
import org.jackhuang.hmcl.task.FileDownloadTask; | ||
import org.jackhuang.hmcl.ui.animation.ContainerAnimations; | ||
import org.jackhuang.hmcl.ui.animation.TransitionPane; | ||
import org.jackhuang.hmcl.ui.construct.AnnouncementCard; | ||
import org.jackhuang.hmcl.upgrade.RemoteVersion; | ||
|
||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public final class PRCollectionRuntime { | ||
private PRCollectionRuntime() { | ||
} | ||
|
||
@Redirect | ||
public static String onGetApplicationRawVersion() { | ||
return Constants.DEFAULT_VERSION.getValue(); | ||
} | ||
|
||
@ValueMutation | ||
public static String onInitDisableSelfIntegrityCheckProperty(String value) { | ||
return value == null ? "true" : value; | ||
} | ||
|
||
@Redirect | ||
public static TransitionPane onBuildAnnouncementPane(ObservableList<Node> nodes) { | ||
if (!Constants.SHOULD_DISPLAY_LAUNCH_WARNING) { | ||
return null; | ||
} | ||
|
||
VBox box = new VBox(16); | ||
box.getChildren().add(new AnnouncementCard(Constants.getWarningTitle(), Constants.getWarningBody(), null)); | ||
|
||
TransitionPane pane = new TransitionPane(); | ||
pane.setContent(box, ContainerAnimations.NONE); | ||
|
||
nodes.add(pane); | ||
return pane; | ||
} | ||
|
||
@Redirect | ||
public static List<String> prepareFallbackURLs(RemoteVersion rv) { | ||
if (rv.getChannel() == null) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
return Arrays.stream(Constants.UPDATE_FALLBACKS).parallel().map(s -> { | ||
try { | ||
RemoteVersion r = RemoteVersion.fetch(null, s); | ||
FileDownloadTask.IntegrityCheck r1 = r.getIntegrityCheck(), r2 = rv.getIntegrityCheck(); | ||
if (!Objects.equals(r1.getAlgorithm(), r2.getAlgorithm()) || !Objects.equals(r1.getChecksum(), r2.getChecksum())) { | ||
return null; | ||
} | ||
|
||
return r.getUrl(); | ||
} catch (IOException e) { | ||
return null; | ||
} | ||
}).filter(Objects::nonNull).collect(Collectors.toList()); | ||
} | ||
|
||
@Redirect | ||
public static List<URL> onGetRemoteVersionUpdateLinks(RemoteVersion rv) { | ||
return Stream.concat(Stream.of(rv.getUrl()), rv.prc$fallbackURL.stream()).map(s -> { | ||
try { | ||
return new URL(s); | ||
} catch (MalformedURLException e) { | ||
return null; | ||
} | ||
}).filter(Objects::nonNull).collect(Collectors.toList()); | ||
} | ||
|
||
@Inject | ||
public static void onCreateUpgradeDialog() { | ||
throw new UnsupportedOperationException("UpdateDialog has been deprecated"); | ||
} | ||
} |
This file contains 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,9 @@ | ||
package net.burningtnt.hmclprs.patch; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Retention(RetentionPolicy.SOURCE) | ||
@Target(ElementType.METHOD) | ||
public @interface Inject { | ||
} |
9 changes: 9 additions & 0 deletions
9
HMCL/src/main/java/net/burningtnt/hmclprs/patch/Redirect.java
This file contains 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,9 @@ | ||
package net.burningtnt.hmclprs.patch; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Retention(RetentionPolicy.SOURCE) | ||
@Target(ElementType.METHOD) | ||
public @interface Redirect { | ||
} |
9 changes: 9 additions & 0 deletions
9
HMCL/src/main/java/net/burningtnt/hmclprs/patch/ValueMutation.java
This file contains 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,9 @@ | ||
package net.burningtnt.hmclprs.patch; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Retention(RetentionPolicy.SOURCE) | ||
@Target(ElementType.METHOD) | ||
public @interface ValueMutation { | ||
} |
Oops, something went wrong.