feat: code
This commit is contained in:
@@ -53,12 +53,11 @@ public class PlayerBindListener implements Listener {
|
||||
return;
|
||||
|
||||
try {
|
||||
var response = this.plugin.getBindRequest()
|
||||
.checkPlayerBindStatus(uuid, event.getConnection().getProfile().getName())
|
||||
.join();
|
||||
var response = this.plugin.getBindRequest().checkPlayerBindStatus(uuid, null).join();
|
||||
|
||||
PlayerBindStatusEnum status = response.getStatus();
|
||||
|
||||
plugin.getSLF4JLogger().info(status.toString());
|
||||
if (status == PlayerBindStatusEnum.BOUND) {
|
||||
return;
|
||||
} else if (status == PlayerBindStatusEnum.NOT_BOUND) {
|
||||
@@ -85,13 +84,31 @@ public class PlayerBindListener implements Listener {
|
||||
audience.showDialog(dialog);
|
||||
|
||||
PlayerBindResponse bindResponse = dialogResponse.join();
|
||||
if (bindResponse.getStatus() != PlayerBindEnum.BOUND) {
|
||||
if (bindResponse == null) {
|
||||
audience.closeDialog();
|
||||
connection.disconnect(
|
||||
Component.text("Operation timed out, please try again.", NamedTextColor.RED)
|
||||
);
|
||||
awaitingResponse.remove(uniqueId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bindResponse.getStatus() == PlayerBindEnum.BOUND) {
|
||||
return;
|
||||
} else if (bindResponse.getStatus() == PlayerBindEnum.PENDING) {
|
||||
audience.closeDialog();
|
||||
String msg = "Binding request submitted!\nPlease go to Mineroo.Online to confirm the "
|
||||
+ "binding. After confirmation, please re-enter the server.";
|
||||
connection.disconnect(Component.text(msg, NamedTextColor.GREEN));
|
||||
} else {
|
||||
audience.closeDialog();
|
||||
|
||||
String statusStr = (status != null) ? status.toString() : "UNKNOWN_STATUS";
|
||||
String statusStr = (bindResponse.getStatus() != null)
|
||||
? bindResponse.getStatus().toString()
|
||||
: "UNKNOWN_STATUS";
|
||||
String msg = bindResponse.getMessage();
|
||||
if (msg == null)
|
||||
msg = "Unkown";
|
||||
msg = "Bind failed.";
|
||||
|
||||
String kickMessage = statusStr + " : " + msg;
|
||||
|
||||
@@ -145,7 +162,7 @@ public class PlayerBindListener implements Listener {
|
||||
BindRequest bindRequest = plugin.getBindRequest();
|
||||
String playerName = conn.getProfile().getName();
|
||||
|
||||
bindRequest.PlayerBindRequest(userEmail, uniqueId.toString(), conn.getProfile().getName())
|
||||
bindRequest.PlayerBindRequest(userEmail, uniqueId, conn.getProfile().getName())
|
||||
.thenAccept(response -> { setConnectionJoinResult(uniqueId, response); })
|
||||
.exceptionally(ex -> {
|
||||
logger.error("Error occurred during bind request for " + playerName, ex);
|
||||
|
||||
Reference in New Issue
Block a user