mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-10-16 16:04:32 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b3370739a5 | ||
|
ecc6f0440a | ||
|
92b44352b3 | ||
|
1d5a787b02 | ||
|
b5983800e8 | ||
|
4b3c279e71 | ||
|
b413371306 | ||
|
1d2ec61232 |
30
.gitignore
vendored
30
.gitignore
vendored
@@ -1,9 +1,9 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/java,gradle,intellij
|
||||
# Edit at https://www.gitignore.io/?templates=java,gradle,intellij
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/java,gradle,intellij+all
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=java,gradle,intellij+all
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
### Intellij+all ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
@@ -33,6 +33,9 @@
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
@@ -72,13 +75,18 @@ fabric.properties
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### Intellij Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
### Intellij+all Patch ###
|
||||
# Ignores the whole .idea folder and all .iml files
|
||||
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
.idea/
|
||||
|
||||
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
|
||||
|
||||
*.iml
|
||||
modules.xml
|
||||
.idea/misc.xml
|
||||
*.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
.idea/sonarlint
|
||||
@@ -127,4 +135,4 @@ gradle-app.setting
|
||||
### Gradle Patch ###
|
||||
**/build/
|
||||
|
||||
# End of https://www.gitignore.io/api/java,gradle,intellij
|
||||
# End of https://www.toptal.com/developers/gitignore/api/java,gradle,intellij+all
|
||||
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
5
.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
36
.idea/inspectionProfiles/Project_Default.xml
generated
36
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,36 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="INNER_CLASS_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="METHOD_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="FIELD_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="IGNORE_DEPRECATED" value="false" />
|
||||
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||
<option name="myAdditionalJavadocTags" value="wbp.parser.entryPoint" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
20
.idea/jarRepositories.xml
generated
20
.idea/jarRepositories.xml
generated
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
10
.idea/misc.xml
generated
10
.idea/misc.xml
generated
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="com.google.gson.annotations.SerializedName" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
||||
</project>
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@@ -1,2 +1,2 @@
|
||||
# packwiz-installer
|
||||
An installer for launching packwiz modpacks with MultiMC.
|
||||
An installer for launching packwiz modpacks with MultiMC. You'll need [the bootstrapper](https://github.com/comp500/packwiz-installer-bootstrap/releases) to actually use this.
|
||||
|
@@ -1,3 +1,5 @@
|
||||
@file:JvmName("Main")
|
||||
|
||||
package link.infra.packwiz.installer
|
||||
|
||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
|
||||
@@ -16,6 +18,9 @@ import kotlin.system.exitProcess
|
||||
|
||||
@Suppress("unused")
|
||||
class Main(args: Array<String>) {
|
||||
// Don't attempt to start a GUI if we are headless
|
||||
var guiEnabled = !GraphicsEnvironment.isHeadless()
|
||||
|
||||
private fun startup(args: Array<String>) {
|
||||
val options = Options()
|
||||
addNonBootstrapOptions(options)
|
||||
@@ -26,19 +31,24 @@ class Main(args: Array<String>) {
|
||||
parser.parse(options, args)
|
||||
} catch (e: ParseException) {
|
||||
e.printStackTrace()
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
|
||||
} catch (e1: Exception) {
|
||||
// Ignore the exceptions, just continue using the ugly L&F
|
||||
if (guiEnabled) {
|
||||
EventQueue.invokeAndWait {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
|
||||
} catch (ignored: Exception) {
|
||||
// Ignore the exceptions, just continue using the ugly L&F
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, e.message, "packwiz-installer", JOptionPane.ERROR_MESSAGE)
|
||||
}
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, e.message, "packwiz-installer", JOptionPane.ERROR_MESSAGE)
|
||||
exitProcess(1)
|
||||
}
|
||||
|
||||
// if "headless", GUI creation will fail anyway!
|
||||
val ui = if (cmd.hasOption("no-gui") || GraphicsEnvironment.isHeadless()) {
|
||||
CLIHandler()
|
||||
} else InstallWindow()
|
||||
if (guiEnabled && cmd.hasOption("no-gui")) {
|
||||
guiEnabled = false
|
||||
}
|
||||
|
||||
val ui = if (guiEnabled) InstallWindow() else CLIHandler()
|
||||
|
||||
val unparsedArgs = cmd.args
|
||||
if (unparsedArgs.size > 1) {
|
||||
@@ -47,15 +57,13 @@ class Main(args: Array<String>) {
|
||||
ui.handleExceptionAndExit(RuntimeException("URI to install from must be specified!"))
|
||||
}
|
||||
|
||||
cmd.getOptionValue("title")?.also {
|
||||
ui.setTitle(it)
|
||||
}
|
||||
cmd.getOptionValue("title")?.also(ui::setTitle)
|
||||
|
||||
val inputStateHandler = InputStateHandler()
|
||||
ui.show(inputStateHandler)
|
||||
|
||||
val uOptions = UpdateManager.Options().apply {
|
||||
side = cmd.getOptionValue("side")?.let { UpdateManager.Options.Side.from(it) } ?: side
|
||||
side = cmd.getOptionValue("side")?.let((UpdateManager.Options.Side)::from) ?: side
|
||||
packFolder = cmd.getOptionValue("pack-folder") ?: packFolder
|
||||
manifestFile = cmd.getOptionValue("meta-file") ?: manifestFile
|
||||
}
|
||||
@@ -84,6 +92,7 @@ class Main(args: Array<String>) {
|
||||
|
||||
companion object {
|
||||
// Called by packwiz-installer-bootstrap to set up the help command
|
||||
@JvmStatic
|
||||
fun addNonBootstrapOptions(options: Options) {
|
||||
options.addOption("s", "side", true, "Side to install mods from (client/server, defaults to client)")
|
||||
options.addOption(null, "title", true, "Title of the installer window")
|
||||
@@ -92,6 +101,7 @@ class Main(args: Array<String>) {
|
||||
}
|
||||
|
||||
// TODO: link these somehow so they're only defined once?
|
||||
@JvmStatic
|
||||
private fun addBootstrapOptions(options: Options) {
|
||||
options.addOption(null, "bootstrap-update-url", true, "Github API URL for checking for updates")
|
||||
options.addOption(null, "bootstrap-update-token", true, "Github API Access Token, for private repositories")
|
||||
@@ -109,11 +119,13 @@ class Main(args: Array<String>) {
|
||||
startup(args)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
EventQueue.invokeLater {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
if (guiEnabled) {
|
||||
EventQueue.invokeLater {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"A fatal error occurred: \n" + e.javaClass.canonicalName + ": " + e.message,
|
||||
"packwiz-installer", JOptionPane.ERROR_MESSAGE)
|
||||
exitProcess(1)
|
||||
exitProcess(1)
|
||||
}
|
||||
}
|
||||
// In case the EventQueue is broken, exit after 1 minute
|
||||
Thread.sleep(60 * 1000.toLong())
|
||||
|
@@ -126,7 +126,6 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
|
||||
|
||||
ui.submitProgress(InstallProgress("Loading pack file..."))
|
||||
val packFileSource = try {
|
||||
Objects.requireNonNull(opts.downloadURI)
|
||||
val src = getFileSource(opts.downloadURI!!)
|
||||
getHasher("sha256").getHashingSource(src)
|
||||
} catch (e: Exception) {
|
||||
@@ -191,12 +190,16 @@ class UpdateManager internal constructor(private val opts: Options, val ui: IUse
|
||||
handleCancellation()
|
||||
}
|
||||
try {
|
||||
// This is badly written, I'll probably heavily refactor it at some point
|
||||
// The port to Kotlin made this REALLY messy!!!!
|
||||
getNewLoc(opts.downloadURI, Objects.requireNonNull(pf.index)!!.file)?.let {
|
||||
pf.index!!.hashFormat?.let { it1 ->
|
||||
processIndex(it,
|
||||
getHash(Objects.requireNonNull(pf.index!!.hashFormat)!!, Objects.requireNonNull(pf.index!!.hash)!!), it1, manifest, invalidatedUris)
|
||||
val index = pf.index!!
|
||||
getNewLoc(opts.downloadURI, index.file)?.let { newLoc ->
|
||||
index.hashFormat?.let { hashFormat ->
|
||||
processIndex(
|
||||
newLoc,
|
||||
getHash(index.hashFormat!!, index.hash!!),
|
||||
hashFormat,
|
||||
manifest,
|
||||
invalidatedUris
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (e1: Exception) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package link.infra.packwiz.installer.request
|
||||
|
||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
|
||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerFile
|
||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerGithub
|
||||
import link.infra.packwiz.installer.request.handlers.RequestHandlerHTTP
|
||||
import okio.Source
|
||||
@@ -9,7 +10,8 @@ object HandlerManager {
|
||||
|
||||
private val handlers: List<IRequestHandler> = listOf(
|
||||
RequestHandlerGithub(),
|
||||
RequestHandlerHTTP()
|
||||
RequestHandlerHTTP(),
|
||||
RequestHandlerFile()
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
@@ -0,0 +1,18 @@
|
||||
package link.infra.packwiz.installer.request.handlers
|
||||
|
||||
import link.infra.packwiz.installer.metadata.SpaceSafeURI
|
||||
import link.infra.packwiz.installer.request.IRequestHandler
|
||||
import okio.Source
|
||||
import okio.source
|
||||
import java.nio.file.Paths
|
||||
|
||||
open class RequestHandlerFile : IRequestHandler {
|
||||
override fun matchesHandler(loc: SpaceSafeURI): Boolean {
|
||||
return "file" == loc.scheme
|
||||
}
|
||||
|
||||
override fun getFileSource(loc: SpaceSafeURI): Source? {
|
||||
val path = Paths.get(loc.toURL().toURI())
|
||||
return path.source()
|
||||
}
|
||||
}
|
@@ -65,7 +65,7 @@ class RequestHandlerGithub : RequestHandlerZip(true) {
|
||||
if (!("http" == scheme || "https" == scheme)) {
|
||||
return false
|
||||
}
|
||||
return "github.com" == loc.host
|
||||
// TODO: sanity checks, support for more github urls
|
||||
// TODO: more match testing?
|
||||
return "github.com" == loc.host && branchMatcherPattern.matcher(loc.path).matches()
|
||||
}
|
||||
}
|
@@ -10,10 +10,10 @@ import javax.swing.border.EmptyBorder
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class InstallWindow : IUserInterface {
|
||||
private val frmPackwizlauncher: JFrame
|
||||
private val lblProgresslabel: JLabel
|
||||
private val progressBar: JProgressBar
|
||||
private val btnOptions: JButton
|
||||
private lateinit var frmPackwizlauncher: JFrame
|
||||
private lateinit var lblProgresslabel: JLabel
|
||||
private lateinit var progressBar: JProgressBar
|
||||
private lateinit var btnOptions: JButton
|
||||
|
||||
private var inputStateHandler: InputStateHandler? = null
|
||||
private var title = "Updating modpack..."
|
||||
@@ -23,55 +23,57 @@ class InstallWindow : IUserInterface {
|
||||
// TODO: separate JFrame junk from IUserInterface junk?
|
||||
|
||||
init {
|
||||
frmPackwizlauncher = JFrame().apply {
|
||||
title = this@InstallWindow.title
|
||||
setBounds(100, 100, 493, 95)
|
||||
defaultCloseOperation = JFrame.EXIT_ON_CLOSE
|
||||
setLocationRelativeTo(null)
|
||||
EventQueue.invokeAndWait {
|
||||
frmPackwizlauncher = JFrame().apply {
|
||||
title = this@InstallWindow.title
|
||||
setBounds(100, 100, 493, 95)
|
||||
defaultCloseOperation = JFrame.EXIT_ON_CLOSE
|
||||
setLocationRelativeTo(null)
|
||||
|
||||
// Progress bar and loading text
|
||||
add(JPanel().apply {
|
||||
border = EmptyBorder(10, 10, 10, 10)
|
||||
layout = BorderLayout(0, 0)
|
||||
// Progress bar and loading text
|
||||
add(JPanel().apply {
|
||||
border = EmptyBorder(10, 10, 10, 10)
|
||||
layout = BorderLayout(0, 0)
|
||||
|
||||
progressBar = JProgressBar().apply {
|
||||
isIndeterminate = true
|
||||
}
|
||||
add(progressBar, BorderLayout.CENTER)
|
||||
|
||||
lblProgresslabel = JLabel("Loading...")
|
||||
add(lblProgresslabel, BorderLayout.SOUTH)
|
||||
}, BorderLayout.CENTER)
|
||||
|
||||
// Buttons
|
||||
add(JPanel().apply {
|
||||
border = EmptyBorder(0, 5, 0, 5)
|
||||
layout = GridBagLayout()
|
||||
|
||||
btnOptions = JButton("Optional mods...").apply {
|
||||
alignmentX = Component.CENTER_ALIGNMENT
|
||||
|
||||
addActionListener {
|
||||
text = "Loading..."
|
||||
isEnabled = false
|
||||
inputStateHandler?.pressOptionsButton()
|
||||
progressBar = JProgressBar().apply {
|
||||
isIndeterminate = true
|
||||
}
|
||||
}
|
||||
add(btnOptions, GridBagConstraints().apply {
|
||||
gridx = 0
|
||||
gridy = 0
|
||||
})
|
||||
add(progressBar, BorderLayout.CENTER)
|
||||
|
||||
add(JButton("Cancel").apply {
|
||||
addActionListener {
|
||||
isEnabled = false
|
||||
inputStateHandler?.pressCancelButton()
|
||||
lblProgresslabel = JLabel("Loading...")
|
||||
add(lblProgresslabel, BorderLayout.SOUTH)
|
||||
}, BorderLayout.CENTER)
|
||||
|
||||
// Buttons
|
||||
add(JPanel().apply {
|
||||
border = EmptyBorder(0, 5, 0, 5)
|
||||
layout = GridBagLayout()
|
||||
|
||||
btnOptions = JButton("Optional mods...").apply {
|
||||
alignmentX = Component.CENTER_ALIGNMENT
|
||||
|
||||
addActionListener {
|
||||
text = "Loading..."
|
||||
isEnabled = false
|
||||
inputStateHandler?.pressOptionsButton()
|
||||
}
|
||||
}
|
||||
}, GridBagConstraints().apply {
|
||||
gridx = 0
|
||||
gridy = 1
|
||||
})
|
||||
}, BorderLayout.EAST)
|
||||
add(btnOptions, GridBagConstraints().apply {
|
||||
gridx = 0
|
||||
gridy = 0
|
||||
})
|
||||
|
||||
add(JButton("Cancel").apply {
|
||||
addActionListener {
|
||||
isEnabled = false
|
||||
inputStateHandler?.pressCancelButton()
|
||||
}
|
||||
}, GridBagConstraints().apply {
|
||||
gridx = 0
|
||||
gridy = 1
|
||||
})
|
||||
}, BorderLayout.EAST)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user