Add Floodgate integration to LuckPerms#2449
Conversation
|
Looks good so far - let me know when it's ready to be considered for merge. :) |
|
Awesome, great to hear! The Floodgate rewrite seems to be around the corner so this will likely wait until then. |
…dgateintegration
|
Any news yet? |
|
Floodgate 2.0's API is mostly finished, but we're not sure about an ETA. |
|
And? |
|
Just an update that I have not forgotten about this! We have code for the rewrite: https://github.com/Tim203/Floodgate and I'll get back to this once that has entered a testing phase. |
|
Eta? I can't wait for this! |
|
Building @DoctorMacc's Repo and testing it on 1.16.3. |
|
Also quite excited. Thanks for your work ok this @DoctorMacc |
|
Currently doesn't build :/ Error log: https://pastebin.com/FsUSX62G |
|
This has been updated to the latest commit of Master, and the repository for Floodgate has been updated. The rewrite is still incoming but the code here is for the released build of Floodgate. |
|
I just built this successfully and works as expected on my paper server. Thank you! |
|
I've just refactored most of the uuid/username lookup & validation code: 53fb46e This is now all exposed in our API, so other plugins can more easily integrate with our checks instead of having to patch support in across the places where it is implemented in LP. So -- the changes added in this PR can now be more succinctly implemented with the following code: import net.luckperms.api.LuckPerms;
import net.luckperms.api.event.EventBus;
import net.luckperms.api.event.player.lookup.UniqueIdDetermineTypeEvent;
import net.luckperms.api.event.player.lookup.UsernameValidityCheckEvent;
import org.geysermc.floodgate.FloodgateAPI;
import java.util.regex.Pattern;
public class FloodgateHook {
private final Pattern pattern;
public FloodgateHook(LuckPerms luckPerms, String floodgatePrefix) {
if (floodgatePrefix == null || floodgatePrefix.isEmpty()) {
this.pattern = Pattern.compile("[a-zA-Z0-9_]*");
} else {
String pattern = String.format("\\%s?[a-zA-Z0-9_]*", Pattern.quote(floodgatePrefix));
this.pattern = Pattern.compile(pattern);
}
EventBus eventBus = luckPerms.getEventBus();
eventBus.subscribe(UniqueIdDetermineTypeEvent.class, this::onUuidTypeDetermine);
eventBus.subscribe(UsernameValidityCheckEvent.class, this::onUsernameCheck);
}
private void onUuidTypeDetermine(UniqueIdDetermineTypeEvent e) {
if (FloodgateAPI.isBedrockPlayer(e.getUniqueId())) {
e.setType("floodgate");
}
}
private void onUsernameCheck(UsernameValidityCheckEvent e) {
if (!e.isValid() && this.pattern.matcher(e.getUsername()).matches()) {
e.setValid(true);
}
}
}I'm still ok with this being placed in LuckPerms, so long as it can be done in a neat & tidy way. Alternatively, if there is a common module in Floodgate, it might be better suited living there? |
|
There is a common module in Floodgate, yes. I'll deliberate on how to best handle this. Thanks for the heads-up! |
|
how is this going? is still WIP? |
|
Yes, as I plan on waiting until the Floodgate rewrite to complete. |
|
Hope it's going well. Any updates? |
| .append(translatable("luckperms.command.user.info.uuid-type-key")) | ||
| .append(text(": ")) | ||
| .append(mojang ? translatable("luckperms.command.user.info.uuid-type.mojang", DARK_GREEN) : translatable("luckperms.command.user.info.uuid-type.not-mojang", DARK_GRAY)) | ||
| .append(floodgate ? text("Floodgate", GREEN) : mojang ? translatable("luckperms.command.user.info.uuid-type.mojang", DARK_GREEN) : translatable("luckperms.command.user.info.uuid-type.not-mojang", DARK_GRAY)) |
There was a problem hiding this comment.
Small nitpick, why is this GREEN rather than DARK_GREEN as the other options are?
There was a problem hiding this comment.
Just to differentiate it from the other options.
|
@Fernthedev no updates, and the Floodgate rewrite has been making progress but alas it is not here quite yet. |
|
Hello, I'm interested in this update. |
|
The Floodgate rewrite is probably actually coming out soon for realsies.
July 16, 2020 :P |
|
OK, the Floodgate rewrite is finally out for testing. However, with the suggestion Lucko proposed, the changes in Floodgate 2.0, and me not wanting to deal with merge conflicts, I'm going to close this and make a new PR soon. |
Addresses #2236.
This commit adds integration with Floodgate and allows for users to be marked valid without lenient username checking. This has been tested on a Paper instance, and Bungee + Velocity run (though I am not sure how to test them).
/lp user <user> infoalso specifies if a user is Floodgate.TODO:
/lp user <user> infocommand sees the username suggestion as invalid, but the command still runs. This seems specific to LuckPerms.