Improve BungeeCord support
Opened this issue · 2 comments
To me, the current BungeeCord module is quite simple and not as well-thought-out as some others modules.
I see some improvements we could make (it's annoying to create a lot of issues so we can discuss here and then split):
Outdated argument/contextual message approach
This module doesn't use modern MessageKey
system and still uses legacy generic+constructor variant.
No Adventure environment present
Maybe we can add something like bukkit-adventure
which would accept a BungeeAudiences
instance? Adventure supports BungeeCord and we all (I hope) love MiniMessage, so this is something what default modern plugin would use. BungeeCord isn't really legacy thing by its own, it still can be used in many modern environments.
No platform-specific arguments
To me, we need to add at least:
ProxiedPlayer
Nothing to say, just online player.
ServerInfo
Maybe also restrict it somehow, so players won't see servers they don't have access to in tab-complete? However, I would use such an argument only for admins.
Offline players
It's a kinda difficult but would look nicely - we don't have OfflinePlayer
like in Bukkit but we can extract nicknames from some different source, like optionally hooking into LuckPerms. Also, it's important that such an argument must accept any input, maybe we can do a POJO like a OfflineProxiedPlayer(@Nullable ProxiedPlayer)
This can be a great and platform-independent API, actually. We could make something like...
interface OfflinePlayerSource {
Optional<PlatformOfflinePlayer> find(String name);
Set<String> names();
}
...and then add a default implementation that would use something it can, for example, hook into the LuckPerms if it's installed or remember player names entered the network during this session. There are a lot to discuss.
I am ready to contribute for these features.
It's a how we would take all the nicknames from LuckPerms (it's in Kotlin but I believe you understand the idea):
fun main() {
with(LuckPermsProvider.get().userManager) {
val nicknames = uniqueUsers.join().asSequence()
.map { getOrLoadUser(it) }
.mapNotNull { it.username }
.toCollection(HashSet())
}
}
fun UserManager.getOrLoadUser(uuid: UUID): User {
return this.getUser(uuid) ?: this.loadUser(uuid).join()
}
We could load all usernames on startup async and then listen to UserFirstLoginEvent
so we can update a local cache without database lookup.
Thanks @BlackBaroness for issue. Yeah, I forgot to implement the modern features in the bungee platform.
TODO list:
- ProxiedPlayer argument
- ServerInfo argument
- ServerInfo context provider
- use modern MessageKey for messages
Offline player
I think it's better for someone to self-implement it.
No Adventure environment present
Currently you can use adventure on the Bungee platform.
See on this code:
You can use only litecommands-bukkit
and litecommands-adventure-platform
to enable the adventure extension.