-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathJavaCommand.java
33 lines (28 loc) · 1.29 KB
/
JavaCommand.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package me.earth.headlessmc.launcher.command;
import me.earth.headlessmc.command.CommandUtil;
import me.earth.headlessmc.launcher.Launcher;
import me.earth.headlessmc.launcher.LauncherProperties;
import me.earth.headlessmc.launcher.java.Java;
import me.earth.headlessmc.util.Table;
public class JavaCommand extends AbstractLauncherCommand {
public JavaCommand(Launcher launcher) {
super(launcher, "java", "Reloads the config property "
+ LauncherProperties.JAVA.getName() + ".");
args.put("-current", "Output the java version of the JVM headlessmc is running in.");
}
@Override
public void execute(String... args) {
if (CommandUtil.hasFlag("-current", args)) {
Java current = ctx.getJavaService().getCurrent();
ctx.log("Current: Java " + current.getVersion() + " at " + current.getPath());
return;
}
ctx.getJavaService().refresh();
ctx.log(new Table<Java>()
.withColumn("version", java -> String.valueOf(java.getVersion()))
.withColumn("path", Java::getPath)
.withColumn("current", java -> java.equals(ctx.getJavaService().getCurrent()) ? "<------" : "")
.addAll(ctx.getJavaService())
.build());
}
}