民主指令
一款 Minecraft Forge 模组,将民主带入服务器管理!非 OP(管理员)玩家可提议需要 OP 权限的指令,并由所有在线玩家投票表决。
功能特性
- 民主投票系统 - 非 OP 玩家可以提议需要 OP 权限的指令,但必须获得社区批准
- 自动拦截指令 - 只需像往常一样输入 OP 指令——模组会自动处理投票过程
- 完整自动补全支持 - 非 OP 玩家可以看到所有 OP 指令的建议列表
- 可配置的投票规则 - 设置通过阈值、最低投票人数、超时时间等
- 全面的审计日志 - 所有投票均记录有时间戳、参与者和结果
- 智能弃权处理 - AFK(挂机)玩家不会阻碍投票完成
安装方法
- 从 Releases 页面下载最新版本
- 将
.jar 文件放入服务器的 mods 文件夹中
- 确保你运行的是 Minecraft Forge 1.20.1(版本 47.2.0 或更高)
- 启动服务器——模组将在首次运行时生成配置文件
工作原理
- 非 OP 玩家 输入一个 OP 指令(例如
/gamemode creative PlayerName)
- 发起投票 - 所有在线玩家都会收到通知
- 玩家投票 - 使用
/vote yes 或 /vote no 进行投票
- 投票结束 当满足以下条件之一时:
- 所有人都已投票,或者
- 超时时间到期(默认:30 秒)
- 执行指令 - 如果投票结果符合配置的阈值,则指令被执行
示例工作流程
Player1: /weather clear
[Server]: ===== VOTE INITIATED =====
[Server]: Player1 wants to execute: /weather clear
[Server]: Vote using: [YES] [NO]
[Server]: Vote expires in 30 seconds
Player2: /vote yes
Player3: /vote yes
Player1: /vote yes
[Server]: ===== VOTE CONCLUDED =====
[Server]: YES: 3 | NO: 0 | Abstained: 0
[Server]: ✓ VOTE PASSED
[Server]: Command executed successfully!
指令
| 指令 |
描述 |
所需权限 |
/vote |
显示帮助信息和可用的投票指令 |
无 |
/vote yes |
对当前提案投赞成票 |
无 |
/vote no |
对当前提案投反对票 |
无 |
/vote status |
检查当前投票的状态 |
无 |
配置
配置文件位于 config/democraticcommands-server.toml,并在服务器首次启动时创建。
投票设置
| 设置项 |
默认值 |
描述 |
voteTimeout |
30 |
投票自动结束的超时时间(秒) |
minimumVoters |
2 |
发起投票所需的最低在线玩家数 |
minimumVotesRequired |
2 |
产生有效结果所需的最小实际投票数(不包括弃权) |
approvalThreshold |
0.5 |
通过所需的赞成票比例(0.5 = 50%,0.66 = 66%) |
requireMajorityParticipation |
true |
如果为 true,则需要超过 50% 的在线玩家投票(而非弃权) |
countAbstentionsAsNo |
false |
如果为 true,弃权票将被计为反对票 |
logVotes |
true |
启用将所有投票记录到文件中 |
指令列表
| 设置项 |
默认值 |
描述 |
opCommands |
见下方 |
非 OP 玩家使用时需要投票的指令列表 |
默认 OP 指令:
opCommands = [
"gamemode", "gamerule", "give", "tp", "teleport",
"kill", "ban", "kick", "op", "deop", "whitelist",
"difficulty", "stop", "setblock", "fill", "summon",
"effect", "enchant", "weather", "time", "spawnpoint",
"setworldspawn"
]
示例配置
# 要求 66% 的赞成率且至少 3 票
voteTimeout = 45
minimumVoters = 3
minimumVotesRequired = 3
approvalThreshold = 0.66
requireMajorityParticipation = true
countAbstentionsAsNo = false
logVotes = true
# 向投票系统添加更多指令
opCommands = [
"gamemode", "gamerule", "give", "tp", "teleport",
"kill", "ban", "kick", "op", "deop", "whitelist",
"difficulty", "stop", "setblock", "fill", "summon",
"effect", "enchant", "weather", "time", "spawnpoint",
"setworldspawn", "scoreboard", "team", "worldborder",
"xp", "experience", "particle", "playsound"
]
投票判定逻辑
当满足以下所有条件时,投票通过:
- ✅ 总投票数 ≥
minimumVotesRequired
- ✅ 如果
requireMajorityParticipation 为 true:超过 50% 的在线玩家进行了投票
- ✅ 赞成票数 ÷ (赞成票数 + 反对票数) ≥
approvalThreshold
- ✅ 如果
countAbstentionsAsNo 为 true:弃权票被计为反对票
如果未满足任何一项条件,投票失败,并会提供清晰的失败原因反馈。
审计日志
当启用 logVotes 时,所有投票都会记录在 world/logs/audit.txt 中:
[2024-01-15 14:32:45] Vote INITIATED
Command: /gamemode creative Player1
Initiator: Player2
YES votes (2): Player2, Player3
NO votes (1): Player4
Abstained (1): Player5
Result: PASSED
----------------------------------------
故障排除
玩家无法看到 OP 指令的建议
- 该模组会自动将列入白名单的 OP 命令对所有玩家可见
- 如果建议未显示,请检查该命令是否已添加到
opCommands 列表中
投票未触发
- 确保该命令已包含在
opCommands 配置列表中
- 检查是否满足最低投票人数要求
- 验证该玩家是否已经拥有 OP 权限
无需投票即可执行命令
- 该命令可能不在
opCommands 列表中
- 该玩家可能已拥有 OP 权限(OP 可绕过投票机制)
贡献指南
欢迎贡献!如有 bug 或功能请求,请随时提交拉取请求(Pull Request)或创建 Issue。
Java 并非我的第一编程语言,但这是我制作的第一款模组,因此很可能仍有诸多改进空间。
许可证
本模组采用 MIT 许可证——详见 LICENSE 文件。
致谢
Democratic Commands
A Minecraft Forge mod that brings democracy to server administration! Non-OP players can propose OP commands that are voted on by all online players.
Features
- Democratic Voting System - Non-OP players can propose OP commands that require community approval
- Automatic Command Interception - Just type OP commands normally - the mod handles the voting automatically
- Full Autocomplete Support - Non-OP players see command suggestions for all OP commands
- Configurable Voting Rules - Set approval thresholds, minimum voters, timeout periods, and more
- Comprehensive Audit Logging - All votes are logged with timestamps, participants, and results
- Smart Abstention Handling - AFK players won't block votes from completing
Installation
- Download the latest release from the Releases page
- Place the
.jar file in your server's mods folder
- Ensure you're running Minecraft Forge 1.20.1 (version 47.2.0 or higher)
- Start your server - the mod will generate a config file on first run
How It Works
- Non-OP player types an OP command (e.g.,
/gamemode creative PlayerName)
- Vote initiates automatically - all online players are notified
- Players vote using
/vote yes or /vote no
- Vote concludes when:
- Everyone has voted, OR
- The timeout period expires (default: 30 seconds)
- Command executes if the vote passes based on configured thresholds
Example Workflow
Player1: /weather clear
[Server]: ===== VOTE INITIATED =====
[Server]: Player1 wants to execute: /weather clear
[Server]: Vote using: [YES] [NO]
[Server]: Vote expires in 30 seconds
Player2: /vote yes
Player3: /vote yes
Player1: /vote yes
[Server]: ===== VOTE CONCLUDED =====
[Server]: YES: 3 | NO: 0 | Abstained: 0
[Server]: ✓ VOTE PASSED
[Server]: Command executed successfully!
Commands
| Command |
Description |
Permission Required |
/vote |
Shows help and available vote commands |
None |
/vote yes |
Vote YES on the current proposal |
None |
/vote no |
Vote NO on the current proposal |
None |
/vote status |
Check the status of the current vote |
None |
Configuration
The configuration file is located at config/democraticcommands-server.toml and is created on first server start.
Voting Settings
| Setting |
Default |
Description |
voteTimeout |
30 |
Time in seconds before a vote automatically concludes |
minimumVoters |
2 |
Minimum players online required to initiate a vote |
minimumVotesRequired |
2 |
Minimum actual votes (not abstentions) for a valid result |
approvalThreshold |
0.5 |
Percentage of YES votes required to pass (0.5 = 50%, 0.66 = 66%) |
requireMajorityParticipation |
true |
If true, requires >50% of online players to vote (not abstain) |
countAbstentionsAsNo |
false |
If true, abstentions count as NO votes |
logVotes |
true |
Enable logging of all votes to file |
Command List
| Setting |
Default |
Description |
opCommands |
See below |
List of commands that require voting when used by non-ops |
Default OP Commands:
opCommands = [
"gamemode", "gamerule", "give", "tp", "teleport",
"kill", "ban", "kick", "op", "deop", "whitelist",
"difficulty", "stop", "setblock", "fill", "summon",
"effect", "enchant", "weather", "time", "spawnpoint",
"setworldspawn"
]
Example Configuration
# Require 66% approval with at least 3 votes
voteTimeout = 45
minimumVoters = 3
minimumVotesRequired = 3
approvalThreshold = 0.66
requireMajorityParticipation = true
countAbstentionsAsNo = false
logVotes = true
# Add more commands to the voting system
opCommands = [
"gamemode", "gamerule", "give", "tp", "teleport",
"kill", "ban", "kick", "op", "deop", "whitelist",
"difficulty", "stop", "setblock", "fill", "summon",
"effect", "enchant", "weather", "time", "spawnpoint",
"setworldspawn", "scoreboard", "team", "worldborder",
"xp", "experience", "particle", "playsound"
]
Vote Resolution Logic
A vote passes when ALL of the following conditions are met:
- ✅ Total votes ≥
minimumVotesRequired
- ✅ If
requireMajorityParticipation is true: More than 50% of online players voted
- ✅ YES votes ÷ (YES + NO votes) ≥
approvalThreshold
- ✅ If
countAbstentionsAsNo is true: Abstentions are counted as NO votes
A vote fails if any condition is not met, with clear feedback about why.
Audit Logging
When logVotes is enabled, all votes are logged to world/logs/audit.txt:
[2024-01-15 14:32:45] Vote INITIATED
Command: /gamemode creative Player1
Initiator: Player2
YES votes (2): Player2, Player3
NO votes (1): Player4
Abstained (1): Player5
Result: PASSED
----------------------------------------
Troubleshooting
Players can't see OP command suggestions
- The mod automatically makes whitelisted OP commands visible to all players
- If suggestions aren't showing, check that the command is in the
opCommands list
Votes aren't triggering
- Ensure the command is in the
opCommands configuration list
- Check that minimum voter requirements are met
- Verify the player doesn't already have OP permissions
Commands execute without voting
- The command might not be in the
opCommands list
- The player might have OP permissions (ops bypass voting)
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
Java isn't my first language, but it is my first mod, so there are probably several things that can be improved.
License
This mod is licensed under the MIT License - see the LICENSE file for details.
Credits
评论 0
登录后参与评分
还没有评论,来抢沙发吧