Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ dependencies {
// Fabric API
implementation(libs.fabric.api)

// Permissions
implementationAndInclude(libs.fabric.permissions)

// Translations
implementationAndInclude(libs.translations)

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/inspect.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Inspect
`/ledger inspect`
Alias: `i`
Permission: `ledger.commands.inspect`
Permission: `ledger:command/inspect` or permission level 3

---

Expand Down
4 changes: 2 additions & 2 deletions docs/commands/player.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Player
`/ledger player`
Permission: `ledger.commands.player`
Alias: `pl`
Alias: `pl`
Permission: `ledger:command/player` or permission level 3

---

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/preview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Preview
`/ledger preview`
Alias: `pv`
Permission: `ledger.commands.preview`
Permission: `ledger:command/preview` or permission level 3

---

Expand Down
5 changes: 3 additions & 2 deletions docs/commands/purge.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Purge
`/ledger purge`
Permission: `ledger.commands.purge`
`/ledger purge`
Alias: None
Permission: `ledger:command/purge` or purge permission level as specified in the config

---

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/restore.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Restore
`/ledger restore`
Alias: None
Permission: `ledger.commands.rollback`
Permission: `ledger:command/rollback` or permission level 3

---

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/rollback.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Rollback
`/ledger rollback`
Alias: `rb`
Permission: `ledger.commands.rollback`
Permission: `ledger:command/rollback` or permission level 3

---

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/root.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Root
`/ledger`
Alias: `lg`
Permission: `ledger.commands.root`
Permission: `ledger:command/root` or permission level 3

---

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/search.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Search
`/ledger search`
Alias: `s`
Permission: `ledger.commands.search`
Permission: `ledger:command/search` or permission level 3

---

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/status.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Status
`/ledger status`
Alias: None
Permission: `ledger.commands.status`
Permission: `ledger:command/status` or permission level 3

---

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/teleport.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Teleport
`/ledger tp`
Alias: None
Permission: `ledger.commands.tp`
Permission: `ledger:command/tp` or permission level 3

---

Expand Down
15 changes: 13 additions & 2 deletions docs/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ Ledger supports numerous custom packets for interacting with supported client mo

## Versions

All packets are correct for Ledger Networking v3, which is included in Ledger 1.3.0 and later.

The information on this page is applicable for Ledger Networking version 3, which is the version in Ledger versions `1.3.0` and later

## Permissions

The `ledger:networking` permission is required to interact with Ledger over the networking API. There is no fallback to a permission level: you **must** explicitly give players this permission to be able to use Ledger's functionality over the networking API.

Each packet also requires the permissions that the corresponding command does, but note that this does have fallback to permission level.

### Permissions prior to version 1.3.24

Permission codes were changed in version 1.3.24 to enable support for the Fabric Permissions API v1. In older versions, the `ledger.networking` permission from lucko's [Fabric Permissions API](https://github.com/lucko/fabric-permissions-api) was required in addition to the corresponding packet type permissions, with no fallback to permission level provided for this permission.

## Packet Types

The server will not respond to packets unless the player has the correct permissions, which is `ledger.networking` and the relevant command permission

#### Notation
Types shown here are the Java variable types. They have the equivalent value (if applicable) in Kotlin when used in Ledger's internal code
Expand Down Expand Up @@ -62,7 +73,7 @@ Mod NBT should contain the following:

- Mod ID (`modid`) [`String`] : Mod identifier of the mod

- Protocol version (`protocol_version`) [`int`] : Ledger protocol version
- Protocol version (`protocol_version`) [`int`] : Ledger protocol version (currently 3)

### Purge Packet

Expand Down
7 changes: 2 additions & 5 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
[versions]
minecraft = "26.2-rc-2"
minecraft = "26.2"
fabric-loader = "0.19.3"

fabric-api = "0.152.1+26.2"
fabric-api = "0.158.0+26.2"

# Kotlin
kotlin = "2.3.10"
# Also modrinth version in gradle.properties
fabric-kotlin = "1.13.9+kotlin.2.3.10"

fabric-permissions = "0.7.0"
translations = "3.1.0+26.2"

exposed = "1.0.0-rc-2"
Expand All @@ -26,7 +24,6 @@ fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-l
fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" }
fabric-kotlin = { module = "net.fabricmc:fabric-language-kotlin", version.ref = "fabric-kotlin" }

fabric-permissions = { module = "me.lucko:fabric-permissions-api", version.ref = "fabric-permissions" }
translations = { module = "xyz.nucleoid:server-translations-api", version.ref = "translations" }

exposed-core = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
package com.github.quiltservertools.ledger.commands

object CommandConsts {
const val PARAMS = "params"
const val PERMISSION_LEVEL = 3
}
const val PARAMS = "params"
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ import com.github.quiltservertools.ledger.commands.subcommands.RollbackCommand
import com.github.quiltservertools.ledger.commands.subcommands.SearchCommand
import com.github.quiltservertools.ledger.commands.subcommands.StatusCommand
import com.github.quiltservertools.ledger.commands.subcommands.TeleportCommand
import com.github.quiltservertools.ledger.permissions.Permissions
import com.github.quiltservertools.ledger.utility.BrigadierUtils
import com.github.quiltservertools.ledger.utility.Dispatcher
import me.lucko.fabric.api.permissions.v0.Permissions
import net.minecraft.commands.Commands.literal

fun registerCommands(dispatcher: Dispatcher) {
val rootNode =
literal("ledger").requires(Permissions.require("ledger.commands.root", CommandConsts.PERMISSION_LEVEL))
literal("ledger")
.requires(Permissions.has(Permissions.ROOT))
.build()

dispatcher.root.addChild(rootNode)
dispatcher.root.addChild(
literal("lg")
.requires(Permissions.require("ledger.commands.root", CommandConsts.PERMISSION_LEVEL)).redirect(rootNode)
.requires(Permissions.has(Permissions.ROOT)).redirect(rootNode)
.build(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ object SearchParamArgument {
builder.sourceNames!!.add(nonPlayer)
}
} else {
val profile = source.server.services().nameToIdCache?.get(sourceInput.property)
val profile = source.server.services().nameToIdCache.get(sourceInput.property)
// If the player doesn't exist use a random UUID to make the query not match
val id = profile?.orElse(null)?.id ?: UUID.randomUUID()
val id = profile.orElse(null)?.id ?: UUID.randomUUID()

if (id != null) {
val playerIdEntry = Negatable(id, sourceInput.allowed)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package com.github.quiltservertools.ledger.commands.subcommands

import com.github.quiltservertools.ledger.commands.BuildableCommand
import com.github.quiltservertools.ledger.commands.CommandConsts
import com.github.quiltservertools.ledger.permissions.Permissions
import com.github.quiltservertools.ledger.utility.Context
import com.github.quiltservertools.ledger.utility.LiteralNode
import com.github.quiltservertools.ledger.utility.inspectBlock
import com.github.quiltservertools.ledger.utility.inspectOff
import com.github.quiltservertools.ledger.utility.inspectOn
import com.github.quiltservertools.ledger.utility.isInspecting
import me.lucko.fabric.api.permissions.v0.Permissions
import net.minecraft.commands.Commands.argument
import net.minecraft.commands.Commands.literal
import net.minecraft.commands.arguments.coordinates.BlockPosArgument
import net.minecraft.core.BlockPos

object InspectCommand : BuildableCommand {
override fun build(): LiteralNode = literal("inspect")
.requires(Permissions.require("ledger.commands.inspect", CommandConsts.PERMISSION_LEVEL))
.requires(Permissions.has(Permissions.INSPECT))
.executes { toggleInspect(it) }
.then(
literal("on")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ object PageCommand : BuildableCommand {
source,
results,
Component.translatable(
"text.ledger.header.search"
).setStyle(TextColorPallet.primary)
"text.ledger.header.search",
).setStyle(TextColorPallet.primary),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package com.github.quiltservertools.ledger.commands.subcommands

import com.github.quiltservertools.ledger.Ledger
import com.github.quiltservertools.ledger.commands.BuildableCommand
import com.github.quiltservertools.ledger.commands.CommandConsts
import com.github.quiltservertools.ledger.database.DatabaseManager
import com.github.quiltservertools.ledger.permissions.Permissions
import com.github.quiltservertools.ledger.utility.LiteralNode
import com.github.quiltservertools.ledger.utility.MessageUtils
import kotlinx.coroutines.launch
import me.lucko.fabric.api.permissions.v0.Permissions
import net.minecraft.commands.CommandSourceStack
import net.minecraft.commands.Commands.argument
import net.minecraft.commands.Commands.literal
Expand All @@ -17,7 +16,7 @@ import net.minecraft.server.players.NameAndId
object PlayerCommand : BuildableCommand {
override fun build(): LiteralNode {
return literal("player")
.requires(Permissions.require("ledger.commands.player", CommandConsts.PERMISSION_LEVEL))
.requires(Permissions.has(Permissions.PLAYER))
.then(
argument("player", GameProfileArgument.gameProfile())
.executes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ import com.github.quiltservertools.ledger.Ledger
import com.github.quiltservertools.ledger.actionutils.ActionSearchParams
import com.github.quiltservertools.ledger.actionutils.Preview
import com.github.quiltservertools.ledger.commands.BuildableCommand
import com.github.quiltservertools.ledger.commands.CommandConsts
import com.github.quiltservertools.ledger.commands.PARAMS
import com.github.quiltservertools.ledger.commands.arguments.SearchParamArgument
import com.github.quiltservertools.ledger.database.DatabaseManager
import com.github.quiltservertools.ledger.permissions.Permissions
import com.github.quiltservertools.ledger.utility.Context
import com.github.quiltservertools.ledger.utility.LiteralNode
import com.github.quiltservertools.ledger.utility.MessageUtils
import kotlinx.coroutines.launch
import me.lucko.fabric.api.permissions.v0.Permissions
import net.minecraft.commands.Commands
import net.minecraft.network.chat.Component

object PreviewCommand : BuildableCommand {
override fun build(): LiteralNode = Commands.literal("preview")
.requires(Permissions.require("ledger.commands.preview", CommandConsts.PERMISSION_LEVEL))
.requires(Permissions.has(Permissions.PREVIEW))
.then(
Commands.literal("rollback")
.then(
SearchParamArgument.argument(CommandConsts.PARAMS)
SearchParamArgument.argument(PARAMS)
.executes {
preview(
it,
SearchParamArgument.get(it, CommandConsts.PARAMS),
SearchParamArgument.get(it, PARAMS),
Preview.Type.ROLLBACK,
)
},
Expand All @@ -34,11 +34,11 @@ object PreviewCommand : BuildableCommand {
.then(
Commands.literal("restore")
.then(
SearchParamArgument.argument(CommandConsts.PARAMS)
SearchParamArgument.argument(PARAMS)
.executes {
preview(
it,
SearchParamArgument.get(it, CommandConsts.PARAMS),
SearchParamArgument.get(it, PARAMS),
Preview.Type.RESTORE,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@ package com.github.quiltservertools.ledger.commands.subcommands
import com.github.quiltservertools.ledger.Ledger
import com.github.quiltservertools.ledger.actionutils.ActionSearchParams
import com.github.quiltservertools.ledger.commands.BuildableCommand
import com.github.quiltservertools.ledger.commands.CommandConsts
import com.github.quiltservertools.ledger.commands.PARAMS
import com.github.quiltservertools.ledger.commands.arguments.SearchParamArgument
import com.github.quiltservertools.ledger.config.SearchSpec
import com.github.quiltservertools.ledger.config.config
import com.github.quiltservertools.ledger.database.DatabaseManager
import com.github.quiltservertools.ledger.permissions.Permissions
import com.github.quiltservertools.ledger.utility.Context
import com.github.quiltservertools.ledger.utility.LiteralNode
import com.github.quiltservertools.ledger.utility.TextColorPallet
import kotlinx.coroutines.launch
import me.lucko.fabric.api.permissions.v0.Permissions
import net.minecraft.commands.Commands.literal
import net.minecraft.network.chat.Component

object PurgeCommand : BuildableCommand {
override fun build(): LiteralNode = literal("purge")
.requires(Permissions.require("ledger.commands.purge", config[SearchSpec.purgePermissionLevel]))
.requires(Permissions.has(Permissions.PURGE))
.then(
SearchParamArgument.argument(CommandConsts.PARAMS).executes {
runPurge(it, SearchParamArgument.get(it, CommandConsts.PARAMS))
SearchParamArgument.argument(PARAMS).executes {
runPurge(it, SearchParamArgument.get(it, PARAMS))
},
)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ package com.github.quiltservertools.ledger.commands.subcommands
import com.github.quiltservertools.ledger.Ledger
import com.github.quiltservertools.ledger.actionutils.ActionSearchParams
import com.github.quiltservertools.ledger.commands.BuildableCommand
import com.github.quiltservertools.ledger.commands.CommandConsts
import com.github.quiltservertools.ledger.commands.arguments.SearchParamArgument
import com.github.quiltservertools.ledger.database.DatabaseManager
import com.github.quiltservertools.ledger.permissions.Permissions
import com.github.quiltservertools.ledger.utility.Context
import com.github.quiltservertools.ledger.utility.LiteralNode
import com.github.quiltservertools.ledger.utility.MessageUtils
import com.github.quiltservertools.ledger.utility.TextColorPallet
import com.github.quiltservertools.ledger.utility.launchMain
import com.github.quiltservertools.ledger.utility.literal
import kotlinx.coroutines.launch
import me.lucko.fabric.api.permissions.v0.Permissions
import net.minecraft.commands.Commands
import net.minecraft.network.chat.Component

object RestoreCommand : BuildableCommand {
override fun build(): LiteralNode = Commands.literal("restore")
.requires(Permissions.require("ledger.commands.rollback", CommandConsts.PERMISSION_LEVEL))
.requires(Permissions.has(Permissions.RESTORE))
.then(
SearchParamArgument.argument("params")
.executes { restore(it, SearchParamArgument.get(it, "params")) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ package com.github.quiltservertools.ledger.commands.subcommands
import com.github.quiltservertools.ledger.Ledger
import com.github.quiltservertools.ledger.actionutils.ActionSearchParams
import com.github.quiltservertools.ledger.commands.BuildableCommand
import com.github.quiltservertools.ledger.commands.CommandConsts
import com.github.quiltservertools.ledger.commands.arguments.SearchParamArgument
import com.github.quiltservertools.ledger.database.DatabaseManager
import com.github.quiltservertools.ledger.permissions.Permissions
import com.github.quiltservertools.ledger.utility.Context
import com.github.quiltservertools.ledger.utility.LiteralNode
import com.github.quiltservertools.ledger.utility.MessageUtils
import com.github.quiltservertools.ledger.utility.TextColorPallet
import com.github.quiltservertools.ledger.utility.launchMain
import com.github.quiltservertools.ledger.utility.literal
import kotlinx.coroutines.launch
import me.lucko.fabric.api.permissions.v0.Permissions
import net.minecraft.commands.Commands
import net.minecraft.network.chat.Component

object RollbackCommand : BuildableCommand {
override fun build(): LiteralNode = Commands.literal("rollback")
.requires(Permissions.require("ledger.commands.rollback", CommandConsts.PERMISSION_LEVEL))
.requires(Permissions.has(Permissions.ROLLBACK))
.then(
SearchParamArgument.argument("params")
.executes { rollback(it, SearchParamArgument.get(it, "params")) },
Expand Down
Loading
Loading