mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-30 22:24:18 +01:00
Add ServerInfo method to send plugin message only if server is online
This commit is contained in:
parent
8676dd47f6
commit
b544bb34cb
@ -57,9 +57,24 @@ public interface ServerInfo
|
|||||||
*
|
*
|
||||||
* @param channel the channel to send this data via
|
* @param channel the channel to send this data via
|
||||||
* @param data the data to send
|
* @param data the data to send
|
||||||
|
* @deprecated use #sendData(String, byte[], boolean). Deprecated to highlight queuing behaviour of this method.
|
||||||
|
* @see #sendData(String, byte[], boolean)
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
void sendData(String channel, byte[] data);
|
void sendData(String channel, byte[] data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send data by any available means to this server.
|
||||||
|
*
|
||||||
|
* @param channel the channel to send this data via
|
||||||
|
* @param data the data to send
|
||||||
|
* @param queueIfEmpty if set to <code>true</code> and this server is empty, the data will be queued until a player
|
||||||
|
* joins that server.
|
||||||
|
* @return <code>true</code> if the message was sent immediately, <code>false</code> otherwise (if queueIfEmpty is
|
||||||
|
* true, it has been queued, if it is false it has been discarded).
|
||||||
|
*/
|
||||||
|
boolean sendData(String channel, byte[] data, boolean queueIfEmpty);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asynchronously gets the current player count on this server.
|
* Asynchronously gets the current player count on this server.
|
||||||
*
|
*
|
||||||
|
@ -88,9 +88,15 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
return address.hashCode();
|
return address.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Don't like this method
|
|
||||||
@Override
|
@Override
|
||||||
public void sendData(String channel, byte[] data)
|
public void sendData(String channel, byte[] data)
|
||||||
|
{
|
||||||
|
sendData( channel, data, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Don't like this method
|
||||||
|
@Override
|
||||||
|
public boolean sendData(String channel, byte[] data, boolean queue)
|
||||||
{
|
{
|
||||||
Preconditions.checkNotNull( channel, "channel" );
|
Preconditions.checkNotNull( channel, "channel" );
|
||||||
Preconditions.checkNotNull( data, "data" );
|
Preconditions.checkNotNull( data, "data" );
|
||||||
@ -101,10 +107,12 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
if ( server != null )
|
if ( server != null )
|
||||||
{
|
{
|
||||||
server.sendData( channel, data );
|
server.sendData( channel, data );
|
||||||
} else
|
return true;
|
||||||
|
} else if ( queue )
|
||||||
{
|
{
|
||||||
packetQueue.add( new PluginMessage( channel, data ) );
|
packetQueue.add( new PluginMessage( channel, data ) );
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user