Automatically queue packets to send when a player connects, and change the API regarding this. Please don't use the Server methods anymore, instead use ServerInfo.

CC: @TheDgtl
This commit is contained in:
md_5
2013-01-31 20:51:59 +11:00
parent 0721e3cc75
commit ecf5b4dc30
7 changed files with 128 additions and 32 deletions

View File

@@ -2,6 +2,7 @@ package net.md_5.bungee.api;
import net.md_5.bungee.api.plugin.PluginManager;
import com.google.common.base.Preconditions;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Map;
import java.util.logging.Logger;
@@ -75,7 +76,11 @@ public abstract class ProxyServer
*
* @param name the name to lookup
* @return the associated server
* @deprecated in most cases the {@link #getServerInfo(java.lang.String)}
* method should be used, as it will return a server even when no players
* are online.
*/
@Deprecated
public abstract Server getServer(String name);
/**
@@ -196,4 +201,14 @@ public abstract class ProxyServer
* @return the Minecraft protocol version
*/
public abstract byte getProtocolVersion();
/**
* Factory method to construct an implementation specific server info
* instance.
*
* @param name name of the server
* @param address connectable Minecraft address + port of the server
* @return the constructed instance
*/
public abstract ServerInfo constructServerInfo(String name, InetSocketAddress address);
}

View File

@@ -7,6 +7,8 @@ import java.util.Collections;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Synchronized;
import net.md_5.bungee.api.Callback;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.connection.ProxiedPlayer;
/**
@@ -14,7 +16,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
*/
@Data
@AllArgsConstructor
public class ServerInfo
public abstract class ServerInfo
{
/**
@@ -62,4 +64,19 @@ public class ServerInfo
{
return Collections.unmodifiableCollection(players);
}
/**
* Send data by any available means to this server.
*
* @param channel the channel to send this data via
* @param data the data to send
*/
public abstract void sendData(String channel, byte[] data);
/**
* Asynchronously gets the current player count on this server.
*
* @param callback the callback to call when the count has been retrieved.
*/
public abstract void ping(Callback<ServerPing> callback);
}

View File

@@ -1,8 +1,8 @@
package net.md_5.bungee.api.connection;
import net.md_5.bungee.api.Callback;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.config.ServerInfo;
/**
* Represents a destination which this proxy might connect to.
@@ -29,6 +29,9 @@ public interface Server extends Connection
* Asynchronously gets the current player count on this server.
*
* @param callback the callback to call when the count has been retrieved.
* @deprecated use the corresponding method in {@link ServerInfo} for
* clarity
*/
@Deprecated
public abstract void ping(Callback<ServerPing> callback);
}