Package de.themoep.connectorplugin
Class BridgeCommon<P extends ConnectorPlugin<R>,R>
java.lang.Object
de.themoep.connectorplugin.BridgeCommon<P,R>
- Direct Known Subclasses:
Bridge
,ProxyBridgeCommon
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
protected static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<String,
BridgeCommon.PlayerInfo> protected final P
protected static final Random
protected final com.google.common.cache.Cache<Long,
ResponseHandler<?>> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPlayerInfo
(BridgeCommon.PlayerInfo playerInfo) getLocation
(String player) Get the location a player is atabstract CompletableFuture<LocationInfo>
getLocation
(R player) Get the location a player is atGet the server a player is connected toabstract CompletableFuture<String>
Get the server a player is connected toprotected void
handleResponse
(long id, com.google.common.io.ByteArrayDataInput in) boolean
isTeleporting
(String playerName) Get whether a player with that name is currently teleporting.protected boolean
markTeleporting
(String playerName) protected BiConsumer<R,
Message> registerHandler
(String action, BiConsumer<R, byte[]> handler) Register a bridge data handler for a certain actionprotected BiConsumer<R,
Message> registerMessageHandler
(String action, BiConsumer<R, BridgeCommon.BridgeMessage> handler) Register a bridge message handler for a certain actionprotected void
removePlayerInfo
(String player) runProxyConsoleCommand
(String proxy, String command, Consumer<String>... consumer) Run a console command on a specific other proxyrunServerConsoleCommand
(String server, String command, Consumer<String>... consumer) Run a console command on the target servervoid
sendData
(String action, MessageTarget target, byte[] data) Send data to a specific targetprotected void
sendData
(String action, MessageTarget target, String targetData, byte[] data) Send data to a specific targetprotected void
sendData
(String action, MessageTarget target, R player, byte[] data) Send data to a specific targetprotected void
sendResponse
(String target, long id, Object response, String... messages) protected abstract void
sendResponseData
(String target, byte[] out) protected void
sendResponseMessage
(String target, long id, String... messages) abstract CompletableFuture<Boolean>
teleport
(String playerName, LocationInfo location, Consumer<String>... consumer) Teleport a player to a certain location in the networkabstract CompletableFuture<Boolean>
Teleport a player to a certain location in the networkabstract CompletableFuture<Boolean>
Teleport a player to a certain other player in the networkabstract CompletableFuture<Boolean>
teleport
(R player, LocationInfo location, Consumer<String>... consumer) Teleport a player to a certain location in the networkabstract CompletableFuture<Boolean>
Teleport a player to a certain location in the networkabstract CompletableFuture<Boolean>
Teleport a player to a certain other player in the networkprotected boolean
unmarkTeleporting
(String playerName)
-
Field Details
-
plugin
-
playerInfoMap
-
responses
-
consumers
-
RANDOM
-
-
Constructor Details
-
BridgeCommon
-
-
Method Details
-
registerHandler
Register a bridge data handler for a certain action- Parameters:
action
- The action to register (case sensitive)handler
- A BiConsumer which takes the receiving player and the data- Returns:
- The previously registered handler if there was one
-
registerMessageHandler
protected BiConsumer<R,Message> registerMessageHandler(String action, BiConsumer<R, BridgeCommon.BridgeMessage> handler) Register a bridge message handler for a certain action- Parameters:
action
- The action to register (case sensitive)handler
- A BiConsumer which takes the receiving player and the message- Returns:
- The previously registered handler if there was one
-
teleport
public abstract CompletableFuture<Boolean> teleport(R player, LocationInfo location, Consumer<String>... consumer) Teleport a player to a certain location in the network- Parameters:
player
- The player to teleportlocation
- The location to teleport toconsumer
- Details about the teleport- Returns:
- A future about whether the player could be teleported
-
teleport
public abstract CompletableFuture<Boolean> teleport(String playerName, LocationInfo location, Consumer<String>... consumer) Teleport a player to a certain location in the network- Parameters:
playerName
- The name of the player to teleportlocation
- The location to teleport toconsumer
- Details about the teleport- Returns:
- A future about whether the player could be teleported
-
teleport
public abstract CompletableFuture<Boolean> teleport(String playerName, String serverName, String worldName, Consumer<String>... consumer) Teleport a player to a certain location in the network- Parameters:
playerName
- The name of the player to teleportserverName
- The target serverworldName
- The target worldconsumer
- Details about the teleport- Returns:
- A future about whether the player could be teleported
-
teleport
public abstract CompletableFuture<Boolean> teleport(R player, String serverName, String worldName, Consumer<String>... consumer) Teleport a player to a certain location in the network- Parameters:
player
- The player to teleportserverName
- The target serverworldName
- The target worldconsumer
- Details about the teleport- Returns:
- A future about whether the player could be teleported
-
teleport
public abstract CompletableFuture<Boolean> teleport(R player, R target, Consumer<String>... consumer) Teleport a player to a certain other player in the network- Parameters:
player
- The player to teleporttarget
- The target playerconsumer
- Details about the teleport- Returns:
- A future about whether the player could be teleported
-
teleport
public abstract CompletableFuture<Boolean> teleport(String playerName, String targetName, Consumer<String>... consumer) Teleport a player to a certain other player in the network- Parameters:
playerName
- The name of the player to teleporttargetName
- The name of the target playerconsumer
- Details about the teleport- Returns:
- A future about whether the player could be teleported
-
runServerConsoleCommand
public CompletableFuture<Boolean> runServerConsoleCommand(String server, String command, Consumer<String>... consumer) Run a console command on the target server- Parameters:
server
- The server to run teh command oncommand
- The command to runconsumer
- Optional Consumer (or multiple) for the messages triggered by the command- Returns:
- A future for whether the command was run successfully
-
runProxyConsoleCommand
public CompletableFuture<Boolean> runProxyConsoleCommand(String proxy, String command, Consumer<String>... consumer) Run a console command on a specific other proxy- Parameters:
proxy
- The proxy to run the command oncommand
- The command to runconsumer
- Optional Consumer (or multiple) for the messages triggered by the command- Returns:
- A future for whether the command was run successfully
-
getLocation
Get the location a player is at- Parameters:
player
- The player to get the location for- Returns:
- A future for when the location was queried
-
getLocation
Get the location a player is at- Parameters:
player
- The player to get the location for- Returns:
- A future for when the location was queried
-
getServer
Get the server a player is connected to- Parameters:
player
- The player to get the server for- Returns:
- A future for when the server was queried
-
getServer
Get the server a player is connected to- Parameters:
player
- The player to get the server for- Returns:
- A future for when the server was queried
-
sendData
Send data to a specific target- Parameters:
action
- The action for which data is senttarget
- Where to send data todata
- The data
-
sendData
Send data to a specific target- Parameters:
action
- The action for which data is senttarget
- Where to send data toplayer
- Additional player data to use for sending (required in case the target isMessageTarget.SERVER
orMessageTarget.PROXY
)data
- The data
-
sendData
Send data to a specific target- Parameters:
action
- The action for which data is senttarget
- Where to send data totargetData
- Additional data to use for sending (required in case the target isMessageTarget.SERVER
)data
- The data
-
sendResponse
-
sendResponseMessage
-
sendResponseData
-
handleResponse
protected void handleResponse(long id, com.google.common.io.ByteArrayDataInput in) -
isTeleporting
Get whether a player with that name is currently teleporting. Useful for checking of a quit/join is from a teleport or not.- Returns:
- Whether the player is currently teleporting with ConnectorPlugin
-
markTeleporting
-
unmarkTeleporting
-
addPlayerInfo
-
removePlayerInfo
-