public void onEnable() {
        settings = Settings.getInstance();
        m = Messages.getInstance();

        switch (settings.getDataSource()) {
            case FILE:
                try {
                    database = new FileDataSource();
                } catch (IOException ex) {
                    ConsoleLogger.showError(ex.getMessage());
                    this.getServer().getPluginManager().disablePlugin(this);
                    return;
                }
                break;
            case MYSQL:
                try {
                    database = new MySQLDataSource();
                } catch (ClassNotFoundException ex) {
                    ConsoleLogger.showError(ex.getMessage());
                    this.getServer().getPluginManager().disablePlugin(this);
                    return;
                } catch (SQLException ex) {
                    ConsoleLogger.showError(ex.getMessage());
                    this.getServer().getPluginManager().disablePlugin(this);
                    return;
                } catch(TimeoutException ex) {
                    ConsoleLogger.showError(ex.getMessage());
                    this.getServer().getPluginManager().disablePlugin(this);
                    return;
                }
                break;
        }

        if (settings.isCachingEnabled()) {
            database = new CacheDataSource(database);
        }

        AuthMePlayerListener playerListener = new AuthMePlayerListener(this, database);
        AuthMeBlockListener blockListener = new AuthMeBlockListener(database);
        AuthMeEntityListener entityListener = new AuthMeEntityListener(database);

        PluginManager pm = getServer().getPluginManager();
        pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_KICK, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.PLAYER_INTERACT_ENTITY, playerListener,
                         Priority.Low, this);
        pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener,
                         Priority.Low, this);
        pm.registerEvent(Event.Type.PLAYER_BED_ENTER, playerListener,
                         Priority.Low, this);
        pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.FOOD_LEVEL_CHANGE, entityListener,
                         Priority.Low, this);
        pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener,
                         Priority.Lowest, this);
        pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener,
                         Priority.Lowest, this);

        this.getCommand("authme").setExecutor(new AdminCommand(database));
        this.getCommand("register").setExecutor(new RegisterCommand(database));
        this.getCommand("login").setExecutor(new LoginCommand(database));
        this.getCommand("changepassword").setExecutor(new ChangePasswordCommand(database));
        this.getCommand("logout").setExecutor(new LogoutCommand(this,database));
        this.getCommand("unregister").setExecutor(new UnregisterCommand(this, database));

        onReload(this.getServer().getOnlinePlayers());
        ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " enabled");
    }