diff --git a/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java b/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java index d5e8dffbe..122cd1193 100644 --- a/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java +++ b/api/src/main/java/net/md_5/bungee/api/config/ListenerInfo.java @@ -3,7 +3,7 @@ package net.md_5.bungee.api.config; import java.net.InetSocketAddress; import java.util.Map; 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 diff --git a/api/src/main/java/net/md_5/bungee/api/TabAPI.java b/api/src/main/java/net/md_5/bungee/api/tab/TabAPI.java similarity index 93% rename from api/src/main/java/net/md_5/bungee/api/TabAPI.java rename to api/src/main/java/net/md_5/bungee/api/tab/TabAPI.java index 4881ed949..e774bed91 100644 --- a/api/src/main/java/net/md_5/bungee/api/TabAPI.java +++ b/api/src/main/java/net/md_5/bungee/api/tab/TabAPI.java @@ -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. */ -public interface TabAPI +public interface TabAPI extends TabListHandler { /** diff --git a/api/src/main/java/net/md_5/bungee/api/tab/TabListAdapter.java b/api/src/main/java/net/md_5/bungee/api/tab/TabListAdapter.java new file mode 100644 index 000000000..133a2ee92 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/tab/TabListAdapter.java @@ -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) + { + } +} diff --git a/api/src/main/java/net/md_5/bungee/api/TabListHandler.java b/api/src/main/java/net/md_5/bungee/api/tab/TabListHandler.java similarity index 63% rename from api/src/main/java/net/md_5/bungee/api/TabListHandler.java rename to api/src/main/java/net/md_5/bungee/api/tab/TabListHandler.java index d3673c6de..e47d4add4 100644 --- a/api/src/main/java/net/md_5/bungee/api/TabListHandler.java +++ b/api/src/main/java/net/md_5/bungee/api/tab/TabListHandler.java @@ -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; -@Data -public abstract class TabListHandler +public interface 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. */ - public void onConnect() - { - } + void onConnect(); /** * Called when a player first connects to the proxy. * * @param player the connecting player */ - public void onServerChange() - { - } + void onServerChange(); /** * 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 ping the player's new ping. */ - public void onPingChange(int ping) - { - } + void onPingChange(int ping); /** * Called when a player disconnects. * * @param player the disconnected player */ - public void onDisconnect() - { - } + void onDisconnect(); /** * 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 * @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); } diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 912ff6654..349001187 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -41,7 +41,6 @@ import lombok.Synchronized; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; 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.ListenerInfo; import net.md_5.bungee.api.config.ServerInfo; diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index aef25eba9..17f7b250b 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -21,13 +21,13 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import net.md_5.bungee.api.ChatColor; 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.TexturePackInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PermissionCheckEvent; import net.md_5.bungee.api.event.ServerConnectEvent; 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.netty.ChannelWrapper; import net.md_5.bungee.netty.HandlerBoss; diff --git a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java index 6e8d577ca..31d332afe 100644 --- a/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java +++ b/proxy/src/main/java/net/md_5/bungee/config/YamlConfig.java @@ -18,11 +18,11 @@ import lombok.RequiredArgsConstructor; import net.md_5.bungee.Util; import net.md_5.bungee.api.ChatColor; 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.ListenerInfo; import net.md_5.bungee.api.config.ServerInfo; 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.GlobalPing; import net.md_5.bungee.tablist.ServerUnique; diff --git a/proxy/src/main/java/net/md_5/bungee/tablist/Custom.java b/proxy/src/main/java/net/md_5/bungee/tablist/Custom.java index 317a03ed7..bf3bee562 100644 --- a/proxy/src/main/java/net/md_5/bungee/tablist/Custom.java +++ b/proxy/src/main/java/net/md_5/bungee/tablist/Custom.java @@ -1,15 +1,15 @@ package net.md_5.bungee.tablist; -import net.md_5.bungee.api.TabAPI; import com.google.common.base.Preconditions; import java.util.Collection; import java.util.HashSet; 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.tab.TabAPI; +import net.md_5.bungee.api.tab.TabListAdapter; 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; @@ -20,11 +20,6 @@ public class Custom extends TabListHandler implements TabAPI private String[][] sent = new String[ ROWS ][ COLUMNS ]; private String[][] pending = new String[ ROWS ][ COLUMNS ]; - public Custom(ProxiedPlayer player) - { - super( player ); - } - @Override public synchronized void setSlot(int row, int column, String text) { diff --git a/proxy/src/main/java/net/md_5/bungee/tablist/Global.java b/proxy/src/main/java/net/md_5/bungee/tablist/Global.java index db6c4767d..269d6d61b 100644 --- a/proxy/src/main/java/net/md_5/bungee/tablist/Global.java +++ b/proxy/src/main/java/net/md_5/bungee/tablist/Global.java @@ -2,20 +2,15 @@ package net.md_5.bungee.tablist; import net.md_5.bungee.BungeeCord; 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.tab.TabListAdapter; import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem; -public class Global extends TabListHandler +public class Global extends TabListAdapter { private boolean sentPing; - public Global(ProxiedPlayer player) - { - super( player ); - } - @Override public void onConnect() { diff --git a/proxy/src/main/java/net/md_5/bungee/tablist/GlobalPing.java b/proxy/src/main/java/net/md_5/bungee/tablist/GlobalPing.java index 24f4c05db..dc9e005bb 100644 --- a/proxy/src/main/java/net/md_5/bungee/tablist/GlobalPing.java +++ b/proxy/src/main/java/net/md_5/bungee/tablist/GlobalPing.java @@ -11,11 +11,6 @@ public class GlobalPing extends Global /*========================================================================*/ private int lastPing; - public GlobalPing(ProxiedPlayer player) - { - super( player ); - } - @Override public void onPingChange(int ping) { diff --git a/proxy/src/main/java/net/md_5/bungee/tablist/ServerUnique.java b/proxy/src/main/java/net/md_5/bungee/tablist/ServerUnique.java index 505e1edc2..2757a17c2 100644 --- a/proxy/src/main/java/net/md_5/bungee/tablist/ServerUnique.java +++ b/proxy/src/main/java/net/md_5/bungee/tablist/ServerUnique.java @@ -2,20 +2,14 @@ package net.md_5.bungee.tablist; import java.util.Collection; import java.util.HashSet; -import net.md_5.bungee.api.TabListHandler; -import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.tab.TabListAdapter; import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem; -public class ServerUnique extends TabListHandler +public class ServerUnique extends TabListAdapter { private final Collection usernames = new HashSet<>(); - public ServerUnique(ProxiedPlayer player) - { - super( player ); - } - @Override public void onServerChange() {