PerWorldChat and PerWorldTab

Discussion in 'Spigot Plugin Development' started by MangoCodes, Jun 5, 2016.

  1. Does anyone know on how I could go about doing this?
  2. For the chat you can cancel event and then loop all players in the same world the player that sended the message is.

    For tab you can listen for PacketPlayOutPlayerInfo and just show the players in the current world.
  3. Never cancel the chat event just to send a message to all players in replace.. that breaks so many things :s

    Instead, simply iterate the recipients and remove the ones that are not in the same world as the chat sender. Simple.

    Code (Text):

    public void onChat(PlayerAsyncChatEvent event) {
        Iterator iter = event.getRecipients().iterator();
        while(iter.hasNext()) {
            if (! {
    That is the general idea for per world chat. Wrote code on phone, so may contain typos. ;)
    #3 BillyGalbreath, Jun 8, 2016
    Last edited: Jun 8, 2016
  4. For PerWorldTab:

    Code (Java):
    public void onJoin(PlayerJoinEvent e) {

    public void onWorldChange(PlayerChangedWorldEvent e) {

    public void setup(Player p) {
    for(Player o : Bukkit.getOnlinePlayers()) {
    if(o.getName().equals(p.getName())) continue;

    if(!o.getWorld().getName().equals(p.getWorld().getName())) {
    } else {