Refactor all the tab APIs
This commit is contained in:
parent
9b9addfccd
commit
b4220e9229
@ -3,7 +3,7 @@ package net.md_5.bungee.api.config;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
import net.md_5.bungee.api.tab.TabListHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing the configuration of a server listener. Used for allowing
|
* Class representing the configuration of a server listener. Used for allowing
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package net.md_5.bungee.api;
|
package net.md_5.bungee.api.tab;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a custom tab list, which may have slots manipulated.
|
* Represents a custom tab list, which may have slots manipulated.
|
||||||
*/
|
*/
|
||||||
public interface TabAPI
|
public interface TabAPI extends TabListHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
@ -0,0 +1,40 @@
|
|||||||
|
package net.md_5.bungee.api.tab;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import net.md_5.bungee.api.tab.TabListHandler;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public abstract class TabListAdapter implements TabListHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private ProxiedPlayer player;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(ProxiedPlayer player)
|
||||||
|
{
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnect()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisconnect()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServerChange()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPingChange(int ping)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -1,29 +1,30 @@
|
|||||||
package net.md_5.bungee.api;
|
package net.md_5.bungee.api.tab;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@Data
|
public interface TabListHandler
|
||||||
public abstract class TabListHandler
|
|
||||||
{
|
{
|
||||||
|
|
||||||
private final ProxiedPlayer player;
|
/**
|
||||||
|
* Called so that this class may set member fields to keep track of its
|
||||||
|
* internal state. You should not do any packet sending or manipulation of
|
||||||
|
* the passed player, other than storing it.
|
||||||
|
*
|
||||||
|
* @param player the player to be associated with this list
|
||||||
|
*/
|
||||||
|
void init(ProxiedPlayer player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when this player first connects to the proxy.
|
* Called when this player first connects to the proxy.
|
||||||
*/
|
*/
|
||||||
public void onConnect()
|
void onConnect();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player first connects to the proxy.
|
* Called when a player first connects to the proxy.
|
||||||
*
|
*
|
||||||
* @param player the connecting player
|
* @param player the connecting player
|
||||||
*/
|
*/
|
||||||
public void onServerChange()
|
void onServerChange();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a players ping changes. The new ping will have not updated in
|
* Called when a players ping changes. The new ping will have not updated in
|
||||||
@ -32,18 +33,14 @@ public abstract class TabListHandler
|
|||||||
* @param player the player who's ping changed
|
* @param player the player who's ping changed
|
||||||
* @param ping the player's new ping.
|
* @param ping the player's new ping.
|
||||||
*/
|
*/
|
||||||
public void onPingChange(int ping)
|
void onPingChange(int ping);
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player disconnects.
|
* Called when a player disconnects.
|
||||||
*
|
*
|
||||||
* @param player the disconnected player
|
* @param player the disconnected player
|
||||||
*/
|
*/
|
||||||
public void onDisconnect()
|
void onDisconnect();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a list update packet is sent from server to client.
|
* Called when a list update packet is sent from server to client.
|
||||||
@ -54,5 +51,5 @@ public abstract class TabListHandler
|
|||||||
* @param ping ping of the subject player
|
* @param ping ping of the subject player
|
||||||
* @return whether to send the packet to the client
|
* @return whether to send the packet to the client
|
||||||
*/
|
*/
|
||||||
public abstract boolean onListUpdate(String name, boolean online, int ping);
|
boolean onListUpdate(String name, boolean online, int ping);
|
||||||
}
|
}
|
@ -41,7 +41,6 @@ import lombok.Synchronized;
|
|||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.ReconnectHandler;
|
import net.md_5.bungee.api.ReconnectHandler;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
|
||||||
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
||||||
import net.md_5.bungee.api.config.ListenerInfo;
|
import net.md_5.bungee.api.config.ListenerInfo;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
@ -21,13 +21,13 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.config.TexturePackInfo;
|
import net.md_5.bungee.api.config.TexturePackInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PermissionCheckEvent;
|
import net.md_5.bungee.api.event.PermissionCheckEvent;
|
||||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||||
import net.md_5.bungee.api.scoreboard.Scoreboard;
|
import net.md_5.bungee.api.scoreboard.Scoreboard;
|
||||||
|
import net.md_5.bungee.api.tab.TabListHandler;
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.netty.HandlerBoss;
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
|
@ -18,11 +18,11 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import net.md_5.bungee.Util;
|
import net.md_5.bungee.Util;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
|
||||||
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
||||||
import net.md_5.bungee.api.config.ListenerInfo;
|
import net.md_5.bungee.api.config.ListenerInfo;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.config.TexturePackInfo;
|
import net.md_5.bungee.api.config.TexturePackInfo;
|
||||||
|
import net.md_5.bungee.api.tab.TabListHandler;
|
||||||
import net.md_5.bungee.tablist.Global;
|
import net.md_5.bungee.tablist.Global;
|
||||||
import net.md_5.bungee.tablist.GlobalPing;
|
import net.md_5.bungee.tablist.GlobalPing;
|
||||||
import net.md_5.bungee.tablist.ServerUnique;
|
import net.md_5.bungee.tablist.ServerUnique;
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package net.md_5.bungee.tablist;
|
package net.md_5.bungee.tablist;
|
||||||
|
|
||||||
import net.md_5.bungee.api.TabAPI;
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.tab.TabAPI;
|
||||||
|
import net.md_5.bungee.api.tab.TabListAdapter;
|
||||||
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
||||||
|
|
||||||
public class Custom extends TabListHandler implements TabAPI
|
public class Custom extends TabListAdapter implements TabAPI
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final int ROWS = 20;
|
private static final int ROWS = 20;
|
||||||
@ -20,11 +20,6 @@ public class Custom extends TabListHandler implements TabAPI
|
|||||||
private String[][] sent = new String[ ROWS ][ COLUMNS ];
|
private String[][] sent = new String[ ROWS ][ COLUMNS ];
|
||||||
private String[][] pending = new String[ ROWS ][ COLUMNS ];
|
private String[][] pending = new String[ ROWS ][ COLUMNS ];
|
||||||
|
|
||||||
public Custom(ProxiedPlayer player)
|
|
||||||
{
|
|
||||||
super( player );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void setSlot(int row, int column, String text)
|
public synchronized void setSlot(int row, int column, String text)
|
||||||
{
|
{
|
||||||
|
@ -2,20 +2,15 @@ package net.md_5.bungee.tablist;
|
|||||||
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.tab.TabListAdapter;
|
||||||
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
||||||
|
|
||||||
public class Global extends TabListHandler
|
public class Global extends TabListAdapter
|
||||||
{
|
{
|
||||||
|
|
||||||
private boolean sentPing;
|
private boolean sentPing;
|
||||||
|
|
||||||
public Global(ProxiedPlayer player)
|
|
||||||
{
|
|
||||||
super( player );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnect()
|
public void onConnect()
|
||||||
{
|
{
|
||||||
|
@ -11,11 +11,6 @@ public class GlobalPing extends Global
|
|||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
private int lastPing;
|
private int lastPing;
|
||||||
|
|
||||||
public GlobalPing(ProxiedPlayer player)
|
|
||||||
{
|
|
||||||
super( player );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPingChange(int ping)
|
public void onPingChange(int ping)
|
||||||
{
|
{
|
||||||
|
@ -2,20 +2,14 @@ package net.md_5.bungee.tablist;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import net.md_5.bungee.api.TabListHandler;
|
import net.md_5.bungee.api.tab.TabListAdapter;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
|
||||||
|
|
||||||
public class ServerUnique extends TabListHandler
|
public class ServerUnique extends TabListAdapter
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Collection<String> usernames = new HashSet<>();
|
private final Collection<String> usernames = new HashSet<>();
|
||||||
|
|
||||||
public ServerUnique(ProxiedPlayer player)
|
|
||||||
{
|
|
||||||
super( player );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServerChange()
|
public void onServerChange()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user