This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
forked from SpigotMC/BungeeCord
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SpigotMC#2447: Add API for fluent server connect requests
API allows for more control over callback to see why the callback was performed whilst maintaining backwards compatibility
- Loading branch information
Showing
3 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package net.md_5.bungee.api; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import net.md_5.bungee.api.config.ServerInfo; | ||
import net.md_5.bungee.api.event.ServerConnectEvent; | ||
|
||
/** | ||
* A request to connect a server. | ||
*/ | ||
@Getter | ||
@Builder(builderClassName = "Builder") | ||
public class ServerConnectRequest | ||
{ | ||
|
||
/** | ||
* The result from this callback after request has been executed by proxy. | ||
*/ | ||
public enum Result | ||
{ | ||
|
||
/** | ||
* ServerConnectEvent to the new server was canceled. | ||
*/ | ||
EVENT_CANCEL, | ||
/** | ||
* Already connected to target server. | ||
*/ | ||
ALREADY_CONNECTED, | ||
/** | ||
* Already connecting to target server. | ||
*/ | ||
ALREADY_CONNECTING, | ||
/** | ||
* Successfully connected to server. | ||
*/ | ||
SUCCESS, | ||
/** | ||
* Connection failed, error can be accessed from callback method handle. | ||
*/ | ||
FAIL | ||
} | ||
|
||
/** | ||
* Target server to connect to. | ||
*/ | ||
@NonNull | ||
private final ServerInfo target; | ||
/** | ||
* Reason for connecting to server. | ||
*/ | ||
@NonNull | ||
private final ServerConnectEvent.Reason reason; | ||
/** | ||
* Callback to execute post request. | ||
*/ | ||
private final Callback<Result> callback; | ||
/** | ||
* Timeout in milliseconds for request. | ||
*/ | ||
private final int connectTimeout; | ||
/** | ||
* Should the player be attempted to connect to the next server in their | ||
* queue if the initial request fails. | ||
*/ | ||
private final boolean retry; | ||
|
||
/** | ||
* Class that sets default properties/adds methods to the lombok builder | ||
* generated class. | ||
*/ | ||
public static class ServerConnectRequestBuilder | ||
{ | ||
|
||
private int connectTimeout = 5000; // TODO: Configurable | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters