Update JDK 11

This commit is contained in:
sky 2020-02-03 18:40:13 +08:00
parent 725d2899b2
commit 82d1a1b826
2 changed files with 26 additions and 16 deletions

View File

@ -18,8 +18,8 @@ import java.util.UUID;
*/
public class CommandBuilder {
public static final CompleterTab EMPTY_COMPLETER_TAB = ((sender, args) -> new ArrayList<>());
public static final CompleterCommand EMPTY_COMPLETER_COMMAND = ((sender, args) -> {});
public static final CompleterCommand EMPTY_COMPLETER_COMMAND = ((sender, args) -> {
});
private String command;
private Plugin plugin;
@ -28,7 +28,7 @@ public class CommandBuilder {
private List<String> aliases;
private String permission;
private String permissionMessage;
private CompleterTab completerTab = EMPTY_COMPLETER_TAB;
private CompleterTab completerTab;
private CompleterCommand completerCommand = EMPTY_COMPLETER_COMMAND;
private boolean forceRegister;
private boolean build;
@ -106,7 +106,6 @@ public class CommandBuilder {
Preconditions.checkNotNull(plugin, "缺少 \"plugin\" 部分");
Preconditions.checkNotNull(command, "缺少 \"command\" 部分");
Preconditions.checkNotNull(completerCommand, "缺少 \"CompleterCommand\" 部分");
Preconditions.checkNotNull(completerTab, "缺少 \"CompleterTab\" 部分");
if (forceRegister) {
TCommandHandler.getKnownCommands().remove(command);
}
@ -118,10 +117,12 @@ public class CommandBuilder {
aliases,
permission,
permissionMessage,
completerCommand == null ? null :
(sender, command, s, args) -> {
completerCommand.execute(sender, args);
return true;
},
completerTab == null ? null :
(sender, command, s, args) -> {
try {
return completerTab.execute(sender, args);

View File

@ -319,6 +319,15 @@ public class Files {
}
}
public static void write(File file, WriteHandle writeHandle, boolean append) {
try (FileWriter fileWriter = new FileWriter(file, append); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) {
writeHandle.write(bufferedWriter);
bufferedWriter.flush();
} catch (Throwable t) {
t.printStackTrace();
}
}
public static void write(OutputStream out, WriteHandle writeHandle) {
try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(out); BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter)) {
writeHandle.write(bufferedWriter);