投票制举报系统

By Ganxiaozhe    2019/01/14

许多熊孩子都会选择在服务器防守最薄弱的时候(OP不在线时)“为非作歹”,普通玩家没有权限,难以将其捉拿。现在,有了这个系统,玩家可以随时触发投票举报,并秉承公平公正的概念,为服务器带来和谐高素质的环境。


如图:目前条件就只录了单人的演示:3

我的世界REPORT

注: 图片里的tigger之前打错了!!!应为trigger,代码中已经修改了,图片还没来得及修改。

图片就介绍到这里,下面是详情以及代码部分~


[原理]

  • 指定玩家 - 跟以往的一些多人系统一样,用记分板实现UID来确定到某个玩家。UID:创建一个永远存在于服务器的载体,当玩家进入服务器时或理解为当玩家无UID时,给载体+1分,并将玩家UID=载体分值。以此重复。
  • 触发投票 - 运用检测副手物品来判定玩家是否用指定物品按了F(触发),教程:检测背包及手持物品等。触发后进行某些参数的重置与初始化。
  • 投票过程 - 应用trigger来进行投票,而trigger设置的值就是要投票玩家的UID值。投票过程中玩家可用/trigger反复修改要举报的玩家,结束后进行统计。
  • 投票统计 - 玩家投票结束后,首先判定参投人数是否达到最低要求(5人),若没达到,则结束系统;若达到要求,则进行下一步操作,即哪些玩家被举报。这里判定运用report_temp来等同玩家UID后对temp进行操作从而不影响到玩家UID。具体操作为依次用所有玩家的temp(UID)来减去每个玩家投票的值,若相等,则差为0,也就是temp-=投票值=>temp=0。进而temp=0的玩家就是被投票的玩家,并在每次操作后给temp=0的玩家统计票数的记分板+1分值。
  • 判断最高票数 - 可见教程选中计分板分数最高/低玩家
  • 有关完善 - 该系统超多人数情况下未测试,理论可行,大家若发现bug可提供给我,我会在第一时间更改并将您列入该系统的贡献列表。


代码:

初始化:

  1. /scoreboard teams add report_list
  2. /scoreboard objectives add report_id dummy
  3. /scoreboard objectives add report_ts dummy
  4. /scoreboard objectives add report_tt dummy
  5. /scoreboard objectives add report_num dummy
  6. /scoreboard objectives add report_numb dummy
  7. /scoreboard objectives add rPoll trigger
  8. /scoreboard objectives add report_temp dummy
  9. /scoreboard objectives add report_bad dummy
  10. /scoreboard players set 2 report_temp 2
  11. /summon minecraft:armor_stand ~ ~1 ~ {CustomName:"reportMasker",CustomNameVisible:true,CanPickUpLoot:false,PersistenceRequired:true,Invisible:true}
  12. /tellraw @a ["\n\n \u00a7l欢迎使用\u00a7b\u00a7lREPORT-投票制举报\u00a7r\u00a7l原版模组,你可以",{"text":"单击我前往查看","color":"gold","bold":true,"underlined":true,"clickEvent":{"action":"open_url","value":"http://www.ganxiaozhe.com/mc/mlxt/201901140.html"}},"\u00a7l关于它的原理、功能以及获取更新\n\n"]

标记ID:[高频循环]

  1. /scoreboard players add @a report_id 0
  2. /give @p[score_report_id_min=0,score_report_id=0] minecraft:reeds 1 0 {display:{Name:"举报玩家 (F键)",Lore:["公正公平的举报系统","来自 - Ganxiaozhe"]},Unbreakable:1b,HideFlags:63b,ench:[{id:19s,lvl:1s}],gReport:1b}
  3. /execute @p[score_report_id_min=0,score_report_id=0] ~ ~ ~ scoreboard players add @e[type=armor_stand,name=reportMasker] report_id 1
  4. /execute @p[score_report_id_min=0,score_report_id=0] ~ ~ ~ scoreboard players operation @p[r=0] report_id = @e[type=armor_stand,name=reportMasker] report_id

触发举报:[高频循环]

  1. /scoreboard players tag @p add do_report {Inventory:[{id:"minecraft:reeds",Damage:0s,Slot:-106b,tag:{gReport:1b}}]}
  2. /execute @a[tag=do_report] ~ ~ ~ /execute @a ~ ~ ~ tellraw @a ["> \u00a7a玩家名字: ",{"selector":"@p[r=0]","color":"white","bold":"true"}," \u00a7a玩家UID: ",{"score":{"name":"@p[r=0]","objective":"report_id"},"color":"white","bold":"true"}]
  3. /execute @a[tag=do_report] ~ ~ ~ tellraw @a ["\n\u00a77\u00a7l[REPORT] ",{"selector":"@p[tag=do_report,r=0]","color":"green","bold":"true"},"\u00a7c\u00a7l发起了举报投票,请输入\u00a76\u00a7l/trigger rPoll set \u00a76\u00a7lN\u00a7c\u00a7l进行你想举报的玩家,N为玩家列表旁的数字(UID)。\n"]
  4. /execute @a[tag=do_report] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=reportMasker] report_ts 60
  5. /execute @a[tag=do_report] ~ ~ ~ scoreboard players set @e[type=armor_stand,name=reportMasker] report_tt 0
  6. /execute @a[tag=do_report] ~ ~ ~ scoreboard players reset @a rPoll
  7. /execute @a[tag=do_report] ~ ~ ~ scoreboard players tag @e[type=armor_stand,name=reportMasker] add reporting
  8. /execute @e[type=armor_stand,name=reportMasker,tag=reporting] ~ ~ ~ clear @a reeds 0 64 {gReport:1b}
  9. /execute @e[type=armor_stand,name=reportMasker,tag=reporting] ~ ~ ~ scoreboard players tag @a[tag=do_report] remove do_report
  10. /execute @e[type=armor_stand,name=reportMasker,tag=reporting] ~ ~ ~ scoreboard players enable @a rPoll

