Search in sources :

Example 1 with NoModuleException

use of uk.co.drnaylor.quickstart.exceptions.NoModuleException in project Nucleus by NucleusPowered.

the class GeoIpListener method shouldEnable.

@Override
public boolean shouldEnable() {
    try {
        GeoIpConfig gic = Nucleus.getNucleus().getModuleContainer().getConfigAdapterForModule(GeoIpModule.ID, GeoIpConfigAdapter.class).getNodeOrDefault();
        if (gic.isAcceptLicence()) {
            if (!isPrinted) {
                Nucleus.getNucleus().getLogger().info("GeoIP is enabled. Nucleus makes use of GeoLite2 data created by MaxMind, available from http://www.maxmind.com");
                isPrinted = true;
            }
            return gic.isAlertOnLogin();
        }
        return false;
    } catch (NoModuleException | IncorrectAdapterTypeException e) {
        if (Nucleus.getNucleus().isDebugMode()) {
            e.printStackTrace();
        }
        return false;
    }
}
Also used : NoModuleException(uk.co.drnaylor.quickstart.exceptions.NoModuleException) IncorrectAdapterTypeException(uk.co.drnaylor.quickstart.exceptions.IncorrectAdapterTypeException) GeoIpConfigAdapter(io.github.nucleuspowered.nucleus.modules.geoip.config.GeoIpConfigAdapter) GeoIpConfig(io.github.nucleuspowered.nucleus.modules.geoip.config.GeoIpConfig)

Aggregations

GeoIpConfig (io.github.nucleuspowered.nucleus.modules.geoip.config.GeoIpConfig)1 GeoIpConfigAdapter (io.github.nucleuspowered.nucleus.modules.geoip.config.GeoIpConfigAdapter)1 IncorrectAdapterTypeException (uk.co.drnaylor.quickstart.exceptions.IncorrectAdapterTypeException)1 NoModuleException (uk.co.drnaylor.quickstart.exceptions.NoModuleException)1