package net.minecraft.server.level; import java.util.Objects; public final class Ticket implements Comparable> { private final TicketType type; private final int ticketLevel; private final T key; private long createdTick; protected Ticket(TicketType type, int ticketLevel, T key) { this.type = type; this.ticketLevel = ticketLevel; this.key = key; } public int compareTo(Ticket other) { int i = Integer.compare(this.ticketLevel, other.ticketLevel); if (i != 0) { return i; } else { int j = Integer.compare(System.identityHashCode(this.type), System.identityHashCode(other.type)); return j != 0 ? j : this.type.getComparator().compare(this.key, other.key); } } public boolean equals(Object object) { if (this == object) { return true; } else { return !(object instanceof Ticket ticket) ? false : this.ticketLevel == ticket.ticketLevel && Objects.equals(this.type, ticket.type) && Objects.equals(this.key, ticket.key); } } public int hashCode() { return Objects.hash(new Object[]{this.type, this.ticketLevel, this.key}); } public String toString() { return "Ticket[" + this.type + " " + this.ticketLevel + " (" + this.key + ")] at " + this.createdTick; } public TicketType getType() { return this.type; } public int getTicketLevel() { return this.ticketLevel; } protected void setCreatedTick(long timestamp) { this.createdTick = timestamp; } protected boolean timedOut(long currentTime) { long l = this.type.timeout(); return l != 0L && currentTime - this.createdTick > l; } }