Statistic-Books-MC
一个用于追踪所有统计数据并允许在书中显示高分榜的数据包。
该数据包的开发发生在 此 GitHub 仓库 中。你可以在那里找到早于 1.4 版本(适用于 MC 1.20)的版本。
运行 /trigger sb.help 以获取面向玩家、根据设置定制的游戏中概览,了解其工作原理。管理员/OP 和更熟悉的玩家请继续阅读。
目录
功能介绍
此数据包允许你在 lectern(讲台)中的书里追踪任何及所有的统计信息或其他记分板目标(objective)。它会按最高分排序,从而展示谁拥有最佳分数。
注意:所有统计信息均通过记分板进行追踪。因此,它们在被创建之前无法开始追踪。请记住尽早创建你的记分板。本数据包内置了一个函数,可为你设置所有可能的目标,详见 如何知道记分板名称。
局限性
由于底层必须使用记分板目标,而记分板目标仅在创建时开始记录数字,并不会回溯包含已发生的事件,因此该数据包仅从添加之时开始追踪统计信息,而非从世界创建之时开始。建议在世界创建时或创建后立即添加此数据包及其记分板。
如果你希望稍后将其添加到世界中,可以使用我的 stats to scoreboards 工具将新的记分板目标与现有统计信息同步。
由于记分板的工作方式,只能查询在线玩家的分数。为了也能包含离线玩家,此数据包会每 5 分钟缓存一次所有被追踪玩家的分数。这带来了各种影响:
- 分数不是实时更新的,最多每 5 分钟更新一次。
- 如果玩家至少 5 分钟不在线,其分数可能不会被记录。
- 只有在书籍创建后在线(持续 5 分钟以上)的玩家才能被包含在书中。
只有放置在 lectern(讲台)中的书籍才会更新!
如何获取书籍
要获得系统中可用的书籍,你需要取一本可编辑的书,在第一页上只写入你要追踪的目标名称作为文本(无空格或换行),签署该书并将其命名为“MCStats”。这本书会在首次放入 lectern(讲台)时自动转换。当书中的内容被统计信息替换(或最初为空,最多需要 5 分钟才能填充)时,你就知道它成功了。
为了让书籍实际接收到关于追踪统计信息的更新,它需要被放置在 lectern(讲台)内,并且根据设置,在刷新发生时处于加载状态。
如何知道记分板名称
你可以追踪任何记分板目标,不仅是内置的,也包括你自己创建的。该数据包附带一个函数,可以创建游戏提供的所有统计类型记分板——将近 8000 个。如果你想添加这些,请在加载数据包后立即运行 /function sb:setup_objectives!
要了解哪些统计信息可用,请参阅维基:
游戏中的资源位置命名形式为 A.B:C.D。由于 A 和 C 对于原版事物始终都是 minecraft,我选择省略它们,只包含另外两个。此数据包命名目标的约定是 sb.<B>.<D>。
以下是一些示例:
| 原版 |
Statistics Book 数据包 |
minecraft.custom:minecraft.walk_one_cm |
sb.custom.walk_one_cm |
minecraft.mined:minecraft.stone |
sb.mined.stone |
minecraft.killed:minecraft.zombie |
sb.killed.zombie |
秘密模式
如果在设置中启用,玩家可以通过站在 lectern(讲台)上并运行 /trigger sb.secret 来为 lectern(讲台)内的任何书籍启用秘密模式。这将循环切换不同的模式:
默认:显示所有内容。
隐藏名字:名字被隐藏,分数可见。
隐藏分数:名字可见,分数被隐藏。
设置
有多种设置可供你根据需要调整数据包的行为。所有这些设置都存储在 sb.settings 目标中,只能通过 OP 等级为 2 或以上的玩家通过记分板命令更改。
/scoreboard players set <settingName> sb.settings <value>
你可以通过将侧边栏设置为显示 sb.settings 来显示所有当前设置。
/scoreboard objectives setdisplay sidebar sb.settings
要再次隐藏它们,请运行相同的命令,但去掉末尾的 sb.settings。
autoOptIn
默认值:1
如果 autoOptIn 设置为 1,所有人都会自动包含在统计收集中,且他们无法退出。如果设置为 0,玩家需要运行 /trigger sb.optin 才能被包含在统计收集中。
如果之前已选择加入的玩家选择退出,他们的分数将从存储中移除,并在下次更新时从书籍中移除。
注意:如果你将此值从 1 切换到 0,除非玩家特别选择退出,否则所有收集的值仍将保留(但不再更新)。
allowSecret
默认值:1
设置为 1 时,允许玩家使用 /trigger sb.secret 来切换书籍的“秘密”模式(见上文)。
设置为 2 时,保密状态将保持激活,但只有管理员可以使用 /function sb:admin/secret 更改此状态。
设置为 0 会禁用秘密功能,但书籍会记住其状态,因此如果重新启用,书籍将再次变为秘密模式。
refreshType
默认值:0
刷新书籍可能是一项资源密集型任务,具体取决于服务器上的玩家数量、需要更新的书籍数量等因素。这些选项允许你微调书籍更新的时间和方式。
| 值 |
类型 |
描述 |
| 0 |
打开时 |
(默认) 每次有人与放置了书籍的 lectern(讲台)交互时更新一本书。这可能是大多数服务器的最佳选择。如果统计数据显示有超过 30 名玩家在线,则不推荐使用。 |
| 1 |
单次触发 |
当运行 /trigger sb.update 时,更新玩家所站立的 lectern 中的书籍。 |
| 2 |
区域触发 |
更新玩家周围 16 格半径内所有 lectern 中的书籍,前提是运行了 /trigger sb.update。 |
| 3 |
全局计时器 |
每 5 分钟自动刷新所有已加载的 lectern(与统计数据存储更新同步进行)。 |
| 4 |
仅限管理员 |
仅当管理员或版主执行如下所述的相关命令时才更新。 |
/function sb:admin/one: 更新玩家所站立的 lectern 中的书籍。
/function sb:admin/area: 更新玩家周围 16 格半径内所有 lectern 中的书籍。
/function sb:admin/all 更新所有已加载的 lectern。
其他修改
文本
该数据包对其所有文本(包括书籍标题和描述)使用翻译文本。因此,如果你想调整这些文本,可以在资源包中创建一个语言文件,包含你想要覆盖的任何文本,它将优先使用这些自定义文本。
包含的文本列表:
| 标识符 |
文本 |
| sb.update.success |
Lectern(s) updated. |
| sb.update.fail |
No lectern found. |
| sb.book.title |
Statistics Book |
| sb.book.lore.1 |
Automatically lists everyones statistic. |
| sb.book.lore.2 |
Needs to be placed in lectern. |
| sb.book.lore.3 |
Tracked statistic: |
| sb.opt_in |
You have chosen to be included in the statistics. |
| sb.opt_out |
You have chosen not to be included in the statistics. Your scores will be removed the next time the books are updated. |
| sb.secret.default |
Secret Mode: No secrets. |
| sb.secret.names |
Secret Mode: Names hidden. |
| sb.secret.scores |
Secret Mode: Scores hidden. |
合并记分板
有时你可能希望拥有一个无法通过默认统计数据轻松追踪的记分板,因为它是由两个或多个不同的分数/统计数据组合而成的。
从 v1.5.1 开始,你可以将一个函数注册到 sb:run_before 函数标签中,该函数会在玩家分数存入存储之前以 as @a 的身份运行。
这让你可以轻松添加即时汇总的组合记分板,而不需要 constantly 进行合并。
你可以使用 这个记分板组合工具 轻松地创建此类组合记分板。
管理工作
如果你想要/需要了解管理方面的细节(例如移除跟踪的统计数据、移除玩家等),最直接的方法是直接联系我,发送邮件至 contact@plagiatus.net,或者使用我网站上的 联系表单。
Statistic-Books-MC
A Datapack that tracks all statistics in scores and allows to display highscores in books.
Development of this datapack happens in this github repository. You can find versions earlier than 1.4 (for MC 1.20) on there.
Run /trigger sb.help to get a setting-sensitive in-game overview of how it works for players. Admins/OPs and more informed players should read on.
Table of contents
What it does
This datapack allows you to track any and all statistics or other scoreboard objectives in a book in a lectern. It sorts it by highest and thus shows whoever has the best score.
NOTE: All statistics are tracked through scoreboards. Because of this they cannot start tracking before they are created. So remember to create your scoreboards early. This pack comes with a built-in function that sets up all possible objectives for you, see How to know the scoreboard name.
Limitations
Because under the hood it has to use scoreboard objectives, and scoreboard objectives only start tracking numbers when they are created and don't retroactively include the already happened things, the pack only starts tracking the statistics from the point they is added, not the point of world creation. It is thus recommended to add the pack and its scoreboards at world creation or immediately afterwards.
If you want to add it later to a world, you can use my stats to scoreboards tool to bring the new scoreboard objectives up to sync with your existing stats.
Because the way scoreboards work, only online players can be queried for their scores. To be able to also include offline players, this pack caches all players tracked scores every 5 minutes. This has various implications:
- Scores aren't updated live, but at max every 5 minutes.
- Players who aren't online for at least 5 minutes might not have their scores recorded.
- Only players who were online (for 5+ minutes) after a books creation can be included in the book.
Only books placed in lecterns will be updated!
How to get a book
To get a book that works in the system, you take a writable book, put the name of the objective you want to track as the only text in the book on the first page (no spaces or newlines), sign the book and name it "MCStats". The book gets converted automatically when first put into a lectern. You know it worked when the books content is replaced by the statistics (or empty at first, it takes up to 5 minutes to fill).
For the book to actually receive updates about the tracked statistics, it needs to be placed inside a lectern and, depending on the settings, be loaded when a refresh occurs.
How to know the scoreboard name
You can track any scoreboard objective, not just the built-in ones but ones you create yourself as well. The pack comes with a function that creates all statistic type scoreboards the game has to offer - just shy of 8000 of them. If you want to add that, run /function sb:setup_objectives right after loading the datapack!
To find out what statistics are available, consult the wiki:
Resource locations in the game are named in the form A.B:C.D. Since A and C are both always minecraft for vanilla things, I chose to omit them and only include the other two. The convention for named objectives of this datapack is sb.<B>.<D>.
Here are some examples:
| Vanilla |
Statistics Book Datapack |
minecraft.custom:minecraft.walk_one_cm |
sb.custom.walk_one_cm |
minecraft.mined:minecraft.stone |
sb.mined.stone |
minecraft.killed:minecraft.zombie |
sb.killed.zombie |
Secret Mode
If enabled in the settings, players can enable secret mode for any book inside a lectern by standing on the lectern and running /trigger sb.secret. This will cycle through the different modes:
Default: Everything is shown.
Secret Names: Names are hidden, scores are visible.
Secret Scores: Names are visible, scores are hidden.
Settings
There are various settings you can use to adjust the datapacks behavior to your liking. All of these are stored in the sb.settings objective and can only be changed by an OP of lvl 2 or above through a scoreboard command.
/scoreboard players set <settingName> sb.settings <value>
You can show all current settings by setting the sidebar to display sb.settings.
/scoreboard objectives setdisplay sidebar sb.settings
To hide them again, run the same command without the sb.settings at the end.
autoOptIn
Default: 1
If autoOptIn is set to 1, everyone is automatically included in the statistics collection and they cannot opt-out. If set to 0, players need to run /trigger sb.optin to be included in the statistics collection.
If a player that was previously opted in chooses to opt-out, their scores are removed from the storage and will be removed from the books in the next update.
Note: If you switch this value from 1 to 0, all collected values will stay included (but won't get updated anymore) unless a player specifically opts out again.
allowSecret
Default: 1
When set to 1 it allows players to use /trigger sb.secret to toggle a books "secretive" mode (see above).
Setting it to 2 keeps the secrecy status active, but the stati can only be changed by admins using /function sb:admin/secret.
Setting it to 0 does disable secrets, but books remember their status, so if it's re-enabled the books will turn secretive again.
refreshType
Default: 0
Refreshing books can be a resource intensive task, depending on the amount of players a server has, how many books need to be updated and more. These options allow you to finetune when and how books are supposed to be updated.
| Value |
Type |
Description |
| 0 |
Upon Opening |
(Default) Updates a book every time someone interacts with the lectern the book is placed on. Probably best option for most servers. Not recommended if you have more than 30+ players that show up in the statistics. |
| 1 |
Single Trigger |
Updates the book inside the lectern the player is standing on when running /trigger sb.update. |
| 2 |
Area Trigger |
Updates all books in lecterns in a 16 block radius around the player running /trigger sb.update. |
| 3 |
Global Timer |
Will automatically refresh all loaded lecterns every 5 minutes (together with the statistics storage update). |
| 4 |
Admin Only |
Only updates when an admin / moderator runs the respective commands as described below. |
/function sb:admin/one: Updates the book inside the lectern the player is standing on.
/function sb:admin/area: Updates all books in lecterns in a 16 block radius around the player.
/function sb:admin/all Updates all loaded lecterns.
Other modifications
Text
The pack uses translation text for all its texts, including the title and the lore of the books. So if you want to adjust that, you can create a language file in a resourcepack that include whatever texts you want to override and it should use those texts instead.
List of included texts:
| Identifier |
Text |
| sb.update.success |
Lectern(s) updated. |
| sb.update.fail |
No lectern found. |
| sb.book.title |
Statistics Book |
| sb.book.lore.1 |
Automatically lists everyones statistic. |
| sb.book.lore.2 |
Needs to be placed in lectern. |
| sb.book.lore.3 |
Tracked statistic: |
| sb.opt_in |
You have chosen to be included in the statistics. |
| sb.opt_out |
You have chosen not to be included in the statistics. Your scores will be removed the next time the books are updated. |
| sb.secret.default |
Secret Mode: No secrets. |
| sb.secret.names |
Secret Mode: Names hidden. |
| sb.secret.scores |
Secret Mode: Scores hidden. |
Combining Scoreboards
Sometimes you want to have a scoreboard that isn't easily tracked by the default stats, because it's a combination of two or more different scores / stats.
Starting in v1.5.1 you can register a function to the sb:run_before function tag that is run as @a before the player scores are stored in the storage.
This lets you easily add combined scoreboards that are tallied up just-in-time instead of needing to combine them constantly.
You can use this Scoreboard Combiner Utility to create such combined scoreboards easily.
Administrative work
If you want / need to get into the nitty gritty of the administrative side (removing tracked statistics, removing players, etc), it's probably easiest to contact me directly at contact@plagiatus.net or use my contact form on my website.
评论 0
登录后参与评分
还没有评论,来抢沙发吧