Skip to content

Add Floodgate integration to LuckPerms#2449

Closed
Camotoy wants to merge 7 commits into
LuckPerms:masterfrom
Camotoy:floodgateintegration
Closed

Add Floodgate integration to LuckPerms#2449
Camotoy wants to merge 7 commits into
LuckPerms:masterfrom
Camotoy:floodgateintegration

Conversation

@Camotoy
Copy link
Copy Markdown

@Camotoy Camotoy commented Jul 10, 2020

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> info also specifies if a user is Floodgate.

TODO:

  • A Java account running the /lp user <user> info command sees the username suggestion as invalid, but the command still runs. This seems specific to LuckPerms.
  • Floodgate may get an API overhaul - one of the reasons this is marked as WIP.

@lucko
Copy link
Copy Markdown
Member

lucko commented Jul 16, 2020

Looks good so far - let me know when it's ready to be considered for merge. :)

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Jul 16, 2020

Awesome, great to hear! The Floodgate rewrite seems to be around the corner so this will likely wait until then.

@Peda1996
Copy link
Copy Markdown

Any news yet?

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Aug 22, 2020

Floodgate 2.0's API is mostly finished, but we're not sure about an ETA.

@CodeDoctorDE
Copy link
Copy Markdown

And?

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Oct 3, 2020

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.

@DwifteJB
Copy link
Copy Markdown

Eta? I can't wait for this!

@DwifteJB
Copy link
Copy Markdown

Building @DoctorMacc's Repo and testing it on 1.16.3.

@ericgcollyer
Copy link
Copy Markdown

Also quite excited. Thanks for your work ok this @DoctorMacc

@acanthii
Copy link
Copy Markdown

Currently doesn't build :/

Error log: https://pastebin.com/FsUSX62G

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Nov 16, 2020

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.

@incredimike
Copy link
Copy Markdown

I just built this successfully and works as expected on my paper server. Thank you!

@lucko
Copy link
Copy Markdown
Member

lucko commented Nov 24, 2020

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?

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Nov 24, 2020

There is a common module in Floodgate, yes.

I'll deliberate on how to best handle this. Thanks for the heads-up!

@Snivine
Copy link
Copy Markdown

Snivine commented Dec 1, 2020

how is this going? is still WIP?

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Dec 1, 2020

Yes, as I plan on waiting until the Floodgate rewrite to complete.

@Fernthedev
Copy link
Copy Markdown

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))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick, why is this GREEN rather than DARK_GREEN as the other options are?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to differentiate it from the other options.

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Jan 13, 2021

@Fernthedev no updates, and the Floodgate rewrite has been making progress but alas it is not here quite yet.

@PappoYT
Copy link
Copy Markdown

PappoYT commented Mar 3, 2021

Hello, I'm interested in this update.
Are there any news about? TY

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Mar 4, 2021

The Floodgate rewrite is probably actually coming out soon for realsies.

The Floodgate rewrite seems to be around the corner

July 16, 2020 :P

@Camotoy
Copy link
Copy Markdown
Author

Camotoy commented Mar 25, 2021

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.

@Camotoy Camotoy closed this Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.