Skip to content

Commit

Permalink
feat: bump 0.2.1 +b
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolLoong committed Mar 21, 2024
1 parent 18a15f4 commit e487026
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 288 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# PNX-CLI
[![English](https://img.shields.io/badge/English-100%25-green?style=flat-square)](https://github.com/PowerNukkitX/PNX-CLI/blob/master/README.md)
[![简体中文](https://img.shields.io/badge/简体中文-100%25-green?style=flat-square)](https://github.com/PowerNukkitX/PNX-CLI/blob/master/lang/ZH-README.md)


PNX-CLI is a command line tool for PNX. It can help you to install and start PNX quickly.
PNX-CLI is a command line tool for PNX. It can help you start PNX quickly.
windows using . \pnx.exe to run.
linux use . /pnx to run.
Hereafter abbreviated to pnx.
linux use . /pnx to run.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>cn.powernukkitx</groupId>
<artifactId>PNX-CLI</artifactId>
<version>0.2.0</version>
<version>0.2.1</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/cn/powernukkitx/cli/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cn.powernukkitx.cli.cmd.StartCommand;
import cn.powernukkitx.cli.cmd.SysInstallCommand;
import cn.powernukkitx.cli.cmd.UpdateCommand;
import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.util.*;
import picocli.CommandLine;
Expand All @@ -20,8 +19,7 @@
@Command(name = "pnx", aliases = {"pnx", "PNX", "cli"}, version = CLIConstant.version, mixinStandardHelpOptions = true,
resourceBundle = "cn.powernukkitx.cli.App", subcommands = {
SysInstallCommand.class,
StartCommand.class,
UpdateCommand.class
StartCommand.class
})
public final class App implements Callable<Integer> {

Expand Down
50 changes: 24 additions & 26 deletions src/main/java/cn/powernukkitx/cli/cmd/StartCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import cn.powernukkitx.cli.data.locator.JarLocator;
import cn.powernukkitx.cli.data.locator.JavaLocator;
import cn.powernukkitx.cli.share.CLIConstant;
import cn.powernukkitx.cli.util.ConfigUtils;
import cn.powernukkitx.cli.util.InputUtils;
import cn.powernukkitx.cli.util.Logger;
import cn.powernukkitx.cli.util.OSUtils;
import cn.powernukkitx.cli.util.*;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
Expand All @@ -19,7 +16,6 @@
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.text.ParseException;
import java.util.*;
import java.util.concurrent.Callable;

Expand Down Expand Up @@ -61,20 +57,21 @@ public Integer call() {
var pnxList = new JarLocator(CLIConstant.userDir, "cn.nukkit.PlayerHandle").locate();
//auto install
if (pnxList.isEmpty()) {
try {
File file = new File(CLIConstant.userDir, "PowerNukkitX-Core.zip");

if (file.exists()) {
new JarLocator(CLIConstant.userDir, "cn.nukkit.PlayerHandle").locate().forEach(each -> each.getFile().delete());
try {
CompressUtils.uncompressZipFile(file, new File(""));
Files.deleteIfExists(file.toPath());
} catch (IOException e) {
throw new RuntimeException(e);
}
pnxList = new JarLocator(CLIConstant.userDir, "cn.nukkit.PlayerHandle").locate();
} else {
Logger.warn(ansi().fgBrightRed().a(new Formatter().format(bundle.getString("no-pnx"), OSUtils.getProgramName())).fgDefault());
var download = new UpdateCommand();
download.core = true;
download.latest = true;
download.call();
} catch (ParseException e) {
e.printStackTrace();
return 1;
} catch (Exception e) {
e.printStackTrace();
return 1;
}
pnxList = new JarLocator(CLIConstant.userDir, "cn.nukkit.PlayerHandle").locate();
}
var libDir = new File(CLIConstant.userDir, "libs");
if (!libDir.exists()) {
Expand All @@ -83,17 +80,18 @@ public Integer call() {
}
var oldLibFiles = new LinkedList<>(Arrays.asList(Objects.requireNonNull(libDir.listFiles((dir, name) -> name.endsWith(".jar")))));
if (oldLibFiles.size() < 32) {
try {
File file = new File(CLIConstant.userDir, "PowerNukkitX-Libs.zip");
if (file.exists()) {
File libs = new File(CLIConstant.userDir, "libs");
FileUtils.deleteDir(libs);
try {
CompressUtils.uncompressZipFile(file, libs);
Files.deleteIfExists(file.toPath());
} catch (IOException e) {
throw new RuntimeException(e);
}
}else {
Logger.warn(ansi().fgBrightRed().a(new Formatter().format(bundle.getString("no-libs"), OSUtils.getProgramName())).fgDefault());
var download = new UpdateCommand();
download.libs = true;
download.latest = true;
download.call();
} catch (ParseException e) {
e.printStackTrace();
return 1;
} catch (Exception e) {
e.printStackTrace();
return 1;
}
}
Expand Down
115 changes: 0 additions & 115 deletions src/main/java/cn/powernukkitx/cli/cmd/UpdateCommand.java

This file was deleted.

108 changes: 0 additions & 108 deletions src/main/java/cn/powernukkitx/cli/data/remote/GithubHelper.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/cn/powernukkitx/cli/share/CLIConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;

public interface CLIConstant {
String version = "0.2.0";
String version = "0.2.1";
List<String> authors = List.of("超神的冰凉", "CoolLoong");
File userDir = new File(System.getProperty("user.dir"));
File programDir = new File(OSUtils.getProgramDir());
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/cn/powernukkitx/cli/cmd/Start.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
usage.description = Generator start command and start pnx server.
generate-only = Generate start command only, do not start pnx server.
no-java17 = No java17 vms are found. Try `%1s jvm install` to install a java17 vm.
usage.description=Generator start command and start pnx server.
generate-only=Generate start command only, do not start pnx server.
no-java17=No java17 vms are found. Try `%1s jvm install` to install a java17 vm.
using-jvm=Using JVM: %s1
no-pnx=PNX core not found, will be installed automatically
no-pnx=PNX core not found, Please manual download `PowerNukkitX-Core` from https://github.com/PowerNukkitX/PowerNukkitX/actions
using-pnx=Using PNX core: %s1
restart = Auto-restart pnx server if it crashes.
restart=Auto-restart pnx server if it crashes.
stdin=Input into PNX through a specific file.
no-libs=PNX Libs not found, will be installed automatically
no-libs=PNX Libs not found, Please manual download `PowerNukkitX-Libs` from https://github.com/PowerNukkitX/PowerNukkitX/actions
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ usage.description = \u751f\u6210\u542f\u52a8\u547d\u4ee4\u5e76\u542f\u52a8\u0050
generate-only = \u4ec5\u751f\u6210\u542f\u52a8\u547d\u4ee4\uff0c\u5e76\u4e0d\u542f\u52a8\u0050\u004e\u0058\u670d\u52a1\u5668\u3002
no-java17 = \u5728\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u672a\u627e\u5230\u004a\u0061\u0076\u0061\u0031\u0037\uff0c\u8bf7\u5c1d\u8bd5\u8f93\u5165\u0060\u0025\u0031\u0073\u0020\u006a\u0076\u006d\u0020\u0069\u006e\u0073\u0074\u0061\u006c\u006c\u0060\u6765\u5b89\u88c5\u004a\u0061\u0076\u0061\u0031\u0037\u3002
using-jvm=\u4f7f\u7528\u7684\u004a\u0056\u004d\uff1a%1s
no-pnx=\u672a\u53d1\u73b0PNX\u6838\u5fc3\uff0c\u5c06\u8981\u81ea\u52a8\u5b89\u88c5
no-pnx=\u627e\u4e0d\u5230\u0050\u004e\u0058\u0020\u0063\u006f\u0072\u0065\uff0c\u8bf7\u624b\u52a8\u4e0b\u8f7d\u0060\u0050\u006f\u0077\u0065\u0072\u004e\u0075\u006b\u006b\u0069\u0074\u0058\u002d\u0043\u006f\u0072\u0065\u0060\u0020\u4ece\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0067\u0069\u0074\u0068\u0075\u0062\u002e\u0063\u006f\u006d\u002f\u0050\u006f\u0077\u0065\u0072\u004e\u0075\u006b\u006b\u0069\u0074\u0058\u002f\u0050\u006f\u0077\u0065\u0072\u004e\u0075\u006b\u006b\u0069\u0074\u0058\u002f\u0061\u0063\u0074\u0069\u006f\u006e\u0073
using-pnx=\u4f7f\u7528\u7684\u0050\u004e\u0058\u6838\u5fc3\uff1a%1s
restart = \u5982\u679c\u0070\u006e\u0078\u670d\u52a1\u5668\u5d29\u6e83\uff0c\u5219\u81ea\u52a8\u91cd\u65b0\u542f\u52a8\u3002
stdin=\u4ece\u6307\u5b9a\u6587\u4ef6\u4e2d\u8bfb\u53d6\u63a7\u5236\u53f0\u8f93\u5165
no-libs=PNX\u4f9d\u8d56\u5e93\u672a\u53d1\u73b0\u5c06\u8981\u81ea\u52a8\u5b89\u88c5
no-libs=\u627e\u4e0d\u5230\u0050\u004e\u0058\u0020\u006c\u0069\u0062\u0073\uff0c\u8bf7\u624b\u52a8\u4e0b\u8f7d\u0060\u0050\u006f\u0077\u0065\u0072\u004e\u0075\u006b\u006b\u0069\u0074\u0058\u002d\u004c\u0069\u0062\u0073\u0060\u0020\u4ece\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0067\u0069\u0074\u0068\u0075\u0062\u002e\u0063\u006f\u006d\u002f\u0050\u006f\u0077\u0065\u0072\u004e\u0075\u006b\u006b\u0069\u0074\u0058\u002f\u0050\u006f\u0077\u0065\u0072\u004e\u0075\u006b\u006b\u0069\u0074\u0058\u002f\u0061\u0063\u0074\u0069\u006f\u006e\u0073
10 changes: 0 additions & 10 deletions src/test/java/TestGithubHelper.java

This file was deleted.

Loading

0 comments on commit e487026

Please sign in to comment.