From 8dce5c1c7bb648f778d32028fcec508c1d6f928f Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Sun, 19 Feb 2023 15:29:18 +0100 Subject: [PATCH] use `mtdb.NewBlockDB` instead of the whole db context --- main.go | 5 +++-- protected.go | 4 ++-- remove.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index b9462f1..040be53 100644 --- a/main.go +++ b/main.go @@ -7,11 +7,12 @@ import ( "github.com/minetest-go/areasparser" "github.com/minetest-go/mtdb" + "github.com/minetest-go/mtdb/block" "github.com/sirupsen/logrus" ) var Version string -var ctx *mtdb.Context +var block_repo block.BlockRepository var wd string func main() { @@ -35,7 +36,7 @@ func main() { "version": Version, }).Info("Starting mapcleaner") - ctx, err = mtdb.New(wd) + block_repo, err = mtdb.NewBlockDB(wd) if err != nil { panic(err) } diff --git a/protected.go b/protected.go index 295c474..e7f0f9d 100644 --- a/protected.go +++ b/protected.go @@ -85,7 +85,7 @@ func IsEmerged(chunk_x, chunk_y, chunk_z int) (bool, error) { for _, x := range []int{x1, x2} { for _, y := range []int{y1, y2} { for _, z := range []int{z1, z2} { - data, err := ctx.Blocks.GetByPos(x, y, z) + data, err := block_repo.GetByPos(x, y, z) if err != nil { return false, err } @@ -133,7 +133,7 @@ func IsProtected(chunk_x, chunk_y, chunk_z int) (bool, error) { "z": z, }).Debug("Checking mapblock") - block, err := ctx.Blocks.GetByPos(x, y, z) + block, err := block_repo.GetByPos(x, y, z) if err != nil { return false, err } diff --git a/remove.go b/remove.go index ab8d49b..988cfcc 100644 --- a/remove.go +++ b/remove.go @@ -14,7 +14,7 @@ func RemoveChunk(chunk_x, chunk_y, chunk_z int) error { "z": z, }).Debug("Removing mapblock") - err := ctx.Blocks.Delete(x, y, z) + err := block_repo.Delete(x, y, z) if err != nil { return err }