Finish up TabApi impl.

This commit is contained in:
md_5 2013-06-16 07:55:15 +10:00
parent 184154a8b3
commit fa0671ab2a
6 changed files with 34 additions and 4 deletions

View File

@ -12,9 +12,9 @@ import lombok.Getter;
import net.md_5.bungee.api.config.ConfigurationAdapter;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.scheduler.TaskScheduler;
import net.md_5.bungee.api.tab.CustomTabList;
public abstract class ProxyServer
{
@ -241,4 +241,11 @@ public abstract class ProxyServer
* @param message the message to broadcast
*/
public abstract void broadcast(String message);
/**
* Gets a new instance of this proxies custom tab list.
*
* @return a new {@link CustomTabList} instance
*/
public abstract CustomTabList customTabList();
}

View File

@ -3,6 +3,7 @@ package net.md_5.bungee.api.connection;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.config.TexturePackInfo;
import net.md_5.bungee.api.tab.TabListHandler;
/**
* Represents a player who's connection is being connected to somewhere else,
@ -77,4 +78,12 @@ public interface ProxiedPlayer extends Connection, CommandSender
* @param pack the pack to request
*/
public void setTexturePack(TexturePackInfo pack);
/**
* Sets the new tab list for the user. At this stage it is not advisable to
* change after the user has logged in!
*
* @param list the new list
*/
public void setTabList(TabListHandler list);
}

View File

@ -3,7 +3,7 @@ package net.md_5.bungee.api.tab;
/**
* Represents a custom tab list, which may have slots manipulated.
*/
public interface TabAPI extends TabListHandler
public interface CustomTabList extends TabListHandler
{
/**

View File

@ -51,6 +51,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
import net.md_5.bungee.api.scheduler.TaskScheduler;
import net.md_5.bungee.api.tab.CustomTabList;
import net.md_5.bungee.command.*;
import net.md_5.bungee.config.YamlConfig;
import net.md_5.bungee.log.LoggingOutputStream;
@ -60,6 +61,7 @@ import net.md_5.bungee.protocol.packet.Packet3Chat;
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
import net.md_5.bungee.protocol.Vanilla;
import net.md_5.bungee.scheduler.BungeeThreadPool;
import net.md_5.bungee.tablist.Custom;
import net.md_5.bungee.util.CaseInsensitiveMap;
/**
@ -512,4 +514,10 @@ public class BungeeCord extends ProxyServer
connectionLock.writeLock().unlock();
}
}
@Override
public CustomTabList customTabList()
{
return new Custom();
}
}

View File

@ -120,6 +120,12 @@ public final class UserConnection implements ProxiedPlayer
}
}
public void setTabList(TabListHandler tabList)
{
tabList.init( this );
this.tabList = tabList;
}
public void sendPacket(byte[] b)
{
ch.write( b );

View File

@ -4,11 +4,11 @@ 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.tab.TabAPI;
import net.md_5.bungee.api.tab.CustomTabList;
import net.md_5.bungee.api.tab.TabListAdapter;
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
public class Custom extends TabListAdapter implements TabAPI
public class Custom extends TabListAdapter implements CustomTabList
{
private static final int ROWS = 20;