当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
文件
.gitattributes
config.js
main.js
money.js
package.json
placeholders.js
playerdata.js
replacement.js
rollAnimations.js
ui.js
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
placeholders.js 12.11 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
//新增内置计数器时一定要云replacement里面检查下if那些
let tpscounter=[];
let papipath=null;
let onlinePlayers=0;
let allEntities=0;
let localAPIs=[];
if(File.exists("plugins\\lib\\BEPlaceholderAPI-JS.js")){
//papipath=__dirname.match(/(.+)nodejs\\sidebardesigner/)[1]+"lib\\BEPlaceholderAPI-JS";
papipath=__dirname.replace(/nodejs\\sidebardesigner/,"lib\\BEPlaceholderAPI-JS");
//冗余措施,找不到的时候发出提示
}else if(!ll.listPlugins().includes("BEPlaceholderAPI")){
logger.info("BEPlaceholderAPI的依赖库未正确加载,sidebarDesigner可能会加载失败,请检查lib/BEPlaceholderAPI-JS.js是否存在")
}
mc.listen("onTick",()=>{
localAPIs.forEach((currentFunction)=>{
currentFunction();
})
})
mc.listen("onServerStarted",()=>{
if(new tps().plugin()==null){localAPIs.push(calculateTPS)}
if(new entities().plugin()==null){localAPIs.push(calculateEntities)}
if(new online().plugin()==null){localAPIs.push(calculateOnlinePlayers)}
})
function calculateTPS(){
tpscounter.push(new Date().getTime());
if(tpscounter.length>100){
tpscounter.shift();
}
}
function calculateEntities(){
allEntities=mc.getAllEntities().length;
}
function calculateOnlinePlayers(){
let realOnlinePlayers=0;
mc.getOnlinePlayers().forEach((player)=>{
if(!player.isSimulatedPlayer()){
realOnlinePlayers++;
}
})
onlinePlayers=realOnlinePlayers;
}
function profTpsCounter(){
let i;
let tps;
if(tpscounter.length>20){
//log(tpscounter.length)
for(i=tpscounter.length-1;i>=0;i--){
if(tpscounter[tpscounter.length-1]-tpscounter[i]<1030 && tpscounter[tpscounter.length-1]-tpscounter[i-1]>=1030){
return tpscounter.length-1-i;
}
}
}
else{
return 20;
}
}
class tps{
constructor(){
let i = 0;
const availabletpsplugins=["QueryTPS","BEPlaceholderAPI","Cleaner","dynamicPlayerLim"];
for(i=0;i<availabletpsplugins.length;i++){
if(ll.listPlugins().includes(availabletpsplugins[i])){
this.type=availabletpsplugins[i];
break;
}
}
}
currentTps(){
let tpsfunc;
switch(this.type){
case "QueryTPS": {
tpsfunc=ll.import("QueryTPS", "GetCurrentTPS");
return tpsfunc();
}
case "BEPlaceholderAPI": {
tpsfunc=require(papipath).PAPI;
return tpsfunc.getValue("server_tps");
}
case "Cleaner": {
tpsfunc=ll.import("Cleaner", "GetCurrentTPS");
return tpsfunc();
}
case "dynamicPlayerLim": {
tpsfunc=ll.import("dynamicPlayerLim", "currentTps");
return tpsfunc();
}
default:{
return profTpsCounter();
}
}
}
averageTps(){
let tpsfunc;
switch(this.type){
case "QueryTPS": {
tpsfunc=ll.import("QueryTPS", "GetAverageTPS");
return tpsfunc();
}
case "BEPlaceholderAPI": {
tpsfunc=require(papipath).PAPI;
return tpsfunc.getValue("server_tps");
}
case "Cleaner": {
tpsfunc=ll.import("Cleaner", "GetAverageTPS");
return tpsfunc();
}
case "dynamicPlayerLim": {
tpsfunc=ll.import("dynamicPlayerLim", "currentTps");
return tpsfunc();
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class mspt{
constructor(){
let i;
const availableplugins=["QueryTPS","BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let msptfunc;
switch(this.type){
case "QueryTPS": {
msptfunc=ll.import("QueryTPS", "GetMSPT");
return msptfunc();
}
case "BEPlaceholderAPI": {
msptfunc=require(papipath).PAPI;
return msptfunc.getValue("server_mspt");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class version{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_version");
}
default:{
return mc.BDSVersion();
}
}
}
plugin(){
return this.type;
}
}
class protocol{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_protocol_version");
}
default:{
return mc.getServerProtocolVersion();
}
}
}
plugin(){
return this.type;
}
}
class entities{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_total_entities");
}
default:{
return allEntities;
}
}
}
plugin(){
return this.type;
}
}
class uptime{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_uptime");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class online{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_online");
}
default:{
return onlinePlayers;
}
}
}
plugin(){
return this.type;
}
}
class max_players{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_max_players");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class levelName{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_world_name");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class levelSeed{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_seed");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class levelDifficulty{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_difficulty");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class port{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_port");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class port6{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_port_v6");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class bdsram{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_ram_bds_used");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class ram{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_ram_used");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class ramFree{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_ram_free");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class ramTotal{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValue("server_ram_max");
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class speed{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(player){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return getfunc.getValueByPlayer("player_name",player);
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
class playerBedPos{
constructor(){
let i;
const availableplugins=["BEPlaceholderAPI"];
for(i=0;i<availableplugins.length;i++){
if(ll.listPlugins().includes(availableplugins[i])){
this.type=availableplugins[i];
break;
}
}
}
get(player){
let getfunc;
switch(this.type){
case "BEPlaceholderAPI": {
getfunc=require(papipath).PAPI;
return {
x:getfunc.getValueByPlayer("player_bed_x",player),
y:getfunc.getValueByPlayer("player_bed_y",player),
y:getfunc.getValueByPlayer("player_bed_z",player)
}
}
default:{
return null;
}
}
}
plugin(){
return this.type;
}
}
module.exports={
tps,
mspt,
version,
protocol,
entities,
uptime,
online,
max_players,
levelName,
levelSeed,
levelDifficulty,
port,
port6,
bdsram,
ram,
ramFree,
ramTotal,
speed,
playerBedPos
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化