投票过程:[高频循环]

  1. /execute @e[type=armor_stand,name=reportMasker,tag=reporting] ~ ~ ~ scoreboard players add @e[r=0,tag=reporting] report_tt 1 /execute @e[name=reportMasker,tag=reporting,score_report_tt_min=20] ~ ~ ~ scoreboard players remove @e[r=0,tag=reporting] report_ts 1 /execute @e[name=reportMasker,tag=reporting,score_report_tt_min=20] ~ ~ ~ scoreboard players reset @e[r=0,tag=reporting] report_tt /execute @e[type=armor_stand,name=reportMasker,tag=reporting] ~ ~ ~ /execute @a ~ ~ ~ title @p[r=0] actionbar ["\u00a7c\u00a7l投票进行中,距离结束还有 ",{"score":{"name":"@e[tag=reporting,score_report_ts_min=0]","objective":"report_ts"},"color":"aqua","bold":"true"},"\u00a7c\u00a7l 秒结束"] /execute @e[type=armor_stand,name=reportMasker,tag=reporting] ~ ~ ~ scoreboard players set @e[r=0,tag=reporting] report_num 0 /execute @a[score_rPoll_min=1] ~ ~ ~ scoreboard players add @e[type=armor_stand,name=reportMasker,tag=reporting] report_num 1

投票结束:[高频循环]

  1. /scoreboard players operation @e[name=reportMasker,tag=reporting,score_report_ts=0,c=1] report_numb = @e[name=reportMasker,tag=reporting,score_report_ts=0,c=1] report_num
  2. /execute @e[name=reportMasker,tag=reporting,score_report_ts=0,score_report_num_min=5] ~ ~ ~ /scoreboard players tag @e[r=0,tag=reporting] add rep_res_sys
  3. /execute @e[name=reportMasker,tag=reporting,score_report_ts=0,score_report_num_min=5] ~ ~ ~ tellraw @a ["\n\n\u00a7c\u00a7l投票结束,系统处理中,共有",{"score":{"name":"@e[tag=reporting,score_report_num_min=5]","objective":"report_num"},"color":"yellow","bold":"true"},"\u00a7c\u00a7l人参投\n\n"]
  4. /execute @e[name=reportMasker,tag=reporting,score_report_ts=0,score_report_num=4] ~ ~ ~ tellraw @a ["\n\n\u00a7c\u00a7l投票结束,参投人数不足5人,无法判定\n\n"]
  5. /execute @e[name=reportMasker,tag=reporting,score_report_ts=0,score_report_num=4] ~ ~ ~ give @a minecraft:reeds 1 0 {display:{Name:"举报玩家 (F键)",Lore:["公正公平的举报系统","来自 - Ganxiaozhe"]},Unbreakable:1b,HideFlags:63b,ench:[{id:19s,lvl:1s}],gReport:1b}
  6. /execute @e[name=reportMasker,tag=reporting,score_report_ts=0] ~ ~ ~ /scoreboard players tag @e[r=0,tag=reporting] remove reporting

计算最高:[高频循环]

  1. /execute @e[tag=rep_res_sys,score_report_num=0] ~ ~ ~ /scoreboard players set r_marker report_bad 0
  2. /execute @a[score_report_bad_min=1] ~ ~ ~ scoreboard players operation r_marker report_bad > @p[r=0] report_bad
  3. /scoreboard players operation @e[tag=rep_res_sys,score_report_numb_min=1] report_numb /= 2 report_temp
  4. /scoreboard players operation @e[tag=rep_res_sys] report_numb -= r_marker report_bad
  5. /execute @e[tag=rep_res_sys,score_report_numb=-1] ~ ~ ~ /execute @a[score_report_bad_min=1] ~ ~ ~ scoreboard players operation @p[r=0] report_bad -= r_marker report_bad
  6. /execute @e[tag=rep_res_sys,score_report_numb=-1] ~ ~ ~ /tellraw @a ["\n\u00a77\u00a7l[REPORT] \u00a7c\u00a7l玩家",{"selector":"@p[score_report_bad_min=0,score_report_bad=0]","color":"dark_red","bold":"true"},"\u00a7c\u00a7l以被举报票数",{"score":{"name":"r_marker","objective":"report_bad"},"color":"yellow","bold":"true"},"\u00a7c\u00a7l而被拉入黑名单"]
  7. /scoreboard teams join report_list @a[score_report_bad_min=0,score_report_bad=0]
  8. /execute @e[tag=rep_res_sys,score_report_numb_min=0] ~ ~ ~ tellraw @a ["\n\u00a77\u00a7l[REPORT] \u00a7e\u00a7l被举报次数最多玩家票数仍不过参投人数之半,投票无效"]
  9. /execute @e[tag=rep_res_sys,score_report_num=0] ~ ~ ~ scoreboard players reset @a report_bad
  10. /scoreboard players tag @e[tag=rep_res_sys,score_report_num=0] remove rep_res_sys

当report_numb小于0->投票举报成功,当report_numb大于等于0->投票举报无效。


惩罚措施:[高频循环]

  1. /gamemode 2 @a[team=report_list,m=!2]
  2. /execute @a[team=report_list] ~ ~ ~ tp @p[team=report_list,r=0] @p[r=0]
  3. /effect @a[team=report_list] minecraft:blindness 10 255 true
  4. /effect @a[team=report_list] minecraft:resistance 10 255 true


OOC:

v1.11.2-v1.12.2
展开


LOADING | 此框架正在加载中
QQ群:771363745