Class Feature

java.lang.Object
io.github.projectunified.faststats.core.Feature
Direct Known Subclasses:
ErrorTracker, PaperErrorTracker

public abstract class Feature extends Object
An abstract representation of a feature that can submit telemetry payloads on demand.
  • Constructor Details

    • Feature

      public Feature()
  • Method Details

    • onStart

      public void onStart()
      Called when the Metrics coordinator is started. Subclasses can override this to initialize scheduling or start listeners.
    • onShutdown

      public void onShutdown()
      Called when the Metrics coordinator is shutdown. Subclasses can override this to release resources or stop listeners.
    • getDefaultProperties

      public Map<String,String> getDefaultProperties()
      Gets the default properties to assign to the configuration.
      Returns:
      the default properties
    • submit

      protected final void submit(Map<String,Object> dataMap, boolean includeData) throws Exception
      Submits the given data map payload.
      Parameters:
      dataMap - a map of keys to their data maps
      Throws:
      Exception - if submission fails
    • getProperty

      public final String getProperty(String key, String defaultValue)
      Gets a configuration property.
      Parameters:
      key - the property key
      defaultValue - the default value to return if the property is missing
      Returns:
      the property value, or the default value if metrics is not initialized
    • getFeature

      public final <T extends Feature> Optional<T> getFeature(Class<T> featureClass)
      Finds a registered feature of the specified class.
      Type Parameters:
      T - the feature type
      Parameters:
      featureClass - the feature class
      Returns:
      an Optional containing the feature if found, or empty if not found or metrics is not set
    • getScheduler

      protected final TaskScheduler getScheduler()
      Gets the TaskScheduler instance.
      Returns:
      the TaskScheduler instance