Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Brigadier] Forks and redirects

Aperta
#533 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
java
Ambito
documentation

Direzione di ricerca

Inizia individuando la pagina degli argomenti avanzati della documentazione di Paper Brigadier ed esamina l’esempio Java fornito insieme a CommandSourceStack#withExecutor/Location. Documenta le differenze tra .fork, .forward e .redirect, includi un esempio e indica la disponibilità a partire dalla versione 1.21.4.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

[!NOTE]
This issue is part of a series of issues regarding the extension of the Paper documentation regarding Paper's Brigadier API.

Continuing with the advanced topics, there should also be a page noting the usage of .fork, .forward, and .redirect. Thanks to https://github.com/PaperMC/Paper/pull/11868, this can now be achieved without the usage of internals or userdev.

Basically, the difference between these "flow controlling" methods should be noted and an example should be given. Furthermore, a reference to the CommandSourceStack#withExecutor/Location should be included. The fact that this is only available since the middle of version 1.21.4 could also be helpful.

A possible example could look like this:

final CommandDispatcher<CommandSourceStack> dispatcher = commands.getDispatcher();
final LiteralCommandNode<CommandSourceStack> node = dispatcher.register(Commands.literal("say")
    .then(Commands.literal("hi")
        .executes(ctx -> {
            if (ctx.getSource().getExecutor() instanceof Entity entity) {
                Bukkit.broadcast(MiniMessage.miniMessage().deserialize("<aqua><entity></aqua> says hi!",
                    Placeholder.component("entity", entity.name())
                ));
            }

            return 1;
        })));

dispatcher.register(Commands.literal("say-five").forward(node, ctx -> {
    final List<CommandSourceStack> stacks = new ArrayList<>();
    final List<Entity> entities = ctx.getSource().getLocation().getWorld().getEntities().stream().toList();

    for (int i = 0; i < 5; i++) {
        if (entities.size() < i) {
            break;
        }

        stacks.add(ctx.getSource().withExecutor(entities.get(i)));
    }

    return stacks;
}, true));

Image

Lingua principale
MDX
Stelle
74
Fork
281
Merge medio
6g 52m
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PaperMC/docs

Tutte le issue di PaperMC/docs

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.