Updated to 1.21 by switching to cosmos
This commit is contained in:
@@ -7,7 +7,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -39,12 +39,13 @@ public class PartyCommand implements SimpleCommand {
|
||||
CommandSource source = invocation.source();
|
||||
|
||||
if (args.length < 1) {
|
||||
if (!source.hasPermission("party.use"))
|
||||
if (!source.hasPermission("party.use")) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NO_PERMISSION));
|
||||
else if (source instanceof Player)
|
||||
} else if (source instanceof Player) {
|
||||
source.sendMessage(getHelpMessage(source));
|
||||
else
|
||||
} else {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NO_CONSOLE));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,11 +53,12 @@ public class PartyCommand implements SimpleCommand {
|
||||
.filter(subCommand -> subCommand.getName().equalsIgnoreCase(args[0]))
|
||||
.findFirst()
|
||||
.ifPresentOrElse(subCommand -> {
|
||||
if (source.hasPermission(subCommand.getPermission()))
|
||||
if (source.hasPermission(subCommand.getPermission())) {
|
||||
subCommand.execute(args, source);
|
||||
else
|
||||
} else {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NO_PERMISSION));
|
||||
}, () -> source.sendMessage(getHelpMessage(source)));
|
||||
}
|
||||
}, () -> source.sendMessage(getHelpMessage(source)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,9 +66,9 @@ public class PartyCommand implements SimpleCommand {
|
||||
String[] args = invocation.arguments();
|
||||
List<String> suggest = new ArrayList<>();
|
||||
|
||||
if (!invocation.source().hasPermission("party.use"))
|
||||
if (!invocation.source().hasPermission("party.use")) {
|
||||
return suggest;
|
||||
else if (args.length == 0) {
|
||||
} else if (args.length == 0) {
|
||||
subCommands.stream()
|
||||
.filter(subCommand -> invocation.source().hasPermission(subCommand.getPermission()))
|
||||
.forEach(subCommand -> suggest.add(subCommand.getName()));
|
||||
@@ -83,10 +85,11 @@ public class PartyCommand implements SimpleCommand {
|
||||
.ifPresent(subCommand -> suggest.addAll(subCommand.suggest(args, invocation.source())));
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
if (args.length == 0) {
|
||||
return suggest;
|
||||
else
|
||||
} else {
|
||||
return finalizeSuggest(suggest, args[args.length - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> finalizeSuggest(List<String> possibleValues, String remaining) {
|
||||
@@ -101,19 +104,21 @@ public class PartyCommand implements SimpleCommand {
|
||||
return finalValues;
|
||||
}
|
||||
|
||||
public Component getHelpMessage(CommandSource source) {
|
||||
public ComponentLike getHelpMessage(CommandSource source) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
subCommands.stream()
|
||||
.filter(subCommand -> source.hasPermission(subCommand.getPermission()))
|
||||
.forEach(subCommand -> stringBuilder.append(subCommand.getHelpMessage()).append("\n"));
|
||||
if (source.hasPermission("command.chat.p"))
|
||||
if (source.hasPermission("command.chat.p")) {
|
||||
stringBuilder.append(Config.PARTY_HELP_CHAT).append("\n");
|
||||
if (stringBuilder.length() != 0)
|
||||
}
|
||||
if (!stringBuilder.isEmpty()) {
|
||||
stringBuilder.replace(stringBuilder.length() - 1, stringBuilder.length(), "");
|
||||
}
|
||||
|
||||
return Utility.parseMiniMessage(Config.PARTY_HELP_WRAPPER,
|
||||
Placeholder.component("commands", Utility.parseMiniMessage(stringBuilder.toString()))
|
||||
);
|
||||
Placeholder.component("commands", Utility.parseMiniMessage(stringBuilder.toString()))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user