feat: allow /phome <name> on uniquely named homes

If multiple public homes with the same name exist, typing /phome (name) will bring up a filtered public home list containing the list of public homes with that name for you to click on. The username-prefixed name will also be the only one to show up in TAB.

This commit also fixes a bug with home/warp lists showing a blank description on hover instead of `(none)`.
This commit is contained in:
William committed 2024-03-31 17:40:38 +01:00
1 parent 0135966c6e
commit 4e9046395c
32 files changed
+353 -81

No files matched your search

@@ -81,9 +81,11 @@ public class HomesManager {
*/
@NotNull
public Map<String, List<String>> getPublicHomes() {
return publicHomes.stream()
.collect(HashMap::new, (m, e) -> m.put(e.getOwner().getUsername(), List.of(e.getName())),
HashMap::putAll);
return publicHomes.stream().collect(
HashMap::new,
(m, e) -> m.put(e.getOwner().getUsername(), List.of(e.getName())),
HashMap::putAll
);
}
/**
@@ -92,9 +94,26 @@ public class HomesManager {
* @return a list of all cached public home identifiers
*/
@NotNull
public List<String> getPublicHomeIdentifiers() {
public List<String> getPublicHomeIdentifierNames() {
return publicHomes.stream().map(Home::getIdentifier).toList();
}
/**
* Get a list of all cached public homes.
* <p>
* This will return the full home identifier if there are multiple homes with the same name.
*
* @return a list of all cached public home identifiers
*/
@NotNull
public List<String> getPublicHomeNames() {
return publicHomes.stream()
.map(Home::getIdentifier)
.map(home -> {
if (publicHomes.stream().filter(h -> h.getName().equals(home.getName())).count() > 1) {
return home.getIdentifier();
}
return home.getName();
})
.toList();
}