Skip to content

Commit a5f31eb

Browse files
committed
make ready for mc-client HMCL integration upgrade to Java 9, some JavaFX additions and UI refactorings
1 parent 5552dd1 commit a5f31eb

File tree

12 files changed

+573
-38
lines changed

12 files changed

+573
-38
lines changed

pom.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AUTO-GENERATED FILE, CHANGES SHOULD BE DONE IN ./JPM.java or ./src/main/java/JPM
1414
<version>8.3.1</version>
1515
<properties>
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17-
<java.version>8</java.version>
17+
<java.version>9</java.version>
1818
<version>8.3.1</version>
1919
<main-class>com.osiris.autoplug.client.Main</main-class>
2020
<slf4j.version>2.0.13</slf4j.version>
@@ -249,18 +249,24 @@ AUTO-GENERATED FILE, CHANGES SHOULD BE DONE IN ./JPM.java or ./src/main/java/JPM
249249
<version>2.2</version>
250250
<scope>compile</scope>
251251
</dependency>
252-
<dependency>
253-
<groupId>me.hsgamer</groupId>
254-
<artifactId>mc-server-updater-lib</artifactId>
255-
<version>3.7.0</version>
256-
<scope>compile</scope>
257-
</dependency>
258252
<dependency>
259253
<groupId>org.apache.sshd</groupId>
260254
<artifactId>sshd-core</artifactId>
261255
<version>2.13.0</version>
262256
<scope>compile</scope>
263257
</dependency>
258+
<dependency>
259+
<groupId>org.nanohttpd</groupId>
260+
<artifactId>nanohttpd</artifactId>
261+
<version>2.3.1</version>
262+
<scope>compile</scope>
263+
</dependency>
264+
<dependency>
265+
<groupId>org.glavo.kala</groupId>
266+
<artifactId>kala-compress</artifactId>
267+
<version>1.27.1-1</version>
268+
<scope>compile</scope>
269+
</dependency>
264270
<dependency>
265271
<groupId>org.junit.jupiter</groupId>
266272
<artifactId>junit-jupiter</artifactId>
@@ -275,8 +281,8 @@ AUTO-GENERATED FILE, CHANGES SHOULD BE DONE IN ./JPM.java or ./src/main/java/JPM
275281
<artifactId>maven-compiler-plugin</artifactId>
276282
<version>3.8.1</version>
277283
<configuration>
278-
<source>8</source>
279-
<target>8</target>
284+
<source>9</source>
285+
<target>9</target>
280286
</configuration>
281287
</plugin>
282288
<plugin>

