Record Class ScenarioVoteSnapshot

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.scenario.vote.ScenarioVoteSnapshot
Record Components:
runtimeId - the match this vote belongs to
status - where the vote stands
secondsLeft - how long voting stays open, 0 once it closed
eligible - the scenarios that could be voted for
tallies - votes per scenario; scenarios with no votes are present with a count of 0
votesByPlayer - what each player voted for, empty once voting closed and the session was cleared
winners - the locked-in winners, empty until the vote resolves
voteLimit - how many scenarios one player may vote for
winnerCount - how many scenarios the vote elects
allowChanges - whether a player may take a vote back
visibility - how much of the tally players may see

public record ScenarioVoteSnapshot(@NotNull String runtimeId, @NotNull ScenarioVoteStatus status, int secondsLeft, @NotNull Set<String> eligible, @NotNull Map<String,Integer> tallies, @NotNull Map<UUID,Set<String>> votesByPlayer, @NotNull List<String> winners, int voteLimit, int winnerCount, boolean allowChanges, @NotNull ScenarioVoteVisibility visibility) extends Record
A detached read of one match's vote at a single moment.

Snapshots never change after they are handed out, so an addon can hold one without racing the live session.

Since:
1.6.0
  • Constructor Details

    • ScenarioVoteSnapshot

      public ScenarioVoteSnapshot(@NotNull @NotNull String runtimeId, @NotNull @NotNull ScenarioVoteStatus status, int secondsLeft, @NotNull @NotNull Set<String> eligible, @NotNull @NotNull Map<String,Integer> tallies, @NotNull @NotNull Map<UUID,Set<String>> votesByPlayer, @NotNull @NotNull List<String> winners, int voteLimit, int winnerCount, boolean allowChanges, @NotNull @NotNull ScenarioVoteVisibility visibility)
      Creates an instance of a ScenarioVoteSnapshot record class.
      Parameters:
      runtimeId - the value for the runtimeId record component
      status - the value for the status record component
      secondsLeft - the value for the secondsLeft record component
      eligible - the value for the eligible record component
      tallies - the value for the tallies record component
      votesByPlayer - the value for the votesByPlayer record component
      winners - the value for the winners record component
      voteLimit - the value for the voteLimit record component
      winnerCount - the value for the winnerCount record component
      allowChanges - the value for the allowChanges record component
      visibility - the value for the visibility record component
  • Method Details

    • isOpen

      public boolean isOpen()
      Whether players may still cast or change votes.
    • votesFor

      public int votesFor(@NotNull @NotNull String scenarioId)
      How many votes a scenario has.
    • votesOf

      @NotNull public @NotNull Set<String> votesOf(@NotNull @NotNull UUID playerId)
      What one player voted for.
    • voterCount

      public int voterCount()
      How many distinct players cast at least one vote.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • runtimeId

      @NotNull public @NotNull String runtimeId()
      Returns the value of the runtimeId record component.
      Returns:
      the value of the runtimeId record component
    • status

      @NotNull public @NotNull ScenarioVoteStatus status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • secondsLeft

      public int secondsLeft()
      Returns the value of the secondsLeft record component.
      Returns:
      the value of the secondsLeft record component
    • eligible

      @NotNull public @NotNull Set<String> eligible()
      Returns the value of the eligible record component.
      Returns:
      the value of the eligible record component
    • tallies

      @NotNull public @NotNull Map<String,Integer> tallies()
      Returns the value of the tallies record component.
      Returns:
      the value of the tallies record component
    • votesByPlayer

      @NotNull public @NotNull Map<UUID,Set<String>> votesByPlayer()
      Returns the value of the votesByPlayer record component.
      Returns:
      the value of the votesByPlayer record component
    • winners

      @NotNull public @NotNull List<String> winners()
      Returns the value of the winners record component.
      Returns:
      the value of the winners record component
    • voteLimit

      public int voteLimit()
      Returns the value of the voteLimit record component.
      Returns:
      the value of the voteLimit record component
    • winnerCount

      public int winnerCount()
      Returns the value of the winnerCount record component.
      Returns:
      the value of the winnerCount record component
    • allowChanges

      public boolean allowChanges()
      Returns the value of the allowChanges record component.
      Returns:
      the value of the allowChanges record component
    • visibility

      @NotNull public @NotNull ScenarioVoteVisibility visibility()
      Returns the value of the visibility record component.
      Returns:
      the value of the visibility record component