Skip to content

Commit

Permalink
Fix togglehome not tab completing the HomeAccessType, fix error messa…
Browse files Browse the repository at this point in the history
…ge missing param
  • Loading branch information
md5sha256 committed Mar 23, 2024
1 parent b524b1c commit 703bbc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Singleton
Expand Down Expand Up @@ -59,7 +60,7 @@ public void execute(CommandSender sender, String[] args) {
try {
accessType = HomeAccessType.valueOf(rawAccessType.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
this.messageBridge.message(sender, "togglehome-unknownAccessType");
this.messageBridge.message(sender, "togglehome-unknownAccessType", rawAccessType);
return;
}
final GeneralRegion region;
Expand Down Expand Up @@ -101,22 +102,29 @@ public List<String> getTabCompleteList(int toComplete, String[] start, CommandSe
return Collections.emptyList();
}
if (start.length == 1) {
return Stream.of(HomeAccessType.values())
.map(HomeAccessType::name)
.filter(name -> name.startsWith(start[0]))
.sorted(Comparator.reverseOrder())
.collect(Collectors.toList());
}
if (start.length == 2) {
Stream<GeneralRegion> stream = this.fileManager.getRegions().stream();
if (!sender.hasPermission("sethome.control.other") && sender instanceof Player player) {
stream = stream.filter(region -> region.isOwner(player.getUniqueId()));
}
return stream.map(GeneralRegion::getName)
.filter(name -> name.startsWith(start[0]))
.sorted(Comparator.reverseOrder())
.toList();
.collect(Collectors.toList());
}
if (start.length == 2 && sender instanceof Player player) {
if (start.length == 3 && sender instanceof Player player) {
return this.fileManager.getRegions().stream()
.filter(region -> region.isOwner(player.getUniqueId()))
.map(GeneralRegion::getName)
.filter(name -> name.startsWith(start[0]))
.sorted(Comparator.reverseOrder())
.toList();
.collect(Collectors.toList());
}
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static Component convertMessage(@Nonnull Message message) {
message.doReplacements();

StringBuilder messageStr = new StringBuilder();
for (String line : message.get()) {
for (String line : message.getRaw()) {
messageStr.append(line);
}

Expand Down

0 comments on commit 703bbc6

Please sign in to comment.