Class GeolocationCache

  • All Implemented Interfaces:
    SubSystem

    @Singleton
    public class GeolocationCache
    extends java.lang.Object
    implements SubSystem
    This class contains the geolocation cache.

    It caches all IPs with their matching country.

    • Constructor Summary

      Constructors 
      Constructor Description
      GeolocationCache​(Locale locale, PlanConfig config, GeoLite2Geolocator geoLite2Geolocator, net.playeranalytics.plugin.server.PluginLogger logger, net.playeranalytics.plugin.scheduling.RunnableFactory runnableFactory)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canGeolocate()  
      void clearCache()
      Clears the cache
      void disable()
      Performs disable actions for the subsystem
      void enable()
      Performs enable actions for the subsystem.
      java.lang.String getCountry​(java.lang.String ipAddress)
      Retrieves the country in full length (e.g.
      void tryToPrepareGeoLite2()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeolocationCache

        @Inject
        public GeolocationCache​(Locale locale,
                                PlanConfig config,
                                GeoLite2Geolocator geoLite2Geolocator,
                                net.playeranalytics.plugin.server.PluginLogger logger,
                                net.playeranalytics.plugin.scheduling.RunnableFactory runnableFactory)
    • Method Detail

      • enable

        public void enable()
        Description copied from interface: SubSystem
        Performs enable actions for the subsystem.
        Specified by:
        enable in interface SubSystem
      • canGeolocate

        public boolean canGeolocate()
      • tryToPrepareGeoLite2

        public void tryToPrepareGeoLite2()
      • getCountry

        public java.lang.String getCountry​(java.lang.String ipAddress)
        Retrieves the country in full length (e.g. United States) from the IP Address.
        Parameters:
        ipAddress - The IP Address for which the country is retrieved
        Returns:
        The name of the country in full length or null if the country could not be fetched.
      • disable

        public void disable()
        Description copied from interface: SubSystem
        Performs disable actions for the subsystem
        Specified by:
        disable in interface SubSystem
      • clearCache

        public void clearCache()
        Clears the cache