package info.faceland.q;

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.PlayerCommandPreprocessEvent;

public class QListener implements Listener {

    private QPlugin plugin;

    public QListener(QPlugin plugin) {
        this.plugin = plugin;
    }

    @EventHandler(priority = EventPriority.LOWEST)
    public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) {
        if (event.isCancelled()) {
            return;
        }
        String cmd = event.getMessage().substring(1);
        plugin.getLogger().info(cmd);
        Player player = event.getPlayer();
        if (!plugin.getQuestionManager().hasQuestion(player.getUniqueId())) {
            return;
        }
        try {
            Runnable reaction = plugin.getQuestionManager().answerFirstQuestion(player.getUniqueId(), cmd);
            int id = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, reaction);
            if (id == -1) {
                return;
            }
            plugin.getQuestionManager().removeFirstQuestion(player.getUniqueId());
            event.setCancelled(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

@@ -225,16 +225,49 @@
 Event;%0A%0A
+import java.util.logging.Level;%0A%0A
 public c
@@ -671,78 +671,109 @@
     
-plugin.getLogger().info(cmd);%0A        Player player = event.getPlayer(
+Player player = event.getPlayer();%0A        plugin.debug(Level.FINE, player.getName() + %22 used %22 + cmd
 );%0A 

use the debug, Luke