Enum Class MindustryTimeUnit

java.lang.Object
java.lang.Enum<MindustryTimeUnit>
com.xpdustry.distributor.common.scheduler.MindustryTimeUnit
All Implemented Interfaces:
Serializable, Comparable<MindustryTimeUnit>, Constable

public enum MindustryTimeUnit extends Enum<MindustryTimeUnit>
Time units used by the PluginTask.Builder and PluginTask classes to represent time.
  • Enum Constant Details

    • MILLISECONDS

      public static final MindustryTimeUnit MILLISECONDS
      Time unit representing one thousandth of a second.
    • TICKS

      public static final MindustryTimeUnit TICKS
      Time unit representing one game loop, which is 60 times per second.
    • SECONDS

      public static final MindustryTimeUnit SECONDS
      Time unit representing one thousandth of a millisecond.
    • MINUTES

      public static final MindustryTimeUnit MINUTES
      Time unit representing sixty seconds.
    • HOURS

      public static final MindustryTimeUnit HOURS
      Time unit representing sixty minutes.
    • DAYS

      public static final MindustryTimeUnit DAYS
      Time unit representing twenty-four hours.
  • Method Details

    • values

      public static MindustryTimeUnit[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static MindustryTimeUnit valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • convert

      public long convert(long sourceDuration, MindustryTimeUnit sourceUnit)
      Converts the given duration in the given time unit to this time unit.

      Since this method is equivalent to TimeUnit.convert(long, TimeUnit):

      • If it overflows, the result will be Long.MAX_VALUE if the duration is positive, or Long.MIN_VALUE if it is negative.
      • Conversions are floored so converting 999 milliseconds to seconds results in 0.
      Parameters:
      sourceDuration - the duration to convert
      sourceUnit - the time unit of the duration
      Returns:
      the converted duration
      See Also:
    • getJavaTimeUnit

      public Optional<TimeUnit> getJavaTimeUnit()
      Returns the Java time unit associated with this Mindustry time unit, if any.