checkstyle
This commit is contained in:
1 parent
e8a6d48e65
commit
da44e9eb6c
25 files changed
+322
-98
No files matched your search
@@ -16,4 +16,5 @@
|
||||
!/LICENSE
|
||||
!/README.md
|
||||
!/settings.gradle
|
||||
!/checkstyle.xml
|
||||
!/.editorconfig
|
||||
@@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id "checkstyle"
|
||||
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||
id "org.cadixdev.licenser" version "0.6.0"
|
||||
id "de.undercouch.download" version "4.1.1"
|
||||
@@ -33,6 +34,11 @@ tasks.withType(JavaCompile).configureEach {
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
configFile = project.file("checkstyle.xml")
|
||||
toolVersion = "8.45"
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': 'FabricInstaller',
|
||||
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
|
||||
<module name="Checker">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="fileExtensions" value="java"/>
|
||||
<property name="localeLanguage" value="en"/>
|
||||
<property name="localeCountry" value="US"/>
|
||||
<property name="tabWidth" value="4"/>
|
||||
|
||||
<module name="NewlineAtEndOfFile"/>
|
||||
|
||||
<!-- disallow trailing whitespace -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\s+$"/>
|
||||
<property name="message" value="trailing whitespace"/>
|
||||
</module>
|
||||
|
||||
<!-- note: RegexpMultiline shows nicer messages than Regexp, but has to be outside TreeWalker -->
|
||||
<!-- disallow multiple consecutive blank lines -->
|
||||
<module name="RegexpMultiline">
|
||||
<property name="format" value="\n[\t ]*\r?\n[\t ]*\r?\n"/>
|
||||
<property name="message" value="adjacent blank lines"/>
|
||||
</module>
|
||||
|
||||
<!-- disallow blank after { -->
|
||||
<module name="RegexpMultiline">
|
||||
<property name="format" value="\{[\t ]*\r?\n[\t ]*\r?\n"/>
|
||||
<property name="message" value="blank line after '{'"/>
|
||||
</module>
|
||||
|
||||
<!-- disallow blank before } -->
|
||||
<module name="RegexpMultiline">
|
||||
<property name="format" value="\n[\t ]*\r?\n[\t ]*\}"/>
|
||||
<property name="message" value="blank line before '}'"/>
|
||||
</module>
|
||||
|
||||
<!-- require blank before { in the same indentation level -->
|
||||
<module name="RegexpMultiline">
|
||||
<!-- the regex works as follows:
|
||||
It matches (=fails) for \n<indentation><something>\n<same indentation><control statement>[...]{\n
|
||||
while <something> is a single line comment, it'll look for a blank line one line earlier
|
||||
if <something> is a space, indicating a formatting error or ' */', it'll ignore the instance
|
||||
if <something> is a tab, indicating a continued line, it'll ignore the instance
|
||||
<control statement> is 'if', 'do', 'while', 'for', 'try' or nothing (instance initializer block)
|
||||
- first \n: with positive lookbehind (?<=\n) to move the error marker to a more reasonable place
|
||||
- capture tabs for <indentation>, later referenced via \1
|
||||
- remaining preceding line as a non-comment (doesn't start with '/', '//', ' ' or '\t') or multiple lines where all but the first are a single line comment with the same indentation
|
||||
- new line
|
||||
- <indentation> as captured earlier
|
||||
- <control statement> as specified above
|
||||
- { before the next new line -->
|
||||
<property name="format" value="(?<=\n)([\t]+)(?:[^/\r\n \t][^\r\n]*|/[^/\r\n][^\r\n]*|[^/\r\n][^\r\n]*(\r?\n\1//[^\r\n]*)+)\r?\n\1(|(if|do|while|for|try)[^\r\n]+)\{[\t ]*\r?\n"/>
|
||||
<property name="message" value="missing blank line before block at same indentation level"/>
|
||||
</module>
|
||||
|
||||
<!-- require blank after } in the same indentation level -->
|
||||
<module name="RegexpMultiline">
|
||||
<!-- \n<indentation>}\n<same indentation><whatever unless newline, '}' or starting with cas(e) or def(ault)> -->
|
||||
<property name="format" value="(?<=\n)([\t]+)\}\r?\n\1(?:[^\r\n\}cd]|c[^\r\na]|ca[^\r\ns]|d[^\r\ne]|de[^\r\nf])"/>
|
||||
<property name="message" value="missing blank line after block at same indentation level"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<!-- Ensure all imports are ship shape -->
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="IllegalImport"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports"/>
|
||||
|
||||
<module name="ImportOrder">
|
||||
<property name="groups" value="java,javax,*,net.minecraft,net.fabricmc"/>
|
||||
<property name="ordered" value="false"/><!-- the plugin orders alphabetically without considering separators.. -->
|
||||
<property name="separated" value="true"/>
|
||||
<property name="option" value="top"/>
|
||||
<property name="sortStaticImportsAlphabetically" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Ensures braces are at the end of a line -->
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
|
||||
<!-- single line statements on one line, -->
|
||||
<module name="NeedBraces">
|
||||
<property name="tokens" value="LITERAL_IF,LITERAL_FOR,LITERAL_WHILE"/>
|
||||
<property name="allowSingleLineStatement" value="true"/>
|
||||
</module>
|
||||
<module name="NeedBraces">
|
||||
<property name="tokens" value="LITERAL_ELSE,LITERAL_DO"/>
|
||||
<property name="allowSingleLineStatement" value="false"/>
|
||||
</module>
|
||||
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
<property name="allowMultipleEmptyLines" value="false"/>
|
||||
<!-- exclude METHOD_DEF and VARIABLE_DEF -->
|
||||
<property name="tokens" value="PACKAGE_DEF,IMPORT,STATIC_IMPORT,CLASS_DEF,INTERFACE_DEF,ENUM_DEF,STATIC_INIT,INSTANCE_INIT,CTOR_DEF"/>
|
||||
</module>
|
||||
|
||||
<module name="OperatorWrap"/>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="tokens" value="DOT,ELLIPSIS,AT"/>
|
||||
<property name="option" value="nl"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="tokens" value="COMMA,SEMI"/>
|
||||
<property name="option" value="eol"/>
|
||||
</module>
|
||||
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="caseIndent" value="0"/>
|
||||
<property name="throwsIndent" value="4"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
<property name="lineWrappingIndentation" value="8"/>
|
||||
</module>
|
||||
|
||||
<module name="ParenPad"/>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="NoWhitespaceAfter">
|
||||
<!-- allow ARRAY_INIT -->
|
||||
<property name="tokens" value="AT,INC,DEC,UNARY_MINUS,UNARY_PLUS,BNOT,LNOT,DOT,ARRAY_DECLARATOR,INDEX_OP"/>
|
||||
</module>
|
||||
<module name="WhitespaceAfter"/>
|
||||
<module name="WhitespaceAround">
|
||||
<!-- Allow PLUS, MINUS, MUL, DIV as they may be more readable without spaces in some cases -->
|
||||
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV_ASSIGN,DO_WHILE,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND"/>
|
||||
</module>
|
||||
<module name="SingleSpaceSeparator"/>
|
||||
<module name="GenericWhitespace"/>
|
||||
<module name="CommentsIndentation"/>
|
||||
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="DefaultComesLast">
|
||||
<property name="skipIfLastAndSharedWithCase" value="true"/>
|
||||
</module>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
<module name="StringLiteralEquality"/>
|
||||
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="RedundantModifier"/>
|
||||
|
||||
<module name="AnnotationLocation"/>
|
||||
<module name="MissingOverride"/>
|
||||
|
||||
<!-- By default this allows catch blocks with only comments -->
|
||||
<module name="EmptyCatchBlock"/>
|
||||
|
||||
<!-- Enforce tabs -->
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="^\t* ([^*]|\*[^ /])"/>
|
||||
<property name="message" value="non-tab indentation"/>
|
||||
</module>
|
||||
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="PackageDeclaration"/>
|
||||
<module name="PackageName"/>
|
||||
|
||||
<!--<module name="InvalidJavadocPosition"/>-->
|
||||
<module name="JavadocParagraph"/>
|
||||
<module name="JavadocStyle"/>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="tagOrder" value="@param,@return,@throws,@deprecated"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
@@ -42,7 +42,6 @@ import net.fabricmc.installer.util.MetaHandler;
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
public abstract class Handler implements InstallerProgress {
|
||||
|
||||
public JButton buttonInstall;
|
||||
|
||||
public JComboBox<String> gameVersionComboBox;
|
||||
@@ -121,17 +120,21 @@ public abstract class Handler implements InstallerProgress {
|
||||
|
||||
Main.LOADER_META.onComplete(versions -> {
|
||||
int stableIndex = -1;
|
||||
|
||||
for (int i = 0; i < versions.size(); i++) {
|
||||
MetaHandler.GameVersion version = versions.get(i);
|
||||
loaderVersionComboBox.addItem(version.getVersion());
|
||||
|
||||
if (version.isStable()) {
|
||||
stableIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
//If no stable versions are found, default to the latest version
|
||||
if (stableIndex == -1) {
|
||||
stableIndex = 0;
|
||||
}
|
||||
|
||||
loaderVersionComboBox.setSelectedIndex(stableIndex);
|
||||
statusLabel.setText(Utils.BUNDLE.getString("prompt.ready.install"));
|
||||
});
|
||||
@@ -141,12 +144,15 @@ public abstract class Handler implements InstallerProgress {
|
||||
|
||||
private void updateGameVersions() {
|
||||
gameVersionComboBox.removeAllItems();
|
||||
|
||||
for (MetaHandler.GameVersion version : Main.GAME_VERSION_META.getVersions()) {
|
||||
if (!snapshotCheckBox.isSelected() && !version.isStable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
gameVersionComboBox.addItem(version.getVersion());
|
||||
}
|
||||
|
||||
gameVersionComboBox.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
@@ -163,7 +169,7 @@ public abstract class Handler implements InstallerProgress {
|
||||
return String.format(
|
||||
"font-family:%s;font-weight:%s;font-size:%dpt;background-color: rgb(%d,%d,%d);",
|
||||
font.getFamily(), (font.isBold() ? "bold" : "normal"), font.getSize(), color.getRed(), color.getGreen(), color.getBlue()
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,7 +197,7 @@ public abstract class Handler implements InstallerProgress {
|
||||
textPane,
|
||||
Utils.BUNDLE.getString("prompt.exception.occurrence"),
|
||||
JOptionPane.ERROR_MESSAGE
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
protected void addRow(Container parent, Consumer<JPanel> consumer) {
|
||||
@@ -203,11 +209,13 @@ public abstract class Handler implements InstallerProgress {
|
||||
protected String getGameVersion(ArgumentParser args) {
|
||||
return args.getOrDefault("mcversion", () -> {
|
||||
System.out.println("Using latest game version");
|
||||
|
||||
try {
|
||||
Main.GAME_VERSION_META.load();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to load latest versions", e);
|
||||
}
|
||||
|
||||
return Main.GAME_VERSION_META.getLatestVersion(args.has("snapshot")).getVersion();
|
||||
});
|
||||
}
|
||||
@@ -215,13 +223,14 @@ public abstract class Handler implements InstallerProgress {
|
||||
protected String getLoaderVersion(ArgumentParser args) {
|
||||
return args.getOrDefault("loader", () -> {
|
||||
System.out.println("Using latest loader version");
|
||||
|
||||
try {
|
||||
Main.LOADER_META.load();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to load latest versions", e);
|
||||
}
|
||||
|
||||
return Main.LOADER_META.getLatestVersion(false).getVersion();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,19 +16,24 @@
|
||||
|
||||
package net.fabricmc.installer;
|
||||
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import java.awt.*;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class InstallerGui extends JFrame {
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
public class InstallerGui extends JFrame {
|
||||
public static InstallerGui instance;
|
||||
|
||||
private JTabbedPane contentPane;
|
||||
@@ -71,5 +76,4 @@ public class InstallerGui extends JFrame {
|
||||
contentPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
Main.HANDLERS.forEach(handler -> contentPane.addTab(Utils.BUNDLE.getString("tab." + handler.name().toLowerCase(Locale.ROOT)), handler.makePanel(this)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
package net.fabricmc.installer;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.fabricmc.installer.client.ClientHandler;
|
||||
import net.fabricmc.installer.server.ServerHandler;
|
||||
import net.fabricmc.installer.util.ArgumentParser;
|
||||
@@ -23,13 +28,7 @@ import net.fabricmc.installer.util.CrashDialog;
|
||||
import net.fabricmc.installer.util.MetaHandler;
|
||||
import net.fabricmc.installer.util.Reference;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static MetaHandler GAME_VERSION_META;
|
||||
public static MetaHandler LOADER_META;
|
||||
|
||||
@@ -51,14 +50,14 @@ public class Main {
|
||||
LOADER_META = new MetaHandler(Reference.getMetaServerEndpoint("v2/versions/loader"));
|
||||
|
||||
//Default to the help command in a headless environment
|
||||
if(GraphicsEnvironment.isHeadless() && command == null){
|
||||
if (GraphicsEnvironment.isHeadless() && command == null) {
|
||||
command = "help";
|
||||
}
|
||||
|
||||
if (command == null) {
|
||||
try {
|
||||
InstallerGui.start();
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
new CrashDialog(e);
|
||||
}
|
||||
@@ -78,12 +77,13 @@ public class Main {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to install " + handler.name(), e);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Only reached if a handler is not found
|
||||
System.out.println("No handler found for " + args[0] + " see help");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ public final class ServerLauncher {
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
LaunchData launchData;
|
||||
|
||||
try {
|
||||
launchData = initialise();
|
||||
} catch (IOException e) {
|
||||
@@ -157,7 +158,7 @@ public final class ServerLauncher {
|
||||
final Path launchJar;
|
||||
final String mainClass;
|
||||
|
||||
public LaunchData(Path serverJar, Path launchJar, String mainClass) {
|
||||
private LaunchData(Path serverJar, Path launchJar, String mainClass) {
|
||||
this.serverJar = Objects.requireNonNull(serverJar, "serverJar");
|
||||
this.launchJar = Objects.requireNonNull(launchJar, "launchJar");
|
||||
this.mainClass = Objects.requireNonNull(mainClass, "mainClass");
|
||||
|
||||
@@ -38,7 +38,6 @@ import net.fabricmc.installer.util.Reference;
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
public class ClientHandler extends Handler {
|
||||
|
||||
private JCheckBox createProfile;
|
||||
|
||||
@Override
|
||||
@@ -51,21 +50,27 @@ public class ClientHandler extends Handler {
|
||||
String gameVersion = (String) gameVersionComboBox.getSelectedItem();
|
||||
String loaderVersion = (String) loaderVersionComboBox.getSelectedItem();
|
||||
System.out.println("Installing");
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
updateProgress(new MessageFormat(Utils.BUNDLE.getString("progress.installing")).format(new Object[]{loaderVersion}));
|
||||
Path mcPath = Paths.get(installLocation.getText());
|
||||
|
||||
if (!Files.exists(mcPath)) {
|
||||
throw new RuntimeException(Utils.BUNDLE.getString("progress.exception.no.launcher.directory"));
|
||||
}
|
||||
|
||||
String profileName = ClientInstaller.install(mcPath, gameVersion, loaderVersion, this);
|
||||
|
||||
if (createProfile.isSelected()) {
|
||||
ProfileInstaller.setupProfile(mcPath, profileName, gameVersion);
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(() -> showInstalledMessage(loaderVersion, gameVersion));
|
||||
} catch (Exception e) {
|
||||
error(e);
|
||||
}
|
||||
|
||||
buttonInstall.setEnabled(true);
|
||||
}).start();
|
||||
}
|
||||
@@ -73,6 +78,7 @@ public class ClientHandler extends Handler {
|
||||
private void showInstalledMessage(String loaderVersion, String gameVersion) {
|
||||
JEditorPane pane = new JEditorPane("text/html", "<html><body style=\"" + buildEditorPaneStyle() + "\">" + new MessageFormat(Utils.BUNDLE.getString("prompt.install.successful")).format(new Object[]{loaderVersion, gameVersion, Reference.fabricApiUrl}) + "</body></html>");
|
||||
pane.setEditable(false);
|
||||
|
||||
pane.addHyperlinkListener(e -> {
|
||||
try {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
@@ -86,12 +92,14 @@ public class ClientHandler extends Handler {
|
||||
error(throwable);
|
||||
}
|
||||
});
|
||||
|
||||
JOptionPane.showMessageDialog(null, pane, Utils.BUNDLE.getString("prompt.install.successful.title"), JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installCli(ArgumentParser args) throws Exception {
|
||||
Path path = Paths.get(args.getOrDefault("dir", () -> Utils.findDefaultInstallDir().toString()));
|
||||
|
||||
if (!Files.exists(path)) {
|
||||
throw new FileNotFoundException("Launcher directory not found at " + path.toString());
|
||||
}
|
||||
@@ -100,9 +108,11 @@ public class ClientHandler extends Handler {
|
||||
String loaderVersion = getLoaderVersion(args);
|
||||
|
||||
String profileName = ClientInstaller.install(path, gameVersion, loaderVersion, InstallerProgress.CONSOLE);
|
||||
|
||||
if (args.has("noprofile")) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProfileInstaller.setupProfile(path, profileName, gameVersion);
|
||||
}
|
||||
|
||||
@@ -113,7 +123,6 @@ public class ClientHandler extends Handler {
|
||||
|
||||
@Override
|
||||
public void setupPane1(JPanel pane, InstallerGui installerGui) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,5 +131,4 @@ public class ClientHandler extends Handler {
|
||||
|
||||
installLocation.setText(Utils.findDefaultInstallDir().toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,15 +16,16 @@
|
||||
|
||||
package net.fabricmc.installer.client;
|
||||
|
||||
import net.fabricmc.installer.util.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ClientInstaller {
|
||||
import net.fabricmc.installer.util.InstallerProgress;
|
||||
import net.fabricmc.installer.util.Reference;
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
public class ClientInstaller {
|
||||
public static String install(Path mcDir, String gameVersion, String loaderVersion, InstallerProgress progress) throws IOException {
|
||||
System.out.println("Installing " + gameVersion + " with fabric " + loaderVersion);
|
||||
|
||||
@@ -50,7 +51,6 @@ public class ClientInstaller {
|
||||
Files.deleteIfExists(dummyJar);
|
||||
Files.createFile(dummyJar);
|
||||
|
||||
|
||||
URL profileUrl = new URL(Reference.getMetaServerEndpoint(String.format("v2/versions/loader/%s/%s/profile/json", gameVersion, loaderVersion)));
|
||||
Utils.downloadFile(profileUrl, profileJson);
|
||||
|
||||
|
||||
@@ -16,19 +16,20 @@
|
||||
|
||||
package net.fabricmc.installer.client;
|
||||
|
||||
import mjson.Json;
|
||||
import net.fabricmc.installer.util.Reference;
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Date;
|
||||
|
||||
public class ProfileInstaller {
|
||||
import mjson.Json;
|
||||
|
||||
import net.fabricmc.installer.util.Reference;
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
public class ProfileInstaller {
|
||||
public static void setupProfile(Path path, String name, String gameVersion) throws IOException {
|
||||
Path launcherProfiles = path.resolve("launcher_profiles.json");
|
||||
|
||||
if (!Files.exists(launcherProfiles)) {
|
||||
System.out.println("Could not find launcher_profiles");
|
||||
return;
|
||||
@@ -42,6 +43,7 @@ public class ProfileInstaller {
|
||||
String profileName = Reference.LOADER_NAME + "-" + gameVersion;
|
||||
|
||||
Json profile;
|
||||
|
||||
if (profiles.has(profileName)) {
|
||||
profile = profiles.at(profileName);
|
||||
} else {
|
||||
@@ -63,5 +65,4 @@ public class ProfileInstaller {
|
||||
jsonObject.set("icon", Utils.getProfileIcon());
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,7 +31,6 @@ import net.fabricmc.installer.util.InstallerProgress;
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
public class ServerHandler extends Handler {
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "Server";
|
||||
@@ -48,6 +47,7 @@ public class ServerHandler extends Handler {
|
||||
} catch (Exception e) {
|
||||
error(e);
|
||||
}
|
||||
|
||||
buttonInstall.setEnabled(true);
|
||||
}).start();
|
||||
}
|
||||
@@ -55,14 +55,16 @@ public class ServerHandler extends Handler {
|
||||
@Override
|
||||
public void installCli(ArgumentParser args) throws Exception {
|
||||
Path dir = Paths.get(args.getOrDefault("dir", () -> ".")).toAbsolutePath().normalize();
|
||||
|
||||
if (!Files.isDirectory(dir)) {
|
||||
throw new FileNotFoundException("Server directory not found at " + dir + " or not a directory");
|
||||
}
|
||||
|
||||
String loaderVersion = getLoaderVersion(args);
|
||||
String gameVersion = getGameVersion(args);
|
||||
ServerInstaller.install(dir, loaderVersion, gameVersion, InstallerProgress.CONSOLE);
|
||||
|
||||
if(args.has("downloadMinecraft")){
|
||||
if (args.has("downloadMinecraft")) {
|
||||
InstallerProgress.CONSOLE.updateProgress(Utils.BUNDLE.getString("progress.download.minecraft"));
|
||||
Path serverJar = dir.resolve("server.jar");
|
||||
MinecraftServerDownloader downloader = new MinecraftServerDownloader(gameVersion);
|
||||
@@ -80,12 +82,10 @@ public class ServerHandler extends Handler {
|
||||
|
||||
@Override
|
||||
public void setupPane1(JPanel pane, InstallerGui installerGui) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPane2(JPanel pane, InstallerGui installerGui) {
|
||||
installLocation.setText(Paths.get(".").toAbsolutePath().normalize().toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -135,6 +135,7 @@ public class ServerInstaller {
|
||||
try (InputStream is = Files.newInputStream(f);
|
||||
JarInputStream jis = new JarInputStream(is)) {
|
||||
JarEntry entry;
|
||||
|
||||
while ((entry = jis.getNextJarEntry()) != null) {
|
||||
if (entry.isDirectory()) continue;
|
||||
|
||||
@@ -149,6 +150,7 @@ public class ServerInstaller {
|
||||
zipOutputStream.putNextEntry(newEntry);
|
||||
|
||||
int r;
|
||||
|
||||
while ((r = jis.read(buffer, 0, buffer.length)) >= 0) {
|
||||
zipOutputStream.write(buffer, 0, r);
|
||||
}
|
||||
|
||||
@@ -16,14 +16,19 @@
|
||||
|
||||
package net.fabricmc.installer.server;
|
||||
|
||||
import mjson.Json;
|
||||
import net.fabricmc.installer.InstallerGui;
|
||||
import net.fabricmc.installer.util.LauncherMeta;
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -39,8 +44,24 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ServerPostInstallDialog extends JDialog {
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
import mjson.Json;
|
||||
|
||||
import net.fabricmc.installer.InstallerGui;
|
||||
import net.fabricmc.installer.util.LauncherMeta;
|
||||
import net.fabricmc.installer.util.Utils;
|
||||
|
||||
public class ServerPostInstallDialog extends JDialog {
|
||||
private static final int MB = 1000000;
|
||||
|
||||
private JPanel panel = new JPanel();
|
||||
@@ -87,8 +108,6 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
JTextField textField = new JTextField("java -jar fabric-server-launch.jar");
|
||||
textField.setHorizontalAlignment(JTextField.CENTER);
|
||||
panel.add(textField);
|
||||
|
||||
|
||||
});
|
||||
|
||||
addRow(panel, panel -> {
|
||||
@@ -106,23 +125,24 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
});
|
||||
panel.add(closeButton);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private boolean isValidJarPresent() {
|
||||
if (!Files.exists(minecraftJar)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try (JarFile jarFile = new JarFile(minecraftJar.toFile())) {
|
||||
JarEntry versionEntry = jarFile.getJarEntry("version.json");
|
||||
|
||||
if (versionEntry == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
InputStream inputStream = jarFile.getInputStream(versionEntry);
|
||||
|
||||
|
||||
|
||||
String text;
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
|
||||
text = reader.lines().collect(Collectors.joining("\n"));
|
||||
}
|
||||
@@ -141,6 +161,7 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
if (serverJarLabel == null) {
|
||||
serverJarLabel = new JLabel();
|
||||
}
|
||||
|
||||
if (isValidJarPresent()) {
|
||||
serverJarLabel.setText(new MessageFormat(Utils.BUNDLE.getString("prompt.server.jar.valid")).format(new Object[]{minecraftVersion}));
|
||||
color(serverJarLabel, Color.GREEN.darker());
|
||||
@@ -152,6 +173,7 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
|
||||
private void doServerJarDownload() {
|
||||
downloadButton.setEnabled(false);
|
||||
|
||||
try {
|
||||
Files.deleteIfExists(minecraftJar);
|
||||
Files.deleteIfExists(minecraftJarTmp);
|
||||
@@ -160,6 +182,7 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
serverHandler.error(e);
|
||||
return;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
URL url = new URL(LauncherMeta.getLauncherMeta().getVersion(minecraftVersion).getVersionMeta().downloads.get("server").url);
|
||||
@@ -174,6 +197,7 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
byte[] buffer = new byte[1024];
|
||||
long downloaded = 0;
|
||||
int len;
|
||||
|
||||
while ((len = inputStream.read(buffer, 0, 1024)) >= 0) {
|
||||
downloaded += len;
|
||||
|
||||
@@ -182,6 +206,7 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
|
||||
bufferedOutputStream.write(buffer, 0, len);
|
||||
}
|
||||
|
||||
bufferedOutputStream.close();
|
||||
inputStream.close();
|
||||
|
||||
@@ -189,7 +214,6 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
|
||||
updateServerJarLabel();
|
||||
downloadButton.setEnabled(true);
|
||||
|
||||
} catch (IOException e) {
|
||||
color(serverJarLabel, Color.RED).setText(e.getMessage());
|
||||
serverHandler.error(e);
|
||||
@@ -205,6 +229,7 @@ public class ServerPostInstallDialog extends JDialog {
|
||||
launchScripts.put(installDir.resolve("start.sh"), "#!/usr/bin/env bash\n" + launchCommand);
|
||||
|
||||
boolean exists = launchScripts.entrySet().stream().anyMatch(entry -> Files.exists(entry.getKey()));
|
||||
|
||||
if (exists && (JOptionPane.showConfirmDialog(this, Utils.BUNDLE.getString("prompt.server.overwrite"), "Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ArgumentParser {
|
||||
|
||||
private String[] args;
|
||||
private Map<String, String> argMap;
|
||||
//The command will be the first argument passed, and if it doesnt start with -
|
||||
@@ -38,17 +37,21 @@ public class ArgumentParser {
|
||||
if (!argMap.containsKey(argument)) {
|
||||
throw new IllegalArgumentException(String.format("Could not find %s in the arguments", argument));
|
||||
}
|
||||
|
||||
String arg = argMap.get(argument);
|
||||
|
||||
if (arg == null) {
|
||||
throw new IllegalArgumentException(String.format("Could not value for %s", argument));
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
public String getOrDefault(String argument, Supplier<String> stringSuppler) {
|
||||
if(!argMap.containsKey(argument)){
|
||||
if (!argMap.containsKey(argument)) {
|
||||
return stringSuppler.get();
|
||||
}
|
||||
|
||||
return argMap.get(argument);
|
||||
}
|
||||
|
||||
@@ -57,7 +60,7 @@ public class ArgumentParser {
|
||||
}
|
||||
|
||||
public void ifPresent(String argument, Consumer<String> consumer) {
|
||||
if(has(argument)) {
|
||||
if (has(argument)) {
|
||||
consumer.accept(get(argument));
|
||||
}
|
||||
}
|
||||
@@ -68,21 +71,27 @@ public class ArgumentParser {
|
||||
|
||||
private void parse() {
|
||||
argMap = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].startsWith("-")) {
|
||||
String key = args[i].substring(1);
|
||||
String value = null;
|
||||
|
||||
if (i + 1 < args.length) {
|
||||
value = args[i + 1];
|
||||
|
||||
if (value.startsWith("-")) {
|
||||
argMap.put(key, "");
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (argMap.containsKey(key)) {
|
||||
throw new IllegalArgumentException(String.format("Argument %s already passed", key));
|
||||
}
|
||||
|
||||
argMap.put(key, value);
|
||||
} else if (i == 0) {
|
||||
command = args[i];
|
||||
@@ -93,5 +102,4 @@ public class ArgumentParser {
|
||||
public static ArgumentParser create(String[] args) {
|
||||
return new ArgumentParser(args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CompletableHandler<T> {
|
||||
|
||||
private boolean complete;
|
||||
|
||||
private List<Consumer<T>> completeConsumers = new ArrayList<>();
|
||||
@@ -30,7 +29,7 @@ public class CompletableHandler<T> {
|
||||
completeConsumers.add(completeConsumer);
|
||||
}
|
||||
|
||||
protected void complete(T value){
|
||||
protected void complete(T value) {
|
||||
complete = true;
|
||||
completeConsumers.forEach(listConsumer -> listConsumer.accept(value));
|
||||
}
|
||||
@@ -38,5 +37,4 @@ public class CompletableHandler<T> {
|
||||
public boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,13 +16,17 @@
|
||||
|
||||
package net.fabricmc.installer.util;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public class CrashDialog {
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
public class CrashDialog {
|
||||
public CrashDialog(Throwable throwable) {
|
||||
JFrame frame = new JFrame("Fabric installer has crashed!");
|
||||
Container pane = frame.getContentPane();
|
||||
@@ -42,4 +46,4 @@ public class CrashDialog {
|
||||
frame.doLayout();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
package net.fabricmc.installer.util;
|
||||
|
||||
public interface InstallerProgress {
|
||||
|
||||
InstallerProgress CONSOLE = new InstallerProgress() {
|
||||
@Override
|
||||
public void updateProgress(String text) {
|
||||
@@ -33,5 +32,4 @@ public interface InstallerProgress {
|
||||
void updateProgress(String text);
|
||||
|
||||
void error(Throwable throwable);
|
||||
|
||||
}
|
||||
@@ -16,22 +16,22 @@
|
||||
|
||||
package net.fabricmc.installer.util;
|
||||
|
||||
import mjson.Json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LauncherMeta {
|
||||
import mjson.Json;
|
||||
|
||||
public class LauncherMeta {
|
||||
private static LauncherMeta launcherMeta = null;
|
||||
|
||||
public static LauncherMeta getLauncherMeta() throws IOException {
|
||||
if(launcherMeta == null){
|
||||
if (launcherMeta == null) {
|
||||
launcherMeta = load();
|
||||
}
|
||||
|
||||
return launcherMeta;
|
||||
}
|
||||
|
||||
@@ -75,18 +75,18 @@ public class LauncherMeta {
|
||||
}
|
||||
|
||||
public VersionMeta getVersionMeta() throws IOException {
|
||||
if(versionMeta == null){
|
||||
if (versionMeta == null) {
|
||||
URL url = new URL(this.url);
|
||||
String str = Utils.readTextFile(url);
|
||||
Json json = Json.read(str);
|
||||
versionMeta = new VersionMeta(json);
|
||||
}
|
||||
|
||||
return versionMeta;
|
||||
}
|
||||
}
|
||||
|
||||
public Version getVersion(String version){
|
||||
public Version getVersion(String version) {
|
||||
return versions.stream().filter(v -> v.id.equals(version)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package net.fabricmc.installer.util;
|
||||
|
||||
import mjson.Json;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import mjson.Json;
|
||||
|
||||
public class Library {
|
||||
public final String name;
|
||||
public final String url;
|
||||
|
||||
@@ -16,16 +16,15 @@
|
||||
|
||||
package net.fabricmc.installer.util;
|
||||
|
||||
import mjson.Json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetaHandler extends CompletableHandler<List<MetaHandler.GameVersion>> {
|
||||
import mjson.Json;
|
||||
|
||||
public class MetaHandler extends CompletableHandler<List<MetaHandler.GameVersion>> {
|
||||
private final String metaUrl;
|
||||
private List<GameVersion> versions;
|
||||
|
||||
@@ -50,12 +49,12 @@ public class MetaHandler extends CompletableHandler<List<MetaHandler.GameVersion
|
||||
return Collections.unmodifiableList(versions);
|
||||
}
|
||||
|
||||
public GameVersion getLatestVersion(boolean snapshot){
|
||||
if(snapshot){
|
||||
public GameVersion getLatestVersion(boolean snapshot) {
|
||||
if (snapshot) {
|
||||
return versions.get(0);
|
||||
} else {
|
||||
return versions.stream()
|
||||
.filter(GameVersion::isStable).findFirst().orElse(null);
|
||||
.filter(GameVersion::isStable).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,5 +75,4 @@ public class MetaHandler extends CompletableHandler<List<MetaHandler.GameVersion
|
||||
return stable;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,13 +39,13 @@ import java.util.ResourceBundle;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static final DateFormat ISO_8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
public static final ResourceBundle BUNDLE = ResourceBundle.getBundle("lang/installer", Locale.getDefault(), new ResourceBundle.Control() {
|
||||
@Override
|
||||
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
|
||||
final String bundleName = toBundleName(baseName, locale);
|
||||
final String resourceName = toResourceName(bundleName, "properties");
|
||||
|
||||
try (InputStream stream = loader.getResourceAsStream(resourceName)) {
|
||||
if (stream != null) {
|
||||
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
|
||||
@@ -53,6 +53,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.newBundle(baseName, locale, format, loader, reload);
|
||||
}
|
||||
});
|
||||
@@ -104,7 +105,6 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String getProfileIcon() {
|
||||
|
||||
try (InputStream is = Utils.class.getClassLoader().getResourceAsStream("profile_icon.png")) {
|
||||
byte[] ret = new byte[4096];
|
||||
int offset = 0;
|
||||
@@ -116,10 +116,10 @@ public class Utils {
|
||||
}
|
||||
|
||||
return "data:image/png;base64," + Base64.getEncoder().encodeToString(Arrays.copyOf(ret, offset));
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "TNT"; // Fallback to TNT icon if we cant load Fabric icon.
|
||||
}
|
||||
|
||||
@@ -127,11 +127,11 @@ public class Utils {
|
||||
return bytesToHex(sha1(path));
|
||||
}
|
||||
|
||||
public static byte[] sha1(Path path) throws IOException {
|
||||
public static byte[] sha1(Path path) throws IOException {
|
||||
MessageDigest digest = sha1Digest();
|
||||
|
||||
try (InputStream is = Files.newInputStream(path)) {
|
||||
byte[] buffer = new byte[64*1024];
|
||||
byte[] buffer = new byte[64 * 1024];
|
||||
int len;
|
||||
|
||||
while ((len = is.read(buffer)) >= 0) {
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
|
||||
package net.fabricmc.installer.util;
|
||||
|
||||
import mjson.Json;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class VersionMeta {
|
||||
import mjson.Json;
|
||||
|
||||
public class VersionMeta {
|
||||
public final String id;
|
||||
public final Map<String, Download> downloads;
|
||||
|
||||
public VersionMeta(Json json) {
|
||||
id = json.at("id").asString();
|
||||
downloads = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Json> entry : json.at("downloads").asJsonMap().entrySet()) {
|
||||
downloads.put(entry.getKey(), new Download(entry.getValue()));
|
||||
}
|
||||
@@ -45,6 +45,4 @@ public class VersionMeta {
|
||||
url = json.at("url").asString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -32,6 +32,6 @@ prompt.server.jar.invalid=無効な {0} server jar が見つかりました。
|
||||
prompt.server.generate=生成
|
||||
prompt.server.overwrite=既存の起動スクリプトを上書きしてもよろしいですか?
|
||||
prompt.install.successful.title=正常にインストールされました
|
||||
prompt.install.successful= {1}のFabric Loader {0} が正常にインストールされました。<br>多くのmodは<a href="{2}">Fabric API</a> をmodsフォルダに入れる必要があります。
|
||||
prompt.install.successful={1}のFabric Loader {0} が正常にインストールされました。<br>多くのmodは<a href="{2}">Fabric API</a> をmodsフォルダに入れる必要があります。
|
||||
tab.client=クライアント
|
||||
tab.server=サーバー
|
||||
@@ -1,6 +1,5 @@
|
||||
# Translator: pan93412 <pan93412@gmail.com>, 2019.
|
||||
# Former Translator: shedaniel, 2019.
|
||||
|
||||
installer.title=Fabric 安裝程式
|
||||
option.create.profile=建立設定檔
|
||||
option.show.snapshots=顯示快照
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package net.fabricmc.installer.test;
|
||||
|
||||
import net.fabricmc.installer.util.ArgumentParser;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ArgumentTests {
|
||||
import net.fabricmc.installer.util.ArgumentParser;
|
||||
|
||||
public class ArgumentTests {
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = new String[]{"command", "-arg1", "Hello", "-arg2", "-anotherArg", "123"};
|
||||
@@ -36,7 +36,6 @@ public class ArgumentTests {
|
||||
Assert.assertFalse(handler.has("arg3"));
|
||||
|
||||
Assert.assertEquals(handler.getCommand().get(), "command");
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -61,5 +60,4 @@ public class ArgumentTests {
|
||||
|
||||
Assert.assertFalse(ArgumentParser.create(new String[]{"-arg1", "Hello"}).getCommand().isPresent());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user