src/main/java/JPM.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public ThisProject(List<String> args) {
2525
this.mainClass = "com.osiris.autoplug.client.Main";
2626
this.jarName = "AutoPlug-Client-original.jar";
2727
this.fatJarName = "AutoPlug-Client.jar";
28-
this.javaVersionSource = "8";
29-
this.javaVersionTarget = "8";
28+
this.javaVersionSource = "9";
29+
this.javaVersionTarget = "9";
3030

3131
// Add repositories
3232
addRepository("https://oss.sonatype.org/content/repositories/snapshots");
@@ -72,9 +72,12 @@ public ThisProject(List<String> args) {
7272
implementation("org.quartz-scheduler:quartz:2.3.2");
7373
implementation("org.tomlj:tomlj:1.0.0");
7474
implementation("com.formdev:flatlaf:2.2");
75-
implementation("me.hsgamer:mc-server-updater-lib:3.7.0");
7675
implementation("org.apache.sshd:sshd-core:2.13.0");
7776

77+
// Minecraft client:
78+
implementation("org.nanohttpd:nanohttpd:2.3.1");
79+
implementation("org.glavo.kala:kala-compress:1.27.1-1");
80+
7881
testImplementation("org.junit.jupiter:junit-jupiter:5.9.2");
7982

8083
// Add custom plugins
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2022-2024 Osiris-Team.
3+
* All rights reserved.
4+
*
5+
* This software is copyrighted work, licensed under the terms
6+
* of the MIT-License. Consult the "LICENSE" file for details.
7+
*/
8+
9+
package com.osiris.autoplug.client.ui;
10+
11+
import com.osiris.autoplug.client.Target;
12+
import com.osiris.autoplug.client.console.Commands;
13+
import com.osiris.autoplug.client.ui.utils.HintTextField;
14+
import com.osiris.autoplug.client.ui.utils.MyMouseListener;
15+
import com.osiris.autoplug.client.utils.GD;
16+
import com.osiris.betterlayout.BLayout;
17+
import com.osiris.jlib.logger.AL;
18+
import com.osiris.jlib.logger.MessageFormatter;
19+
20+
import javax.swing.*;
21+
import java.awt.*;
22+
import java.awt.event.KeyEvent;
23+
import java.awt.event.KeyListener;
24+
import java.util.ArrayList;
25+
26+
public class ClientPanel extends BLayout {
27+
28+
public ClientPanel(Container parent) throws Exception {
29+
super(parent);
30+
31+
JTabbedPane tabs = new JTabbedPane();
32+
this.addV(tabs).height(80).widthFull();
33+
tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
34+
35+
if (GD.TARGET == Target.MINECRAFT_CLIENT || GD.TARGET == Target.MINECRAFT_SERVER) {
36+
SettingsPanel servers = new SettingsPanel(tabs);
37+
tabs.addTab("Servers", servers); // TODO list of favorite servers with play/join button which auto-selects
38+
// (TODO) and launches the correct minecraft client version
39+
40+
SettingsPanel profiles = new SettingsPanel(tabs);
41+
tabs.addTab("Profiles", profiles); // TODO game profile containing settings and mods
42+
// (TODO) is not tied to a minecraft version, meaning internally
43+
// (TODO) mods/settings will be down/upgraded to match the launched version
44+
45+
MinecraftModsPanel minecraftMods = new MinecraftModsPanel(tabs);
46+
tabs.addTab("Mods", minecraftMods);
47+
48+
} else if (GD.TARGET == Target.MINDUSTRY_CLIENT || GD.TARGET == Target.MINDUSTRY_SERVER) {
49+
MindustryModsPanel mindustryModsPanel = new MindustryModsPanel(tabs);
50+
tabs.addTab("Mods", mindustryModsPanel);
51+
} else { // Target.OTHER
52+
53+
}
54+
SettingsPanel settingsPanel = new SettingsPanel(tabs);
55+
tabs.addTab("Settings", settingsPanel);
56+
}
57+
58+
private JButton getBtnMinecraftLaunch() {
59+
JButton btn = new JButton("Launch Minecraft");
60+
btn.addMouseListener(new MyMouseListener().onClick(event -> {
61+
62+
}));
63+
return btn;
64+
}
65+
66+
private java.util.List<JLabel> toLabel(String ansi) {
67+
// TODO convert ansi colors to awt
68+
String[] lines = ansi.split("\n");
69+
java.util.List<JLabel> list = new ArrayList<>();
70+
for (String line : lines) {
71+
list.add(new JLabel(line));
72+
}
73+
return list;
74+
}
75+
}

src/main/java/com/osiris/autoplug/client/ui/MainWindow.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.formdev.flatlaf.FlatDarculaLaf;
1212
import com.formdev.flatlaf.FlatDarkLaf;
1313
import com.formdev.flatlaf.FlatLightLaf;
14-
import com.osiris.autoplug.client.Target;
1514
import com.osiris.autoplug.client.configs.GeneralConfig;
1615
import com.osiris.autoplug.client.ui.utils.MyMouseListener;
1716
import com.osiris.autoplug.client.utils.GD;
@@ -154,32 +153,14 @@ private void initUI() throws Exception {
154153
titleTray.putClientProperty("FlatLaf.style", "font: 200% $light.font");
155154
thisLy.addH(titleTray).delPadding().paddingTop();
156155

157-
JTabbedPane tabbedPane = new JTabbedPane();
158-
thisLy.addV(tabbedPane).height(80).widthFull();
159-
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
156+
JTabbedPane mainTab = new JTabbedPane();
157+
thisLy.addV(mainTab).height(80).widthFull();
158+
mainTab.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
160159

161160
// Tab panels/layouts
162161
try {
163-
tabbedPane.addTab("Home", new HomePanel(tabbedPane));
164-
if (GD.TARGET == Target.MINECRAFT_CLIENT) {
165-
MinecraftPluginsPanel minecraftMods = new MinecraftPluginsPanel(tabbedPane);
166-
tabbedPane.addTab("Mods", minecraftMods);
167-
} else if (GD.TARGET == Target.MINECRAFT_SERVER) {
168-
MinecraftPluginsPanel minecraftPluginsPanel = new MinecraftPluginsPanel(tabbedPane);
169-
MinecraftModsPanel minecraftModsPanel = new MinecraftModsPanel(tabbedPane);
170-
tabbedPane.addTab("Plugins", minecraftPluginsPanel);
171-
tabbedPane.addTab("Mods", minecraftModsPanel);
172-
} else if (GD.TARGET == Target.MINDUSTRY_SERVER) {
173-
MindustryModsPanel mindustryModsPanel = new MindustryModsPanel(tabbedPane);
174-
tabbedPane.addTab("Mods", mindustryModsPanel);
175-
} else if (GD.TARGET == Target.MINDUSTRY_CLIENT) {
176-
MindustryModsPanel mindustryModsPanel = new MindustryModsPanel(tabbedPane);
177-
tabbedPane.addTab("Mods", mindustryModsPanel);
178-
} else { // Target.OTHER
179-
180-
}
181-
SettingsPanel settingsPanel = new SettingsPanel(tabbedPane);
182-
tabbedPane.addTab("Settings", settingsPanel);
162+
mainTab.addTab("Server", new ServerPanel(mainTab));
163+
mainTab.addTab("Client", new ClientPanel(mainTab));
183164
//tabbedPane.addChangeListener(e -> selectedTabChanged());
184165
} catch (Exception e) {
185166
AL.warn(e);

src/main/java/com/osiris/autoplug/client/ui/HomePanel.java renamed to src/main/java/com/osiris/autoplug/client/ui/ServerConsolePanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
import java.awt.event.KeyListener;
2222
import java.util.ArrayList;
2323

24-
public class HomePanel extends BLayout {
24+
public class ServerConsolePanel extends BLayout {
2525

2626
public JLabel labelConsole = new JLabel("Console");
2727
public BLayout txtConsole;
2828
public HintTextField txtSendCommand = new HintTextField("Send command...");
2929
private final JButton execute;
3030

31-
public HomePanel(Container parent) {
31+
public ServerConsolePanel(Container parent) {
3232
super(parent);
3333

3434
execute = new JButton("Execute");
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2022-2024 Osiris-Team.
3+
* All rights reserved.
4+
*
5+
* This software is copyrighted work, licensed under the terms
6+
* of the MIT-License. Consult the "LICENSE" file for details.
7+
*/
8+
9+
package com.osiris.autoplug.client.ui;
10+
11+
import com.osiris.autoplug.client.Target;
12+
import com.osiris.autoplug.client.ui.utils.MyMouseListener;
13+
import com.osiris.autoplug.client.utils.GD;
14+
import com.osiris.betterlayout.BLayout;
15+
16+
import javax.swing.*;
17+
import java.awt.*;
18+
import java.util.ArrayList;
19+
20+
public class ServerPanel extends BLayout {
21+
22+
public ServerPanel(Container parent) throws Exception {
23+
super(parent);
24+
25+
JTabbedPane tabs = new JTabbedPane();
26+
this.addV(tabs).height(80).widthFull();
27+
tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
28+
29+
if (GD.TARGET == Target.MINECRAFT_CLIENT || GD.TARGET == Target.MINECRAFT_SERVER) {
30+
MinecraftPluginsPanel minecraftPluginsPanel = new MinecraftPluginsPanel(tabs);
31+
MinecraftModsPanel minecraftModsPanel = new MinecraftModsPanel(tabs);
32+
tabs.addTab("Plugins", minecraftPluginsPanel);
33+
tabs.addTab("Mods", minecraftModsPanel);
34+
} else if (GD.TARGET == Target.MINDUSTRY_SERVER || GD.TARGET == Target.MINDUSTRY_CLIENT) {
35+
MindustryModsPanel mindustryModsPanel = new MindustryModsPanel(tabs);
36+
tabs.addTab("Mods", mindustryModsPanel);
37+
} else { // Target.OTHER
38+
39+
}
40+
SettingsPanel settingsPanel = new SettingsPanel(tabs);
41+
tabs.addTab("Settings", settingsPanel);
42+
43+
}
44+
45+
private JButton getBtnMinecraftLaunch() {
46+
JButton btn = new JButton("Launch Minecraft");
47+
btn.addMouseListener(new MyMouseListener().onClick(event -> {
48+
49+
}));
50+
return btn;
51+
}
52+
53+
private java.util.List<JLabel> toLabel(String ansi) {
54+
// TODO convert ansi colors to awt
55+
String[] lines = ansi.split("\n");
56+
java.util.List<JLabel> list = new ArrayList<>();
57+
for (String line : lines) {
58+
list.add(new JLabel(line));
59+
}
60+
return list;
61+
}
62+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package javafx.application;
2+
3+
/**
4+
* Fake class
5+
*/
6+
public class Platform {
7+
public static void runLater(Runnable code) {
8+
new Thread(code).start();
9+
}
10+
}

0 commit comments

Comments
 (0)