Skip to content

Commit

Permalink
Updated forms to match the transactions being passed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandertv committed Nov 25, 2024
1 parent c59d0ba commit d780792
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dev/Forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"fmt"
"github.com/df-mc/dragonfly/server/player"
"github.com/df-mc/dragonfly/server/player/form"
"github.com/df-mc/dragonfly/server/world"
)

// SomeForm holds the structure of our form. The order in which elements appear is defined by the order of
Expand All @@ -53,7 +54,7 @@ type SomeForm struct {

// Submit is called when the form is submitted. It must have this signature in order to implement the
// form.Submittable interface.
func (f SomeForm) Submit(submitter form.Submitter) {
func (f SomeForm) Submit(submitter form.Submitter, tx *world.Tx) {
// A form.Submitter is guaranteed to be a *player.Player when sent to a player, so we can assert it to a
// player right away.
p := submitter.(*player.Player)
Expand Down
4 changes: 4 additions & 0 deletions dev/World-Transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ Commands now have a transaction passed to them too, and players/entities returne
a `[]Target` parameter will only include those from the same world as the caller of
the command.

### Forms
Like with commands, forms are opened within a transaction now. The transaction is
passed to all Submit methods and Close methods.

### Accepting players
Accepting players was changed from the following:
```go
Expand Down

0 comments on commit d780792

Please sign in to comment.