parent
07f8101c13
commit
9585dab04d
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>me.skymc</groupId>
|
||||
<artifactId>TabooLib</artifactId>
|
||||
<version>4.21</version>
|
||||
<version>4.22</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
|
|
@ -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<String> 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,
|
||||
|
|
|
@ -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<BaseComponent> 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<BaseComponent> components = new ArrayList<>(this.components);
|
||||
components.addAll(componentsLatest);
|
||||
return components.toArray(new BaseComponent[0]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue