Commands now filter searched terms.

This commit is contained in:
jameslfc19 2020-07-12 18:29:57 +01:00
parent f59a61662d
commit 2ff2ec75bf
3 changed files with 11 additions and 11 deletions

View File

@ -183,10 +183,10 @@ public class AutoCraftCommand extends ServerCommand {
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
case ADD:
case OPEN:
return Config.getAutoCraft().getOpenableStorageList(player);
return Config.getAutoCraft().getOpenableStorageList(player, args[1]);
case REMOVE:
case RENAME:
return Config.getAutoCraft().getStorageList(player);
return Config.getAutoCraft().getStorageList(player, args[1]);
case MEMBER:
return Arrays.asList("add","remove","list");
}
@ -196,7 +196,7 @@ public class AutoCraftCommand extends ServerCommand {
try {
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
case MEMBER:
return Config.getAutoCraft().getStorageList(player);
return Config.getAutoCraft().getStorageList(player, args[2]);
}
} catch (IllegalArgumentException ignored) { }
}

View File

@ -204,11 +204,11 @@ public class ChestLinkCommand extends ServerCommand {
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
case ADD:
case OPEN:
return Config.getChestLink().getOpenableStorageList(player);
return Config.getChestLink().getOpenableStorageList(player, args[1]);
case REMOVE:
case SORT:
case RENAME:
return Config.getChestLink().getStorageList(player);
return Config.getChestLink().getStorageList(player, args[1]);
case MEMBER:
return Arrays.asList("add","remove","list");
}
@ -218,7 +218,7 @@ public class ChestLinkCommand extends ServerCommand {
try {
switch (OPTIONS.valueOf(args[0].toUpperCase())) {
case MEMBER:
return Config.getChestLink().getStorageList(player);
return Config.getChestLink().getStorageList(player, args[2]);
case SORT:
return SortMethod.valuesList;
}

View File

@ -329,13 +329,13 @@ public abstract class StorageType<T extends AbstractStorage> {
}
}
public List<String> getStorageList(Player player){
return getStorageMap(player.getUniqueId()).values().stream().map(AbstractStorage::getIdentifier).collect(Collectors.toList());
public List<String> getStorageList(Player player, String searchedArg){
return getStorageMap(player.getUniqueId()).values().stream().filter(t -> t.getIdentifier().contains(searchedArg)).map(AbstractStorage::getIdentifier).collect(Collectors.toList());
}
public List<String> getOpenableStorageList(Player player){
List<String> playerList = getStorageList(player);
List<String> memberList = getStorageMemberOf(player).stream().map(storage -> storage.getOwner().getName()+":"+storage.getIdentifier()).collect(Collectors.toList());
public List<String> getOpenableStorageList(Player player, String searchedArg){
List<String> playerList = getStorageList(player, searchedArg);
List<String> memberList = getStorageMemberOf(player).stream().filter(t -> t.getIdentifier().contains(searchedArg)).map(storage -> storage.getOwner().getName()+":"+storage.getIdentifier()).collect(Collectors.toList());
playerList.addAll(memberList);
return playerList;
}