diff --git a/build.gradle b/build.gradle index 9296c56..97da60c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'com.bobbyl140' -version = '1.1.1-SNAPSHOT' +version = '1.1.2-SNAPSHOT' repositories { mavenCentral() diff --git a/src/main/java/com/bobbyl140/boulder/Boulder.java b/src/main/java/com/bobbyl140/boulder/Boulder.java index 12ada6b..1dcae79 100644 --- a/src/main/java/com/bobbyl140/boulder/Boulder.java +++ b/src/main/java/com/bobbyl140/boulder/Boulder.java @@ -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; @@ -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()); } }