Skip to content

Commit

Permalink
Change PreLoginEvent to PostLoginEvent to fix Bedrock XUID to UUID.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyl140 committed Oct 2, 2024
1 parent 5461774 commit 73d780b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.bobbyl140'
version = '1.1.1-SNAPSHOT'
version = '1.1.2-SNAPSHOT'

repositories {
mavenCentral()
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/bobbyl140/boulder/Boulder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.slf4j.Logger;

import com.velocitypowered.api.event.connection.PreLoginEvent;
import com.velocitypowered.api.event.connection.PostLoginEvent;

import javax.inject.Inject;
import java.io.IOException;
Expand Down Expand Up @@ -133,14 +134,14 @@ public void sendNotificationToStaff(String message, String uuid) {
}

@Subscribe
public void onPreLogin(PreLoginEvent event) {
UUID account = event.getUniqueId();
public void onPostLogin(PostLoginEvent event) {
UUID account = event.getPlayer().getUniqueId();

if (isValidUUID(account.toString()) && !whitelist.contains(account.toString())) {
event.setResult(PreLoginEvent.PreLoginComponentResult.denied(Component.text("You have not been whitelisted on this server. Please contact a moderator for access.")));
logger.info("User {} with UUID {} tried to login.", event.getUsername(), event.getUniqueId());
event.getPlayer().disconnect(Component.text("You have not been whitelisted on this server. Please contact a moderator for access."));
logger.info("User {} with UUID {} tried to login.", event.getPlayer().getUsername(), event.getPlayer().getUsername());
logger.info("To whitelist this user, run the following: /whitelist add " + account);
sendNotificationToStaff("User " + event.getUsername() + " with UUID " + event.getUniqueId() + " tried to login. Click HERE and press enter to whitelist them.", event.getUniqueId().toString());
sendNotificationToStaff("User " + event.getPlayer().getUsername() + " with UUID " + event.getPlayer().getUniqueId() + " tried to login. Click HERE and press enter to whitelist them.", event.getPlayer().getUniqueId().toString());
}
}

Expand Down

0 comments on commit 73d780b

Please sign in to comment.