Resource icon

JSR DynamicMotd - 动态Motd的js实现 v0

Source of resources
Original
Copyright link
#
Language
Chinese(Simplified)
Supported version
  1. 1.16
如题
自行修改js进行配置
建议直接看源码

[CODE lang="javascript" title="圆??"]const Config = {
MotdList: [//JSON数组:表示Motd的列表
"§cDedicated Server",
"§aDedicated Server",
"§bDedicated Server"
],
Interval: 5000//切换Motd的间隔(单位:毫秒)
}


let currentIndex = 0
function ChangeMotd_PFJSR() {
setServerMotd(Config.MotdList[currentIndex], true)//设置Motd
currentIndex = (currentIndex + 1) % Config.MotdList.length;//计数+1以及重置0
}
function ChangeMotd_NetJSR() {
setServerMotd(Config.MotdList[currentIndex], true)//设置Motd
currentIndex = (currentIndex + 1) % Config.MotdList.length;//计数+1以及重置0
setTimeout("ChangeMotd_NetJSR();", Config.Interval);//延时后再次执行
}
if (Config.MotdList.length === 0) {//判断列表是否无内容
log("[" + TimeNow() + " Error][DynamicMotd]请设置的MotdList!")
} else {
try {
setInterval(ChangeMotd_PFJSR, Config.Interval);//使用PFJSR的setInterval方法
} catch (_) {
ChangeMotd_NetJSR();//没有setInterval方法,那就是NetJSR,改用setTimeout方式执行
}
log(`[${TimeNow()} INFO][DynamicMotd]加载成功!共计${Config.MotdList.length}条Motd记录,切换间隔:${Config.Interval}ms`)
}[/CODE]
  • Like
Reactions: yqs112358
Author
LazuliKao
Downloads
60
Views
1,083
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from LazuliKao

Share this resource