diff --git a/pom.xml b/pom.xml
index 8900a75..995be96 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.skymc
TabooLib
- 4.21
+ 4.22
UTF-8
diff --git a/src/main/java/me/skymc/taboolib/commands/builder/SimpleCommandBuilder.java b/src/main/java/me/skymc/taboolib/commands/builder/SimpleCommandBuilder.java
index 656cb56..9e7efbd 100644
--- a/src/main/java/me/skymc/taboolib/commands/builder/SimpleCommandBuilder.java
+++ b/src/main/java/me/skymc/taboolib/commands/builder/SimpleCommandBuilder.java
@@ -19,6 +19,9 @@ import java.util.List;
*/
public class SimpleCommandBuilder {
+ public static final CompleterTab EMPTY_COMPLETER_TAB = ((sender, args) -> new ArrayList<>());
+ public static final CompleterCommand EMPTY_COMPLETER_COMMAND = ((sender, args) -> false);
+
private final String command;
private final Plugin plugin;
private String description;
@@ -26,8 +29,8 @@ public class SimpleCommandBuilder {
private List aliases;
private String permission;
private String permissionMessage;
- private CompleterCommand completerCommand;
- private CompleterTab completerTab;
+ private CompleterTab completerTab = EMPTY_COMPLETER_TAB;
+ private CompleterCommand completerCommand = EMPTY_COMPLETER_COMMAND;
SimpleCommandBuilder(String command, Plugin plugin) {
this.command = command;
@@ -78,6 +81,7 @@ public class SimpleCommandBuilder {
public SimpleCommandBuilder build() {
Preconditions.checkNotNull(completerCommand, "缺少 \"CompleterCommand\" 部分");
+ Preconditions.checkNotNull(completerTab, "缺少 \"CompleterTab\" 部分");
TCommandHandler.registerPluginCommand(
plugin,
command,
diff --git a/src/main/java/me/skymc/taboolib/json/tellraw/TellrawJson.java b/src/main/java/me/skymc/taboolib/json/tellraw/TellrawJson.java
index 94ba081..ba2e288 100644
--- a/src/main/java/me/skymc/taboolib/json/tellraw/TellrawJson.java
+++ b/src/main/java/me/skymc/taboolib/json/tellraw/TellrawJson.java
@@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
/**
* @Author sky
@@ -93,6 +94,12 @@ public class TellrawJson {
return this;
}
+ public BaseComponent[] getComponentsAll() {
+ List components = this.components.stream().filter(component -> !(component instanceof TextComponent) || !((TextComponent) component).getText().isEmpty()).collect(Collectors.toList());
+ this.componentsLatest.stream().filter(component -> !(component instanceof TextComponent) || !((TextComponent) component).getText().isEmpty()).forEach(components::add);
+ return components.toArray(new BaseComponent[0]);
+ }
+
public String getItemComponent(ItemStack itemStack) {
try {
Method asNMSCopyMethod = ReflectionUtils.getMethod(craftItemStackClazz, "asNMSCopy", ItemStack.class);
@@ -138,10 +145,4 @@ public class TellrawJson {
public BaseComponent[] getComponents() {
return components.toArray(new BaseComponent[0]);
}
-
- public BaseComponent[] getComponentsAll() {
- List components = new ArrayList<>(this.components);
- components.addAll(componentsLatest);
- return components.toArray(new BaseComponent[0]);
- }
}