Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.21.5 snapshots] Tickets have changed #2574

Open
gabizou opened this issue Jan 11, 2025 · 0 comments
Open

[1.21.5 snapshots] Tickets have changed #2574

gabizou opened this issue Jan 11, 2025 · 0 comments
Labels
status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage

Comments

@gabizou
Copy link
Member

gabizou commented Jan 11, 2025

Major SpongeAPI version

Likely to be API-15

Is this likely to be a breaking change?

Yes

What are you requesting?

As is currently, TicketType is not a registered kind, but with snapshot 25w02a, TicketType is now a registry type and the comparisons are vastly different. Compare what we have currently:

public interface TicketType<T>  {
    String name();
    Ticks lifetime();
}
public interface Ticket {

}

The underlying engine now has this representation:

record TicketType(long timeout, boolean persist, TicketType.TicketUse use) {
    public static final int NO_TIMEOUT = 0;
    public static final TicketType START = register("start", 0L, false, TicketType.TicketUse.LOADING_AND_SIMULATION);
    public static final TicketType DRAGON = register("dragon", 0L, false, TicketType.TicketUse.LOADING_AND_SIMULATION);
    public static final TicketType PLAYER_LOADING = register("player_loading", 0L, false, TicketType.TicketUse.LOADING);
    public static final TicketType PLAYER_SIMULATION = register("player_simulation", 0L, false, TicketType.TicketUse.SIMULATION);
    public static final TicketType FORCED = register("forced", 0L, true, TicketType.TicketUse.LOADING_AND_SIMULATION);
    public static final TicketType PORTAL = register("portal", 300L, true, TicketType.TicketUse.LOADING_AND_SIMULATION);
    public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, false, TicketType.TicketUse.LOADING_AND_SIMULATION);
    public static final TicketType UNKNOWN = register("unknown", 1L, false, TicketType.TicketUse.LOADING);

    private static TicketType register(String $$0, long $$1, boolean $$2, TicketType.TicketUse $$3) {
        return Registry.register(BuiltInRegistries.TICKET_TYPE, $$0, new TicketType($$1, $$2, $$3));
    }
    public boolean doesLoad() {
        return this.use == TicketType.TicketUse.LOADING || this.use == TicketType.TicketUse.LOADING_AND_SIMULATION;
    }

    public boolean doesSimulate() {
        return this.use == TicketType.TicketUse.SIMULATION || this.use == TicketType.TicketUse.LOADING_AND_SIMULATION;
    }

    public boolean hasTimeout() {
        return this.timeout != 0L;
    }

    public static enum TicketUse {
        LOADING,
        SIMULATION,
        LOADING_AND_SIMULATION;
    }
}
public class Ticket {
    private final TicketType type;
    private final int ticketLevel;
    private long ticksLeft;
}

Of course we've always obviated the exposure of level and ticks left through the api ChunkManager, but if we want to continue to allow plugins to register a new TicketType, we ought to make that viable through registries.

@gabizou gabizou added the status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage label Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage
Projects
None yet
Development

No branches or pull requests

1 participant