Skip to content
This repository was archived by the owner on Apr 21, 2024. It is now read-only.

Commit 59de2f9

Browse files
committed
ui: 更新 ui
1 parent 01f96ed commit 59de2f9

File tree

23 files changed

+243
-215
lines changed

23 files changed

+243
-215
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ configurations {
115115
dependencies {
116116
// Groovy
117117
//implementation gradleApi()
118-
implementation 'org.apache.groovy:groovy-all:4.0.19'
118+
// implementation 'org.apache.groovy:groovy-all:4.0.19'
119+
implementation localGroovy()
119120

120121
// Annotations
121122
annotationProcessor(implementation("org.projectlombok:lombok:1.18.30"))
@@ -151,6 +152,9 @@ dependencies {
151152
shadow "org.ow2.asm:asm-tree:9.6"
152153
shadow "org.ow2.asm:asm-util:9.6"
153154

155+
// UI
156+
shadow 'com.formdev:flatlaf:3.4'
157+
154158
// Tests
155159
annotationProcessor(testImplementation("org.projectlombok:lombok:1.18.30"))
156160
testImplementation platform('org.junit:junit-bom:5.10.2')
@@ -164,10 +168,6 @@ processResources {
164168
filesMatching("config.yml") {
165169
expand "version": project.version
166170
}
167-
168-
filesMatching("grasslauncher.extension.yml") {
169-
expand "version": project.version
170-
}
171171
}
172172

173173
test {

src/main/java/xyz/mrcraftteammc/grasslauncher/common/CommonConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import java.nio.file.FileSystems;
44

5-
public class CommonConstants {
5+
public final class CommonConstants {
66
public static final String NAME = "GrassLauncher";
77
public static final String VERSION = "1.0.0-SNAPSHOT";
88

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package xyz.mrcraftteammc.grasslauncher.common;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
7+
@Data
8+
@AllArgsConstructor
9+
@NoArgsConstructor
10+
public final class Configuration {
11+
// base info
12+
private String version;
13+
14+
// i18n
15+
private String language;
16+
private String country;
17+
}

src/main/java/xyz/mrcraftteammc/grasslauncher/common/DefaultExtension.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@
55
import xyz.mrcraftteammc.grasslauncher.extension.ExtensionManifest;
66
import xyz.mrcraftteammc.grasslauncher.extension.annotations.ExtensionInstance;
77
import xyz.mrcraftteammc.grasslauncher.extension.exception.ExtensionException;
8+
import xyz.mrcraftteammc.grasslauncher.common.core.Text;
9+
import xyz.mrcraftteammc.grasslauncher.main.Main;
10+
11+
import java.io.*;
12+
import java.net.URISyntaxException;
13+
import java.nio.file.Files;
14+
import java.nio.file.Paths;
15+
import java.util.Objects;
816

917
@ExtensionInstance
1018
public class DefaultExtension extends Extension {
1119
private final Logger logger = super.getLogger();
20+
private final Text text = Text.translatable();
1221

1322
public DefaultExtension() {
1423
super(ExtensionManifest.defaultManifest());
1524
}
1625

1726
@Override
1827
public void onLoad() throws ExtensionException {
19-
this.logger.info("Hello DefaultExtension!");
28+
2029
}
2130

2231
@Override
@@ -28,4 +37,22 @@ public void onEnabled() throws ExtensionException {
2837
public void onDisabled() throws ExtensionException {
2938
super.onDisabled();
3039
}
40+
41+
public String exportConfiguration() throws URISyntaxException, IOException {
42+
String jarFolder = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile().getPath().replace('\\', '/');
43+
InputStream is = Main.class.getResourceAsStream("/config.yml");
44+
OutputStream os = Files.newOutputStream(Paths.get(jarFolder + "/config.yml"));
45+
46+
byte[] buf = new byte[4096];
47+
int readbytes;
48+
49+
while ((readbytes = Objects.requireNonNull(is).read(buf)) > 0) {
50+
os.write(buf, 0, readbytes);
51+
}
52+
53+
is.close();
54+
os.close();
55+
56+
return jarFolder + "/config.yml";
57+
}
3158
}

src/main/java/xyz/mrcraftteammc/grasslauncher/common/core/Factory.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/java/xyz/mrcraftteammc/grasslauncher/common/core/ProcessCallBack.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.Getter;
44

5+
@Deprecated
56
@Getter
67
public class ProcessCallBack {
78
private final int exitCode;

src/main/java/xyz/mrcraftteammc/grasslauncher/common/core/Property.java

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
package xyz.mrcraftteammc.grasslauncher.common.core;
2+
3+
import lombok.EqualsAndHashCode;
4+
import lombok.ToString;
5+
import org.jetbrains.annotations.Contract;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import java.io.Serializable;
9+
import java.util.Locale;
10+
import java.util.ResourceBundle;
11+
12+
@SuppressWarnings({"unused"})
13+
@EqualsAndHashCode
14+
@ToString
15+
public abstract class Text
16+
implements Serializable, Cloneable, Comparable<String>, CharSequence {
17+
private static final long serialVersionUID = 1L;
18+
19+
public abstract String getText(String id, String defaultText, Object... args);
20+
21+
public String getText(String id, Object... args) {
22+
return this.getText(id, "" , args);
23+
}
24+
25+
public String getText(String id) {
26+
return this.getText(id, (Object[]) null);
27+
}
28+
29+
public String getText(Object o) {
30+
return this.getText(o.toString());
31+
}
32+
33+
@Contract(" -> new")
34+
@NotNull
35+
public static Text literal() {
36+
return new LiteralText();
37+
}
38+
39+
@Contract(" -> new")
40+
@NotNull
41+
public static Text translatable() {
42+
return new TranslatableText();
43+
}
44+
45+
@Override
46+
public Text clone() {
47+
try {
48+
return (Text) super.clone();
49+
} catch (CloneNotSupportedException e) {
50+
throw new AssertionError();
51+
}
52+
}
53+
54+
private static class LiteralText extends Text {
55+
private String text = "";
56+
57+
@Override
58+
public String getText(String id, String defaultText, Object... args) {
59+
if (id == null || id.isEmpty()) {
60+
return defaultText;
61+
}
62+
63+
if (args != null) {
64+
for (Object o : args) {
65+
id = id.replaceFirst("%_", o.toString());
66+
}
67+
}
68+
69+
this.text = id;
70+
return id;
71+
}
72+
73+
@Override
74+
public int length() {
75+
return this.text.length();
76+
}
77+
78+
@Override
79+
public char charAt(int index) {
80+
return this.text.charAt(index);
81+
}
82+
83+
@NotNull
84+
@Override
85+
public CharSequence subSequence(int start, int end) {
86+
return this.text.subSequence(start, end);
87+
}
88+
89+
@Override
90+
public int compareTo(@NotNull String o) {
91+
return this.text.compareTo(o);
92+
}
93+
}
94+
95+
private static class TranslatableText extends Text {
96+
private String text = "";
97+
98+
@Override
99+
public String getText(String id, String defaultText, Object... args) {
100+
if (id == null || id.isEmpty()) {
101+
return defaultText;
102+
}
103+
104+
ResourceBundle bundle = ResourceBundle.getBundle("i18n.lang", Locale.getDefault());
105+
String text2 = bundle.getString(id);
106+
107+
if (args != null) {
108+
for (Object o : args) {
109+
text2 = text2.replaceFirst("%_", o.toString());
110+
}
111+
}
112+
113+
this.text = text2;
114+
return text2;
115+
}
116+
117+
@Override
118+
public int length() {
119+
return this.text.length();
120+
}
121+
122+
@Override
123+
public char charAt(int index) {
124+
return this.text.charAt(index);
125+
}
126+
127+
@NotNull
128+
@Override
129+
public CharSequence subSequence(int start, int end) {
130+
return this.text.subSequence(start, end);
131+
}
132+
133+
@Override
134+
public int compareTo(@NotNull String o) {
135+
return this.text.compareTo(o);
136+
}
137+
}
138+
}

src/main/java/xyz/mrcraftteammc/grasslauncher/common/network/Form.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/main/java/xyz/mrcraftteammc/grasslauncher/common/network/Url.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)