[1.0.1] pref: update tab complete

This commit is contained in:
thehrz 2025-03-15 09:59:15 +08:00
parent 219f43243d
commit 5311716574
Signed by: thehrz
GPG Key ID: C84CBCE7D5F88855
13 changed files with 28 additions and 29 deletions

View File

@ -5,7 +5,7 @@ plugins {
} }
group = "io.github.thehrz.allmusicreload" group = "io.github.thehrz.allmusicreload"
version = "1.0.0" version = "1.0.1"
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -5,7 +5,7 @@ import java.util.List;
public abstract class ACommand implements ICommand { public abstract class ACommand implements ICommand {
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
return Collections.emptyList(); return Collections.emptyList();
} }
} }

View File

@ -25,7 +25,7 @@ public class CommandBan extends ACommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index || (args.length == index + 1 && args[index].isEmpty())) { if (args.length == index || (args.length == index + 1 && args[index].isEmpty())) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
if (PlayMusic.nowPlayMusic != null) { if (PlayMusic.nowPlayMusic != null) {

View File

@ -18,7 +18,7 @@ public class CommandBanPlayer implements ICommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index || (args.length == index + 1 && args[index].isEmpty())) { if (args.length == index || (args.length == index + 1 && args[index].isEmpty())) {
return AllMusic.side.getPlayerList(); return AllMusic.side.getPlayerList();
} }

View File

@ -50,7 +50,7 @@ public class CommandCancel implements ICommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == 1 || (args.length == 2 && args[1].isEmpty())) { if (args.length == 1 || (args.length == 2 && args[1].isEmpty())) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
List<SongInfoObj> list1 = PlayMusic.getList(); List<SongInfoObj> list1 = PlayMusic.getList();

View File

@ -33,7 +33,7 @@ public class CommandDelete extends ACommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == 1 || (args.length == 2 && args[1].isEmpty())) { if (args.length == 1 || (args.length == 2 && args[1].isEmpty())) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
for (int a = 0; a < PlayMusic.getListSize(); a++) { for (int a = 0; a < PlayMusic.getListSize(); a++) {

View File

@ -153,12 +153,11 @@ public class CommandEX {
if (args[0].contains("id=") && !args[0].contains("/?userid")) { if (args[0].contains("id=") && !args[0].contains("/?userid")) {
if (args[0].contains("&uct2")) { if (args[0].contains("&uct2")) {
musicID = Function.getString(args[0], "id=", "&uct2"); musicID = Function.getString(args[0], "id=", "&uct2");
} } else if (args[0].contains("&user"))
else if (args[0].contains("&user"))
musicID = Function.getString(args[0], "id=", "&user"); musicID = Function.getString(args[0], "id=", "&user");
else else
musicID = Function.getString(args[0], "id=", null); musicID = Function.getString(args[0], "id=", null);
} else if (args[0].contains("song/")) { } else if (args[0].contains("song/")) {
if (args[0].contains("/?userid")) if (args[0].contains("/?userid"))
musicID = Function.getString(args[0], "song/", "/?userid"); musicID = Function.getString(args[0], "song/", "/?userid");
else else
@ -213,7 +212,7 @@ public class CommandEX {
return true; return true;
} }
} }
return false; return false;
} }
/** /**
@ -263,11 +262,11 @@ public class CommandEX {
* @param arg 参数 * @param arg 参数
* @return 指令列表 * @return 指令列表
*/ */
public static List<String> getTabList(String name, String[] arg) { public static List<String> getTabList(Object sender, String name, String[] arg) {
List<String> arguments = new ArrayList<>(); List<String> arguments = new ArrayList<>();
if (arg.length == 0) { if (arg.length == 0) {
arguments.addAll(normal); arguments.addAll(normal);
if (AllMusic.side.checkPermission(name)) { if (AllMusic.side.checkPermission(sender)) {
arguments.addAll(admin); arguments.addAll(admin);
} }
if (AllMusic.getSearch(name) != null) { if (AllMusic.getSearch(name) != null) {
@ -276,7 +275,7 @@ public class CommandEX {
} else { } else {
if (arg[0] == null || arg[0].isEmpty() || arg.length == 1) { if (arg[0] == null || arg[0].isEmpty() || arg.length == 1) {
arguments.addAll(normal); arguments.addAll(normal);
if (AllMusic.side.checkPermission(name)) { if (AllMusic.side.checkPermission(sender)) {
arguments.addAll(admin); arguments.addAll(admin);
} }
if (arg[0] == null || arg[0].isEmpty()) { if (arg[0] == null || arg[0].isEmpty()) {
@ -287,12 +286,12 @@ public class CommandEX {
} else { } else {
ICommand command = CommandEX.commandList.get(arg[0]); ICommand command = CommandEX.commandList.get(arg[0]);
if (command != null) { if (command != null) {
arguments.addAll(command.tab(name, arg, 1)); arguments.addAll(command.tab(sender, name, arg, 1));
} }
if (AllMusic.side.checkPermission(name)) { if (AllMusic.side.checkPermission(sender)) {
command = CommandEX.commandAdminList.get(arg[0]); command = CommandEX.commandAdminList.get(arg[0]);
if (command != null) { if (command != null) {
arguments.addAll(command.tab(name, arg, 1)); arguments.addAll(command.tab(sender, name, arg, 1));
} }
} }
} }

View File

@ -45,13 +45,13 @@ public class CommandHud extends ACommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index + 1) { if (args.length == index + 1) {
return hudlist; return hudlist;
} else { } else {
ICommand command = commandList.get(args[index]); ICommand command = commandList.get(args[index]);
if (command != null) { if (command != null) {
return command.tab(name, args, index + 1); return command.tab(player, name, args, index + 1);
} }
} }
return Collections.emptyList(); return Collections.emptyList();
@ -76,7 +76,7 @@ public class CommandHud extends ACommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index + 1) { if (args.length == index + 1) {
return tf; return tf;
} }

View File

@ -65,7 +65,7 @@ public class CommandHudSet extends AHudCommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index + 1) { if (args.length == index + 1) {
List<String> list = new ArrayList<>(hud); List<String> list = new ArrayList<>(hud);
if (type == HudType.PIC) { if (type == HudType.PIC) {
@ -78,7 +78,7 @@ public class CommandHudSet extends AHudCommand {
} else { } else {
ICommand command = commandList.get(args[index]); ICommand command = commandList.get(args[index]);
if (command != null) { if (command != null) {
return command.tab(name, args, index + 1); return command.tab(player, name, args, index + 1);
} }
} }
return Collections.emptyList(); return Collections.emptyList();
@ -104,7 +104,7 @@ public class CommandHudSet extends AHudCommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index + 1) { if (args.length == index + 1) {
return tf; return tf;
} }
@ -181,7 +181,7 @@ public class CommandHudSet extends AHudCommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index + 1) { if (args.length == index + 1) {
return dir; return dir;
} }
@ -229,7 +229,7 @@ public class CommandHudSet extends AHudCommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index + 1) { if (args.length == index + 1) {
return tf; return tf;
} }
@ -263,7 +263,7 @@ public class CommandHudSet extends AHudCommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index + 1) { if (args.length == index + 1) {
return tf; return tf;
} }

View File

@ -95,7 +95,7 @@ public class CommandPush extends ACommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == 1 || (args.length == 2 && args[1].isEmpty())) { if (args.length == 1 || (args.length == 2 && args[1].isEmpty())) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
List<SongInfoObj> list1 = PlayMusic.getList(); List<SongInfoObj> list1 = PlayMusic.getList();

View File

@ -38,7 +38,7 @@ public class CommandSelect extends ACommand {
} }
@Override @Override
public List<String> tab(String name, String[] args, int index) { public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == 1 || (args.length == 2 && args[1].isEmpty())) { if (args.length == 1 || (args.length == 2 && args[1].isEmpty())) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
SearchPageObj obj = AllMusic.getSearch(name); SearchPageObj obj = AllMusic.getSearch(name);

View File

@ -6,5 +6,5 @@ public interface ICommand {
void execute(Object sender, String name, String[] args); void execute(Object sender, String name, String[] args);
List<String> tab(String name, String[] args, int index); List<String> tab(Object sender, String name, String[] args, int index);
} }

View File

@ -32,7 +32,7 @@ public class CommandVelocity implements SimpleCommand {
if (invocation.source() instanceof Player) { if (invocation.source() instanceof Player) {
Player player = (Player) invocation.source(); Player player = (Player) invocation.source();
String name = player.getUsername(); String name = player.getUsername();
return CommandEX.getTabList(name, args); return CommandEX.getTabList(player, name, args);
} }
return ImmutableList.of(); return ImmutableList.of();
} }