package vg.civcraft.mc.civmodcore.chatDialog;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.TabCompleteEvent;

public class ChatListener implements Listener {

	@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
	public void tabComplete(TabCompleteEvent e) {
		if (!(e.getSender() instanceof Player)) {
			return;
		}
		Dialog dia = DialogManager.getDialog((Player) e.getSender());
		if (dia != null) {
			String[] split = e.getBuffer().split(" ");
			e.setCompletions(dia.onTabComplete(split.length > 0 ? split[split.length - 1] : "", split));
		}
	}

	@EventHandler
	public void logoff(PlayerQuitEvent e) {
		DialogManager.forceEndDialog(e.getPlayer());
	}

}

@@ -40,16 +40,70 @@
 ialog;%0A%0A
+import java.util.Collections;%0Aimport java.util.List;%0A%0A
 import o
@@ -699,25 +699,32 @@
 %0A%09%09%09
-e.setC
+List %3CString%3E c
 omplet
-ions(
+ = 
 dia.
@@ -792,16 +792,115 @@
 , split)
+;%0A%09%09%09if (complet == null) %7B%0A%09%09%09%09complet = Collections.emptyList();%0A%09%09%09%7D%0A%09%09%09e.setCompletions(complet
 );%0A%09%09%7D%0A%09

FIx exception in dialog tab completion