From 89ecd942ff6b275f2705667dd1662c750fd5c665 Mon Sep 17 00:00:00 2001 From: Smell of curry <75345244+smell-of-curry@users.noreply.github.com> Date: Sat, 11 Feb 2023 15:32:30 -0500 Subject: [PATCH] 2.6.0 --- entities/database.json | 2 +- package-lock.json | 42 +- package.json | 8 +- scripts/index.js | 3960 ++++++++++++++++- scripts/index.js.map | 8 +- src/rubedo/config/database.ts | 24 +- src/rubedo/database/Database.ts | 141 +- src/rubedo/lib/Command/ArgumentTypes.ts | 5 +- src/rubedo/lib/Command/utils.ts | 6 +- src/rubedo/lib/Events/EntitiesLoad.ts | 52 +- src/utils.ts | 31 + src/vendor/Anti-Cheat/config/movement.ts | 2 +- src/vendor/Anti-Cheat/modules/commands/ban.ts | 29 +- .../Anti-Cheat/modules/events/import.ts | 2 +- .../Anti-Cheat/modules/events/playerJoin.ts | 25 - .../Anti-Cheat/modules/events/playerSpawn.ts | 26 + src/vendor/Anti-Cheat/modules/managers/ban.ts | 52 +- .../Anti-Cheat/modules/managers/import.ts | 2 +- .../Anti-Cheat/modules/managers/region.ts | 25 +- .../Anti-Cheat/modules/protections/cbe.ts | 70 - .../Anti-Cheat/modules/protections/crasher.ts | 36 - .../Anti-Cheat/modules/protections/import.ts | 6 +- .../modules/protections/movement.ts | 7 +- .../Anti-Cheat/modules/protections/nbt.ts | 85 - .../Anti-Cheat/modules/protections/spam.ts | 2 +- .../modules/protections/unobtainable.ts | 99 - src/vendor/Anti-Cheat/protections.ts | 17 +- src/vendor/GlobalBans/index.ts | 6 +- 28 files changed, 4254 insertions(+), 516 deletions(-) delete mode 100644 src/vendor/Anti-Cheat/modules/events/playerJoin.ts create mode 100644 src/vendor/Anti-Cheat/modules/events/playerSpawn.ts delete mode 100644 src/vendor/Anti-Cheat/modules/protections/cbe.ts delete mode 100644 src/vendor/Anti-Cheat/modules/protections/crasher.ts delete mode 100644 src/vendor/Anti-Cheat/modules/protections/nbt.ts delete mode 100644 src/vendor/Anti-Cheat/modules/protections/unobtainable.ts diff --git a/entities/database.json b/entities/database.json index 96e8f81..a492dfa 100644 --- a/entities/database.json +++ b/entities/database.json @@ -2,7 +2,7 @@ "format_version": "1.17.10", "minecraft:entity": { "description": { - "identifier": "rubedo:database", + "identifier": "database:database", "is_spawnable": false, "is_summonable": true, "is_experimental": false diff --git a/package-lock.json b/package-lock.json index 69f9519..daaf663 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,13 +9,15 @@ "version": "2.6.7-beta", "license": "ISC", "dependencies": { - "@minecraft/server": "^1.1.0-beta.preview.1.19.50.24", - "@minecraft/server-ui": "^1.0.0-beta.preview.1.19.50.24", "esbuild": "^0.15.9", "fs-extra": "^10.1.0", "i": "^0.3.7", "javascript-obfuscator": "^4.0.0", "npm": "^8.19.2" + }, + "devDependencies": { + "@minecraft/server": "^1.1.0-beta.1.19.60-stable", + "@minecraft/server-ui": "^1.0.0-beta.1.19.60-stable" } }, "node_modules/@esbuild/android-arm": { @@ -74,16 +76,18 @@ } }, "node_modules/@minecraft/server": { - "version": "1.1.0-beta.preview.1.19.50.24", - "resolved": "https://registry.npmjs.org/@minecraft/server/-/server-1.1.0-beta.preview.1.19.50.24.tgz", - "integrity": "sha512-nJjFYzOjdR5RpPj7q02dTudcimh5+w3gxw0NMjOgDTp2SE8tmoFU/xNcbf2E9Puo4v6NLZHBeOkTEhdaRVgpDw==" + "version": "1.1.0-beta.1.19.60-stable", + "resolved": "https://registry.npmjs.org/@minecraft/server/-/server-1.1.0-beta.1.19.60-stable.tgz", + "integrity": "sha512-o7koQPeyX/R+MUdgexYMIfoZtdkWgr51s+e1f7gR2EqomTUu8/J/8N3sDEWIdeMU2zM5MzWaezCJK0+rEUpZTg==", + "dev": true }, "node_modules/@minecraft/server-ui": { - "version": "1.0.0-beta.preview.1.19.50.24", - "resolved": "https://registry.npmjs.org/@minecraft/server-ui/-/server-ui-1.0.0-beta.preview.1.19.50.24.tgz", - "integrity": "sha512-wiPeEP+tDmU4oSg8jRjgd70Qw9kQYpWF1VAbgkbRk5BdOs5qTXIws4UXJ5T53y6XR4GsL0o2heKfrpQ2xC/Fcw==", + "version": "1.0.0-beta.1.19.60-stable", + "resolved": "https://registry.npmjs.org/@minecraft/server-ui/-/server-ui-1.0.0-beta.1.19.60-stable.tgz", + "integrity": "sha512-IBua5RvLSNDDB/nETfE8j0KF1Bq0VJ87UXz+XlmO0XTjy+ucn5NpiEb5LJmRrweJoYznmDwonM6LumvcsRuhOw==", + "dev": true, "dependencies": { - "@minecraft/server": "1.1.0-beta.preview.1.19.50.24" + "@minecraft/server": "1.1.0-beta.1.19.60-stable" } }, "node_modules/@types/minimatch": { @@ -3401,7 +3405,7 @@ "dependencies": { "agent-base": "^6.0.2", "debug": "^4.3.3", - "socks": "^2.6.7" + "socks": "^2.6.2" }, "engines": { "node": ">= 10" @@ -3961,16 +3965,18 @@ "integrity": "sha512-CZFX7UZVN9VopGbjTx4UXaXsi9ewoM1buL0kY7j1ftYdSs7p2spv9opxFjHlQ/QGTgh4UqufYqJJ0WKLml7b6w==" }, "@minecraft/server": { - "version": "1.1.0-beta.preview.1.19.50.24", - "resolved": "https://registry.npmjs.org/@minecraft/server/-/server-1.1.0-beta.preview.1.19.50.24.tgz", - "integrity": "sha512-nJjFYzOjdR5RpPj7q02dTudcimh5+w3gxw0NMjOgDTp2SE8tmoFU/xNcbf2E9Puo4v6NLZHBeOkTEhdaRVgpDw==" + "version": "1.1.0-beta.1.19.60-stable", + "resolved": "https://registry.npmjs.org/@minecraft/server/-/server-1.1.0-beta.1.19.60-stable.tgz", + "integrity": "sha512-o7koQPeyX/R+MUdgexYMIfoZtdkWgr51s+e1f7gR2EqomTUu8/J/8N3sDEWIdeMU2zM5MzWaezCJK0+rEUpZTg==", + "dev": true }, "@minecraft/server-ui": { - "version": "1.0.0-beta.preview.1.19.50.24", - "resolved": "https://registry.npmjs.org/@minecraft/server-ui/-/server-ui-1.0.0-beta.preview.1.19.50.24.tgz", - "integrity": "sha512-wiPeEP+tDmU4oSg8jRjgd70Qw9kQYpWF1VAbgkbRk5BdOs5qTXIws4UXJ5T53y6XR4GsL0o2heKfrpQ2xC/Fcw==", + "version": "1.0.0-beta.1.19.60-stable", + "resolved": "https://registry.npmjs.org/@minecraft/server-ui/-/server-ui-1.0.0-beta.1.19.60-stable.tgz", + "integrity": "sha512-IBua5RvLSNDDB/nETfE8j0KF1Bq0VJ87UXz+XlmO0XTjy+ucn5NpiEb5LJmRrweJoYznmDwonM6LumvcsRuhOw==", + "dev": true, "requires": { - "@minecraft/server": "1.1.0-beta.preview.1.19.50.24" + "@minecraft/server": "1.1.0-beta.1.19.60-stable" } }, "@types/minimatch": { @@ -6128,7 +6134,7 @@ "requires": { "agent-base": "^6.0.2", "debug": "^4.3.3", - "socks": "^2.6.7" + "socks": "^2.6.2" } }, "spdx-correct": { diff --git a/package.json b/package.json index 4196aa0..30b33e3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,5 @@ { "dependencies": { - "@minecraft/server": "^1.1.0-beta.preview.1.19.50.24", - "@minecraft/server-ui": "^1.0.0-beta.preview.1.19.50.24", "esbuild": "^0.15.9", "fs-extra": "^10.1.0", "i": "^0.3.7", @@ -26,5 +24,9 @@ "bugs": { "url": "https://github.com/smell-of-curry/rubedo/issues" }, - "homepage": "https://github.com/smell-of-curry/rubedo#readme" + "homepage": "https://github.com/smell-of-curry/rubedo#readme", + "devDependencies": { + "@minecraft/server": "^1.1.0-beta.1.19.60-stable", + "@minecraft/server-ui": "^1.0.0-beta.1.19.60-stable" + } } diff --git a/scripts/index.js b/scripts/index.js index 95f4b2a..2121882 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -1,3 +1,3959 @@ -import{system as Mr}from"@minecraft/server";import{world as uo}from"@minecraft/server";var v="-";import{world as lo}from"@minecraft/server";import{ItemStack as Ft,MinecraftItemTypes as zt}from"@minecraft/server";import{BlockLocation as ao}from"@minecraft/server";var Bt=32e3,se="rubedo:database",N=new ao(0,-64,0),ve=128;import{system as _t,world as $t}from"@minecraft/server";import{BlockLocation as We,MinecraftDimensionTypes as X,system as Nt,world as J}from"@minecraft/server";var y={overworld:J.getDimension(X.overworld),nether:J.getDimension(X.nether),theEnd:J.getDimension(X.theEnd),"minecraft:overworld":J.getDimension(X.overworld),"minecraft:nether":J.getDimension(X.nether),"minecraft:the_end":J.getDimension(X.theEnd)};var Mt={y:317098e-16,w:6048e5,d:864e5,h:36e5,m:6e4,s:1e3,ms:1};function ae(t){let e=t.split(","),n=0;for(let o of e){let r=parseInt(o.match(/\d+/)[0]),i=o.match(/[a-zA-Z]+/)[0];if(!Mt[i])throw new Error(`Invalid duration unit: ${i}`);n+=Mt[i]*r}return n}function Z(t){return new Date(t).toString()}function Te(t){return new We(Math.floor(t.x),Math.floor(t.y),Math.floor(t.z))}function Dt(t){return new Promise(e=>{let n=Nt.runSchedule(()=>{e(),Nt.clearRunSchedule(n)},t)})}function Lt(t,e){return t instanceof We||e instanceof We?~~t.x===~~e.x&&~~t.y===~~e.y&&~~t.z===~~e.z:t.x===e.x&&t.y===e.y&&t.z===e.z}function co(t,e){return[t.x,e.x]=[Math.min(t.x,e.x),Math.max(t.x,e.x)],[t.y,e.y]=[Math.min(t.y,e.y),Math.max(t.y,e.y)],[t.z,e.z]=[Math.min(t.z,e.z),Math.max(t.z,e.z)],[t,e]}function Se(t,e,n){let[o,r]=co(e,n),{x:i,y:s,z:c}=t;return i>=o.x&&i<=r.x&&s>=o.y&&s<=r.y&&c>=o.z&&c<=r.z}function Ot(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))}var Y={},Pe=!1;_t.run(async()=>{try{await y.overworld.runCommandAsync("testfor @a"),Pe=!0;for(let[t,e]of Object.entries(Y))e(),delete Y[t]}catch{let e=$t.events.entityCreate.subscribe(n=>{_t.run(()=>{Pe=!0;for(let[o,r]of Object.entries(Y))r(),delete Y[o];$t.events.entityCreate.unsubscribe(e)})})}});var w=class{static async awaitLoad(){if(!Pe)return new Promise(e=>{w.subscribe(e)})}static subscribe(e){if(Pe){e();return}let n=Object.keys(Y).length;return Y[n]=e,n}static unsubscribe(e){delete Y[e]}};var g=class{constructor(e){this.tableName=e;this.tableName=e,this.MEMORY=null,this.QUEUE=[],w.subscribe(async()=>{await this.initData(),this.QUEUE.forEach(n=>n())})}static createTableEntity(e,n){let o=y.overworld.spawnEntity(se,N);return o.setDynamicProperty("tableName",e),o.nameTag=`\xA7aDatabase Table: ${e}\xA7r`,n&&o.setDynamicProperty("index",n),o}static getTableEntities(e){return y.overworld.getEntitiesAtBlockLocation(N).filter(n=>n.typeId==se&&n.getDynamicProperty("tableName")==e)}async addQueueTask(){return new Promise(e=>{this.QUEUE.push(e)})}async saveData(){this.MEMORY||await this.addQueueTask();let e=g.getTableEntities(this.tableName),n=Ot(JSON.stringify(this.MEMORY),Bt),o=Math.ceil(n.length/ve)-e.length;if(o>0)for(let i=0;i0;){let d=new Ft(zt.acaciaBoat);d.nameTag=n[r],c.setItem(i,d),r++}for(let d=c.size;d=r/ve;i--)e[i].triggerEvent("despawn")}async initData(){let e=g.getTableEntities(this.tableName).sort((r,i)=>r.getDynamicProperty("index")-i.getDynamicProperty("index")),n="";for(let r of e){let i=r.getComponent("inventory").container;for(let s=0;se.name===t)}var F=class{constructor(e="literal"){this.name=e;this.typeName="literal";this.name=e}matches(e){return{success:this.name==e}}fail(e){return`${e} should be ${this.name}!`}},ce=class{constructor(e="string"){this.name=e;this.typeName="string";this.name=e}matches(e){return{success:e&&e!="",value:e}}fail(e){return"Value must be of type string!"}},le=class{constructor(e="integer"){this.name=e;this.typeName="int";this.name=e}matches(e){return{success:!isNaN(e),value:parseInt(e)}}fail(e){return"Value must be valid number!"}},Qe=class{constructor(e="float"){this.name=e;this.typeName="float";this.name=e}matches(e){return{success:Boolean(e?.match(/^\d+\.\d+$/)?.[0]),value:parseInt(e)}}fail(e){return"Value must be valid float!"}},K=class{constructor(e="location"){this.name=e;this.typeName="location";this.name=e}matches(e){return{success:/^([~^]{0,1}(-\d)?(\d*)?(\.(\d+))?)$/.test(e),value:e}}fail(e){return"Value needs to be a valid number, value can include: [~,^]"}},me=class{constructor(e="boolean"){this.name=e;this.typeName="boolean";this.name=e}matches(e){return{success:Boolean(e?.match(/^(true|false)$/)?.[0]),value:e=="true"}}fail(e){return`"${e}" can be either "true" or "false"`}},Xe=class{constructor(e="player"){this.name=e;this.typeName="Player";this.name=e}matches(e){return{success:!!Vt(e),value:Vt(e)}}fail(e){return`player: "${e}", is not in this world`}},Je=class{constructor(e="target"){this.name=e;this.typeName="Target";this.name=e}matches(e){return{success:Boolean(e?.match(/^(@.|"[\s\S]+")$/)?.[0]),value:e}}fail(e){return`${e} is not a valid target`}},ue=class{constructor(e="array",n){this.name=e;this.types=n;this.typeName="string";this.name=e,this.types=n,this.typeName=n.join(" | ").replace(/(.{25})..+/,"$1...")}matches(e){return{success:this.types.includes(e),value:e}}fail(e){return`"${e}" must be one of these values: ${this.types.join(" | ")}`}},Ze=class{constructor(e){this.name=e;this.typeName="Duration"}matches(e){return{success:/^(\d+[hdysmw],?)+$/.test(e),value:e}}fail(e){return`"${e}" must be a value like "10d" or "3s" the first part is the length second is unit`}},et=class{constructor(e="playerName"){this.name=e;this.typeName="playerName";this.name=e}matches(e){return{success:!!new g("ids").get(e),value:e}}fail(e){return`player: "${e}" has never played this world before! Tip: if the name has spaces in it use quotes around name!`}},f={string:ce,int:le,float:Qe,location:K,boolean:me,player:Xe,target:Je,array:ue,duration:Ze,playerName:et};var Ae=class{constructor(e){this.data=e,this.sender=e.sender}reply(e){this.sender.tell(e)}};function jt(t,e){try{return t.slice(e.length).trim().match(/"[^"]+"|[^\s]+/g).map(n=>n.replace(/"(.+)"/,"$1").toString())}catch{return[]}}function Yt(t,e){t.tell({rawtext:[{text:"\xA7c"},{translate:"commands.generic.unknown",with:[`${e}`]}]})}function tt(t,e){t.tell({rawtext:[{text:e.data.invalidPermission?e.data.invalidPermission:`\xA7cYou do not have permission to use "${e.data.name}"`}]})}function Kt(t,e,n,o,r){if(t.tell({rawtext:[{text:"\xA7c"},{translate:"commands.generic.syntax",with:[`${v}${e.data.name} ${o.slice(0,r).join(" ")}`,o[r]??" ",o.slice(r+1).join(" ")]}]}),n.children.length>1||!o[r]){let i=n.children.map(s=>s.type instanceof F?s.type.name:s.type?.typeName);t.tell(`\xA7c"${o[r]??"undefined"}" is not valid! Argument "${[...new Set(n.children.map(s=>s.type.name))][0]}" can be typeof: "${i.join('", "')}"`)}else t.tell(`\xA7c${n.children[0]?.type?.fail(o[r])}`)}function mo([t,e,n],{location:o,viewVector:r}){if(!t||!e||!t)return null;let i=[o.x,o.y,o.z],s=[r.x,r.y,r.z],c=[t,e,n].map(h=>{let E=parseFloat(h);return isNaN(E)?0:E}),d=[t,e,n].map((h,E)=>h.includes("~")?c[E]+i[E]:h.includes("^")?c[E]+s[E]:c[E]);return{x:d[0],y:d[1],z:d[2]}}function Gt(t,e,n,o){let r=e[e.length-1]??o,i=[];for(let[s,c]of e.entries())if(!c.type.name.endsWith("*")){if(c.type instanceof K){i.push(mo([t[s],t[s+1],t[s+2]],n.sender));continue}c.type instanceof F||i.push(c.type.matches(t[s]).value??t[s])}r.callback(new Ae(n),...i)}var G=[];uo.events.beforeChat.subscribe(t=>{if(!t.message.startsWith(v))return;t.cancel=!0;let e=jt(t.message,v),n=G.find(c=>c.depth==0&&(c.data.name==e[0]||c.data?.aliases?.includes(e[0]))),o={message:t.message,sendToTargets:t.sendToTargets,sender:t.sender,targets:t.targets};if(!n)return Yt(t.sender,e[0]);if(!n.data?.requires(t.sender))return tt(o.sender,n);e.shift();let r=[],i=(c,d)=>{if(c.children.length>0){let h=c.children.find(E=>E.type.matches(e[d]).success);return!h&&!e[d]&&c.callback?void 0:h?h.data?.requires(o.sender)?(r.push(h),i(h,d+1)):(tt(o.sender,h),"fail"):(Kt(o.sender,n,c,e,d),"fail")}};i(n,0)!="fail"&&Gt(e,r,o,n)});import{ItemStack as Eo,MinecraftItemTypes as vo,system as fn,world as To}from"@minecraft/server";var Ht="rubedo:gui",de="rubedo:inventory";import{system as Xt}from"@minecraft/server";import{system as fo}from"@minecraft/server";var nt={},Ut={},z={};function po(t,e,n){if(e.length!=n.length)return[];let o=[];for(let r=0;rn[r]?.item?.amount&&e[r]?.item?.amount!=0){let i={slot:r,uid:n[r].uid,oldUid:e[r].uid,item:n[r].item,oldItem:e[r].item,changeType:"fluctuation"};o.push(i),z[t.id]=i;continue}if(n[r].uid!=e[r].uid)if(e[r]?.item&&n[r]?.item){let i={slot:r,uid:n[r].uid,oldUid:e[r].uid,item:n[r].item,oldItem:e[r].item,changeType:"swap"};o.push(i),z[t.id]=i}else if(n[r]?.item){if(n[r]?.item)if(z[t.id]?.changeType=="delete"&&z[t.id]?.uid==n[r].uid){let i={slot:r,uid:n[r].uid,item:n[r].item,changeType:"move"};o.push(i),z[t.id]=i;continue}else{let i={slot:r,uid:n[r].uid,item:n[r].item,changeType:"put"};o.push(i),z[t.id]=i}}else{let i={slot:r,uid:e[r].uid,item:e[r].item,changeType:"delete"};o.push(i),z[t.id]=i}}return o}function go(t){if(!t)return"";let e=[];return e.push(t.typeId),e.push(t.nameTag),e.push(t.data),e.push(t.getLore().join("")),e.join("")}function yo(t){let e=[];for(let n=0;n{for(let t of Object.values(nt))for(let e of y.overworld.getEntities(t.entities)){let n=yo(e.getComponent("inventory").container),o=po(e,Ut[e.id]??n,n);if(Ut[e.id]=n,o.length!=0){if(e.hasTag("skipCheck")){e.removeTag("skipCheck"),delete z[e.id];continue}for(let r of o)t.callback(e,r)}}},5);var fe=class{static subscribe(e,n){let o=Date.now();return nt[o]={callback:n,entities:e},o}static unsubscribe(e){delete nt[e]}};import{Location as ho}from"@minecraft/server";var M={},ee={};function qt(t){return t.getComponent("minecraft:inventory").container.getItem(t.selectedSlot)}async function Wt(t,e){try{let n=t.getComponent("minecraft:inventory").container,o=[];for(let r=0;ro.kill())}}function Qt(t,e){return t.getComponent("minecraft:inventory").container.getItem(e)}var xe=class{constructor(e,n,o){this.gui=e,this.slot=n,this.change=o}message(e){this.gui.player.tell(e)}getItemAdded(){return this.slot.item?null:this.gui.entity.getComponent("minecraft:inventory").container.getItem(this.change.slot)}GiveAction(e=this.slot.item.itemStack){this.gui.player.getComponent("minecraft:inventory").container.addItem(e)}TakeAction(e=null){this.gui.player.getComponent("minecraft:inventory").container.addItem(this.slot.item.itemStack),this.gui.page.slots[this.change.slot]=null,e&&e.delete(this.slot.item.components.dbKey)}PageAction(e,n){this.gui.setPage(e,n)}CloseAction(){this.gui.despawn()}SetAction(){this.gui.entity.getComponent("minecraft:inventory").container.setItem(this.change.slot,this.slot.item.itemStack)}async FormAction(e){return this.CloseAction(),await Dt(5),await e.show(this.gui.player)}};var te=class{static spawnEntity(e){try{return e.dimension.spawnEntity(de,e.headLocation)}catch{return null}}constructor(e){this.player=e,this.entity=te.spawnEntity(e),this.entity&&(this.hasChestOpen=!1,this.setPage("home")),this.runScheduleId=Xt.runSchedule(()=>{if(!this.entity)return this.despawn();if(this.player.getComponent("mark_variant").value==1)this.hasChestOpen||(this.slotChangeEvent=fe.subscribe({type:de},(n,o)=>{n.id==this.entity.id&&this.onSlotChange(o)})),this.hasChestOpen=!0;else try{this.entity.teleport(this.player.headLocation,this.player.dimension,this.player.rotation.x,this.player.rotation.y,!0)}catch{this.despawn()}},5)}setPage(e,n){let o=this.entity.getComponent("inventory").container;for(let i=0;i{t.PageAction("moderation:see")}).setSlots([54],new x(Zt.barrier,{nameTag:"\xA7cClose GUI"}),t=>{t.CloseAction()});import{world as V,Player as Io,BlockLocation as ln,MinecraftBlockTypes as wo,GameMode as Co}from"@minecraft/server";import{BlockLocation as on,MinecraftBlockTypes as ko}from"@minecraft/server";var en={doorsAndSwitches:!0,openContainers:!0,pvp:!1,allowedEntities:["minecraft:player","minecraft:npc","minecraft:item","rubedo:inventory","rubedo:database"]},tn=["minecraft:acacia_door","minecraft:acacia_trapdoor","minecraft:acacia_button","minecraft:birch_door","minecraft:birch_trapdoor","minecraft:birch_button","minecraft:crimson_door","minecraft:crimson_trapdoor","minecraft:crimson_button","minecraft:dark_oak_door","minecraft:dark_oak_trapdoor","minecraft:dark_oak_button","minecraft:jungle_door","minecraft:jungle_trapdoor","minecraft:jungle_button","minecraft:mangrove_door","minecraft:mangrove_trapdoor","minecraft:mangrove_button","minecraft:spruce_door","minecraft:spruce_trapdoor","minecraft:spruce_button","minecraft:warped_door","minecraft:warped_trapdoor","minecraft:warped_button","minecraft:wooden_door","minecraft:wooden_button","minecraft:trapdoor","minecraft:iron_door","minecraft:iron_trapdoor","minecraft:polished_blackstone_button","minecraft:lever"],nn=["minecraft:chest","minecraft:ender_chest","minecraft:barrel","minecraft:trapped_chest","minecraft:dispenser","minecraft:dropper","minecraft:furnace","minecraft:blast_furnace","minecraft:lit_furnace","minecraft:lit_blast_furnace","minecraft:hopper","minecraft:shulker_box","minecraft:undyed_shulker_box","minecraft:lit_smoker","minecraft:smoker"];var a={config:new g("config"),freezes:new g("freezes"),mutes:new g("mutes"),bans:new g("bans"),regions:new g("regions"),roles:new g("roles"),tasks:new g("tasks"),npcs:new g("npcs"),ids:new g("ids"),logs:new g("logs"),protections:new g("protections")};var U=[],Re=!1,ot=-64,rt=320,p=class{static async getAllRegionsSync(){if(Re)return U;let e=(await a.regions.valuesSync()).map(n=>new p(n.from,n.to,n.dimensionId,n.permissions,n.key));return e.forEach(n=>{U.push(n)}),Re=!0,e}static getAllRegions(){if(Re)return U;let e=a.regions.values().map(n=>new p(n.from,n.to,n.dimensionId,n.permissions,n.key));return e.forEach(n=>{U.push(n)}),Re=!0,e}static blockLocationInRegion(e,n){return this.getAllRegions().find(o=>o.dimensionId==n&&Se(e,{x:o.from.x,y:ot,z:o.from.z},{x:o.to.x,y:rt,z:o.to.z}))}static async blockLocationInRegionSync(e,n){return(await this.getAllRegionsSync()).find(o=>o.dimensionId==n&&Se(e,{x:o.from.x,y:ot,z:o.from.z},{x:o.to.x,y:rt,z:o.to.z}))}static async removeRegionAtBlockLocation(e,n){let o=this.blockLocationInRegion(e,n);return o?a.regions.delete(o.key):!1}constructor(e,n,o,r,i){this.from=e,this.to=n,this.dimensionId=o,this.permissions=r??en,this.key=i||Date.now().toString(),i||this.update().then(()=>{Be(),U.push(this)})}async update(){return a.regions.set(this.key,{key:this.key,from:this.from,dimensionId:this.dimensionId,permissions:this.permissions,to:this.to})}async delete(){let e=a.regions.get(this.key),n=new on(e.from.x,e.dimensionId=="minecraft:overworld"?-64:0,e.from.z),o=new on(e.to.x,e.dimensionId=="minecraft:overworld"?-64:0,e.to.z);for(let r of n.blocksBetween(o))y[e.dimensionId].getBlock(r)?.setType(ko.bedrock);return U=U.filter(r=>r.key!=this.key),a.regions.delete(this.key)}entityInRegion(e){return this.dimensionId==e.dimension.id&&Se(e.location,{x:this.from.x,y:ot,z:this.from.z},{x:this.to.x,y:rt,z:this.to.z})}changePermission(e,n){this.permissions[e]=n,this.update()}};var L=class{static getTasks(){return a.tasks.get("changePlayerRole")??[]}static getPlayersRoleToSet(e){return L.getTasks().find(o=>o.playerName==e)?.role}constructor(e,n){let o=L.getTasks();o.push({playerName:e,role:n}),a.tasks.set("changePlayerRole",o)}};import{MinecraftBlockTypes as it,MinecraftItemTypes as u}from"@minecraft/server";var Ne="https://discord.gg/dMa3A5UYKX",rn=[u.beehive.id,u.beeNest.id,u.axolotlBucket.id,u.codBucket.id,u.tadpoleBucket.id,u.tropicalFishBucket.id,u.salmonBucket.id,u.pufferfishBucket.id],sn=[u.allow.id,u.barrier.id,u.borderBlock.id,u.debugStick?.id??"minecraft:debug_stick",u.deny.id,u.jigsaw.id,u.lightBlock.id,u.commandBlock.id,u.repeatingCommandBlock.id,u.chainCommandBlock.id,u.commandBlockMinecart.id,u.structureBlock.id,u.structureVoid.id,u.bedrock.id,u.endPortalFrame.id,"minecraft:info_update","minecraft:info_update2","minecraft:reserved3","minecraft:reserved4","minecraft:reserved6","minecraft:movingBlock","minecraft:moving_block","minecraft:movingblock","minecraft:piston_arm_collision","minecraft:piston_arm_collision","minecraft:pistonarmcollision","minecraft:stickyPistonArmCollision","minecraft:sticky_piston_arm_collision","minecraft:unknown","minecraft:glowingobsidian","minecraft:invisible_bedrock","minecraft:invisiblebedrock","minecraft:netherreactor","minecraft:portal","minecraft:fire","minecraft:water","minecraft:lava","minecraft:flowing_lava","minecraft:flowing_water","minecraft:soul_fire"],an=[it.dispenser.id],cn=[it.bedrock.id,it.barrier.id,"minecraft:invisiblebedrock","minecraft:movingBlock","minecraft:movingblock","minecraft:moving_block"],us=[u.chest.id,u.trappedChest.id,u.barrel.id,u.dispenser.id,u.dropper.id,u.furnace.id,"minecraft:lit_furnace",u.blastFurnace.id,"minecraft:lit_blast_furnace",u.smoker.id,"minecraft:lit_smoker",u.hopper.id,u.shulkerBox.id,u.undyedShulkerBox.id];var Me={aquaAffinity:1,baneOfArthropods:5,binding:1,blastProtection:4,channeling:1,depthStrider:3,efficiency:5,featherFalling:4,fireAspect:2,fireProtection:4,flame:1,fortune:3,frostWalker:2,impaling:5,infinity:1,knockback:2,looting:3,loyalty:4,luckOfTheSea:3,lure:3,mending:1,multishot:1,piercing:4,power:5,projectileProtection:4,protection:4,punch:2,quickCharge:3,respiration:3,riptide:3,sharpness:5,silkTouch:1,smite:5,soulSpeed:3,swiftSneak:4,thorns:3,unbreaking:3,vanishing:1};function j(t,e=[],n){if(pe(t))return console.warn("[WARNING]: TRIED TO KICK OWNER"),t.tell("You have been tried to kick, but you cant!"),n?.();try{t.runCommandAsync(`kick "${t.name}" \xA7r${e.join(` -`)}`),t.triggerEvent("kick")}catch(o){if(t.triggerEvent("kick"),!/"statusCode":-2147352576/.test(o))return;n&&n()}}function l(t){return t instanceof Io?a.roles.get(t.name)??"member":a.roles.get(t)??"member"}function ne(t,e){if(typeof t=="string"){a.roles.set(t,e);let n=[...V.getPlayers()].find(o=>o.name==t);n?n.setDynamicProperty("role",e):new L(t,e)}else a.roles.set(t.name,e),t.setDynamicProperty("role",e)}function pe(t){return V.getDynamicProperty("worldsOwner")==t.id}function st(){let t=V.getDynamicProperty("worldsOwner");return!t||t==""?null:t}function mn(){let t=st();if(!t)return null;let e=a.ids.collection();return Object.keys(e).find(n=>e[n]===t)}function ge(t){if(!t)return V.setDynamicProperty("worldsOwner","");V.setDynamicProperty("worldsOwner",t.id.toString())}function De(){return V.getDynamicProperty("isLockDown")??!1}function at(t){V.setDynamicProperty("isLockDown",t)}function Be(){for(let t of p.getAllRegions()){let e=new ln(t.from.x,t.dimensionId=="minecraft:overworld"?-64:0,t.from.z),n=new ln(t.to.x,t.dimensionId=="minecraft:overworld"?-64:0,t.to.z);for(let o of e.blocksBetween(n))y[t.dimensionId].getBlock(o)?.setType(wo.deny)}}function C(t){switch(t){case"banned_items":return a.config.get("banned_items")??sn;case"banned_blocks":return a.config.get("banned_blocks")??cn;case"enchantments":return a.config.get("enchantments")??Me;case"appealLink":return a.config.get("appealLink")??Ne}}function q(t,e){a.config.set(t,e)}function un(t){return C("enchantments")[t.type.id]??t.type.maxLevel}function dn(t){return Object.values(Co).find(e=>[...V.getPlayers({name:t.name,gameMode:e})].length)}var T=new Eo(vo.acaciaBoat,0);w.subscribe(()=>{fn.runSchedule(()=>{for(let t of To.getPlayers()){if(qt(t)?.typeId!=Ht){M[t.name]&&M[t.name].despawn();continue}Object.keys(M).includes(t?.name)||l(t)=="admin"&&(M[t.name]=new te(t))}},10)});fn.runSchedule(()=>{let t=Object.values(M).map(e=>e.entity.id);for(let e of y.overworld.getEntities({type:de}))t.includes(e.id)||e.triggerEvent("despawn")},100);import{DynamicPropertiesDefinition as So,EntityTypes as Po,world as Ao}from"@minecraft/server";Ao.events.worldInitialize.subscribe(({propertyRegistry:t})=>{y.overworld.runCommandAsync(`tickingarea add ${N.x} ${N.y} ${N.z} ${N.x} ${N.y} ${N.z} db true`);let e=new So;e.defineString("tableName",30),e.defineNumber("index"),t.registerEntityTypeDynamicProperties(e,Po.get(se))});import{system as xo,world as Ro}from"@minecraft/server";import{MinecraftBlockTypes as pn}from"@minecraft/server";var Le=[pn.chest.id,pn.trappedChest.id],W={x:7,y:7,z:7};var Oe=class{constructor(e){this.emptySlotsCount=e.emptySlotsCount,this.size=e.size,this.items=[];for(let n=0;n{_e={};for(let t of Ro.getPlayers()){if(t.dimension.id!="minecraft:overworld")continue;let e=Te(t.location),n=e.offset(W.x,W.y,W.z),o=e.offset(-W.x,-W.y,-W.z);for(let r of n.blocksBetween(o)){if(r.y<-64)continue;let i=t.dimension.getBlock(r);!i||!Le.includes(i.typeId)||(_e[JSON.stringify(r)]=new Oe(i.getComponent("inventory").container))}}},100);import{system as Bo}from"@minecraft/server";var ye={};w.subscribe(()=>{Bo.run(()=>{for(let t of Object.values(ye))!t.getConfig().enabled||t.enable()})});import{Player as yn}from"@minecraft/server";function gn(t,e,n,o="No Reason",r="Rubedo Auto Mod"){let i={key:e,playerName:t instanceof yn?t.name:t,date:Date.now(),duration:n?ae(n):null,expire:n?ae(n)+Date.now():null,reason:o,by:r};a.bans.set(e,i)}var S=class{constructor(e,n,o="No Reason",r="Rubedo Auto Mod"){e instanceof yn?gn(e,e.id,n,o,r):gn(e,a.ids.get(e),n,o,r)}};import{MessageFormData as No}from"@minecraft/server-ui";var oe=class{constructor(e,n){this.title=e,this.body=n,this.form=new No,e&&this.form.title(e),n&&this.form.body(n),this.triedToShow=0}setButton1(e,n){return this.button1={text:e,callback:n},this.form.button1(e),this}setButton2(e,n){return this.button2={text:e,callback:n},this.form.button2(e),this}show(e){this.form.show(e).then(n=>{if(n.canceled){if(n.cancelationReason=="userBusy"){if(this.triedToShow>200)return e.tell("\xA7cForm Timeout: tried to show form, but you were busy (close chat after running command)");this.triedToShow++,this.show(e)}return}n.selection==1&&this.button1?.callback?.(),n.selection==0&&this.button2?.callback?.()})}};function Q(t,e,n,o=()=>{}){new oe("Confirm To Continue",e).setButton1("Confirm",n).setButton2("Never Mind",o).show(t)}var m=class{constructor(e,n,o=0,r){this.data=e;this.type=n;this.depth=o;this.parent=r;e.requires||(e.requires=i=>!0),this.data=e,this.type=n??new F(this.data.name),this.children=[],this.depth=o,this.parent=r,this.callback=null,G.push(this)}argument(e){let n=new m(this.data,e,this.depth+1,this);return this.children.push(n),n}string(e){return this.argument(new ce(e))}int(e){return this.argument(new le(e))}array(e,n){return this.argument(new ue(e,n))}boolean(e){return this.argument(new me(e))}location(e){let n=this.argument(new K(e));return e.endsWith("*")?n:n.location(e+"_y*").location(e+"_z*")}literal(e){let n=new m(e,new F(e.name),this.depth+1,this);return this.children.push(n),n}executes(e){return this.callback=e,this}};var P={"api.name":()=>"Smelly API","api.error.unknown":()=>"An unknown error has occurred.","api.database.error.table_name":(t,e)=>`The display name ${t} is too long for an objective, it can be at most ${e} characters long`,"api.utilities.formatter.error.ms":t=>`${t} is not a string or a number`,"api.Providers.form.invalidType":(t,e)=>`Type ${t} is not a valid type to add a ${e}`,"modules.protections.cps.clickingToFast":()=>"You are clicking to fast! Please click slower!","modules.managers.mute.isMuted":()=>"\xA7cYou've been temporarily muted in chat.","modules.commands.ban.reply":(t,e,n="")=>`\xA7cBanned \xA7f"\xA7a${t}\xA7f" \xA7cfor ${e} Because: "${n??"No reason Provided"}" \xA7aSuccessfully`,"lockdown.kick.message":()=>["\xA7cYou have been kicked!","\xA7aReason: \xA7fServer is currently under LockDown","\xA7fServer will be up soon, Try to join later"],"commands.ban.list.player":(t,e,n)=>`- "${t}" Because: ${e}, Expiry ${n}`,"commands.freeze.list.player":(t,e)=>`- "${t}" Because: ${e}`,"commands.mutes.list.player":(t,e,n)=>`- "${t}" Because: ${e}, Expiry: ${n}`,"commands.lockdown.confirm":"Are you sure you want to lockdown the server, this will kick all active players and all players who try to join who are not admin"};import{ActionFormData as Mo}from"@minecraft/server-ui";var R=class{constructor(e,n){this.title=e,this.body=n,this.form=new Mo,e&&this.form.title(e),n&&this.form.body(n),this.buttons=[],this.triedToShow=0}addButton(e,n=null,o){return this.buttons.push({text:e,iconPath:n,callback:o}),this.form.button(e,n),this}show(e){this.form.show(e).then(n=>{if(n.canceled){if(n.cancelationReason=="userBusy"){if(this.triedToShow>200)return e.tell("\xA7cForm Timeout: tried to show form, but you were busy (close chat after running command)");this.triedToShow++,this.show(e)}return}this.buttons[n.selection].callback?.()})}};import{ModalFormData as Do}from"@minecraft/server-ui";var $e=class{constructor(e,n,o){this.form=e,this.player=n,this.callback=o}error(e){new oe("Error",e).setButton1("Return to form",()=>{this.form.show(this.player,this.callback)}).setButton2("Cancel",null).show(this.player)}};var A=class{constructor(e){this.title=e,this.form=new Do,e&&this.form.title(e),this.args=[]}addDropdown(e,n,o){return this.args.push({type:"dropdown",options:n}),this.form.dropdown(e,n,o),this}addSlider(e,n,o,r,i){return this.args.push({type:"slider"}),this.form.slider(e,n,o,r,i),this}addToggle(e,n){return this.args.push({type:"toggle"}),this.form.toggle(e,n),this}addTextField(e,n,o){return this.args.push({type:"textField"}),this.form.textField(e,n,o),this}async show(e,n){for(let o=0;o<200;o++){let r=await this.form.show(e);if(r.cancelationReason!="userBusy"){n(new $e(this,e,n),...r.formValues.map((i,s)=>this.args[s].type=="dropdown"?this.args[s].options[i]:i));return}}return e.tell("\xA7cForm Timeout: tried to show form, but you were busy (close chat after running command)")}};function ct(t,e,n,o,r){if(a.bans.get(a.ids.get(e)))return t.reply(`\xA7c${e} is already banned`);t.reply("\xA7aClose chat to confirm"),Q(t.sender,`Are you sure you want to ban ${e}, for ${n??"forever"}`,()=>{new S(e,n,o,t.sender.name),t.reply(P["modules.commands.ban.reply"](e,n,o))})}var Fe=new m({name:"ban",description:"Manage bans",requires:t=>["admin","moderator"].includes(l(t))});Fe.literal({name:"add",description:"Bans a player"}).argument(new f.playerName).executes((t,e)=>{ct(t,e,null,null,t.sender.name)}).argument(new f.duration("duration")).executes((t,e,n)=>{ct(t,e,n,null,t.sender.name)}).string("reason").executes((t,e,n,o)=>{ct(t,e,n,o,t.sender.name)});Fe.literal({name:"remove",description:"un-bans a player"}).argument(new f.playerName("playerName")).executes((t,e)=>{let n=a.bans.values().find(o=>o.playerName==e);if(!n)return t.reply(`${e} is not banned`);a.bans.delete(n.key)?t.reply(`\xA7a${e}\xA7r has been Unbanned!`):t.reply(`\xA7cFailed to un-ban ${e}`)});Fe.literal({name:"list",description:"Lists all bans"}).executes(t=>{let e=a.bans.values();if(e.length==0)return t.sender.tell("\xA7cNo one is banned!");t.sender.tell(`\xA72--- Showing Bans (${e.length}) ---`);for(let n of e)t.sender.tell(P["commands.ban.list.player"](n.playerName,n.reason,n.expire?Z(n.duration):"Forever"))});Fe.literal({name:"test",description:"sdhsd"}).executes(t=>{new R("Manage Bans").addButton("Ban a Player","textures/ui/hammer_r",()=>{new A("Ban a Player").addDropdown("Player Name:",a.ids.keys()).addTextField("Duration","10d, 5h, 2s","null").addTextField("Ban Reason","","No Reason Provided").show(t.sender,(e,n,o,r)=>{console.warn(n,o,r)})}).addButton("Revoke a Ban","textures/ui/hammer_r_disabled",()=>{console.warn("Revoke a player")}).addButton("View Current Bans","textures/ui/store_sort_icon",()=>{console.warn("Revoke a player")}).show(t.sender)});var be=new m({name:"database",description:"Interacts with SA Database",aliases:["db"],requires:t=>l(t)=="admin"});be.literal({name:"get"}).string("table").string("key").executes((t,e,n)=>{try{let o=a[e].get(n);o?t.reply(JSON.stringify(o)):t.reply(`No data could be found for key ${n}`)}catch(o){t.reply(o+o.stack)}});be.literal({name:"set"}).string("table").string("key").string("value").executes((t,e,n,o)=>{try{a[e].set(n,o),t.reply(`Set Key: "${n}", to value: "${o}" on table: "${e}"`)}catch(r){t.reply(r+r.stack)}});be.literal({name:"clear"}).string("table").executes((t,e)=>{try{a[e].clear(),t.reply(`Cleared Table ${e}`)}catch(n){t.reply(n+n.stack)}});be.literal({name:"keys",description:"Returns all keys on a database"}).string("table").executes((t,e)=>{try{let n=a[e].keys();t.reply(`Keys on database: ${e}: ${n}`)}catch(n){t.reply(n+n.stack)}});be.literal({name:"values",description:"Returns all values on a database"}).string("table").executes((t,e)=>{try{let n=a[e].values();t.reply(`Values on database: ${e}: ${JSON.stringify(n,null,2)}`)}catch(n){n instanceof TypeError?t.reply(`No values on database ${e}`):t.reply(n+n.stack)}});new m({name:"ecwipe",description:"Clears a players ender chest",requires:t=>l(t)=="admin"}).argument(new f.player("player")).executes((t,e)=>{for(let n=0;n<27;n++)e.runCommandAsync(`replaceitem entity @s slot.enderchest ${n} air`);t.reply(`\xA7aCleared "${e.name}"'s Ender chest!`)});var ze=class{constructor(e,n="No Reason"){let o={playerName:e.name,key:e.id,reason:n,location:{x:e.location.x,y:e.location.y,z:e.location.z,dimension:e.dimension.id}};a.freezes.set(e.id,o)}};var lt=new m({name:"freeze",description:"Manage Freezes",requires:t=>["admin","moderator"].includes(l(t))});lt.literal({name:"add",description:"Freezes a player"}).argument(new f.player("player")).string("reason").executes((t,e,n)=>{new ze(e,n),t.reply(`\xA7cFroze \xA7f"\xA7a${e.name}\xA7f" Because: "${n}" \xA7aSuccessfully`),t.sender.tell(`\xA7cYou have been frozen by \xA7f"\xA7a${t.sender.name}\xA7f" Because: "${n}"`)});lt.literal({name:"remove",description:"unfreezes a player"}).argument(new f.playerName("playerName")).executes((t,e)=>{let n=a.freezes.values().find(o=>o.playerName==e);if(!n)return t.reply(`${e} is not frozen`);a.freezes.delete(n.key),t.reply(`\xA7a${e}\xA7r has been UnFrozen!`)});lt.literal({name:"list",description:"Lists all freezes"}).executes(t=>{let e=a.freezes.values();if(e.length==0)return t.sender.tell("\xA7cNo one is frozen!");t.sender.tell(`\xA72--- Showing Freezes (${e.length}) ---`);for(let n of e)t.sender.tell(P["commands.freeze.list.player"](n.playerName,n.reason))});var mt=class{constructor(e){this.name=e;this.typeName="CommandName"}matches(e){return{success:Boolean(G.find(n=>n.depth==0&&n.data.name==e)),value:e}}fail(e){return`"${e}" is not a valid command`}};function Lo(t,e,n){n.tell(`${v}${t.data.name} ${e.map(o=>o.type.typeName=="literal"?o.data.name:`<${o.type.name}: ${o.type.typeName}>`).join(" ")}`)}function Ve(t,e,n,o){if(!!e.data?.requires(o)&&(e.callback&&Lo(t,e.depth==0?n:n.concat(e),o),e.children.length>0))for(let r of e.children)Ve(t,r,e.depth==0?n:n.concat(e),o)}function hn(t,e,n){t.tell(`\xA72--- Showing help page ${e} of ${n} (${v}help ) ---`)}function ut(t){return G.filter(e=>e.depth==0&&e.data?.requires(t))}function bn(t){let e=ut(t);return e.length==0?0:Math.ceil(e.length/5)}var kn=new m({name:"help",description:"Provides help/list of commands.",aliases:["?","h"]}).executes(t=>{let e=bn(t.sender),n=ut(t.sender).slice(1*5-5,1*5);hn(t.sender,1,e);for(let o of n)Ve(o,o,[],t.sender)});kn.int("page").executes((t,e)=>{let n=bn(t.sender);e>n&&(e=n);let o=ut(t.sender).slice(e*5-5,e*5);hn(t.sender,e,n);for(let r of o)Ve(r,r,[],t.sender)});kn.argument(new mt("command")).executes((t,e)=>{let n=G.filter(o=>o.depth==0&&o.data.name==e)[0];t.sender.tell(`\xA7e${n.data.name}: ${n.data.aliases?`aliases (${n.data.aliases.join(", ")})`:""}`),t.sender.tell(`\xA7e${n.data.description}`),t.sender.tell("Usage:"),Ve(n,n,[],t.sender)});import{world as In}from"@minecraft/server";new m({name:"lockdown",description:"Toggles the servers lockdown, meaning no one can join",requires:t=>l(t)=="admin"}).executes(t=>{De()?(at(!1),t.sender.tell("\xA7aUnlocked the server!")):(t.reply("\xA7aClose chat to confirm lockdown"),Q(t.sender,P["commands.lockdown.confirm"],()=>{at(!0);for(let e of In.getPlayers())l(e)!="admin"&&j(e,P["lockdown.kick.message"]());In.say("\xA7l\xA7cServer is now LOCKED!")}))});var D=class{static getMuteData(e){return a.mutes.get(e.name)}constructor(e,n,o="No Reason",r="Rubedo Auto Mod"){let i=n?ae(n):null,s={playerName:e.name,date:Date.now(),duration:i,expire:i?i+Date.now():null,reason:o,by:r};a.mutes.set(e.name,s)}};var dt=new m({name:"mute",description:"Manage Mutes",requires:t=>["admin","moderator"].includes(l(t))});dt.literal({name:"add",description:"Mutes a player"}).argument(new f.player("player")).argument(new f.duration("duration")).string("reason").executes((t,e,n,o)=>{new D(e,n,o,t.sender.name),t.reply(`\xA7cMuted \xA7f"\xA7a${e.name}\xA7f" \xA7cfor ${n} Because: "${o}" \xA7aSuccessfully`),e.tell(`\xA7cYou have been muted by \xA7f"${t.sender.name}" \xA7cfor ${n} Because: "${o}"`)});dt.literal({name:"remove",description:"un-mutes a player"}).argument(new f.playerName("playerName")).executes((t,e)=>{let n=a.mutes.values().find(o=>o.playerName==e);if(!n)return t.reply(`${e} is not muted!`);a.mutes.delete(n.playerName);try{t.sender.runCommandAsync(`ability "${e}" mute false`)}catch{}t.reply(`\xA7a${e}\xA7r has been UnMuted!`)});dt.literal({name:"list",description:"Lists all freezes"}).executes(t=>{let e=a.mutes.values();if(e.length==0)return t.sender.tell("\xA7cNo one is muted!");t.sender.tell(`\xA72--- Showing Mutes (${e.length}) ---`);for(let n of e)t.sender.tell(P["commands.mutes.list.player"](n.playerName,n.reason,n.expire?Z(n.expire):"Forever"))});import{Location as Oo}from"@minecraft/server";var re=class{static isValid(e){return e.typeId!="minecraft:npc"?!1:je.find(n=>Lt(n,e.location))?!0:!!a.npcs.keys().find(n=>e.id==n)}constructor(e,n){je.push(e);let o=n.spawnEntity("minecraft:npc",e),r={dimension:o.dimension.id,x:o.location.x,y:o.location.y,z:o.location.z};a.npcs.set(o.id,r),wn()}};new m({name:"npc",description:"Spawns a npc at your coordinates",requires:t=>l(t)=="admin"}).executes(t=>{let{x:e,y:n,z:o}=t.sender.location;new re(new Oo(e,n,o),t.sender.dimension),t.reply("Spawned a verified npc at your current location")});import{system as Cn}from"@minecraft/server";async function _o(){let t=Date.now(),e=0;return new Promise(n=>{let o=Cn.runSchedule(()=>{Date.now()-t<1e3?e++:(Cn.clearRunSchedule(o),n(e))})})}new m({name:"ping",description:"Returns the current Ticks Per Second of the servers ping"}).executes(async t=>{let e=await _o();t.reply(`\xA7aCurrent Ticks Per Second: ${e>18?"\xA7f{ \xA7aGood":e>13?"\xA7f{ \xA7eOk":"\xA7f{ \xA7cSevere"} ${e} \xA7f}`)});import{BlockLocation as ke}from"@minecraft/server";var Ie=new m({name:"region",description:"Create a Region",requires:t=>l(t)=="admin"});Ie.literal({name:"add",description:"Adds a new protection region"}).int("from_x").int("from_z").int("to_x").int("to_z").executes((t,e,n,o,r)=>{new p({x:e,z:n},{x:o,z:r},t.sender.dimension.id),t.reply(`Created Region From ${e} -64 ${n} ${o} 320 ${r}`)});Ie.literal({name:"remove",description:"Removes a region at the players current position"}).executes(t=>{let e=new ke(t.sender.location.x,t.sender.location.y,t.sender.location.z);p.removeRegionAtBlockLocation(e,t.sender.dimension.id)?t.reply(`Removed Region at ${e.x} ${e.y} ${e.z}`):t.reply(`Failed to find/remove region at ${e.x} ${e.y} ${e.z}`)});Ie.literal({name:"removeAll",description:"Removes all regions"}).executes(t=>{p.getAllRegions().forEach(e=>e.delete()),t.reply("Removed All regions")});Ie.literal({name:"list",description:"Lists all regions and positions"}).executes(t=>{let e=p.getAllRegions();for(let n of e)t.reply(`Region from ${n.from.x}, ${n.from.z} to ${n.to.x}, ${n.to.z} in dimension ${n.dimensionId}`);if(e.length==0)return t.reply("No regions have been made yet")});var ft=Ie.literal({name:"permission",description:"Handles permissions for regions"});ft.literal({name:"set",description:"Sets a certain permission on the region the player is currently in to a value"}).array("key",["doorsAndSwitches","openContainers","pvp"]).boolean("value").executes((t,e,n)=>{let o=p.blockLocationInRegion(new ke(t.sender.location.x,t.sender.location.y,t.sender.location.z),t.sender.dimension.id);if(!o)return t.reply("You are not in a region");o.changePermission(e,n),t.reply(`Changed permission ${e} to ${n}`)});ft.literal({name:"list",description:"Lists the permissions for the current region"}).executes(t=>{let e=p.blockLocationInRegion(new ke(t.sender.location.x,t.sender.location.y,t.sender.location.z),t.sender.dimension.id);if(!e)return t.reply("You are not in a region");t.reply(`Current region permissions ${JSON.stringify(e.permissions)}`)});var En=ft.literal({name:"entities",description:"Holds the subCommands for adding or removing allowedEntities"});En.literal({name:"add",description:"Adds a entity to the allowed entities list"}).string("entity").executes((t,e)=>{let n=p.blockLocationInRegion(new ke(t.sender.location.x,t.sender.location.y,t.sender.location.z),t.sender.dimension.id);if(!n)return t.reply("You are not in a region");let o=n.permissions.allowedEntities;o.push(e),n.changePermission("allowedEntities",o),t.reply(`Added entity ${e} to the allowed entities of the region your currently standing in`)});En.literal({name:"remove",description:"Removes a entity from the allowed entities in the region"}).string("entity").executes((t,e)=>{let n=p.blockLocationInRegion(new ke(t.sender.location.x,t.sender.location.y,t.sender.location.z),t.sender.dimension.id);if(!n)return t.reply("You are not in a region");let o=n.permissions.allowedEntities;if(!o.includes(e))return t.reply(`The entity ${e} is not allowed to enter the region`);o=o.filter(r=>r!=e),n.changePermission("allowedEntities",o),t.reply(`Removed entity ${e} to the allowed entities of the region your currently standing in`)});var pt=(r=>(r[r.member=0]="member",r[r.admin=1]="admin",r[r.moderator=2]="moderator",r[r.builder=3]="builder",r))(pt||{});var $o=t=>isNaN(Number(t))===!1;function Fo(t){return Object.keys(t).filter($o).map(e=>t[e])}var gt=new m({name:"role",description:"Changes the role for a player",requires:t=>l(t)=="admin"||pe(t)});gt.literal({name:"set",description:"Sets the role for a player"}).argument(new f.playerName("playerName")).argument(new f.array("role",Fo(pt))).executes((t,e,n)=>{ne(e,n),t.reply(`Changed role of ${e} to ${n}`)});gt.literal({name:"get",description:"Gets the role of a player"}).argument(new f.playerName("playerName")).executes((t,e)=>{let n=l(e);t.reply(`${e} has role: ${n}`)});var yt=gt.literal({name:"owner",description:"Manages the owner"});yt.literal({name:"get",description:"Gets the owner of the world"}).executes(t=>{let e=st(),n=a.ids.collection(),o=Object.keys(n).find(r=>n[r]===e);t.reply(`\xA7aServer Owner: ${o} (id: ${e})`)});yt.literal({name:"transfer",description:"Transfers the owner of the world",requires:t=>pe(t)}).argument(new f.player).executes((t,e)=>{Q(t.sender,`Are you sure you want to transfer the server ownership to ${e.name}, this action is not reversible!`,()=>{ge(e),t.reply(`\xA7aSet the server Owner to: ${e.name} (id: ${e.id})`)}),t.reply("\xA7aClose chat to confirm")});yt.literal({name:"clear",description:"clear's the owner of the world",requires:t=>pe(t)}).executes(t=>{Q(t.sender,"Are you sure you want to clear the server owner, this action is not reversible!",()=>{ge(null),t.reply('\xA7aCleared the server owner! run "/reload" or reload world to run "/function start" again!')}),t.reply("\xA7aClose chat to confirm")});function vn(t){new R("Manage Banned Items").addButton("Remove a Banned Item",null,()=>{zo(t)}).addButton("Ban an item",null,()=>{Vo(t)}).show(t)}function zo(t){new A("Remove Banned Items").addDropdown("Select item to remove",C("banned_items")).show(t,(e,n)=>{let o=C("banned_items");o=o.filter(r=>r!=n),q("banned_items",o),t.tell(`Removed Banned item "${n}"`)})}function Vo(t){new A("Add Banned Item").addTextField("Item Id","minecraft:string").show(t,(e,n)=>{let o=C("banned_items");if(o.includes(n))return e.error(`\xA7cItem "${n}" is already banned`);o.push(n),q("banned_items",o),t.tell(`Banned the item "${n}"`)})}function Tn(t){new R("Manage Banned Blocks").addButton("Remove a Banned Block",null,()=>{jo(t)}).addButton("Ban an block",null,()=>{Yo(t)}).show(t)}function jo(t){new A("Remove Banned Block").addDropdown("Select block to remove",C("banned_blocks")).show(t,(e,n)=>{let o=C("banned_blocks");o=o.filter(r=>r!=n),q("banned_blocks",o),t.tell(`Removed Banned block "${n}"`)})}function Yo(t){new A("Add Banned Block").addTextField("Block Id","minecraft:barrier").show(t,(e,n)=>{let o=C("banned_blocks");if(o.includes(n))return e.error(`\xA7cBlock "${n}" is already banned`);o.push(n),q("banned_blocks",o),t.tell(`Banned the block "${n}"`)})}function Sn(t){new A("Manage Enchantment Levels").addDropdown("Enchantment to change",Object.keys(Me),0).addTextField("Level (number)","5").show(t,(e,n,o)=>{if(isNaN(o))return e.error(`\xA7c"${o}" is not a number, please enter a value like, "3", "9", etc.`);let r=parseInt(o),i=C("enchantments");i[n]=r,q("enchantments",i),t.tell(`Set max level for ${n} to ${r}`)})}function Pn(t){new A("Manage Appeal Link").addTextField("Appeal Link",Ne).show(t,(e,n)=>{q("appealLink",n),t.tell(`Changed the servers appeal link to ${n}`)})}function An(t){let e=new R("Manage Protections");for(let n of Object.values(ye))e.addButton(n.name,n.iconPath,()=>{Go(n,t)});e.addButton("Back","textures/ui/arrow_dark_left_stretch.png",()=>{Ye(t)}).show(t)}function Go(t,e){let n=t.getConfig(),o=new A(`Manage ${t.name} Protection Config`).addToggle("Enabled",n.enabled),r=[];for(let[i,s]of Object.entries(t.configDefault))r.push(i),typeof s.defaultValue=="boolean"?o.addToggle(s.description,n[i]):typeof s.defaultValue=="number"?o.addSlider(s.description,0,100,1,n[i]):o.addTextField(s.description,null,n[i]);o.show(e,(i,s,...c)=>{s!=n.enabled&&(s&&t.enable(),s||t.disable());let d={enabled:s};for(let[h,E]of Object.keys(t.configDefault).entries())d[E]=c[h];t.setConfig(d),e.tell(`Updated config for ${t.name}!`)})}function Ye(t){new R("Rubedo Settings").addButton("Auto Mod","textures/ui/permissions_op_crown.png",()=>{An(t)}).addButton("Banned items","textures/blocks/sculk_shrieker_top.png",()=>{vn(t)}).addButton("Banned blocks","textures/blocks/barrier.png",()=>{Tn(t)}).addButton("Enchantments","textures/items/book_enchanted.png",()=>{Sn(t)}).addButton("Appeal Link","textures/ui/Feedback.png",()=>{Pn(t)}).show(t)}new m({name:"settings",description:"Opens up the settings menu for the player",requires:t=>["admin","moderator"].includes(l(t))}).executes(t=>{Ye(t.sender),t.sender.tell("\xA7aForm request sent, close chat to continue!")});import{world as xn}from"@minecraft/server";function Rn(t,e){if(t.hasTag("spectator")){if(t.runCommandAsync("gamemode c"),t.triggerEvent("removeSpectator"),t.removeTag("spectator"),!e)return;xn.say({rawtext:[{translate:"multiplayer.player.joined",with:[`\xA7e${t.name}`]}]})}else{if(t.runCommandAsync("gamemode spectator"),t.triggerEvent("addSpectator"),t.addTag("spectator"),!e)return;xn.say({rawtext:[{translate:"multiplayer.player.left",with:[`\xA7e${t.name}`]}]})}}new m({name:"vanish",description:"Toggles Vanish Mode on the sender",requires:t=>l(t)=="admin"}).executes(t=>{Rn(t.sender,!1)}).boolean("say").executes((t,e)=>{Rn(t.sender,e)});var Bn="2.6.7-beta";new m({name:"version",description:"Get Current Rubedo Version",aliases:["v"]}).executes(t=>{t.reply(`Current Rubedo Version: ${Bn}`)});new m({name:"kick",description:"Kicks a player from the game",requires:t=>l(t)=="admin"}).argument(new f.player).string("reason").executes((t,e,n)=>{j(e,[n]),t.reply(`\xA7aKicked ${e.name} from world`)});var O=class{constructor(e){this.data=e,console.warn(`[LOG]: ${e.message}`),a.logs.set(Date.now().toString(),e)}};function ht(t){var e=6e4,n=e*60,o=n*24,r=o*30,i=o*365,s=Date.now()-t;return sl(t)=="admin"});we.literal({name:"add",description:"Adds a new log"}).string("message").executes((t,e)=>{new O({message:e}),t.reply(`\xA7aAdded new log: ${e}`)});we.literal({name:"getAll",description:"Gets all logs sorted in descending"}).int("page").array("order",["ascending","descending"]).executes((t,e,n)=>{let o=Object.entries(a.logs.collection()).sort((i,s)=>n=="ascending"?parseInt(s[0])-parseInt(i[0]):parseInt(i[0])-parseInt(s[0]));if(o.length==0)return t.reply("\xA7cNo Logs have been made!");let r=Math.ceil(o.length/8);e>r&&(e=r),t.reply(`\xA72--- Showing logs page ${e} of ${r} (${v}log getAll ) ---`);for(let[i,s]of o.slice(e*8-8,e*8))t.reply(`${ht(parseInt(i))}: ${s.message}`)});we.literal({name:"getPlayersLogs",description:"Gets all logs associated with a player"}).argument(new f.playerName).int("page").array("order",["ascending","descending"]).executes((t,e,n,o)=>{let r=Object.entries(a.logs.collection()).filter(s=>s[1].playerName==e).sort((s,c)=>o=="ascending"?parseInt(c[0])-parseInt(s[0]):parseInt(s[0])-parseInt(c[0]));if(r.length==0)return t.reply(`\xA7cNo Logs exists for "${e}"!`);let i=Math.ceil(r.length/8);n>i&&(n=i),t.reply(`\xA72--- Showing logs for "${e}" page ${n} of ${i} ---`);for(let[s,c]of r.slice(n*8-8,n*8))t.reply(`${ht(parseInt(s))}: ${c.message}`)});we.literal({name:"getProtectionLogs",description:"Gets all logs associated with a protection"}).string("protection").int("page").array("order",["ascending","descending"]).executes((t,e,n,o)=>{let r=Object.entries(a.logs.collection()).filter(s=>s[1].protection==e).sort((s,c)=>o=="ascending"?parseInt(c[0])-parseInt(s[0]):parseInt(s[0])-parseInt(c[0]));if(r.length==0)return t.reply(`\xA7cNo Logs exists for protection: "${e}"!`);let i=Math.ceil(r.length/8);n>i&&(n=i),t.reply(`\xA72--- Showing logs for Protection: "${e}" page ${n} of ${i} ---`);for(let[s,c]of r.slice(n*8-8,n*8))t.reply(`${ht(parseInt(s))}: ${c.message}`)});we.literal({name:"clearAll",description:"Clears all logs"}).executes(t=>{a.logs.clear(),t.reply("\xA7aCleared All logs!")});var Uo=new m({name:"teleport",description:"Teleports entities (players, mobs, etc.).",aliases:["tp"],requires:t=>l(t)=="admin"});Uo.argument(new f.player).location("destination").executes((t,e,n)=>{e.addTag("skip-movement-check"),e.teleport(n,e.dimension,0,0),t.reply(`Teleported ${e.name} to ${n.x} ${n.y} ${n.z}`)});import{system as bt,world as qo}from"@minecraft/server";var Ke={};w.subscribe(()=>{bt.runSchedule(()=>{let t=[...qo.getPlayers()];for(let[e,n]of t.entries())for(let o of Object.values(Ke))o.delay!=0&&bt.currentTick-o.lastCall{try{let e=a.bans.get(t.id);if(!e)return;if(e.expire&&e.expire{console.warn(new Error("Failed to kick player")),a.bans.delete(t.id)})}catch(e){console.warn(e+e.stack)}},20);import{Location as Wo}from"@minecraft/server";B.subscribe(t=>{try{let e=a.freezes.get(t.id);if(!e)return t.getComponent("movement").resetToDefaultValue();t.getComponent("movement").setCurrent(0),t.teleport(new Wo(e.location.x,e.location.y,e.location.z),y[e.location.dimension],0,0)}catch{}},200);import{world as Qo}from"@minecraft/server";var kt={};Qo.events.beforeChat.subscribe(t=>{if(!t.message.startsWith(v))for(let e of Object.values(kt))e.callback(t)});var Ge=class{static subscribe(e){let n=Date.now();return kt[n]={callback:e},n}static unsubscribe(e){delete kt[e]}};Ge.subscribe(t=>{let e=D.getMuteData(t.sender);if(!!e){if(e.expire&&e.expire{Be()},6e3);It.events.beforeItemUseOn.subscribe(t=>{if(["moderator","admin"].includes(l(t.source)))return;let e=p.blockLocationInRegion(t.blockLocation,t.source.dimension.id);if(!e)return;let n=t.source.dimension.getBlock(t.blockLocation);tn.includes(n.typeId)&&e.permissions.doorsAndSwitches||nn.includes(n.typeId)&&e.permissions.openContainers||(t.cancel=!0)});It.events.beforeExplosion.subscribe(t=>{for(let e=0;e{let e=await p.blockLocationInRegionSync(new Xo(t.location.x,t.location.y,t.location.z),t.dimension.id);!e||e.permissions.allowedEntities.includes(t.typeId)||(t.teleport({x:0,y:-64,z:0},t.dimension,0,0),t.kill())});w.subscribe(()=>{Nn.runSchedule(async()=>{for(let t of await p.getAllRegionsSync())for(let e of y[t.dimensionId].getEntities({excludeTypes:t.permissions.allowedEntities}))!t.entityInRegion(e)||(e.teleport({x:0,y:-64,z:0},e.dimension,0,0),e.kill())},100)});B.subscribe(t=>{for(let e of p.getAllRegions())e.entityInRegion(t)?(t.addTag("inRegion"),e.permissions.pvp||t.addTag("region-protected")):(t.removeTag("inRegion"),t.removeTag("region-protected"))},5);import{world as Jo}from"@minecraft/server";Jo.events.playerJoin.subscribe(async({player:t})=>{if(await w.awaitLoad(),De()&&l(t)!="admin")return j(t,P["lockdown.kick.message"]());D.getMuteData(t)&&t.runCommandAsync("ability @s mute true"),a.ids.has(t.name)||a.ids.set(t.name,t.id);let e=L.getPlayersRoleToSet(t.name);e&&ne(t,e)});import{Items as Zo,MinecraftItemTypes as Ce,world as Mn}from"@minecraft/server";var Dn=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44];function er(t,e,n){let o=t.getComponent("minecraft:inventory").container;for(let r=0;r{d.PageAction("moderation:see_inventory",{name:i.name})}}}}function tr(t,e,n){let o=t.getComponent("minecraft:inventory").container;for(let c=0;cc.name==n.name);r||(Object.values(M).find(d=>d.entity.id==t.id).despawn(),r.tell(`"${n.name}" Could not be found, Gui Crashed`));let i=r.getComponent("inventory").container,s=0;for(let c=0;c{c<9?r.runCommandAsync(`replaceitem entity @s slot.hotbar ${c} air`):r.runCommandAsync(`replaceitem entity @s slot.inventory ${c-9} air`),E.GiveAction(),e.slots[h]={item:null,action:so=>{i.addItem(so.getItemAdded())}}}}}}new H("moderation:see",er).setSlots([50],new x(Ce.arrow,{nameTag:"\xA7fBack"}),t=>{t.PageAction("home")}).setSlots([48],new x(Ce.barrier,{nameTag:"\xA7cClose GUI"}),t=>{t.CloseAction()});new H("moderation:see_inventory",tr).setSlots([50],new x(Ce.arrow,{nameTag:"\xA7fBack"}),t=>{t.PageAction("moderation:see")}).setSlots([48],new x(Ce.barrier,{nameTag:"\xA7cClose GUI"}),t=>{t.CloseAction()});import{Player as nr,MinecraftBlockTypes as or}from"@minecraft/server";import{system as Ln,world as On}from"@minecraft/server";var b=class{constructor(e,n,o,r){this.name=e;this.description=n;this.iconPath=o;this.isEnabledByDefault=r;this.name=e,this.description=n,this.iconPath=o,this.configDefault={},this.isEnabled=!1,this.isEnabledByDefault=r,this.events={},this.schedules=[],this.forEachPlayers=[],ye[this.name]=this}setConfigDefault(e){return this.configDefault=e,a.protections.hasSync(this.name).then(n=>{if(n)return;let o={enabled:!0};for(let r of Object.keys(e))o[r]=e[r].defaultValue;a.protections.set(this.name,o)}),this}getConfig(){let e=a.protections.get(this.name);return e||(e={enabled:this.isEnabled}),e}async setConfig(e){return a.protections.set(this.name,e)}triggerChange(e){if(e){this.isEnabled=!0,this.onEnableCallback?.();for(let[n,o]of Object.entries(this.events)){if(o.triggered)continue;let r=On.events[n].subscribe(o.callback);o.triggered=!0,o.callback=r}for(let n of this.forEachPlayers){if(n.key)continue;let o=B.subscribe(n.callback,n.delay);n.key=o}for(let n of this.schedules){if(n.runScheduleId)continue;let o=Ln.runSchedule(n.callback);n.runScheduleId=o}}else{this.isEnabled=!1,this.onDisableCallback?.();for(let[n,o]of Object.entries(this.events))!o.triggered||(On.events[n].unsubscribe(o.callback),o.triggered=!1);for(let n of this.forEachPlayers)!n.key||(B.unsubscribe(n.key),n.key=null);for(let n of this.schedules)!n.runScheduleId||(Ln.clearRunSchedule(n.runScheduleId),n.runScheduleId=null)}}onEnable(e){return this.onEnableCallback=e,this}onDisable(e){return this.onDisableCallback=e,this}subscribe(e,n){return this.events[e]={callback:n,triggered:!1},this}runSchedule(e,n){return this.schedules.push({callback:e,tickInterval:n,runScheduleId:null}),this}forEachPlayer(e,n=0){return this.forEachPlayers.push({callback:e,delay:n,key:null}),this}enable(){this.triggerChange(!0)}disable(){this.triggerChange(!1)}};var rr=["minecraft:command_block_minecart"],He=new b("cbe","Stops CBE","textures/blocks/command_block.png",!0).setConfigDefault({entityCreate:{description:"Adds NPC protection",defaultValue:!0},banSpawnEggs:{description:"If spawn eggs should be banned",defaultValue:!0}});He.subscribe("entityCreate",({entity:t})=>{if(!He.getConfig().entityCreate)return;let n=()=>{try{t.triggerEvent("despawn"),t.kill()}catch{t.kill()}};if(rr.includes(t.typeId)||t.typeId=="minecraft:npc"&&!re.isValid(t))return n()});He.subscribe("beforeItemUseOn",t=>{if(!(t.source instanceof nr)||["admin","moderator"].includes(l(t.source)))return;let e=He.getConfig();if(t.item.typeId.endsWith("spawn_egg")){if(!e.banSpawnEggs||t.source.dimension.getBlock(t.blockLocation).typeId==or.mobSpawner.id)return;t.cancel=!0,t.source.tell("\xA7c[Rubedo]: You cannot place spawnEggs on the floor!"),t.source.playSound("note.bass")}else{if(an.includes(t.item.typeId)){t.cancel=!0;return}if(!C("banned_blocks").includes(t.item.typeId))return;t.cancel=!0,new S(t.source,null,"Placing Banned Blocks")}});var wt=32e4;new b("crasher","Protection against type 1 crasher","textures/ui/servers.png",!0).forEachPlayer(t=>{l(t)!="admin"&&(Math.abs(t.location.x)>wt||Math.abs(t.location.y)>wt||Math.abs(t.location.z)>wt)&&new S(t,null,"Crasher detected")});import{GameMode as sr,world as ar}from"@minecraft/server";import{world as ir}from"@minecraft/server";var k=class{constructor(){this.data=new Map,this.events={playerLeave:ir.events.playerLeave.subscribe(e=>this.data.delete(e.playerName))}}set(e,n){this.data.set(e.name,n)}get(e){return this.data.get(e.name)}has(e){return this.data.has(e.name)}delete(e){this.data.delete(e.name)}clear(){this.data.clear()}playerNames(){return[...this.data.keys()]}includes(e){return this.playerNames().includes(e.name)}};var cr=sr.creative,_n=new k,$n=new b("gamemode","Blocks illegal gamemode","textures/ui/creative_icon.png",!0).setConfigDefault({clearPlayer:{description:"Whether to clear players inventory.",defaultValue:!0},setToSurvival:{description:"If player should be set to survival after being flagged.",defaultValue:!0},banPlayer:{description:"If player should be banned after violation count is met.",defaultValue:!1},violationCount:{description:"The amount of violations before ban.",defaultValue:0}});$n.runSchedule(()=>{let t=$n.getConfig();for(let e of ar.getPlayers({gameMode:cr})){if(["moderator","admin","builder"].includes(l(e)))continue;try{t.setToSurvival&&e.runCommandAsync("gamemode s"),t.clearPlayer&&e.runCommandAsync("clear @s")}catch{}new O({playerName:e.name,protection:"Gamemode",message:`${e.name} has entered into a illegal gamemode!`});let n=(_n.get(e)??0)+1;_n.set(e,n),t.banPlayer&&n>=t.violationCount&&new S(e,null,"Illegal Gamemode")}},20);import{world as lr,Location as mr,system as ur}from"@minecraft/server";var Ct={};lr.events.blockBreak.subscribe(t=>{for(let e of Object.values(Ct))e.callback(new Et(t.block,t.brokenBlockPermutation,t.dimension,t.player))});var Ee=class{static subscribe(e){let n=Date.now();return Ct[n]={callback:e},n}static unsubscribe(e){delete Ct[e]}},Et=class{constructor(e,n,o,r){this.block=e;this.brokenBlockPermutation=n;this.dimension=o;this.player=r;this.block=e,this.brokenBlockPermutation=n,this.dimension=o,this.player=r}set cancel(e){if(this.dimension.getBlock(this.block.location).setPermutation(this.brokenBlockPermutation.clone()),Le.includes(this.brokenBlockPermutation.type.id)){let n=_e[JSON.stringify(this.block.location)];n&&n.load(this.block.getComponent("inventory").container)}ur.run(()=>{[...this.dimension.getEntities({maxDistance:2,type:"minecraft:item",location:new mr(this.block.location.x,this.block.location.y,this.block.location.z)})].forEach(n=>n.kill())})}};var Fn=new k,dr=15,vt=["snow","lush_plants_replaceable","azalea_log_replaceable","minecraft:crop","fertilize_area","plant"],fr=["minecraft:water","minecraft:flowing_water","minecraft:lava","minecraft:flowing_lava","minecraft:bedrock"],zn=new k,Vn=null,jn=new b("nuker","Blocks block breaking too fast","textures/blocks/dirt.png",!0).setConfigDefault({banPlayer:{description:"If the player should be banned once violation count is met",defaultValue:!1},violationCount:{description:"Violations before ban",defaultValue:0}});jn.onEnable(()=>{let t=jn.getConfig();Vn=Ee.subscribe(e=>{if(["moderator","admin"].includes(l(e.player))||e.block.getTags().some(o=>vt.includes(o)))return;let n=Fn.get(e.player);if(Fn.set(e.player,Date.now()),!!n){if(!fr.includes(e.block.typeId)){if(n=t.violationCount&&new S(e.player,null,"Using Nuker")}e.cancel=!0}})}).onDisable(()=>{Ee.unsubscribe(Vn)});var Yn=new k,Kn=new k,Gn=new b("spam","Blocks spam in chat","textures/ui/mute_on.png",!0).setConfigDefault({permMutePlayer:{description:"If player should be permanently muted once violation count is met.",defaultValue:!1},violationCount:{description:"Violation count before permanent mute",defaultValue:0},repeatedMessages:{description:"Blocks repeated messages",defaultValue:!0},zalgo:{description:"Blocks zalgo",defaultValue:!0}});Gn.subscribe("beforeChat",t=>{try{if(t.message.startsWith(v)||["admin","moderator"].includes(l(t.sender)))return;let e=Gn.getConfig(),n=()=>{let o=(Kn.get(t.sender)??0)+1;Kn.set(t.sender,o),e.permMutePlayer&&o>=e.violationCount&&new D(t.sender,null,"Spamming")};if(e.repeatedMessages&&Yn.get(t.sender)==t.message)return t.cancel=!0,n(),t.sender.tell("\xA7cRepeated message detected!");if(e.zalgo&&/%CC%/g.test(encodeURIComponent(t.message)))return t.cancel=!0,n(),t.sender.tell("\xA7cYou message contains some type of zalgo and cannot be sent!");Yn.set(t.sender,t.message)}catch(e){console.warn(e+e.stack)}});var Hn=new k,pr=new b("unobtainable","Blocks unobtainable items","textures/blocks/end_portal.png",!0).setConfigDefault({clearItem:{description:"If the possessed item should be cleared from there inventory",defaultValue:!0},banPlayer:{description:"If the player should be banned once hit violation count.",defaultValue:!0},violationCount:{description:"The amount of times this player can posses a banned item before ban.",defaultValue:3}}).forEachPlayer(t=>{if(l(t)=="admin")return;let e=new Set(C("banned_items")),n=t.getComponent("inventory").container;for(let o=0;oc||s.level<1||i.has(s.type.id))return Ue(t,o);i.add(s.type.id)}}});function Ue(t,e){let n=t.getComponent("inventory").container,o=n.getItem(e),r=pr.getConfig();if(r.clearItem&&n.setItem(e,T),new O({playerName:t.name,message:`${t.name} Has obtained a unobtainable item: ${o.typeId}`,protection:"unobtainable"}),!r.banPlayer)return;let i=(Hn.get(t)??0)+1;Hn.set(t,i),!(i{if(!!br.includes(t.typeId))if([I.chest.id,I.trappedChest.id].includes(t.typeId)){let e=t.getComponent("inventory").container;for(let n=0;n{t.source instanceof hr&&(!kr.includes(t.item.typeId)||(t.cancel=!0,t.source.dimension.spawnEntity(yr.chestBoat.id,t.blockLocation.above()),dn(t.source)!="creative"&&t.source.getComponent("inventory").container.setItem(t.source.selectedSlot,T)))});import{MinecraftBlockTypes as Er,MinecraftEffectTypes as vr,MinecraftItemTypes as xt,Player as qe,system as Rt}from"@minecraft/server";import{system as Un,world as Ir}from"@minecraft/server";var Tt={};function wr(t,e){return!(t.x!=e.x||t.y!=e.y||t.z!=e.z)}var St=new k;Un.runSchedule(()=>{let t=(e,n)=>{for(let o of Object.values(Tt))o.callback(e,n)};for(let e of Ir.getPlayers()){let n=St.get(e);n&&wr(e.location,n.location)||(St.set(e,{location:e.location,dimension:e.dimension,currentTick:Un.currentTick}),n&&t(e,n))}});var $=class{static subscribe(e){let n=Date.now();return Tt[n]={callback:e},n}static unsubscribe(e){delete Tt[e]}static delete(e){St.delete(e)}};var qn={walk:{velocity:.17,distance:.23},run:{velocity:.19,distance:.35}},Wn=.056,Qn=10,Xn=["gliding","riding"],Jn=32767.001953125,Zn=60;var eo=new k,At=new k;function Tr(t,e){return Math.hypot(e.x-t.x,e.z-t.z)}function Sr(t){return(t.getEffect(vr.speed)?.amplifier??0)*Wn}function Pr(t,e,n){let o=Sr(n),r=Rt.currentTick-e,i=qn.run.distance*r+.8;return t>o+i}function Pt(t,e){let n=(eo.get(t)??0)+1;eo.set(t,n),$.delete(t),!(n<3)&&t.teleport(e.location,e.dimension,t.rotation.x,t.rotation.y)}function Ar(t){let e=t.dimension.getBlock(Te(t.location));if(!e.getTags().some(n=>vt.includes(n))&&!e.type.id.endsWith("grass")&&!e.type.id.endsWith("water")&&!e.type.id.endsWith("lava")&&!e.type.id.endsWith("portal")&&!e.type.id.endsWith("gateway")&&e.typeId!=Er.air.id&&!e.type.canBeWaterlogged)return!0}var to=null,ie=new b("movement","Blocks illegal movements on players","textures/ui/move.png",!0).setConfigDefault({tpCheck:{description:"If teleports should be flagged",defaultValue:!0}});ie.onEnable(()=>{let t=ie.getConfig();to=$.subscribe((e,n)=>{if(l(e)=="admin"||e.dimension.id!=n.dimension.id||e.getTags().some(r=>Xn.includes(r)))return;let o=Tr(e.location,n.location);if(e.hasTag("skip-movement-check"))return e.removeTag("skip-movement-check");if(n.location.y!=Jn&&!At.has(e)){if(Ar(e))return Pt(e,n);if(o>Qn){if(!t.tpCheck)return;Pt(e,n)}else{if(!Pr(o,n.currentTick,e))return;Pt(e,n)}}})}).onDisable(()=>{$.unsubscribe(to)});ie.subscribe("dataDrivenEntityTriggerEvent",t=>{if(!(t.entity instanceof qe)||t.id!="on_death")return;let e=t.entity;Rt.run(()=>{$.delete(e)})});ie.subscribe("projectileHit",({projectile:t,source:e})=>{t.typeId==xt.enderPearl.id&&e instanceof qe&&$.delete(e)});ie.subscribe("itemCompleteCharge",({itemStack:t,source:e})=>{t.typeId==xt.chorusFruit.id&&e instanceof qe&&$.delete(e)});ie.subscribe("itemReleaseCharge",({itemStack:t,source:e})=>{t.typeId==xt.trident.id&&e instanceof qe&&(At.set(e,!0),Rt.runSchedule(()=>{At.delete(e)},Zn))});import{MinecraftEffectTypes as xr,Player as Rr,world as no}from"@minecraft/server";var Br=no.events.beforeDataDrivenEntityTriggerEvent.subscribe(t=>{if(!(t.entity instanceof Rr)||t.id!="rubedo:becomeAdmin")return;t.entity.removeTag("CHECK_PACK");let e=mn();if(e)return t.entity.playSound("note.bass"),t.entity.tell(`\xA7cFailed to give server owner: "${e}" is already owner!`),no.events.beforeDataDrivenEntityTriggerEvent.unsubscribe(Br);ne(t.entity,"admin"),ge(t.entity),t.entity.addEffect(xr.blindness,3,255,!0),t.entity.tell('\xA7aYou have now been set as the "owner" of this server. The command "/function start" will not do anything anymore, type "-help" for more information!')});import{DynamicPropertiesDefinition as ro,MinecraftEntityTypes as Nr,world as io}from"@minecraft/server";var oo=[];io.events.worldInitialize.subscribe(({propertyRegistry:t})=>{let e=new ro;e.defineString("role",30),t.registerEntityTypeDynamicProperties(e,Nr.player);let n=new ro;n.defineString("worldsOwner",100),n.defineBoolean("isLockDown"),t.registerWorldDynamicProperties(n);for(let o of oo)io.scoreboard.addObjective(o.objective,o.displayName??"")});var je=[];function wn(){je=[]}console.warn("----- Importing Plugins -----");Mr.events.beforeWatchdogTerminate.subscribe(t=>{t.cancel=!0,console.warn(`WATCHDOG TRIED TO CRASH = ${t.terminateReason}`)}); +// src/index.ts +import { system as system14 } from "@minecraft/server"; + +// src/rubedo/lib/Command/index.ts +import { world as world4 } from "@minecraft/server"; + +// src/rubedo/config/commands.ts +var PREFIX = "-"; + +// src/rubedo/lib/Command/ArgumentTypes.ts +import { world as world3 } from "@minecraft/server"; + +// src/rubedo/database/Database.ts +import { ItemStack, MinecraftItemTypes } from "@minecraft/server"; + +// src/rubedo/config/database.ts +import { BlockLocation } from "@minecraft/server"; +var MAX_DATABASE_STRING_SIZE = 32e3; +var MAX_LORE_ARRAY_SIZE = 2e6; +var ENTITY_IDENTIFIER = "database:database"; +var ENTITY_LOCATION = new BlockLocation(0, -64, 0); +var INVENTORY_SIZE = 128; + +// src/utils.ts +import { + BlockLocation as BlockLocation2, + MinecraftDimensionTypes, + system, + world +} from "@minecraft/server"; +var DIMENSIONS = { + overworld: world.getDimension(MinecraftDimensionTypes.overworld), + nether: world.getDimension(MinecraftDimensionTypes.nether), + theEnd: world.getDimension(MinecraftDimensionTypes.theEnd), + "minecraft:overworld": world.getDimension(MinecraftDimensionTypes.overworld), + "minecraft:nether": world.getDimension(MinecraftDimensionTypes.nether), + "minecraft:the_end": world.getDimension(MinecraftDimensionTypes.theEnd) +}; +var durations = { + y: 317098e-16, + w: 6048e5, + d: 864e5, + h: 36e5, + m: 6e4, + s: 1e3, + ms: 1 +}; +function durationToMs(duration) { + const values = duration.split(","); + let ms = 0; + for (const value of values) { + const length = parseInt(value.match(/\d+/)[0]); + const unit = value.match(/[a-zA-Z]+/)[0]; + if (!durations[unit]) { + throw new Error(`Invalid duration unit: ${unit}`); + } + ms += durations[unit] * length; + } + return ms; +} +function msToTime(duration) { + return new Date(duration).toString(); +} +function vector3ToBlockLocation(loc) { + return new BlockLocation2( + Math.floor(loc.x), + Math.floor(loc.y), + Math.floor(loc.z) + ); +} +function sleep(tick) { + return new Promise((resolve) => { + let runScheduleId = system.runSchedule(() => { + resolve(); + system.clearRunSchedule(runScheduleId); + }, tick); + }); +} +function LocationEquals(a, b) { + if (a instanceof BlockLocation2 || b instanceof BlockLocation2) { + return ~~a.x === ~~b.x && ~~a.y === ~~b.y && ~~a.z === ~~b.z; + } + return a.x === b.x && a.y === b.y && a.z === b.z; +} +function sort3DVectors(vector1, vector2) { + [vector1.x, vector2.x] = [ + Math.min(vector1.x, vector2.x), + Math.max(vector1.x, vector2.x) + ]; + [vector1.y, vector2.y] = [ + Math.min(vector1.y, vector2.y), + Math.max(vector1.y, vector2.y) + ]; + [vector1.z, vector2.z] = [ + Math.min(vector1.z, vector2.z), + Math.max(vector1.z, vector2.z) + ]; + return [vector1, vector2]; +} +function betweenVector3(target, vector1, vector2) { + const [minVector, maxVector] = sort3DVectors(vector1, vector2); + const { x, y, z } = target; + return x >= minVector.x && x <= maxVector.x && y >= minVector.y && y <= maxVector.y && z >= minVector.z && z <= maxVector.z; +} +function splitString(str, maxLength, subArraysMaxLength) { + const subStrings = []; + for (let i = 0; i < str.length; i += maxLength) { + subStrings.push(str.slice(i, i + maxLength)); + } + const subArrays = []; + for (const subString of subStrings) { + subArrays.push( + Array.from( + { length: Math.ceil(subString.length / subArraysMaxLength) }, + (_, i) => subString.slice(i * subArraysMaxLength, (i + 1) * subArraysMaxLength) + ) + ); + } + return subArrays; +} + +// src/rubedo/lib/Events/EntitiesLoad.ts +import { system as system2, world as world2 } from "@minecraft/server"; +var CALLBACKS = {}; +var ENTITIES_LOADED = false; +function setEntitiesLoaded() { + ENTITIES_LOADED = true; + for (const [i, callback] of Object.entries(CALLBACKS)) { + callback(); + delete CALLBACKS[i]; + } +} +system2.run(async () => { + try { + await DIMENSIONS.overworld.runCommandAsync(`testfor @a`); + setEntitiesLoaded(); + } catch (error) { + let e2 = world2.events.playerSpawn.subscribe(() => { + setEntitiesLoaded(); + world2.events.playerSpawn.unsubscribe(e2); + }); + } +}); +var EntitiesLoad = class { + static async awaitLoad() { + if (ENTITIES_LOADED) + return; + return new Promise((resolve) => { + EntitiesLoad.subscribe(resolve); + }); + } + static subscribe(callback) { + const key = Object.keys(CALLBACKS).length; + if (ENTITIES_LOADED) { + callback(); + return key; + } + CALLBACKS[key] = callback; + return key; + } + static unsubscribe(key) { + delete CALLBACKS[key]; + } +}; + +// src/rubedo/database/Database.ts +var Database = class { + constructor(tableName) { + this.tableName = tableName; + this.tableName = tableName; + this.MEMORY = null; + this.QUEUE = []; + this.onLoadCallback = null; + EntitiesLoad.subscribe(async () => { + const data = await this.initData(); + this.onLoadCallback(data); + this.QUEUE.forEach((v) => v()); + }); + } + static createTableEntity(tableName, index) { + const entity = DIMENSIONS.overworld.spawnEntity( + ENTITY_IDENTIFIER, + ENTITY_LOCATION + ); + entity.setDynamicProperty("tableName", tableName); + entity.nameTag = `\xA7aDatabase Table: ${tableName}\xA7r`; + if (index) + entity.setDynamicProperty("index", index); + return entity; + } + static getTableEntities(tableName) { + return DIMENSIONS.overworld.getEntitiesAtBlockLocation(ENTITY_LOCATION).filter( + (e2) => e2.typeId == ENTITY_IDENTIFIER && e2.getDynamicProperty("tableName") == tableName + ); + } + static despawnTableEntities() { + return DIMENSIONS.overworld.getEntitiesAtBlockLocation(ENTITY_LOCATION).map((e2) => e2.triggerEvent("despawn")); + } + async addQueueTask() { + return new Promise((resolve) => { + this.QUEUE.push(resolve); + }); + } + async saveData() { + if (!this.MEMORY) + await this.addQueueTask(); + let entities = Database.getTableEntities(this.tableName); + let chunks = splitString( + JSON.stringify(this.MEMORY), + MAX_DATABASE_STRING_SIZE, + MAX_LORE_ARRAY_SIZE + ); + const entitiesNeeded = Math.ceil(chunks.length / INVENTORY_SIZE) - entities.length; + if (entitiesNeeded > 0) { + for (let i2 = 0; i2 < entitiesNeeded; i2++) { + entities.push(Database.createTableEntity(this.tableName)); + } + } + let savedChunks = 0; + let i = 0; + while (savedChunks < chunks.length) { + const entity = entities[i]; + if (!entity) + continue; + const inventory = entity.getComponent("inventory").container; + inventory.clearAll(); + for (let j = 0; j < inventory.size && savedChunks < chunks.length; j++) { + const chunk = chunks[savedChunks]; + let item = new ItemStack(MinecraftItemTypes.acaciaBoat); + item.setLore(chunk); + inventory.setItem(j, item); + savedChunks++; + } + entity.setDynamicProperty("index", i); + i++; + } + entities.slice(i).forEach((e2) => e2?.triggerEvent("despawn")); + } + async initData() { + let entities = Database.getTableEntities(this.tableName).sort( + (a, b) => a.getDynamicProperty("index") - b.getDynamicProperty("index") + ); + if (entities.length == 0) { + console.warn( + `[Database-Warning]: No data found for table ${this.tableName}!` + ); + } + const stringifiedData = []; + for (const entity of entities) { + const inventory = entity.getComponent("inventory").container; + for (let i = 0; i < inventory.size; i++) { + const item = inventory.getItem(i); + if (item) + stringifiedData.push(...item.getLore()); + } + } + this.MEMORY = JSON.parse(stringifiedData.join("") || "{}"); + console.warn(`table ${this.tableName} memor ${this.MEMORY}`); + return this.MEMORY; + } + async onLoad(callback) { + this.onLoadCallback = callback; + } + async set(key, value) { + this.MEMORY[key] = value; + return this.saveData(); + } + get(key) { + if (!this.MEMORY) + throw new Error( + "Entities not loaded! Consider using `getAsync` instead!" + ); + return this.MEMORY[key]; + } + async getSync(key) { + if (this.MEMORY) + return this.get(key); + await this.addQueueTask(); + return this.MEMORY[key]; + } + keys() { + if (!this.MEMORY) + throw new Error( + "Entities not loaded! Consider using `keysSync` instead!" + ); + return Object.keys(this.MEMORY); + } + async keysSync() { + if (this.MEMORY) + return this.keys(); + await this.addQueueTask(); + return Object.keys(this.MEMORY); + } + values() { + if (!this.MEMORY) + throw new Error( + "Entities not loaded! Consider using `valuesSync` instead!" + ); + return Object.values(this.MEMORY); + } + async valuesSync() { + if (this.MEMORY) + return this.values(); + await this.addQueueTask(); + return Object.values(this.MEMORY); + } + has(key) { + if (!this.MEMORY) + throw new Error("Entities not loaded! Consider using `hasSync` instead!"); + return Object.keys(this.MEMORY).includes(key); + } + async hasSync(key) { + if (this.MEMORY) + return this.has(key); + await this.addQueueTask(); + return Object.keys(this.MEMORY).includes(key); + } + collection() { + if (!this.MEMORY) + throw new Error( + "Entities not loaded! Consider using `collectionSync` instead!" + ); + return this.MEMORY; + } + async collectionSync() { + if (this.MEMORY) + return this.collection(); + await this.addQueueTask(); + return this.MEMORY; + } + async delete(key) { + const status = delete this.MEMORY[key]; + await this.saveData(); + return status; + } + async clear() { + this.MEMORY = {}; + return await this.saveData(); + } +}; + +// src/vendor/Anti-Cheat/tables.ts +var TABLES = { + config: new Database("config"), + freezes: new Database("freezes"), + mutes: new Database("mutes"), + bans: new Database("bans"), + regions: new Database("regions"), + roles: new Database("roles"), + tasks: new Database("tasks"), + npcs: new Database("npcs"), + ids: new Database("ids"), + logs: new Database("logs"), + protections: new Database("protections") +}; + +// src/rubedo/lib/Command/ArgumentTypes.ts +function fetch(playerName) { + return [...world3.getPlayers()].find((player) => player.name === playerName); +} +var LiteralArgumentType = class { + constructor(name = "literal") { + this.name = name; + this.typeName = "literal"; + this.name = name; + } + matches(value) { + return { + success: this.name == value + }; + } + fail(value) { + return `${value} should be ${this.name}!`; + } +}; +var StringArgumentType = class { + constructor(name = "string") { + this.name = name; + this.typeName = "string"; + this.name = name; + } + matches(value) { + return { + success: value && value != "", + value + }; + } + fail(value) { + return `Value must be of type string!`; + } +}; +var IntegerArgumentType = class { + constructor(name = "integer") { + this.name = name; + this.typeName = "int"; + this.name = name; + } + matches(value) { + return { + success: !isNaN(value), + value: parseInt(value) + }; + } + fail(value) { + return `Value must be valid number!`; + } +}; +var FloatArgumentType = class { + constructor(name = "float") { + this.name = name; + this.typeName = "float"; + this.name = name; + } + matches(value) { + return { + success: Boolean(value?.match(/^\d+\.\d+$/)?.[0]), + value: parseInt(value) + }; + } + fail(value) { + return `Value must be valid float!`; + } +}; +var LocationArgumentType = class { + constructor(name = "location") { + this.name = name; + this.typeName = "location"; + this.name = name; + } + matches(value) { + return { + success: /^([~^]{0,1}(-\d)?(\d*)?(\.(\d+))?)$/.test(value), + value + }; + } + fail(value) { + return `Value needs to be a valid number, value can include: [~,^]`; + } +}; +var BooleanArgumentType = class { + constructor(name = "boolean") { + this.name = name; + this.typeName = "boolean"; + this.name = name; + } + matches(value) { + return { + success: Boolean(value?.match(/^(true|false)$/)?.[0]), + value: value == "true" ? true : false + }; + } + fail(value) { + return `"${value}" can be either "true" or "false"`; + } +}; +var PlayerArgumentType = class { + constructor(name = "player") { + this.name = name; + this.typeName = "Player"; + this.name = name; + } + matches(value) { + return { + success: fetch(value) ? true : false, + value: fetch(value) + }; + } + fail(value) { + return `player: "${value}", is not in this world`; + } +}; +var TargetArgumentType = class { + constructor(name = "target") { + this.name = name; + this.typeName = "Target"; + this.name = name; + } + matches(value) { + return { + success: Boolean(value?.match(/^(@.|"[\s\S]+")$/)?.[0]), + value + }; + } + fail(value) { + return `${value} is not a valid target`; + } +}; +var ArrayArgumentType = class { + constructor(name = "array", types) { + this.name = name; + this.types = types; + this.typeName = "string"; + this.name = name; + this.types = types; + this.typeName = types.join(" | ").replace(/(.{25})..+/, "$1..."); + } + matches(value) { + return { + success: this.types.includes(value), + value + }; + } + fail(value) { + return `"${value}" must be one of these values: ${this.types.join(" | ")}`; + } +}; +var DurationArgumentType = class { + constructor(name) { + this.name = name; + this.typeName = "Duration"; + } + matches(value) { + return { + success: /^(\d+[hdysmw],?)+$/.test(value), + value + }; + } + fail(value) { + return `"${value}" must be a value like "10d" or "3s" the first part is the length second is unit`; + } +}; +var PlayerNameArgumentType = class { + constructor(name = "playerName") { + this.name = name; + this.typeName = "playerName"; + this.name = name; + } + matches(value) { + const player = TABLES.ids.get(value); + return { + success: player ? true : false, + value + }; + } + fail(value) { + return `player: "${value}" has never played this world before! Tip: if the name has spaces in it use quotes around name!`; + } +}; +var ArgumentTypes = { + string: StringArgumentType, + int: IntegerArgumentType, + float: FloatArgumentType, + location: LocationArgumentType, + boolean: BooleanArgumentType, + player: PlayerArgumentType, + target: TargetArgumentType, + array: ArrayArgumentType, + duration: DurationArgumentType, + playerName: PlayerNameArgumentType +}; + +// src/rubedo/lib/Command/Callback.ts +var CommandCallback = class { + constructor(data) { + this.data = data; + this.sender = data.sender; + } + reply(text2) { + this.sender.tell(text2); + } +}; + +// src/rubedo/lib/Command/utils.ts +function getChatAugments(message, prefix) { + try { + return message.slice(prefix.length).trim().match(/"[^"]+"|[^\s]+/g).map((e2) => e2.replace(/"(.+)"/, "$1").toString()); + } catch (error) { + return []; + } +} +function commandNotFound(player, command2) { + player.tell({ + rawtext: [ + { + text: `\xA7c` + }, + { + translate: `commands.generic.unknown`, + with: [`${command2}`] + } + ] + }); +} +function noPerm(player, command2) { + player.tell({ + rawtext: [ + { + text: command2.data.invalidPermission ? command2.data.invalidPermission : `\xA7cYou do not have permission to use "${command2.data.name}"` + } + ] + }); +} +function commandSyntaxFail(player, baseCommand, command2, args, i) { + player.tell({ + rawtext: [ + { + text: `\xA7c` + }, + { + translate: `commands.generic.syntax`, + with: [ + `${PREFIX}${baseCommand.data.name} ${args.slice(0, i).join(" ")}`, + args[i] ?? " ", + args.slice(i + 1).join(" ") + ] + } + ] + }); + if (command2.children.length > 1 || !args[i]) { + const types = command2.children.map( + (c) => c.type instanceof LiteralArgumentType ? c.type.name : c.type?.typeName + ); + player.tell( + `\xA7c"${args[i] ?? "undefined"}" is not valid! Argument "${[...new Set(command2.children.map((c) => c.type.name))][0]}" can be typeof: "${types.join('", "')}"` + ); + } else { + player.tell(`\xA7c${command2.children[0]?.type?.fail(args[i])}`); + } +} +function parseLocationArgs([x, y, z], { location, viewDirection }) { + if (!x || !y || !x) + return null; + const locations = [location.x, location.y, location.z]; + const viewVectors = [viewDirection.x, viewDirection.y, viewDirection.z]; + const a = [x, y, z].map((arg) => { + const r = parseFloat(arg); + return isNaN(r) ? 0 : r; + }); + const b = [x, y, z].map((arg, index) => { + return arg.includes("~") ? a[index] + locations[index] : arg.includes("^") ? a[index] + viewVectors[index] : a[index]; + }); + return { x: b[0], y: b[1], z: b[2] }; +} +function sendCallback(cmdArgs, args, event, baseCommand) { + const lastArg = args[args.length - 1] ?? baseCommand; + const argsToReturn = []; + for (const [i, arg] of args.entries()) { + if (arg.type.name.endsWith("*")) + continue; + if (arg.type instanceof LocationArgumentType) { + argsToReturn.push( + parseLocationArgs( + [cmdArgs[i], cmdArgs[i + 1], cmdArgs[i + 2]], + event.sender + ) + ); + continue; + } + if (arg.type instanceof LiteralArgumentType) + continue; + argsToReturn.push(arg.type.matches(cmdArgs[i]).value ?? cmdArgs[i]); + } + lastArg.callback(new CommandCallback(event), ...argsToReturn); +} + +// src/rubedo/lib/Command/index.ts +var COMMANDS = []; +world4.events.beforeChat.subscribe((data) => { + if (!data.message.startsWith(PREFIX)) + return; + data.cancel = true; + const args = getChatAugments(data.message, PREFIX); + const command2 = COMMANDS.find( + (c) => c.depth == 0 && (c.data.name == args[0] || c.data?.aliases?.includes(args[0])) + ); + const event = { + message: data.message, + sendToTargets: data.sendToTargets, + sender: data.sender, + targets: data.targets + }; + if (!command2) + return commandNotFound(data.sender, args[0]); + if (!command2.data?.requires(data.sender)) + return noPerm(event.sender, command2); + args.shift(); + const verifiedCommands = []; + const getArg = (start, i) => { + if (start.children.length > 0) { + const arg = start.children.find((v2) => v2.type.matches(args[i]).success); + if (!arg && !args[i] && start.callback) + return; + if (!arg) + return commandSyntaxFail(event.sender, command2, start, args, i), "fail"; + if (!arg.data?.requires(event.sender)) + return noPerm(event.sender, arg), "fail"; + verifiedCommands.push(arg); + return getArg(arg, i + 1); + } + }; + let v = getArg(command2, 0); + if (v == "fail") + return; + sendCallback(args, verifiedCommands, event, command2); +}); + +// src/rubedo/lib/Chest GUI/index.ts +import { + ItemStack as ItemStack5, + MinecraftItemTypes as MinecraftItemTypes4, + system as system5, + world as world6 +} from "@minecraft/server"; + +// src/rubedo/config/chest.ts +var GUI_ITEM = "rubedo:gui"; +var ENTITY_INVENTORY = "rubedo:inventory"; + +// src/rubedo/lib/Chest GUI/Models/EntityChest.ts +import { system as system4 } from "@minecraft/server"; + +// src/rubedo/lib/Events/onSlotChange.ts +import { + system as system3 +} from "@minecraft/server"; +var CALLBACKS2 = {}; +var MAPPED_INVENTORIES = {}; +var PREVIOUS_CHANGE = {}; +function getSlotChanges(entity, oldInv, newInv) { + if (oldInv.length != newInv.length) + return []; + const changes = []; + for (let i = 0; i < newInv.length; i++) { + if (oldInv[i]?.item?.amount < newInv[i]?.item?.amount || oldInv[i]?.item?.amount > newInv[i]?.item?.amount && oldInv[i]?.item?.amount != 0) { + const change_data = { + slot: i, + uid: newInv[i].uid, + oldUid: oldInv[i].uid, + item: newInv[i].item, + oldItem: oldInv[i].item, + changeType: "fluctuation" + }; + changes.push(change_data); + PREVIOUS_CHANGE[entity.id] = change_data; + continue; + } + if (newInv[i].uid == oldInv[i].uid) + continue; + if (oldInv[i]?.item && newInv[i]?.item) { + const change_data = { + slot: i, + uid: newInv[i].uid, + oldUid: oldInv[i].uid, + item: newInv[i].item, + oldItem: oldInv[i].item, + changeType: "swap" + }; + changes.push(change_data); + PREVIOUS_CHANGE[entity.id] = change_data; + } else if (!newInv[i]?.item) { + const change_data = { + slot: i, + uid: oldInv[i].uid, + item: oldInv[i].item, + changeType: "delete" + }; + changes.push(change_data); + PREVIOUS_CHANGE[entity.id] = change_data; + } else if (newInv[i]?.item) { + if (PREVIOUS_CHANGE[entity.id]?.changeType == "delete" && PREVIOUS_CHANGE[entity.id]?.uid == newInv[i].uid) { + const change_data = { + slot: i, + uid: newInv[i].uid, + item: newInv[i].item, + changeType: "move" + }; + changes.push(change_data); + PREVIOUS_CHANGE[entity.id] = change_data; + continue; + } else { + const change_data = { + slot: i, + uid: newInv[i].uid, + item: newInv[i].item, + changeType: "put" + }; + changes.push(change_data); + PREVIOUS_CHANGE[entity.id] = change_data; + } + } + } + return changes; +} +function getItemUid(item) { + if (!item) + return ""; + const data = []; + data.push(item.typeId); + data.push(item.nameTag); + data.push(item.data); + data.push(item.getLore().join("")); + return data.join(""); +} +function mapInventory(container) { + const inventory = []; + for (let i = 0; i < container.size; i++) { + let item = container.getItem(i); + inventory[i] = { + uid: getItemUid(item), + item + }; + } + return inventory; +} +system3.runSchedule(() => { + for (const callback of Object.values(CALLBACKS2)) { + for (const entity of DIMENSIONS.overworld.getEntities(callback.entities)) { + const inventory = mapInventory( + entity.getComponent("inventory").container + ); + const changes = getSlotChanges( + entity, + MAPPED_INVENTORIES[entity.id] ?? inventory, + inventory + ); + MAPPED_INVENTORIES[entity.id] = inventory; + if (changes.length == 0) + continue; + if (entity.hasTag("skipCheck")) { + entity.removeTag("skipCheck"); + delete PREVIOUS_CHANGE[entity.id]; + continue; + } + for (const change of changes) { + callback.callback(entity, change); + } + } + } +}, 5); +var onEntityInventorySlotChange = class { + static subscribe(entities, callback) { + const key = Date.now(); + CALLBACKS2[key] = { callback, entities }; + return key; + } + static unsubscribe(key) { + delete CALLBACKS2[key]; + } +}; + +// src/rubedo/lib/Chest GUI/utils.ts +import { Location as Location2 } from "@minecraft/server"; +var CHESTGUIS = {}; +var PAGES = {}; +function getHeldItem(player) { + const inventory = player.getComponent("minecraft:inventory").container; + return inventory.getItem(player.selectedSlot); +} +async function clearPlayersPointer(player, ItemToClear) { + try { + const inventory = player.getComponent("minecraft:inventory").container; + let itemsToLoad = []; + for (let i = 0; i < inventory.size; i++) { + const item = inventory.getItem(i); + if (!item) + continue; + if (item?.typeId == ItemToClear?.typeId) { + itemsToLoad.push({ slot: i, item }); + inventory.setItem; + if (i < 9) { + player.runCommandAsync(`replaceitem entity @s slot.hotbar ${i} air`); + } else { + player.runCommandAsync( + `replaceitem entity @s slot.inventory ${i - 9} air` + ); + } + } + } + await player.runCommandAsync( + `clear @s ${ItemToClear?.typeId} ${ItemToClear.data} ${ItemToClear.amount}` + ); + for (const item of itemsToLoad) { + inventory.setItem(item.slot, item.item); + } + } catch (error) { + [ + ...player.dimension.getEntities({ + type: "minecraft:item", + location: new Location2( + player.location.x, + player.location.y, + player.location.z + ), + maxDistance: 2, + closest: 1 + }) + ].forEach((e2) => e2.kill()); + } +} +function getItemAtSlot(entity, slot) { + const inventory = entity.getComponent("minecraft:inventory").container; + return inventory.getItem(slot); +} + +// src/rubedo/lib/Chest GUI/Models/ItemGrabbedCallback.ts +var ItemGrabbedCallback = class { + constructor(gui, slot, change) { + this.gui = gui; + this.slot = slot; + this.change = change; + } + message(text2) { + this.gui.player.tell(text2); + } + getItemAdded() { + if (this.slot.item) + return null; + return this.gui.entity.getComponent("minecraft:inventory").container.getItem(this.change.slot); + } + GiveAction(item = this.slot.item.itemStack) { + this.gui.player.getComponent("minecraft:inventory").container.addItem(item); + } + TakeAction(db = null) { + this.gui.player.getComponent("minecraft:inventory").container.addItem(this.slot.item.itemStack); + this.gui.page.slots[this.change.slot] = null; + if (!db) + return; + db.delete(this.slot.item.components.dbKey); + } + PageAction(page, extras) { + this.gui.setPage(page, extras); + } + CloseAction() { + this.gui.despawn(); + } + SetAction() { + const container = this.gui.entity.getComponent( + "minecraft:inventory" + ).container; + container.setItem(this.change.slot, this.slot.item.itemStack); + } + async FormAction(form) { + this.CloseAction(); + await sleep(5); + return await form.show(this.gui.player); + } +}; + +// src/rubedo/lib/Chest GUI/Models/EntityChest.ts +var ChestGUI = class { + static spawnEntity(player) { + try { + return player.dimension.spawnEntity( + ENTITY_INVENTORY, + player.headLocation + ); + } catch (error) { + return null; + } + } + constructor(player) { + this.player = player; + this.entity = ChestGUI.spawnEntity(player); + if (this.entity) { + this.hasChestOpen = false; + this.setPage("home"); + } + this.runScheduleId = system4.runSchedule(() => { + if (!this.entity) + return this.despawn(); + if (this.player.getComponent("mark_variant").value == 1) { + if (!this.hasChestOpen) { + this.slotChangeEvent = onEntityInventorySlotChange.subscribe( + { type: ENTITY_INVENTORY }, + (entity, change) => { + if (entity.id != this.entity.id) + return; + this.onSlotChange(change); + } + ); + } + this.hasChestOpen = true; + } else { + try { + this.entity.teleport( + this.player.headLocation, + this.player.dimension, + this.player.rotation.x, + this.player.rotation.y, + true + ); + } catch (error) { + this.despawn(); + } + } + }, 5); + } + setPage(pageId, extras) { + const c = this.entity.getComponent("inventory").container; + for (let i = 0; i < c.size; i++) { + c.setItem(i, AIR); + } + if (!Object.keys(PAGES).includes(pageId)) + throw new Error(`pageId ${pageId} does not exist!`); + const page = PAGES[pageId]; + this.page = page; + page.fillType(this.entity, page, extras); + this.entity.nameTag = `size:54`; + } + onSlotChange(change) { + const slot = this.page.slots[change.slot]; + if (!slot) { + this.entity.getComponent("inventory").container.setItem(change.slot, AIR); + } else if (change.changeType == "delete") { + if (slot.item) + clearPlayersPointer(this.player, change.item); + if (!slot.item && !getItemAtSlot(this.entity, change.slot)) + return; + slot.action(new ItemGrabbedCallback(this, slot, change)); + } + } + despawn() { + try { + this.entity?.triggerEvent("despawn"); + } catch (error) { + } + try { + delete CHESTGUIS[this.player.name]; + } catch (error) { + } + if (this.runScheduleId) + system4.clearRunSchedule(this.runScheduleId); + if (this.slotChangeEvent) + onEntityInventorySlotChange.unsubscribe(this.slotChangeEvent); + } +}; + +// src/rubedo/lib/Chest GUI/Models/PageItem.ts +import { + ItemStack as ItemStack4 +} from "@minecraft/server"; +var PageItem = class { + constructor(itemType, components = {}, itemStack) { + this.itemType = itemType; + this.components = components; + this.setItemStack = itemStack; + } + get itemStack() { + if (this.setItemStack) + return this.setItemStack; + const itemStack = new ItemStack4(this.itemType); + if (this.components) { + itemStack.amount = this.components?.amount ?? 1; + itemStack.data = this.components?.data ?? 0; + itemStack.nameTag = this.components?.nameTag; + itemStack.setLore(this.components?.loreList ?? []); + const enchantments = itemStack.getComponent("enchantments").enchantments; + for (const enchantment of this.components?.enchantments ?? []) { + enchantments.addEnchantment(enchantment); + } + itemStack.getComponent("enchantments").enchantments = enchantments; + } + return itemStack; + } +}; + +// src/rubedo/lib/Chest GUI/Models/FillTypes.ts +function DefaultFill(entity, page, extras) { + const container = entity.getComponent("minecraft:inventory").container; + for (let i = 0; i < container.size; i++) { + const slot = page.slots[i]; + if (!slot || !slot.item) { + container.setItem(i, AIR); + continue; + } + container.setItem(i, slot.item.itemStack); + } +} + +// src/rubedo/lib/Chest GUI/Models/Page.ts +var Page = class { + constructor(id, fillType = DefaultFill) { + if (Object.keys(PAGES).includes(id)) + throw new Error(`Page: ${id}, Already exists!`); + this.id = id; + this.fillType = fillType; + this.slots = []; + PAGES[id] = this; + } + setSlots(slot, item, action) { + const data = item ? { item, action } : null; + for (const i of slot) { + this.slots[i] = data; + } + return this; + } +}; + +// src/rubedo/lib/Chest GUI/pages/home.ts +import { MinecraftItemTypes as MinecraftItemTypes2 } from "@minecraft/server"; +var HOME_PAGE = new Page("home").setSlots( + [22], + new PageItem(MinecraftItemTypes2.enderChest, { + nameTag: "\xA7l\xA7bInventory Viewer" + }), + (ctx) => { + ctx.PageAction("moderation:see"); + } +).setSlots( + [54], + new PageItem(MinecraftItemTypes2.barrier, { nameTag: "\xA7cClose GUI" }), + (ctx) => { + ctx.CloseAction(); + } +); + +// src/vendor/Anti-Cheat/utils.ts +import { + world as world5, + Player as Player4, + BlockLocation as BlockLocation4, + MinecraftBlockTypes as MinecraftBlockTypes3, + GameMode +} from "@minecraft/server"; + +// src/vendor/Anti-Cheat/modules/models/Region.ts +import { BlockLocation as BlockLocation3, MinecraftBlockTypes } from "@minecraft/server"; + +// src/vendor/Anti-Cheat/config/region.ts +var DEFAULT_REGION_PERMISSIONS = { + doorsAndSwitches: true, + openContainers: true, + pvp: false, + allowedEntities: [ + "minecraft:player", + "minecraft:npc", + "minecraft:item", + "rubedo:inventory", + "rubedo:database" + ] +}; +var DOORS_SWITCHES = [ + "minecraft:acacia_door", + "minecraft:acacia_trapdoor", + "minecraft:acacia_button", + "minecraft:birch_door", + "minecraft:birch_trapdoor", + "minecraft:birch_button", + "minecraft:crimson_door", + "minecraft:crimson_trapdoor", + "minecraft:crimson_button", + "minecraft:dark_oak_door", + "minecraft:dark_oak_trapdoor", + "minecraft:dark_oak_button", + "minecraft:jungle_door", + "minecraft:jungle_trapdoor", + "minecraft:jungle_button", + "minecraft:mangrove_door", + "minecraft:mangrove_trapdoor", + "minecraft:mangrove_button", + "minecraft:spruce_door", + "minecraft:spruce_trapdoor", + "minecraft:spruce_button", + "minecraft:warped_door", + "minecraft:warped_trapdoor", + "minecraft:warped_button", + "minecraft:wooden_door", + "minecraft:wooden_button", + "minecraft:trapdoor", + "minecraft:iron_door", + "minecraft:iron_trapdoor", + "minecraft:polished_blackstone_button", + "minecraft:lever" +]; +var BLOCK_CONTAINERS = [ + "minecraft:chest", + "minecraft:ender_chest", + "minecraft:barrel", + "minecraft:trapped_chest", + "minecraft:dispenser", + "minecraft:dropper", + "minecraft:furnace", + "minecraft:blast_furnace", + "minecraft:lit_furnace", + "minecraft:lit_blast_furnace", + "minecraft:hopper", + "minecraft:shulker_box", + "minecraft:undyed_shulker_box", + "minecraft:lit_smoker", + "minecraft:smoker" +]; + +// src/vendor/Anti-Cheat/modules/models/Region.ts +var REGIONS = []; +var REGIONS_HAVE_BEEN_GRABBED = false; +var LOWEST_Y_VALUE = -64; +var HIGHEST_Y_VALUE = 320; +var Region = class { + static async getAllRegionsSync() { + if (REGIONS_HAVE_BEEN_GRABBED) + return REGIONS; + const regions = (await TABLES.regions.valuesSync()).map( + (region) => new Region( + region.from, + region.to, + region.dimensionId, + region.permissions, + region.key + ) + ); + regions.forEach((r) => { + REGIONS.push(r); + }); + REGIONS_HAVE_BEEN_GRABBED = true; + return regions; + } + static getAllRegions() { + if (REGIONS_HAVE_BEEN_GRABBED) + return REGIONS; + const regions = TABLES.regions.values().map( + (region) => new Region( + region.from, + region.to, + region.dimensionId, + region.permissions, + region.key + ) + ); + regions.forEach((r) => { + REGIONS.push(r); + }); + REGIONS_HAVE_BEEN_GRABBED = true; + return regions; + } + static blockLocationInRegion(blockLocation, dimensionId) { + return this.getAllRegions().find( + (region) => region.dimensionId == dimensionId && betweenVector3( + blockLocation, + { x: region.from.x, y: LOWEST_Y_VALUE, z: region.from.z }, + { x: region.to.x, y: HIGHEST_Y_VALUE, z: region.to.z } + ) + ); + } + static async blockLocationInRegionSync(blockLocation, dimensionId) { + return (await this.getAllRegionsSync()).find( + (region) => region.dimensionId == dimensionId && betweenVector3( + blockLocation, + { x: region.from.x, y: LOWEST_Y_VALUE, z: region.from.z }, + { x: region.to.x, y: HIGHEST_Y_VALUE, z: region.to.z } + ) + ); + } + static async removeRegionAtBlockLocation(blockLocation, dimensionId) { + const region = this.blockLocationInRegion(blockLocation, dimensionId); + if (!region) + return false; + return TABLES.regions.delete(region.key); + } + constructor(from, to, dimensionId, permissions, key) { + this.from = from; + this.to = to; + this.dimensionId = dimensionId; + this.permissions = permissions ?? DEFAULT_REGION_PERMISSIONS; + this.key = key ? key : Date.now().toString(); + if (!key) { + this.update().then(() => { + loadRegionDenys(); + REGIONS.push(this); + }); + } + } + async update() { + return TABLES.regions.set(this.key, { + key: this.key, + from: this.from, + dimensionId: this.dimensionId, + permissions: this.permissions, + to: this.to + }); + } + async delete() { + const region = TABLES.regions.get(this.key); + const loc1 = new BlockLocation3( + region.from.x, + region.dimensionId == "minecraft:overworld" ? -64 : 0, + region.from.z + ); + const loc2 = new BlockLocation3( + region.to.x, + region.dimensionId == "minecraft:overworld" ? -64 : 0, + region.to.z + ); + for (const blockLocation of loc1.blocksBetween(loc2)) { + DIMENSIONS[region.dimensionId].getBlock(blockLocation)?.setType(MinecraftBlockTypes.bedrock); + } + REGIONS = REGIONS.filter((r) => r.key != this.key); + return TABLES.regions.delete(this.key); + } + entityInRegion(entity) { + return this.dimensionId == entity.dimension.id && betweenVector3( + entity.location, + { x: this.from.x, y: LOWEST_Y_VALUE, z: this.from.z }, + { x: this.to.x, y: HIGHEST_Y_VALUE, z: this.to.z } + ); + } + changePermission(key, value) { + this.permissions[key] = value; + this.update(); + } +}; + +// src/vendor/Anti-Cheat/modules/models/Task.ts +var ChangePlayerRoleTask = class { + static getTasks() { + return TABLES.tasks.get("changePlayerRole") ?? []; + } + static getPlayersRoleToSet(playerName) { + const tasks = ChangePlayerRoleTask.getTasks(); + return tasks.find((t) => t.playerName == playerName)?.role; + } + constructor(playerName, role) { + let tasks = ChangePlayerRoleTask.getTasks(); + tasks.push({ playerName, role }); + TABLES.tasks.set("changePlayerRole", tasks); + } +}; + +// src/vendor/Anti-Cheat/config/moderation.ts +import { MinecraftBlockTypes as MinecraftBlockTypes2, MinecraftItemTypes as MinecraftItemTypes3 } from "@minecraft/server"; +var APPEAL_LINK = "https://discord.gg/dMa3A5UYKX"; +var FORBIDDEN_ITEMS = [ + MinecraftItemTypes3.beehive.id, + MinecraftItemTypes3.beeNest.id, + MinecraftItemTypes3.axolotlBucket.id, + MinecraftItemTypes3.codBucket.id, + MinecraftItemTypes3.tadpoleBucket.id, + MinecraftItemTypes3.tropicalFishBucket.id, + MinecraftItemTypes3.salmonBucket.id, + MinecraftItemTypes3.pufferfishBucket.id +]; +var BANNED_ITEMS = [ + MinecraftItemTypes3.allow.id, + MinecraftItemTypes3.barrier.id, + MinecraftItemTypes3.borderBlock.id, + MinecraftItemTypes3.debugStick?.id ?? "minecraft:debug_stick", + MinecraftItemTypes3.deny.id, + MinecraftItemTypes3.jigsaw.id, + MinecraftItemTypes3.lightBlock.id, + MinecraftItemTypes3.commandBlock.id, + MinecraftItemTypes3.repeatingCommandBlock.id, + MinecraftItemTypes3.chainCommandBlock.id, + MinecraftItemTypes3.commandBlockMinecart.id, + MinecraftItemTypes3.structureBlock.id, + MinecraftItemTypes3.structureVoid.id, + MinecraftItemTypes3.bedrock.id, + MinecraftItemTypes3.endPortalFrame.id, + "minecraft:info_update", + "minecraft:info_update2", + "minecraft:reserved3", + "minecraft:reserved4", + "minecraft:reserved6", + "minecraft:movingBlock", + "minecraft:moving_block", + "minecraft:movingblock", + "minecraft:piston_arm_collision", + "minecraft:piston_arm_collision", + "minecraft:pistonarmcollision", + "minecraft:stickyPistonArmCollision", + "minecraft:sticky_piston_arm_collision", + "minecraft:unknown", + "minecraft:glowingobsidian", + "minecraft:invisible_bedrock", + "minecraft:invisiblebedrock", + "minecraft:netherreactor", + "minecraft:portal", + "minecraft:fire", + "minecraft:water", + "minecraft:lava", + "minecraft:flowing_lava", + "minecraft:flowing_water", + "minecraft:soul_fire" +]; +var FORBIDDEN_BLOCKS = [ + MinecraftBlockTypes2.dispenser.id +]; +var BANNED_BLOCKS = [ + MinecraftBlockTypes2.bedrock.id, + MinecraftBlockTypes2.barrier.id, + "minecraft:invisiblebedrock", + "minecraft:movingBlock", + "minecraft:movingblock", + "minecraft:moving_block" +]; +var CONTAINERS = [ + MinecraftItemTypes3.chest.id, + MinecraftItemTypes3.trappedChest.id, + MinecraftItemTypes3.barrel.id, + MinecraftItemTypes3.dispenser.id, + MinecraftItemTypes3.dropper.id, + MinecraftItemTypes3.furnace.id, + "minecraft:lit_furnace", + MinecraftItemTypes3.blastFurnace.id, + "minecraft:lit_blast_furnace", + MinecraftItemTypes3.smoker.id, + "minecraft:lit_smoker", + MinecraftItemTypes3.hopper.id, + MinecraftItemTypes3.shulkerBox.id, + MinecraftItemTypes3.undyedShulkerBox.id +]; + +// src/vendor/Anti-Cheat/config/enchantments.ts +var ENCHANTMENTS = { + aquaAffinity: 1, + baneOfArthropods: 5, + binding: 1, + blastProtection: 4, + channeling: 1, + depthStrider: 3, + efficiency: 5, + featherFalling: 4, + fireAspect: 2, + fireProtection: 4, + flame: 1, + fortune: 3, + frostWalker: 2, + impaling: 5, + infinity: 1, + knockback: 2, + looting: 3, + loyalty: 4, + luckOfTheSea: 3, + lure: 3, + mending: 1, + multishot: 1, + piercing: 4, + power: 5, + projectileProtection: 4, + protection: 4, + punch: 2, + quickCharge: 3, + respiration: 3, + riptide: 3, + sharpness: 5, + silkTouch: 1, + smite: 5, + soulSpeed: 3, + swiftSneak: 4, + thorns: 3, + unbreaking: 3, + vanishing: 1 +}; + +// src/vendor/Anti-Cheat/utils.ts +function kick(player, message = [], onFail) { + if (isServerOwner(player)) { + console.warn(`[WARNING]: TRIED TO KICK OWNER`); + player.tell(`You have been tried to kick, but you cant!`); + return onFail?.(); + } + try { + player.runCommandAsync(`kick "${player.name}" \xA7r${message.join("\n")}`); + player.triggerEvent("kick"); + } catch (error) { + player.triggerEvent("kick"); + if (!/"statusCode":-2147352576/.test(error)) + return; + if (onFail) + onFail(); + } +} +function getRole(player) { + if (player instanceof Player4) { + return TABLES.roles.get(player.name) ?? "member"; + } else { + return TABLES.roles.get(player) ?? "member"; + } +} +function setRole(player, value) { + if (typeof player == "string") { + TABLES.roles.set(player, value); + const inGamePlayer = [...world5.getPlayers()].find((p) => p.name == player); + if (inGamePlayer) { + inGamePlayer.setDynamicProperty("role", value); + } else { + new ChangePlayerRoleTask(player, value); + } + } else { + TABLES.roles.set(player.name, value); + player.setDynamicProperty("role", value); + } +} +function isServerOwner(player) { + return world5.getDynamicProperty("worldsOwner") == player.id; +} +function getServerOwner() { + const id = world5.getDynamicProperty("worldsOwner"); + if (!id || id == "") + return null; + return id; +} +function getServerOwnerName() { + const ownerId = getServerOwner(); + if (!ownerId) + return null; + const ids = TABLES.ids.collection(); + return Object.keys(ids).find((key) => ids[key] === ownerId); +} +function setServerOwner(player) { + if (!player) + return world5.setDynamicProperty("worldsOwner", ""); + world5.setDynamicProperty("worldsOwner", player.id.toString()); +} +function isLockedDown() { + return world5.getDynamicProperty("isLockDown") ?? false; +} +function setLockDown(val) { + world5.setDynamicProperty("isLockDown", val); +} +function loadRegionDenys() { + for (const region of Region.getAllRegions()) { + const loc1 = new BlockLocation4( + region.from.x, + region.dimensionId == "minecraft:overworld" ? -64 : 0, + region.from.z + ); + const loc2 = new BlockLocation4( + region.to.x, + region.dimensionId == "minecraft:overworld" ? -64 : 0, + region.to.z + ); + for (const blockLocation of loc1.blocksBetween(loc2)) { + DIMENSIONS[region.dimensionId].getBlock(blockLocation)?.setType(MinecraftBlockTypes3.deny); + } + } +} +function getConfigId(id) { + switch (id) { + case "banned_items": + return TABLES.config.get("banned_items") ?? BANNED_ITEMS; + case "banned_blocks": + return TABLES.config.get("banned_blocks") ?? BANNED_BLOCKS; + case "enchantments": + return TABLES.config.get("enchantments") ?? ENCHANTMENTS; + case "appealLink": + return TABLES.config.get("appealLink") ?? APPEAL_LINK; + } +} +function setConfigId(key, value) { + TABLES.config.set(key, value); +} + +// src/rubedo/lib/Chest GUI/index.ts +var AIR = new ItemStack5(MinecraftItemTypes4.acaciaBoat, 0); +EntitiesLoad.subscribe(() => { + system5.runSchedule(() => { + for (const player of world6.getPlayers()) { + if (getHeldItem(player)?.typeId != GUI_ITEM) { + if (CHESTGUIS[player.name]) + CHESTGUIS[player.name].despawn(); + continue; + } + if (Object.keys(CHESTGUIS).includes(player?.name)) + continue; + if (getRole(player) != "admin") + continue; + CHESTGUIS[player.name] = new ChestGUI(player); + } + }, 10); +}); +system5.runSchedule(() => { + const validIds = Object.values(CHESTGUIS).map((c) => c.entity.id); + for (const entity of DIMENSIONS.overworld.getEntities({ + type: ENTITY_INVENTORY + })) { + if (validIds.includes(entity.id)) + continue; + entity.triggerEvent("despawn"); + } +}, 100); + +// src/rubedo/database/index.ts +import { + DynamicPropertiesDefinition, + EntityTypes, + world as world7 +} from "@minecraft/server"; +world7.events.worldInitialize.subscribe(({ propertyRegistry }) => { + DIMENSIONS.overworld.runCommandAsync( + `tickingarea add ${ENTITY_LOCATION.x} ${ENTITY_LOCATION.y} ${ENTITY_LOCATION.z} ${ENTITY_LOCATION.x} ${ENTITY_LOCATION.y} ${ENTITY_LOCATION.z} db true` + ); + let def = new DynamicPropertiesDefinition(); + def.defineString("tableName", 30); + def.defineNumber("index"); + propertyRegistry.registerEntityTypeDynamicProperties( + def, + EntityTypes.get(ENTITY_IDENTIFIER) + ); +}); + +// src/rubedo/lib/Containers/index.ts +import { system as system6, world as world8 } from "@minecraft/server"; + +// src/rubedo/config/containers.ts +import { MinecraftBlockTypes as MinecraftBlockTypes4 } from "@minecraft/server"; +var API_CONTAINERS = [ + MinecraftBlockTypes4.chest.id, + MinecraftBlockTypes4.trappedChest.id +]; +var CHECK_SIZE = { x: 7, y: 7, z: 7 }; + +// src/rubedo/lib/Containers/Container.ts +var Container = class { + constructor(inventory) { + this.emptySlotsCount = inventory.emptySlotsCount; + this.size = inventory.size; + this.items = []; + for (let i = 0; i < this.size; i++) { + this.items[i] = inventory.getItem(i); + } + } + load(block) { + for (let i = 0; i < block.size; i++) { + if (!this.items[i]) + continue; + block.setItem(i, this.items[i]); + } + } +}; + +// src/rubedo/lib/Containers/index.ts +var CONTAINER_LOCATIONS = {}; +system6.runSchedule(() => { + CONTAINER_LOCATIONS = {}; + for (const player of world8.getPlayers()) { + if (player.dimension.id != "minecraft:overworld") + continue; + const blockLoc = vector3ToBlockLocation(player.location); + const pos1 = blockLoc.offset(CHECK_SIZE.x, CHECK_SIZE.y, CHECK_SIZE.z); + const pos2 = blockLoc.offset(-CHECK_SIZE.x, -CHECK_SIZE.y, -CHECK_SIZE.z); + for (const location of pos1.blocksBetween(pos2)) { + if (location.y < -64) + continue; + const block = player.dimension.getBlock(location); + if (!block) + continue; + if (!API_CONTAINERS.includes(block.typeId)) + continue; + CONTAINER_LOCATIONS[JSON.stringify(location)] = new Container( + block.getComponent("inventory").container + ); + } + } +}, 100); + +// src/vendor/Anti-Cheat/protections.ts +var PROTECTIONS = {}; +TABLES.protections.onLoad(() => { + for (const protection5 of Object.values(PROTECTIONS)) { + if (!protection5.getConfig().enabled) + continue; + protection5.enable(); + } +}); + +// src/vendor/Anti-Cheat/modules/models/Ban.ts +import { Player as Player5 } from "@minecraft/server"; +function setBan(player, id, duration, reason = "No Reason", by = "Rubedo Auto Mod") { + const data = { + key: id, + playerName: player instanceof Player5 ? player.name : player, + date: Date.now(), + duration: duration ? durationToMs(duration) : null, + expire: duration ? durationToMs(duration) + Date.now() : null, + reason, + by + }; + TABLES.bans.set(id, data); +} +var Ban = class { + constructor(player, duration, reason = "No Reason", by = "Rubedo Auto Mod") { + if (player instanceof Player5) { + setBan(player, player.id, duration, reason, by); + } else { + setBan(player, TABLES.ids.get(player), duration, reason, by); + } + } +}; + +// src/rubedo/lib/Form/Models/MessageForm.ts +import { MessageFormData } from "@minecraft/server-ui"; + +// src/rubedo/config/form.ts +var TIMEOUT_THRESHOLD = 200; + +// src/rubedo/lib/Form/Models/MessageForm.ts +var MessageForm = class { + constructor(title, body) { + this.title = title; + this.body = body; + this.form = new MessageFormData(); + if (title) + this.form.title(title); + if (body) + this.form.body(body); + this.triedToShow = 0; + } + setButton1(text2, callback) { + this.button1 = { text: text2, callback }; + this.form.button1(text2); + return this; + } + setButton2(text2, callback) { + this.button2 = { text: text2, callback }; + this.form.button2(text2); + return this; + } + show(player) { + this.form.show(player).then((response) => { + if (response.canceled) { + if (response.cancelationReason == "userBusy") { + if (this.triedToShow > TIMEOUT_THRESHOLD) + return player.tell( + `\xA7cForm Timeout: tried to show form, but you were busy (close chat after running command)` + ); + this.triedToShow++; + this.show(player); + } + return; + } + if (response.selection == 1) + this.button1?.callback?.(); + if (response.selection == 0) + this.button2?.callback?.(); + }); + } +}; + +// src/rubedo/lib/Form/utils.ts +function confirmAction(player, action, onConfirm, onCancel = () => { +}) { + new MessageForm("Confirm To Continue", action).setButton1("Confirm", onConfirm).setButton2("Never Mind", onCancel).show(player); +} + +// src/rubedo/lib/Command/Command.ts +var Command = class { + constructor(data, type, depth = 0, parent) { + this.data = data; + this.type = type; + this.depth = depth; + this.parent = parent; + if (!data.requires) + data.requires = (player) => true; + this.data = data; + this.type = type ?? new LiteralArgumentType(this.data.name); + this.children = []; + this.depth = depth; + this.parent = parent; + this.callback = null; + COMMANDS.push(this); + } + argument(type) { + const cmd = new Command( + this.data, + type, + this.depth + 1, + this + ); + this.children.push(cmd); + return cmd; + } + string(name) { + return this.argument(new StringArgumentType(name)); + } + int(name) { + return this.argument(new IntegerArgumentType(name)); + } + array(name, types) { + return this.argument(new ArrayArgumentType(name, types)); + } + boolean(name) { + return this.argument(new BooleanArgumentType(name)); + } + location(name) { + const cmd = this.argument(new LocationArgumentType(name)); + if (!name.endsWith("*")) { + const newArg = cmd.location(name + "_y*").location(name + "_z*"); + return newArg; + } + return cmd; + } + literal(data) { + const cmd = new Command( + data, + new LiteralArgumentType(data.name), + this.depth + 1, + this + ); + this.children.push(cmd); + return cmd; + } + executes(callback) { + this.callback = callback; + return this; + } +}; + +// src/rubedo/lang/text.ts +var text = { + "api.name": () => "Smelly API", + "api.error.unknown": () => "An unknown error has occurred.", + "api.database.error.table_name": (a, b) => `The display name ${a} is too long for an objective, it can be at most ${b} characters long`, + "api.utilities.formatter.error.ms": (a) => `${a} is not a string or a number`, + "api.Providers.form.invalidType": (a, b) => `Type ${a} is not a valid type to add a ${b}`, + "modules.protections.cps.clickingToFast": () => `You are clicking to fast! Please click slower!`, + "modules.managers.mute.isMuted": () => `\xA7cYou've been temporarily muted in chat.`, + "modules.commands.ban.reply": (playerName, duration, reason = "") => `\xA7cBanned \xA7f"\xA7a${playerName}\xA7f" \xA7cfor ${duration} Because: "${reason ?? "No reason Provided"}" \xA7aSuccessfully`, + "lockdown.kick.message": () => [ + `\xA7cYou have been kicked!`, + `\xA7aReason: \xA7fServer is currently under LockDown`, + `\xA7fServer will be up soon, Try to join later` + ], + "commands.ban.list.player": (name, reason, expire) => `- "${name}" Because: ${reason}, Expiry ${expire}`, + "commands.freeze.list.player": (name, reason) => `- "${name}" Because: ${reason}`, + "commands.mutes.list.player": (name, reason, expire) => `- "${name}" Because: ${reason}, Expiry: ${expire}`, + "commands.lockdown.confirm": "Are you sure you want to lockdown the server, this will kick all active players and all players who try to join who are not admin" +}; + +// src/vendor/Anti-Cheat/modules/commands/ban.ts +function ban(ctx, player, duration, reason, by) { + if (TABLES.bans.get(TABLES.ids.get(player))) + return ctx.reply(`\xA7c${player} is already banned`); + ctx.reply(`\xA7aClose chat to confirm`); + confirmAction( + ctx.sender, + `Are you sure you want to ban ${player}, for ${duration ?? "forever"}`, + () => { + new Ban(player, duration, reason, ctx.sender.name); + ctx.reply(text["modules.commands.ban.reply"](player, duration, reason)); + } + ); +} +var root = new Command({ + name: "ban", + description: "Manage bans", + requires: (player) => ["admin", "moderator"].includes(getRole(player)) +}); +root.literal({ + name: "add", + description: "Bans a player" +}).argument(new ArgumentTypes.playerName()).executes((ctx, player) => { + ban(ctx, player, null, null, ctx.sender.name); +}).argument(new ArgumentTypes.duration("duration")).executes((ctx, player, duration) => { + ban(ctx, player, duration, null, ctx.sender.name); +}).string("reason").executes((ctx, player, duration, reason) => { + ban(ctx, player, duration, reason, ctx.sender.name); +}); +root.literal({ + name: "remove", + description: "un-bans a player" +}).argument(new ArgumentTypes.playerName("playerName")).executes((ctx, playerName) => { + const banData = TABLES.bans.values().find((ban2) => ban2.playerName == playerName); + if (!banData) + return ctx.reply(`${playerName} is not banned`); + if (TABLES.bans.delete(banData.key)) { + ctx.reply(`\xA7a${playerName}\xA7r has been Unbanned!`); + } else { + ctx.reply(`\xA7cFailed to un-ban ${playerName}`); + } +}); +root.literal({ + name: "list", + description: "Lists all bans" +}).executes((ctx) => { + const bans = TABLES.bans.values(); + if (bans.length == 0) + return ctx.sender.tell(`\xA7cNo one is banned!`); + ctx.sender.tell(`\xA72--- Showing Bans (${bans.length}) ---`); + for (const ban2 of bans) { + ctx.sender.tell( + text["commands.ban.list.player"]( + ban2.playerName, + ban2.reason, + ban2.expire ? msToTime(ban2.duration) : "Forever" + ) + ); + } +}); + +// src/vendor/Anti-Cheat/modules/commands/database.ts +var root2 = new Command({ + name: "database", + description: "Interacts with SA Database", + aliases: ["db"], + requires: (player) => getRole(player) == "admin" +}); +root2.literal({ + name: "get" +}).string("table").string("key").executes((ctx, table, key) => { + try { + const data = TABLES[table].get(key); + if (data) { + ctx.reply(JSON.stringify(data)); + } else { + ctx.reply(`No data could be found for key ${key}`); + } + } catch (error) { + ctx.reply(error + error.stack); + } +}); +root2.literal({ + name: "set" +}).string("table").string("key").string("value").executes((ctx, table, key, value) => { + try { + TABLES[table].set(key, value); + ctx.reply(`Set Key: "${key}", to value: "${value}" on table: "${table}"`); + } catch (error) { + ctx.reply(error + error.stack); + } +}); +root2.literal({ + name: "clear" +}).string("table").executes((ctx, table) => { + try { + TABLES[table].clear(); + ctx.reply(`Cleared Table ${table}`); + } catch (error) { + ctx.reply(error + error.stack); + } +}); +root2.literal({ + name: "keys", + description: "Returns all keys on a database" +}).string("table").executes((ctx, table) => { + try { + const keys = TABLES[table].keys(); + ctx.reply(`Keys on database: ${table}: ${keys}`); + } catch (error) { + ctx.reply(error + error.stack); + } +}); +root2.literal({ + name: "values", + description: "Returns all values on a database" +}).string("table").executes((ctx, table) => { + try { + const values = TABLES[table].values(); + ctx.reply( + `Values on database: ${table}: ${JSON.stringify(values, null, 2)}` + ); + } catch (error) { + if (error instanceof TypeError) { + ctx.reply(`No values on database ${table}`); + } else { + ctx.reply(error + error.stack); + } + } +}); + +// src/vendor/Anti-Cheat/modules/commands/ecwipe.ts +new Command({ + name: "ecwipe", + description: "Clears a players ender chest", + requires: (player) => getRole(player) == "admin" +}).argument(new ArgumentTypes.player("player")).executes((ctx, player) => { + for (let i = 0; i < 27; i++) { + player.runCommandAsync(`replaceitem entity @s slot.enderchest ${i} air`); + } + ctx.reply(`\xA7aCleared "${player.name}"'s Ender chest!`); +}); + +// src/vendor/Anti-Cheat/modules/models/Freeze.ts +var Freeze = class { + constructor(player, reason = "No Reason") { + const data = { + playerName: player.name, + key: player.id, + reason, + location: { + x: player.location.x, + y: player.location.y, + z: player.location.z, + dimension: player.dimension.id + } + }; + TABLES.freezes.set(player.id, data); + } +}; + +// src/vendor/Anti-Cheat/modules/commands/freeze.ts +var root3 = new Command({ + name: "freeze", + description: "Manage Freezes", + requires: (player) => ["admin", "moderator"].includes(getRole(player)) +}); +root3.literal({ + name: "add", + description: "Freezes a player" +}).argument(new ArgumentTypes.player("player")).string("reason").executes((ctx, player, reason) => { + new Freeze(player, reason); + ctx.reply( + `\xA7cFroze \xA7f"\xA7a${player.name}\xA7f" Because: "${reason}" \xA7aSuccessfully` + ); + ctx.sender.tell( + `\xA7cYou have been frozen by \xA7f"\xA7a${ctx.sender.name}\xA7f" Because: "${reason}"` + ); +}); +root3.literal({ + name: "remove", + description: "unfreezes a player" +}).argument(new ArgumentTypes.playerName("playerName")).executes((ctx, playerName) => { + const freeze = TABLES.freezes.values().find((freeze2) => freeze2.playerName == playerName); + if (!freeze) + return ctx.reply(`${playerName} is not frozen`); + TABLES.freezes.delete(freeze.key); + ctx.reply(`\xA7a${playerName}\xA7r has been UnFrozen!`); +}); +root3.literal({ + name: "list", + description: "Lists all freezes" +}).executes((ctx) => { + const freezes = TABLES.freezes.values(); + if (freezes.length == 0) + return ctx.sender.tell(`\xA7cNo one is frozen!`); + ctx.sender.tell(`\xA72--- Showing Freezes (${freezes.length}) ---`); + for (const freeze of freezes) { + ctx.sender.tell( + text["commands.freeze.list.player"](freeze.playerName, freeze.reason) + ); + } +}); + +// src/vendor/Anti-Cheat/modules/commands/help.ts +var CommandNameArgumentType = class { + constructor(name) { + this.name = name; + this.typeName = "CommandName"; + } + matches(value) { + return { + success: Boolean( + COMMANDS.find((c) => c.depth == 0 && c.data.name == value) + ), + value + }; + } + fail(value) { + return `"${value}" is not a valid command`; + } +}; +function sendCommandType(baseCommand, args, player) { + player.tell( + `${PREFIX}${baseCommand.data.name} ${args.map( + (a) => a.type.typeName == "literal" ? a.data.name : `<${a.type.name}: ${a.type.typeName}>` + ).join(" ")}` + ); +} +function sendArguments(bc, c, args, p) { + if (!c.data?.requires(p)) + return; + if (c.callback) { + sendCommandType(bc, c.depth == 0 ? args : args.concat(c), p); + } + if (c.children.length > 0) { + for (const child of c.children) { + sendArguments(bc, child, c.depth == 0 ? args : args.concat(c), p); + } + } +} +function sendPageHeader(player, p, maxPages) { + player.tell( + `\xA72--- Showing help page ${p} of ${maxPages} (${PREFIX}help ) ---` + ); +} +function getCommands(player) { + return COMMANDS.filter((c) => { + return c.depth == 0 && c.data?.requires(player); + }); +} +function getMaxPages(player) { + const commands = getCommands(player); + if (commands.length == 0) + return 0; + return Math.ceil(commands.length / 5); +} +var root4 = new Command({ + name: "help", + description: "Provides help/list of commands.", + aliases: ["?", "h"] +}).executes((ctx) => { + const maxPages = getMaxPages(ctx.sender); + const commands = getCommands(ctx.sender).slice(1 * 5 - 5, 1 * 5); + sendPageHeader(ctx.sender, 1, maxPages); + for (const cmd of commands) { + sendArguments(cmd, cmd, [], ctx.sender); + } +}); +root4.int("page").executes((ctx, p) => { + const maxPages = getMaxPages(ctx.sender); + if (p > maxPages) + p = maxPages; + const commands = getCommands(ctx.sender).slice(p * 5 - 5, p * 5); + sendPageHeader(ctx.sender, p, maxPages); + for (const cmd of commands) { + sendArguments(cmd, cmd, [], ctx.sender); + } +}); +root4.argument(new CommandNameArgumentType("command")).executes((ctx, command2) => { + const cmd = COMMANDS.filter( + (c) => c.depth == 0 && c.data.name == command2 + )[0]; + ctx.sender.tell( + `\xA7e${cmd.data.name}: ${cmd.data.aliases ? `aliases (${cmd.data.aliases.join(", ")})` : ""}` + ); + ctx.sender.tell(`\xA7e${cmd.data.description}`); + ctx.sender.tell(`Usage:`); + sendArguments(cmd, cmd, [], ctx.sender); +}); + +// src/vendor/Anti-Cheat/modules/commands/lockdown.ts +import { world as world9 } from "@minecraft/server"; +new Command({ + name: "lockdown", + description: "Toggles the servers lockdown, meaning no one can join", + requires: (player) => getRole(player) == "admin" +}).executes((ctx) => { + if (isLockedDown()) { + setLockDown(false); + ctx.sender.tell(`\xA7aUnlocked the server!`); + } else { + ctx.reply(`\xA7aClose chat to confirm lockdown`); + confirmAction(ctx.sender, text["commands.lockdown.confirm"], () => { + setLockDown(true); + for (const player of world9.getPlayers()) { + if (getRole(player) == "admin") + continue; + kick(player, text["lockdown.kick.message"]()); + } + world9.say(`\xA7l\xA7cServer is now LOCKED!`); + }); + } +}); + +// src/vendor/Anti-Cheat/modules/models/Mute.ts +var Mute = class { + static getMuteData(player) { + return TABLES.mutes.get(player.name); + } + constructor(player, duration, reason = "No Reason", by = "Rubedo Auto Mod") { + const msLength = duration ? durationToMs(duration) : null; + const data = { + playerName: player.name, + date: Date.now(), + duration: msLength, + expire: msLength ? msLength + Date.now() : null, + reason, + by + }; + TABLES.mutes.set(player.name, data); + } +}; + +// src/vendor/Anti-Cheat/modules/commands/mute.ts +var root5 = new Command({ + name: "mute", + description: "Manage Mutes", + requires: (player) => ["admin", "moderator"].includes(getRole(player)) +}); +root5.literal({ + name: "add", + description: "Mutes a player" +}).argument(new ArgumentTypes.player("player")).argument(new ArgumentTypes.duration("duration")).string("reason").executes((ctx, player, duration, reason) => { + new Mute(player, duration, reason, ctx.sender.name); + ctx.reply( + `\xA7cMuted \xA7f"\xA7a${player.name}\xA7f" \xA7cfor ${duration} Because: "${reason}" \xA7aSuccessfully` + ); + player.tell( + `\xA7cYou have been muted by \xA7f"${ctx.sender.name}" \xA7cfor ${duration} Because: "${reason}"` + ); +}); +root5.literal({ + name: "remove", + description: "un-mutes a player" +}).argument(new ArgumentTypes.playerName("playerName")).executes((ctx, playerName) => { + const mute = TABLES.mutes.values().find((mute2) => mute2.playerName == playerName); + if (!mute) + return ctx.reply(`${playerName} is not muted!`); + TABLES.mutes.delete(mute.playerName); + try { + ctx.sender.runCommandAsync(`ability "${playerName}" mute false`); + } catch (error) { + } + ctx.reply(`\xA7a${playerName}\xA7r has been UnMuted!`); +}); +root5.literal({ + name: "list", + description: "Lists all freezes" +}).executes((ctx) => { + const mutes = TABLES.mutes.values(); + if (mutes.length == 0) + return ctx.sender.tell(`\xA7cNo one is muted!`); + ctx.sender.tell(`\xA72--- Showing Mutes (${mutes.length}) ---`); + for (const mute of mutes) { + ctx.sender.tell( + text["commands.mutes.list.player"]( + mute.playerName, + mute.reason, + mute.expire ? msToTime(mute.expire) : "Forever" + ) + ); + } +}); + +// src/vendor/Anti-Cheat/modules/commands/npc.ts +import { Location as Location3 } from "@minecraft/server"; + +// src/vendor/Anti-Cheat/modules/models/Npc.ts +var Npc = class { + static isValid(entity) { + if (entity.typeId != "minecraft:npc") + return false; + if (NPC_LOCATIONS.find((l) => LocationEquals(l, entity.location))) + return true; + return TABLES.npcs.keys().find((key) => entity.id == key) ? true : false; + } + constructor(location, dimension) { + NPC_LOCATIONS.push(location); + const entity = dimension.spawnEntity("minecraft:npc", location); + const data = { + dimension: entity.dimension.id, + x: entity.location.x, + y: entity.location.y, + z: entity.location.z + }; + TABLES.npcs.set(entity.id, data); + clearNpcLocations(); + } +}; + +// src/vendor/Anti-Cheat/modules/commands/npc.ts +new Command({ + name: "npc", + description: "Spawns a npc at your coordinates", + requires: (player) => getRole(player) == "admin" +}).executes((ctx) => { + const { x, y, z } = ctx.sender.location; + new Npc(new Location3(x, y, z), ctx.sender.dimension); + ctx.reply(`Spawned a verified npc at your current location`); +}); + +// src/vendor/Anti-Cheat/modules/commands/ping.ts +import { system as system7 } from "@minecraft/server"; +async function getServerTPS() { + let startTime = Date.now(); + let ticks = 0; + return new Promise((resolve) => { + let s = system7.runSchedule(() => { + if (Date.now() - startTime < 1e3) { + ticks++; + } else { + system7.clearRunSchedule(s); + resolve(ticks); + } + }); + }); +} +new Command({ + name: "ping", + description: "Returns the current Ticks Per Second of the servers ping" +}).executes(async (ctx) => { + let ticks = await getServerTPS(); + ctx.reply( + `\xA7aCurrent Ticks Per Second: ${ticks > 18 ? "\xA7f{ \xA7aGood" : ticks > 13 ? "\xA7f{ \xA7eOk" : "\xA7f{ \xA7cSevere"} ${ticks} \xA7f}` + ); +}); + +// src/vendor/Anti-Cheat/modules/commands/region.ts +import { BlockLocation as BlockLocation5 } from "@minecraft/server"; +var command = new Command({ + name: "region", + description: "Create a Region", + requires: (player) => getRole(player) == "admin" +}); +command.literal({ + name: "add", + description: "Adds a new protection region" +}).int("from_x").int("from_z").int("to_x").int("to_z").executes((ctx, from_x, from_z, to_x, to_z) => { + new Region( + { x: from_x, z: from_z }, + { x: to_x, z: to_z }, + ctx.sender.dimension.id + ); + ctx.reply( + `Created Region From ${from_x} -64 ${from_z} ${to_x} 320 ${to_z}` + ); +}); +command.literal({ + name: "remove", + description: "Removes a region at the players current position" +}).executes((ctx) => { + const loc = new BlockLocation5( + ctx.sender.location.x, + ctx.sender.location.y, + ctx.sender.location.z + ); + const r = Region.removeRegionAtBlockLocation(loc, ctx.sender.dimension.id); + if (r) { + ctx.reply(`Removed Region at ${loc.x} ${loc.y} ${loc.z}`); + } else { + ctx.reply(`Failed to find/remove region at ${loc.x} ${loc.y} ${loc.z}`); + } +}); +command.literal({ + name: "removeAll", + description: "Removes all regions" +}).executes((ctx) => { + Region.getAllRegions().forEach((r) => r.delete()); + ctx.reply(`Removed All regions`); +}); +command.literal({ + name: "list", + description: "Lists all regions and positions" +}).executes((ctx) => { + const regions = Region.getAllRegions(); + for (const region of regions) { + ctx.reply( + `Region from ${region.from.x}, ${region.from.z} to ${region.to.x}, ${region.to.z} in dimension ${region.dimensionId}` + ); + } + if (regions.length == 0) + return ctx.reply(`No regions have been made yet`); +}); +var permission = command.literal({ + name: "permission", + description: "Handles permissions for regions" +}); +permission.literal({ + name: "set", + description: "Sets a certain permission on the region the player is currently in to a value" +}).array("key", ["doorsAndSwitches", "openContainers", "pvp"]).boolean("value").executes((ctx, key, value) => { + const region = Region.blockLocationInRegion( + new BlockLocation5( + ctx.sender.location.x, + ctx.sender.location.y, + ctx.sender.location.z + ), + ctx.sender.dimension.id + ); + if (!region) + return ctx.reply(`You are not in a region`); + region.changePermission(key, value); + ctx.reply(`Changed permission ${key} to ${value}`); +}); +permission.literal({ + name: "list", + description: "Lists the permissions for the current region" +}).executes((ctx) => { + const region = Region.blockLocationInRegion( + new BlockLocation5( + ctx.sender.location.x, + ctx.sender.location.y, + ctx.sender.location.z + ), + ctx.sender.dimension.id + ); + if (!region) + return ctx.reply(`You are not in a region`); + ctx.reply( + `Current region permissions ${JSON.stringify(region.permissions)}` + ); +}); +var entityCommands = permission.literal({ + name: "entities", + description: "Holds the subCommands for adding or removing allowedEntities" +}); +entityCommands.literal({ + name: "add", + description: "Adds a entity to the allowed entities list" +}).string("entity").executes((ctx, entity) => { + const region = Region.blockLocationInRegion( + new BlockLocation5( + ctx.sender.location.x, + ctx.sender.location.y, + ctx.sender.location.z + ), + ctx.sender.dimension.id + ); + if (!region) + return ctx.reply(`You are not in a region`); + const currentAllowedEntities = region.permissions.allowedEntities; + currentAllowedEntities.push(entity); + region.changePermission("allowedEntities", currentAllowedEntities); + ctx.reply( + `Added entity ${entity} to the allowed entities of the region your currently standing in` + ); +}); +entityCommands.literal({ + name: "remove", + description: "Removes a entity from the allowed entities in the region" +}).string("entity").executes((ctx, entity) => { + const region = Region.blockLocationInRegion( + new BlockLocation5( + ctx.sender.location.x, + ctx.sender.location.y, + ctx.sender.location.z + ), + ctx.sender.dimension.id + ); + if (!region) + return ctx.reply(`You are not in a region`); + let currentAllowedEntities = region.permissions.allowedEntities; + if (!currentAllowedEntities.includes(entity)) + return ctx.reply( + `The entity ${entity} is not allowed to enter the region` + ); + currentAllowedEntities = currentAllowedEntities.filter((v) => v != entity); + region.changePermission("allowedEntities", currentAllowedEntities); + ctx.reply( + `Removed entity ${entity} to the allowed entities of the region your currently standing in` + ); +}); + +// src/vendor/Anti-Cheat/types.ts +var ROLES = /* @__PURE__ */ ((ROLES2) => { + ROLES2[ROLES2["member"] = 0] = "member"; + ROLES2[ROLES2["admin"] = 1] = "admin"; + ROLES2[ROLES2["moderator"] = 2] = "moderator"; + ROLES2[ROLES2["builder"] = 3] = "builder"; + return ROLES2; +})(ROLES || {}); + +// src/vendor/Anti-Cheat/modules/commands/role.ts +var StringIsNumber = (value) => isNaN(Number(value)) === false; +function ToArray(enumme) { + return Object.keys(enumme).filter(StringIsNumber).map((key) => enumme[key]); +} +var root6 = new Command({ + name: "role", + description: "Changes the role for a player", + requires: (player) => getRole(player) == "admin" || isServerOwner(player) +}); +root6.literal({ + name: "set", + description: "Sets the role for a player" +}).argument(new ArgumentTypes.playerName("playerName")).argument(new ArgumentTypes.array("role", ToArray(ROLES))).executes((ctx, playerName, role) => { + setRole(playerName, role); + ctx.reply(`Changed role of ${playerName} to ${role}`); +}); +root6.literal({ + name: "get", + description: "Gets the role of a player" +}).argument(new ArgumentTypes.playerName("playerName")).executes((ctx, playerName) => { + const role = getRole(playerName); + ctx.reply(`${playerName} has role: ${role}`); +}); +var ownerRoot = root6.literal({ + name: "owner", + description: "Manages the owner" +}); +ownerRoot.literal({ + name: "get", + description: "Gets the owner of the world" +}).executes((ctx) => { + const ownerId = getServerOwner(); + const ids = TABLES.ids.collection(); + const ownerName = Object.keys(ids).find((key) => ids[key] === ownerId); + ctx.reply(`\xA7aServer Owner: ${ownerName} (id: ${ownerId})`); +}); +ownerRoot.literal({ + name: "transfer", + description: "Transfers the owner of the world", + requires: (player) => isServerOwner(player) +}).argument(new ArgumentTypes.player()).executes((ctx, player) => { + confirmAction( + ctx.sender, + `Are you sure you want to transfer the server ownership to ${player.name}, this action is not reversible!`, + () => { + setServerOwner(player); + ctx.reply( + `\xA7aSet the server Owner to: ${player.name} (id: ${player.id})` + ); + } + ); + ctx.reply(`\xA7aClose chat to confirm`); +}); +ownerRoot.literal({ + name: "clear", + description: "clear's the owner of the world", + requires: (player) => isServerOwner(player) +}).executes((ctx) => { + confirmAction( + ctx.sender, + "Are you sure you want to clear the server owner, this action is not reversible!", + () => { + setServerOwner(null); + ctx.reply( + `\xA7aCleared the server owner! run "/reload" or reload world to run "/function start" again!` + ); + } + ); + ctx.reply(`\xA7aClose chat to confirm`); +}); + +// src/rubedo/lib/Form/Models/ActionForm.ts +import { ActionFormData } from "@minecraft/server-ui"; +var ActionForm = class { + constructor(title, body) { + this.title = title; + this.body = body; + this.form = new ActionFormData(); + if (title) + this.form.title(title); + if (body) + this.form.body(body); + this.buttons = []; + this.triedToShow = 0; + } + addButton(text2, iconPath = null, callback) { + this.buttons.push({ + text: text2, + iconPath, + callback + }); + this.form.button(text2, iconPath); + return this; + } + show(player) { + this.form.show(player).then((response) => { + if (response.canceled) { + if (response.cancelationReason == "userBusy") { + if (this.triedToShow > TIMEOUT_THRESHOLD) + return player.tell( + `\xA7cForm Timeout: tried to show form, but you were busy (close chat after running command)` + ); + this.triedToShow++; + this.show(player); + } + return; + } + this.buttons[response.selection].callback?.(); + }); + } +}; + +// src/rubedo/lib/Form/Models/ModelForm.ts +import { ModalFormData } from "@minecraft/server-ui"; + +// src/rubedo/lib/Form/Models/FormCallback.ts +var FormCallback = class { + constructor(form, player, callback) { + this.form = form; + this.player = player; + this.callback = callback; + } + error(message) { + new MessageForm("Error", message).setButton1("Return to form", () => { + this.form.show(this.player, this.callback); + }).setButton2("Cancel", null).show(this.player); + } +}; + +// src/rubedo/lib/Form/Models/ModelForm.ts +var ModalForm = class { + constructor(title) { + this.title = title; + this.form = new ModalFormData(); + if (title) + this.form.title(title); + this.args = []; + } + addDropdown(label, options, defaultValueIndex) { + this.args.push({ type: "dropdown", options }); + this.form.dropdown(label, options, defaultValueIndex); + return this; + } + addSlider(label, minimumValue, maximumValue, valueStep, defaultValue) { + this.args.push({ type: "slider" }); + this.form.slider( + label, + minimumValue, + maximumValue, + valueStep, + defaultValue + ); + return this; + } + addToggle(label, defaultValue) { + this.args.push({ type: "toggle" }); + this.form.toggle(label, defaultValue); + return this; + } + addTextField(label, placeholderText, defaultValue) { + this.args.push({ type: "textField" }); + this.form.textField(label, placeholderText, defaultValue); + return this; + } + async show(player, callback) { + for (let i = 0; i < TIMEOUT_THRESHOLD; i++) { + let response = await this.form.show(player); + if (response.cancelationReason == "userBusy") + continue; + callback( + new FormCallback(this, player, callback), + ...response.formValues.map( + (v, i2) => this.args[i2].type == "dropdown" ? this.args[i2].options[v] : v + ) + ); + return; + } + return player.tell( + `\xA7cForm Timeout: tried to show form, but you were busy (close chat after running command)` + ); + } +}; + +// src/vendor/Anti-Cheat/modules/forms/settings.ts +function manageBannedItemsForm(player) { + new ActionForm("Manage Banned Items").addButton("Remove a Banned Item", null, () => { + removeBannedItemForm(player); + }).addButton("Ban an item", null, () => { + addBannedItemForm(player); + }).show(player); +} +function removeBannedItemForm(player) { + new ModalForm("Remove Banned Items").addDropdown("Select item to remove", getConfigId("banned_items")).show(player, (ctx, item) => { + let items = getConfigId("banned_items"); + items = items.filter((p) => p != item); + setConfigId("banned_items", items); + player.tell(`Removed Banned item "${item}"`); + }); +} +function addBannedItemForm(player) { + new ModalForm("Add Banned Item").addTextField("Item Id", "minecraft:string").show(player, (ctx, item) => { + let items = getConfigId("banned_items"); + if (items.includes(item)) + return ctx.error(`\xA7cItem "${item}" is already banned`); + items.push(item); + setConfigId("banned_items", items); + player.tell(`Banned the item "${item}"`); + }); +} +function manageBannedBlocksForm(player) { + new ActionForm("Manage Banned Blocks").addButton("Remove a Banned Block", null, () => { + removeBannedBlockForm(player); + }).addButton("Ban an block", null, () => { + addBannedBlockForm(player); + }).show(player); +} +function removeBannedBlockForm(player) { + new ModalForm("Remove Banned Block").addDropdown("Select block to remove", getConfigId("banned_blocks")).show(player, (ctx, block) => { + let blocks = getConfigId("banned_blocks"); + blocks = blocks.filter((p) => p != block); + setConfigId("banned_blocks", blocks); + player.tell(`Removed Banned block "${block}"`); + }); +} +function addBannedBlockForm(player) { + new ModalForm("Add Banned Block").addTextField("Block Id", "minecraft:barrier").show(player, (ctx, block) => { + let blocks = getConfigId("banned_blocks"); + if (blocks.includes(block)) + return ctx.error(`\xA7cBlock "${block}" is already banned`); + blocks.push(block); + setConfigId("banned_blocks", blocks); + player.tell(`Banned the block "${block}"`); + }); +} +function manageEnchantmentLevelsForm(player) { + new ModalForm("Manage Enchantment Levels").addDropdown("Enchantment to change", Object.keys(ENCHANTMENTS), 0).addTextField("Level (number)", "5").show(player, (ctx, enchantment, levelString) => { + if (isNaN(levelString)) + return ctx.error( + `\xA7c"${levelString}" is not a number, please enter a value like, "3", "9", etc.` + ); + const level = parseInt(levelString); + let enchants = getConfigId("enchantments"); + enchants[enchantment] = level; + setConfigId("enchantments", enchants); + player.tell(`Set max level for ${enchantment} to ${level}`); + }); +} +function manageAppealLinkForm(player) { + new ModalForm("Manage Appeal Link").addTextField("Appeal Link", APPEAL_LINK).show(player, (ctx, link) => { + setConfigId("appealLink", link); + player.tell(`Changed the servers appeal link to ${link}`); + }); +} + +// src/vendor/Anti-Cheat/modules/forms/automod.ts +function showAutoModHomeForm(player) { + const form = new ActionForm("Manage Protections"); + for (const protection5 of Object.values(PROTECTIONS)) { + form.addButton(protection5.name, protection5.iconPath, () => { + showProtectionConfig(protection5, player); + }); + } + form.addButton("Back", "textures/ui/arrow_dark_left_stretch.png", () => { + showHomeForm(player); + }).show(player); +} +function showProtectionConfig(protection5, player) { + const data = protection5.getConfig(); + const form = new ModalForm( + `Manage ${protection5.name} Protection Config` + ).addToggle("Enabled", data["enabled"]); + let keys = []; + for (const [key, value] of Object.entries(protection5.configDefault)) { + keys.push(key); + if (typeof value.defaultValue == "boolean") { + form.addToggle(value.description, data[key]); + } else if (typeof value.defaultValue == "number") { + form.addSlider(value.description, 0, 100, 1, data[key]); + } else { + form.addTextField(value.description, null, data[key]); + } + } + form.show(player, (ctx, enabled, ...keys2) => { + if (enabled != data["enabled"]) { + if (enabled) + protection5.enable(); + if (!enabled) + protection5.disable(); + } + let config = { + enabled + }; + for (const [i, key] of Object.keys(protection5.configDefault).entries()) { + config[key] = keys2[i]; + } + protection5.setConfig(config); + player.tell(`Updated config for ${protection5.name}!`); + }); +} + +// src/vendor/Anti-Cheat/modules/forms/home.ts +function showHomeForm(player) { + new ActionForm("Rubedo Settings").addButton("Auto Mod", "textures/ui/permissions_op_crown.png", () => { + showAutoModHomeForm(player); + }).addButton("Banned items", "textures/blocks/sculk_shrieker_top.png", () => { + manageBannedItemsForm(player); + }).addButton("Banned blocks", "textures/blocks/barrier.png", () => { + manageBannedBlocksForm(player); + }).addButton("Enchantments", "textures/items/book_enchanted.png", () => { + manageEnchantmentLevelsForm(player); + }).addButton("Appeal Link", "textures/ui/Feedback.png", () => { + manageAppealLinkForm(player); + }).show(player); +} + +// src/vendor/Anti-Cheat/modules/commands/settings.ts +new Command({ + name: "settings", + description: "Opens up the settings menu for the player", + requires: (player) => ["admin", "moderator"].includes(getRole(player)) +}).executes((ctx) => { + showHomeForm(ctx.sender); + ctx.sender.tell(`\xA7aForm request sent, close chat to continue!`); +}); + +// src/vendor/Anti-Cheat/modules/commands/vanish.ts +import { world as world10 } from "@minecraft/server"; +function vanish(player, say) { + if (player.hasTag(`spectator`)) { + player.runCommandAsync(`gamemode c`); + player.triggerEvent(`removeSpectator`); + player.removeTag(`spectator`); + if (!say) + return; + world10.say({ + rawtext: [ + { + translate: "multiplayer.player.joined", + with: [`\xA7e${player.name}`] + } + ] + }); + } else { + player.runCommandAsync(`gamemode spectator`); + player.triggerEvent(`addSpectator`); + player.addTag(`spectator`); + if (!say) + return; + world10.say({ + rawtext: [ + { + translate: "multiplayer.player.left", + with: [`\xA7e${player.name}`] + } + ] + }); + } +} +new Command({ + name: "vanish", + description: "Toggles Vanish Mode on the sender", + requires: (player) => getRole(player) == "admin" +}).executes((ctx) => { + vanish(ctx.sender, false); +}).boolean("say").executes((ctx, say) => { + vanish(ctx.sender, say); +}); + +// src/rubedo/config/app.ts +var VERSION = "2.6.7-beta"; + +// src/vendor/Anti-Cheat/modules/commands/version.ts +new Command({ + name: "version", + description: "Get Current Rubedo Version", + aliases: ["v"] +}).executes((ctx) => { + ctx.reply(`Current Rubedo Version: ${VERSION}`); +}); + +// src/vendor/Anti-Cheat/modules/commands/kick.ts +new Command({ + name: "kick", + description: "Kicks a player from the game", + requires: (player) => getRole(player) == "admin" +}).argument(new ArgumentTypes.player()).string("reason").executes((ctx, player, reason) => { + kick(player, [reason]); + ctx.reply(`\xA7aKicked ${player.name} from world`); +}); + +// src/vendor/Anti-Cheat/modules/models/Log.ts +var Log = class { + constructor(data) { + this.data = data; + console.warn(`[LOG]: ${data.message}`); + TABLES.logs.set(Date.now().toString(), data); + } +}; + +// src/vendor/Anti-Cheat/modules/commands/log.ts +function timeDifference(previous) { + var msPerMinute = 60 * 1e3; + var msPerHour = msPerMinute * 60; + var msPerDay = msPerHour * 24; + var msPerMonth = msPerDay * 30; + var msPerYear = msPerDay * 365; + var elapsed = Date.now() - previous; + if (elapsed < msPerMinute) { + return Math.round(elapsed / 1e3) + " seconds ago"; + } else if (elapsed < msPerHour) { + return Math.round(elapsed / msPerMinute) + " minutes ago"; + } else if (elapsed < msPerDay) { + return Math.round(elapsed / msPerHour) + " hours ago"; + } else if (elapsed < msPerMonth) { + return "approximately " + Math.round(elapsed / msPerDay) + " days ago"; + } else if (elapsed < msPerYear) { + return "approximately " + Math.round(elapsed / msPerMonth) + " months ago"; + } else { + return "approximately " + Math.round(elapsed / msPerYear) + " years ago"; + } +} +var root7 = new Command({ + name: "log", + description: "Manages the log command", + requires: (player) => getRole(player) == "admin" +}); +root7.literal({ + name: "add", + description: "Adds a new log" +}).string("message").executes((ctx, message) => { + new Log({ message }); + ctx.reply(`\xA7aAdded new log: ${message}`); +}); +root7.literal({ + name: "getAll", + description: "Gets all logs sorted in descending" +}).int("page").array("order", ["ascending", "descending"]).executes((ctx, page, order) => { + const allLogs = Object.entries(TABLES.logs.collection()).sort( + (a, b) => order == "ascending" ? parseInt(b[0]) - parseInt(a[0]) : parseInt(a[0]) - parseInt(b[0]) + ); + if (allLogs.length == 0) + return ctx.reply(`\xA7cNo Logs have been made!`); + const maxPages = Math.ceil(allLogs.length / 8); + if (page > maxPages) + page = maxPages; + ctx.reply( + `\xA72--- Showing logs page ${page} of ${maxPages} (${PREFIX}log getAll ) ---` + ); + for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) { + ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`); + } +}); +root7.literal({ + name: "getPlayersLogs", + description: "Gets all logs associated with a player" +}).argument(new ArgumentTypes.playerName()).int("page").array("order", ["ascending", "descending"]).executes((ctx, playerName, page, order) => { + const allLogs = Object.entries(TABLES.logs.collection()).filter((v) => v[1].playerName == playerName).sort( + (a, b) => order == "ascending" ? parseInt(b[0]) - parseInt(a[0]) : parseInt(a[0]) - parseInt(b[0]) + ); + if (allLogs.length == 0) + return ctx.reply(`\xA7cNo Logs exists for "${playerName}"!`); + const maxPages = Math.ceil(allLogs.length / 8); + if (page > maxPages) + page = maxPages; + ctx.reply( + `\xA72--- Showing logs for "${playerName}" page ${page} of ${maxPages} ---` + ); + for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) { + ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`); + } +}); +root7.literal({ + name: "getProtectionLogs", + description: "Gets all logs associated with a protection" +}).string("protection").int("page").array("order", ["ascending", "descending"]).executes((ctx, protection5, page, order) => { + const allLogs = Object.entries(TABLES.logs.collection()).filter((v) => v[1].protection == protection5).sort( + (a, b) => order == "ascending" ? parseInt(b[0]) - parseInt(a[0]) : parseInt(a[0]) - parseInt(b[0]) + ); + if (allLogs.length == 0) + return ctx.reply(`\xA7cNo Logs exists for protection: "${protection5}"!`); + const maxPages = Math.ceil(allLogs.length / 8); + if (page > maxPages) + page = maxPages; + ctx.reply( + `\xA72--- Showing logs for Protection: "${protection5}" page ${page} of ${maxPages} ---` + ); + for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) { + ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`); + } +}); +root7.literal({ + name: "clearAll", + description: "Clears all logs" +}).executes((ctx) => { + TABLES.logs.clear(); + ctx.reply(`\xA7aCleared All logs!`); +}); + +// src/vendor/Anti-Cheat/modules/commands/teleport.ts +var root8 = new Command({ + name: "teleport", + description: "Teleports entities (players, mobs, etc.).", + aliases: ["tp"], + requires: (player) => getRole(player) == "admin" +}); +root8.argument(new ArgumentTypes.player()).location("destination").executes((ctx, player, destination) => { + player.addTag("skip-movement-check"); + player.teleport(destination, player.dimension, 0, 0); + ctx.reply( + `Teleported ${player.name} to ${destination.x} ${destination.y} ${destination.z}` + ); +}); + +// src/rubedo/lib/Events/forEachPlayer.ts +import { system as system8, world as world11 } from "@minecraft/server"; +var CALLBACKS3 = {}; +EntitiesLoad.subscribe(() => { + system8.runSchedule(() => { + const players = [...world11.getPlayers()]; + for (const [i, player] of players.entries()) { + for (const CALLBACK of Object.values(CALLBACKS3)) { + if (CALLBACK.delay != 0 && system8.currentTick - CALLBACK.lastCall < CALLBACK.delay) + continue; + CALLBACK.callback(player); + if (i == players.length - 1) + CALLBACK.lastCall = system8.currentTick; + } + } + }); +}); +var forEachPlayer = class { + static subscribe(callback, delay = 0) { + const key = Object.keys(CALLBACKS3).length; + CALLBACKS3[key] = { callback, delay, lastCall: 0 }; + return key; + } + static unsubscribe(key) { + delete CALLBACKS3[key]; + } +}; + +// src/vendor/Anti-Cheat/modules/managers/ban.ts +TABLES.bans.onLoad(() => { + forEachPlayer.subscribe((player) => { + try { + const banData = TABLES.bans.get(player.id); + if (!banData) + return; + if (banData.expire && banData.expire < Date.now()) + return TABLES.bans.delete(player.id); + kick( + player, + [ + `\xA7cYou have been banned!`, + `\xA7aReason: \xA7f${banData.reason}`, + `\xA7fExpiry: \xA7b${banData.expire ? msToTime(banData.expire - Date.now()) : "Forever"}`, + `\xA7fAppeal at: \xA7b${getConfigId("appealLink")}` + ], + () => { + console.warn(new Error("Failed to kick player")); + TABLES.bans.delete(player.id); + } + ); + } catch (error) { + console.warn(error + error.stack); + } + }, 100); +}); + +// src/vendor/Anti-Cheat/modules/managers/freeze.ts +import { Location as Location4 } from "@minecraft/server"; +forEachPlayer.subscribe((player) => { + try { + const freezeData = TABLES.freezes.get(player.id); + if (!freezeData) + return player.getComponent("movement").resetToDefaultValue(); + player.getComponent("movement").setCurrent(0); + player.teleport( + new Location4( + freezeData.location.x, + freezeData.location.y, + freezeData.location.z + ), + DIMENSIONS[freezeData.location.dimension], + 0, + 0 + ); + } catch (error) { + } +}, 200); + +// src/rubedo/lib/Events/beforeChat.ts +import { world as world12 } from "@minecraft/server"; +var CALLBACKS4 = {}; +world12.events.beforeChat.subscribe((data) => { + if (data.message.startsWith(PREFIX)) + return; + for (const callback of Object.values(CALLBACKS4)) { + callback.callback(data); + } +}); +var beforeChat = class { + static subscribe(callback) { + const key = Date.now(); + CALLBACKS4[key] = { callback }; + return key; + } + static unsubscribe(key) { + delete CALLBACKS4[key]; + } +}; + +// src/vendor/Anti-Cheat/modules/managers/mute.ts +beforeChat.subscribe((data) => { + const muteData = Mute.getMuteData(data.sender); + if (!muteData) + return; + if (muteData.expire && muteData.expire < Date.now()) + return TABLES.mutes.delete(data.sender.name); + data.cancel = true; + data.sender.tell(text["modules.managers.mute.isMuted"]()); +}); + +// src/vendor/Anti-Cheat/modules/managers/region.ts +import { BlockLocation as BlockLocation6, system as system9, world as world13 } from "@minecraft/server"; +system9.runSchedule(() => { + loadRegionDenys(); +}, 6e3); +world13.events.beforeItemUseOn.subscribe((data) => { + if (["moderator", "admin"].includes(getRole(data.source))) + return; + const region = Region.blockLocationInRegion( + data.blockLocation, + data.source.dimension.id + ); + if (!region) + return; + const block = data.source.dimension.getBlock(data.blockLocation); + if (DOORS_SWITCHES.includes(block.typeId) && region.permissions.doorsAndSwitches) + return; + if (BLOCK_CONTAINERS.includes(block.typeId) && region.permissions.openContainers) + return; + data.cancel = true; +}); +world13.events.beforeExplosion.subscribe((data) => { + for (let i = 0; i < data.impactedBlocks.length; i++) { + const bL = data.impactedBlocks[i]; + let region = Region.blockLocationInRegion(bL, data.dimension.id); + if (region) + return data.cancel = true; + } +}); +world13.events.entitySpawn.subscribe(async ({ entity }) => { + const region = await Region.blockLocationInRegionSync( + new BlockLocation6(entity.location.x, entity.location.y, entity.location.z), + entity.dimension.id + ); + if (!region) + return; + if (region.permissions.allowedEntities.includes(entity.typeId)) + return; + entity.teleport({ x: 0, y: -64, z: 0 }, entity.dimension, 0, 0); + entity.kill(); +}); +EntitiesLoad.subscribe(() => { + system9.runSchedule(async () => { + for (const region of await Region.getAllRegionsSync()) { + for (const entity of DIMENSIONS[region.dimensionId].getEntities({ excludeTypes: region.permissions.allowedEntities })) { + if (!region.entityInRegion(entity)) + continue; + entity.teleport({ x: 0, y: -64, z: 0 }, entity.dimension, 0, 0); + entity.kill(); + } + } + }, 100); +}); +TABLES.regions.onLoad(() => { + forEachPlayer.subscribe((player) => { + for (const region of Region.getAllRegions()) { + if (region.entityInRegion(player)) { + player.addTag(`inRegion`); + if (!region.permissions.pvp) + player.addTag(`region-protected`); + } else { + player.removeTag(`inRegion`); + player.removeTag(`region-protected`); + } + } + }, 5); +}); + +// src/vendor/Anti-Cheat/modules/events/playerSpawn.ts +import { world as world14 } from "@minecraft/server"; +world14.events.playerSpawn.subscribe(({ player }) => { + TABLES.ids.onLoad(() => { + if (isLockedDown() && getRole(player) != "admin") + return kick(player, text["lockdown.kick.message"]()); + if (Mute.getMuteData(player)) + player.runCommandAsync(`ability @s mute true`); + if (!TABLES.ids.has(player.name)) { + TABLES.ids.set(player.name, player.id); + } + const roleToSet = ChangePlayerRoleTask.getPlayersRoleToSet(player.name); + if (roleToSet) + setRole(player, roleToSet); + }); +}); + +// src/vendor/Anti-Cheat/modules/pages/see.ts +import { + Items, + MinecraftItemTypes as MinecraftItemTypes5, + world as world15 +} from "@minecraft/server"; +var FILLABLE_SLOTS = [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44 +]; +function ViewPlayersFill(entity, page, extras) { + const container = entity.getComponent( + "minecraft:inventory" + ).container; + for (let i = 0; i < container.size; i++) { + const slot = page.slots[i]; + if (!slot || !slot.item) { + container.setItem(i, AIR); + continue; + } + container.setItem(i, slot.item.itemStack); + } + for (const [i, player] of [...world15.getPlayers()].entries()) { + const slot = FILLABLE_SLOTS[i]; + const item = new PageItem(MinecraftItemTypes5.skull, { + nameTag: player.name, + data: 3 + }); + container.setItem(slot, item.itemStack); + page.slots[slot] = { + item, + action: (ctx) => { + ctx.PageAction("moderation:see_inventory", { name: player.name }); + } + }; + } +} +function ViewPlayerInventoryFill(entity, page, extras) { + const container = entity.getComponent("minecraft:inventory").container; + for (let i = 0; i < container.size; i++) { + const slot = page.slots[i]; + if (!slot || !slot.item) { + container.setItem(i, AIR); + continue; + } + container.setItem(i, slot.item.itemStack); + } + const player = [...world15.getPlayers()].find((p) => p.name == extras.name); + if (!player) { + const gui = Object.values(CHESTGUIS).find((e2) => e2.entity.id == entity.id); + gui.despawn(); + player.tell(`"${extras.name}" Could not be found, Gui Crashed`); + } + const inventory = player.getComponent("inventory").container; + let used_slots = 0; + for (let i = 0; i < inventory.size; i++) { + const item = inventory.getItem(i); + const slot = FILLABLE_SLOTS[used_slots]; + used_slots++; + if (!item) { + container.setItem(slot, AIR); + continue; + } + container.setItem(slot, item); + page.slots[slot] = { + item: new PageItem( + Items.get(item.typeId), + { amount: item.amount, data: item.data }, + item + ), + action: (ctx) => { + if (i < 9) { + player.runCommandAsync(`replaceitem entity @s slot.hotbar ${i} air`); + } else { + player.runCommandAsync( + `replaceitem entity @s slot.inventory ${i - 9} air` + ); + } + ctx.GiveAction(); + page.slots[slot] = { + item: null, + action: (ctx2) => { + inventory.addItem(ctx2.getItemAdded()); + } + }; + } + }; + } +} +new Page("moderation:see", ViewPlayersFill).setSlots( + [50], + new PageItem(MinecraftItemTypes5.arrow, { + nameTag: "\xA7fBack" + }), + (ctx) => { + ctx.PageAction("home"); + } +).setSlots( + [48], + new PageItem(MinecraftItemTypes5.barrier, { nameTag: "\xA7cClose GUI" }), + (ctx) => { + ctx.CloseAction(); + } +); +new Page("moderation:see_inventory", ViewPlayerInventoryFill).setSlots( + [50], + new PageItem(MinecraftItemTypes5.arrow, { + nameTag: "\xA7fBack" + }), + (ctx) => { + ctx.PageAction("moderation:see"); + } +).setSlots( + [48], + new PageItem(MinecraftItemTypes5.barrier, { nameTag: "\xA7cClose GUI" }), + (ctx) => { + ctx.CloseAction(); + } +); + +// src/vendor/Anti-Cheat/modules/protections/gamemode.ts +import { GameMode as GameMode2, world as world18 } from "@minecraft/server"; + +// src/vendor/Anti-Cheat/modules/models/Protection.ts +import { system as system10, world as world16 } from "@minecraft/server"; +var Protection = class { + constructor(name, description, iconPath, isEnabledByDefault) { + this.name = name; + this.description = description; + this.iconPath = iconPath; + this.isEnabledByDefault = isEnabledByDefault; + this.name = name; + this.description = description; + this.iconPath = iconPath; + this.configDefault = {}; + this.isEnabled = false; + this.isEnabledByDefault = isEnabledByDefault; + this.events = {}; + this.schedules = []; + this.forEachPlayers = []; + PROTECTIONS[this.name] = this; + } + setConfigDefault(data) { + this.configDefault = data; + TABLES.protections.hasSync(this.name).then((v) => { + if (v) + return; + let saveData = { + enabled: true + }; + for (const key of Object.keys(data)) { + saveData[key] = data[key].defaultValue; + } + TABLES.protections.set(this.name, saveData); + }); + return this; + } + getConfig() { + let config = TABLES.protections.get(this.name); + if (!config) + config = { enabled: this.isEnabled }; + return config; + } + async setConfig(data) { + return TABLES.protections.set(this.name, data); + } + triggerChange(enabled) { + if (enabled) { + this.isEnabled = true; + this.onEnableCallback?.(); + for (const [key, value] of Object.entries(this.events)) { + if (value.triggered) + continue; + let callback = world16.events[key].subscribe( + value.callback + ); + value.triggered = true; + value.callback = callback; + } + for (const v of this.forEachPlayers) { + if (v.key) + continue; + let key = forEachPlayer.subscribe(v.callback, v.delay); + v.key = key; + } + for (const v of this.schedules) { + if (v.runScheduleId) + continue; + let runScheduleId = system10.runSchedule(v.callback); + v.runScheduleId = runScheduleId; + } + } else { + this.isEnabled = false; + this.onDisableCallback?.(); + for (const [key, value] of Object.entries(this.events)) { + if (!value.triggered) + continue; + world16.events[key].unsubscribe(value.callback); + value.triggered = false; + } + for (const v of this.forEachPlayers) { + if (!v.key) + continue; + forEachPlayer.unsubscribe(v.key); + v.key = null; + } + for (const v of this.schedules) { + if (!v.runScheduleId) + continue; + system10.clearRunSchedule(v.runScheduleId); + v.runScheduleId = null; + } + } + } + onEnable(callback) { + this.onEnableCallback = callback; + return this; + } + onDisable(callback) { + this.onDisableCallback = callback; + return this; + } + subscribe(id, callback) { + this.events[id] = { + callback, + triggered: false + }; + return this; + } + runSchedule(callback, tickInterval) { + this.schedules.push({ + callback, + tickInterval, + runScheduleId: null + }); + return this; + } + forEachPlayer(callback, delay = 0) { + this.forEachPlayers.push({ + callback, + delay, + key: null + }); + return this; + } + enable() { + this.triggerChange(true); + } + disable() { + this.triggerChange(false); + } +}; + +// src/rubedo/database/types/PlayerLog.ts +import { world as world17 } from "@minecraft/server"; +var PlayerLog = class { + constructor() { + this.data = /* @__PURE__ */ new Map(); + this.events = { + playerLeave: world17.events.playerLeave.subscribe( + (data) => this.data.delete(data.playerName) + ) + }; + } + set(player, value) { + this.data.set(player.name, value); + } + get(player) { + return this.data.get(player.name); + } + has(player) { + return this.data.has(player.name); + } + delete(player) { + this.data.delete(player.name); + } + clear() { + this.data.clear(); + } + playerNames() { + return [...this.data.keys()]; + } + includes(player) { + return this.playerNames().includes(player.name); + } +}; + +// src/vendor/Anti-Cheat/modules/protections/gamemode.ts +var ILLEGAL_GAMEMODE = GameMode2.creative; +var ViolationCount = new PlayerLog(); +var protection = new Protection( + "gamemode", + "Blocks illegal gamemode", + "textures/ui/creative_icon.png", + true +).setConfigDefault({ + clearPlayer: { + description: "Whether to clear players inventory.", + defaultValue: true + }, + setToSurvival: { + description: "If player should be set to survival after being flagged.", + defaultValue: true + }, + banPlayer: { + description: "If player should be banned after violation count is met.", + defaultValue: false + }, + violationCount: { + description: "The amount of violations before ban.", + defaultValue: 0 + } +}); +protection.runSchedule(() => { + const config = protection.getConfig(); + for (const player of world18.getPlayers({ gameMode: ILLEGAL_GAMEMODE })) { + if (["moderator", "admin", "builder"].includes(getRole(player))) + continue; + try { + if (config.setToSurvival) + player.runCommandAsync(`gamemode s`); + if (config.clearPlayer) + player.runCommandAsync(`clear @s`); + } catch (error) { + } + new Log({ + playerName: player.name, + protection: "Gamemode", + message: `${player.name} has entered into a illegal gamemode!` + }); + const count = (ViolationCount.get(player) ?? 0) + 1; + ViolationCount.set(player, count); + if (config.banPlayer && count >= config.violationCount) + new Ban(player, null, "Illegal Gamemode"); + } +}, 20); + +// src/vendor/Anti-Cheat/modules/protections/movement.ts +import { + MinecraftBlockTypes as MinecraftBlockTypes5, + MinecraftEffectTypes, + MinecraftItemTypes as MinecraftItemTypes6, + Player as Player13, + system as system13 +} from "@minecraft/server"; + +// src/rubedo/lib/Events/onPlayerMove.ts +import { system as system11, world as world19 } from "@minecraft/server"; +var CALLBACKS5 = {}; +function vector3Equals(from, to) { + if (from.x != to.x) + return false; + if (from.y != to.y) + return false; + if (from.z != to.z) + return false; + return true; +} +var playerLocation = new PlayerLog(); +system11.runSchedule(() => { + const sendCallback2 = (player, data) => { + for (const callback of Object.values(CALLBACKS5)) { + callback.callback(player, data); + } + }; + for (const player of world19.getPlayers()) { + const oldLocation = playerLocation.get(player); + if (oldLocation) { + if (vector3Equals(player.location, oldLocation.location)) { + continue; + } + } + playerLocation.set(player, { + location: player.location, + dimension: player.dimension, + currentTick: system11.currentTick + }); + if (!oldLocation) + continue; + sendCallback2(player, oldLocation); + } +}); +var onPlayerMove = class { + static subscribe(callback) { + const key = Date.now(); + CALLBACKS5[key] = { callback }; + return key; + } + static unsubscribe(key) { + delete CALLBACKS5[key]; + } + static delete(player) { + playerLocation.delete(player); + } +}; + +// src/vendor/Anti-Cheat/config/movement.ts +var MOVEMENT_DISTANCE_THRESHOLD = 0.6; +var MOVEMENT_CONSTANTS = { + walk: { + velocity: 0.17, + distance: 0.23 + }, + run: { + velocity: 0.19, + distance: 0.35 + } +}; +var SPEED_EFFECT_INCREASE = 0.056; +var ANTI_TP_DISTANCE_THRESHOLD = 10; +var TAGS = ["gliding", "riding"]; +var DIMENSION_SWITCH_Y = 32767.001953125; +var RIPTIDE_TIMEOUT = 60; + +// src/rubedo/lib/Events/beforeBlockBreak.ts +import { + world as world20, + Location as Location5, + system as system12 +} from "@minecraft/server"; +var CALLBACKS6 = {}; +world20.events.blockBreak.subscribe((data) => { + for (const callback of Object.values(CALLBACKS6)) { + callback.callback( + new BeforeBlockBreakEvent( + data.block, + data.brokenBlockPermutation, + data.dimension, + data.player + ) + ); + } +}); +var beforeBlockBreak = class { + static subscribe(callback) { + const key = Date.now(); + CALLBACKS6[key] = { callback }; + return key; + } + static unsubscribe(key) { + delete CALLBACKS6[key]; + } +}; +var BeforeBlockBreakEvent = class { + constructor(block, brokenBlockPermutation, dimension, player) { + this.block = block; + this.brokenBlockPermutation = brokenBlockPermutation; + this.dimension = dimension; + this.player = player; + this.block = block; + this.brokenBlockPermutation = brokenBlockPermutation; + this.dimension = dimension; + this.player = player; + } + set cancel(value) { + this.dimension.getBlock(this.block.location).setPermutation(this.brokenBlockPermutation.clone()); + if (API_CONTAINERS.includes(this.brokenBlockPermutation.type.id)) { + const OLD_INVENTORY = CONTAINER_LOCATIONS[JSON.stringify(this.block.location)]; + if (OLD_INVENTORY) { + OLD_INVENTORY.load(this.block.getComponent("inventory").container); + } + } + system12.run(() => { + [ + ...this.dimension.getEntities({ + maxDistance: 2, + type: "minecraft:item", + location: new Location5( + this.block.location.x, + this.block.location.y, + this.block.location.z + ) + }) + ].forEach((e2) => e2.kill()); + }); + } +}; + +// src/vendor/Anti-Cheat/modules/protections/nuker.ts +var log = new PlayerLog(); +var IMPOSSIBLE_BREAK_TIME = 15; +var VALID_BLOCK_TAGS = [ + "snow", + "lush_plants_replaceable", + "azalea_log_replaceable", + "minecraft:crop", + "fertilize_area", + "plant" +]; +var IMPOSSIBLE_BREAKS = [ + "minecraft:water", + "minecraft:flowing_water", + "minecraft:lava", + "minecraft:flowing_lava", + "minecraft:bedrock" +]; +var ViolationCount2 = new PlayerLog(); +var beforeBlockBreakKey = null; +var protection2 = new Protection( + "nuker", + "Blocks block breaking too fast", + "textures/blocks/dirt.png", + true +).setConfigDefault({ + banPlayer: { + description: "If the player should be banned once violation count is met", + defaultValue: false + }, + violationCount: { + description: "Violations before ban", + defaultValue: 0 + } +}); +protection2.onEnable(() => { + const config = protection2.getConfig(); + beforeBlockBreakKey = beforeBlockBreak.subscribe((data) => { + if (["moderator", "admin"].includes(getRole(data.player))) + return; + if (data.block.getTags().some((tag) => VALID_BLOCK_TAGS.includes(tag))) + return; + const old = log.get(data.player); + log.set(data.player, Date.now()); + if (!old) + return; + if (!IMPOSSIBLE_BREAKS.includes(data.block.typeId)) { + if (old < Date.now() - IMPOSSIBLE_BREAK_TIME) + return; + const count = (ViolationCount2.get(data.player) ?? 0) + 1; + ViolationCount2.set(data.player, count); + if (config.banPlayer && count >= config.violationCount) + new Ban(data.player, null, "Using Nuker"); + } + data.cancel = true; + }); +}).onDisable(() => { + beforeBlockBreak.unsubscribe(beforeBlockBreakKey); +}); + +// src/vendor/Anti-Cheat/modules/protections/movement.ts +var violations = new PlayerLog(); +var ON_RIPTIDE_TIMEOUT = new PlayerLog(); +function distanceBetween(loc1, loc2) { + return Math.hypot(loc2.x - loc1.x, loc2.z - loc1.z); +} +function getSpeedOffset(player) { + const speed = player.getEffect(MinecraftEffectTypes.speed)?.amplifier ?? 0; + return speed * SPEED_EFFECT_INCREASE; +} +function isDistanceFlag(distance, tick, player) { + const speedIntensity = getSpeedOffset(player); + const ticks = system13.currentTick - tick; + const offset = MOVEMENT_CONSTANTS.run.distance + MOVEMENT_DISTANCE_THRESHOLD; + return distance / ticks > speedIntensity + offset; +} +function flag(player, old) { + const violationCount = (violations.get(player) ?? 0) + 1; + violations.set(player, violationCount); + onPlayerMove.delete(player); + if (violationCount < 3) + return; + player.teleport( + old.location, + old.dimension, + player.rotation.x, + player.rotation.y + ); +} +function flagPhase(player) { + const blockIn = player.dimension.getBlock( + vector3ToBlockLocation(player.location) + ); + if (blockIn.getTags().some((tag) => VALID_BLOCK_TAGS.includes(tag))) + return; + if (blockIn.type.id.endsWith("grass")) + return; + if (blockIn.type.id.endsWith("water")) + return; + if (blockIn.type.id.endsWith("lava")) + return; + if (blockIn.type.id.endsWith("portal")) + return; + if (blockIn.type.id.endsWith("gateway")) + return; + if (blockIn.typeId != MinecraftBlockTypes5.air.id && !blockIn.type.canBeWaterlogged) + return true; +} +var onPlayerMoveSubKey = null; +var protection3 = new Protection( + "movement", + "Blocks illegal movements on players", + "textures/ui/move.png", + false +).setConfigDefault({ + tpCheck: { + description: "If teleports should be flagged", + defaultValue: true + } +}); +protection3.onEnable(() => { + const config = protection3.getConfig(); + onPlayerMoveSubKey = onPlayerMove.subscribe((player, old) => { + if (getRole(player) == "admin") + return; + if (player.dimension.id != old.dimension.id) + return; + if (player.getTags().some((tag) => TAGS.includes(tag))) + return; + const distance = distanceBetween(player.location, old.location); + if (player.hasTag(`skip-movement-check`)) + return player.removeTag(`skip-movement-check`); + if (old.location.y == DIMENSION_SWITCH_Y) + return; + if (ON_RIPTIDE_TIMEOUT.has(player)) + return; + if (flagPhase(player)) + return flag(player, old); + if (distance > ANTI_TP_DISTANCE_THRESHOLD) { + if (!config.tpCheck) + return; + flag(player, old); + } else { + if (!isDistanceFlag(distance, old.currentTick, player)) + return; + flag(player, old); + } + }); +}).onDisable(() => { + onPlayerMove.unsubscribe(onPlayerMoveSubKey); +}); +protection3.subscribe("dataDrivenEntityTriggerEvent", (data) => { + if (!(data.entity instanceof Player13)) + return; + if (data.id != "on_death") + return; + const player = data.entity; + system13.run(() => { + onPlayerMove.delete(player); + }); +}); +protection3.subscribe("projectileHit", ({ projectile, source }) => { + if (projectile.typeId != MinecraftItemTypes6.enderPearl.id) + return; + if (!(source instanceof Player13)) + return; + onPlayerMove.delete(source); +}); +protection3.subscribe("itemCompleteCharge", ({ itemStack, source }) => { + if (itemStack.typeId != MinecraftItemTypes6.chorusFruit.id) + return; + if (!(source instanceof Player13)) + return; + onPlayerMove.delete(source); +}); +protection3.subscribe("itemReleaseCharge", ({ itemStack, source }) => { + if (itemStack.typeId != MinecraftItemTypes6.trident.id) + return; + if (!(source instanceof Player13)) + return; + ON_RIPTIDE_TIMEOUT.set(source, true); + system13.runSchedule(() => { + ON_RIPTIDE_TIMEOUT.delete(source); + }, RIPTIDE_TIMEOUT); +}); + +// src/vendor/Anti-Cheat/modules/protections/spam.ts +var previousMessage = new PlayerLog(); +var ViolationCount3 = new PlayerLog(); +var protection4 = new Protection( + "spam", + "Blocks spam in chat", + "textures/ui/mute_on.png", + false +).setConfigDefault({ + permMutePlayer: { + description: "If player should be permanently muted once violation count is met.", + defaultValue: false + }, + violationCount: { + description: "Violation count before permanent mute", + defaultValue: 0 + }, + repeatedMessages: { + description: "Blocks repeated messages", + defaultValue: true + }, + zalgo: { + description: "Blocks zalgo", + defaultValue: true + } +}); +protection4.subscribe("beforeChat", (data) => { + try { + if (data.message.startsWith(PREFIX)) + return; + if (["admin", "moderator"].includes(getRole(data.sender))) + return; + const config = protection4.getConfig(); + const isSpam = () => { + const count = (ViolationCount3.get(data.sender) ?? 0) + 1; + ViolationCount3.set(data.sender, count); + if (config.permMutePlayer && count >= config.violationCount) + new Mute(data.sender, null, "Spamming"); + }; + if (config.repeatedMessages && previousMessage.get(data.sender) == data.message) { + data.cancel = true; + isSpam(); + return data.sender.tell(`\xA7cRepeated message detected!`); + } + if (config.zalgo && /%CC%/g.test(encodeURIComponent(data.message))) { + data.cancel = true; + isSpam(); + return data.sender.tell( + `\xA7cYou message contains some type of zalgo and cannot be sent!` + ); + } + previousMessage.set(data.sender, data.message); + } catch (error) { + console.warn(error + error.stack); + } +}); + +// src/vendor/Anti-Cheat/modules/events/beforeDataDrivenEntityTriggerEvent.ts +import { MinecraftEffectTypes as MinecraftEffectTypes2, Player as Player14, world as world21 } from "@minecraft/server"; +var e = world21.events.beforeDataDrivenEntityTriggerEvent.subscribe((data) => { + if (!(data.entity instanceof Player14)) + return; + if (data.id != "rubedo:becomeAdmin") + return; + data.entity.removeTag("CHECK_PACK"); + const serverOwnerName = getServerOwnerName(); + if (serverOwnerName) { + data.entity.playSound("note.bass"); + data.entity.tell( + `\xA7cFailed to give server owner: "${serverOwnerName}" is already owner!` + ); + return world21.events.beforeDataDrivenEntityTriggerEvent.unsubscribe(e); + } + setRole(data.entity, "admin"); + setServerOwner(data.entity); + data.entity.addEffect(MinecraftEffectTypes2.blindness, 3, 255, true); + data.entity.tell( + `\xA7aYou have now been set as the "owner" of this server. The command "/function start" will not do anything anymore, type "-help" for more information!` + ); +}); + +// src/vendor/Anti-Cheat/modules/events/worldInitialize.ts +import { + DynamicPropertiesDefinition as DynamicPropertiesDefinition2, + MinecraftEntityTypes, + world as world22 +} from "@minecraft/server"; + +// src/rubedo/config/objectives.ts +var OBJECTIVES = []; + +// src/vendor/Anti-Cheat/modules/events/worldInitialize.ts +world22.events.worldInitialize.subscribe(({ propertyRegistry }) => { + let def2 = new DynamicPropertiesDefinition2(); + def2.defineString("role", 30); + propertyRegistry.registerEntityTypeDynamicProperties( + def2, + MinecraftEntityTypes.player + ); + let def3 = new DynamicPropertiesDefinition2(); + def3.defineString("worldsOwner", 100); + def3.defineBoolean("isLockDown"); + propertyRegistry.registerWorldDynamicProperties(def3); + for (const obj of OBJECTIVES) { + world22.scoreboard.addObjective(obj.objective, obj.displayName ?? ""); + } +}); + +// src/vendor/Anti-Cheat/index.ts +var NPC_LOCATIONS = []; +function clearNpcLocations() { + NPC_LOCATIONS = []; +} + +// src/vendor/import.ts +console.warn(`----- Importing Plugins -----`); + +// src/index.ts +system14.events.beforeWatchdogTerminate.subscribe((data) => { + data.cancel = true; + console.warn(`WATCHDOG TRIED TO CRASH = ${data.terminateReason}`); +}); //# sourceMappingURL=index.js.map diff --git a/scripts/index.js.map b/scripts/index.js.map index d6b1037..7749a94 100644 --- a/scripts/index.js.map +++ b/scripts/index.js.map @@ -1,7 +1,7 @@ { "version": 3, - "sources": ["../src/index.ts", "../src/rubedo/lib/Command/index.ts", "../src/rubedo/config/commands.ts", "../src/rubedo/lib/Command/ArgumentTypes.ts", "../src/rubedo/database/Database.ts", "../src/rubedo/config/database.ts", "../src/rubedo/lib/Events/EntitiesLoad.ts", "../src/utils.ts", "../src/rubedo/lib/Command/Callback.ts", "../src/rubedo/lib/Command/utils.ts", "../src/rubedo/lib/Chest GUI/index.ts", "../src/rubedo/config/chest.ts", "../src/rubedo/lib/Chest GUI/Models/EntityChest.ts", "../src/rubedo/lib/Events/onSlotChange.ts", "../src/rubedo/lib/Chest GUI/utils.ts", "../src/rubedo/lib/Chest GUI/Models/ItemGrabbedCallback.ts", "../src/rubedo/lib/Chest GUI/Models/PageItem.ts", "../src/rubedo/lib/Chest GUI/Models/FillTypes.ts", "../src/rubedo/lib/Chest GUI/Models/Page.ts", "../src/rubedo/lib/Chest GUI/pages/home.ts", "../src/vendor/Anti-Cheat/utils.ts", "../src/vendor/Anti-Cheat/modules/models/Region.ts", "../src/vendor/Anti-Cheat/config/region.ts", "../src/vendor/Anti-Cheat/tables.ts", "../src/vendor/Anti-Cheat/modules/models/Task.ts", "../src/vendor/Anti-Cheat/config/moderation.ts", "../src/vendor/Anti-Cheat/config/enchantments.ts", "../src/rubedo/database/index.ts", "../src/rubedo/lib/Containers/index.ts", "../src/rubedo/config/containers.ts", "../src/rubedo/lib/Containers/Container.ts", "../src/vendor/Anti-Cheat/protections.ts", "../src/vendor/Anti-Cheat/modules/models/Ban.ts", "../src/rubedo/lib/Form/Models/MessageForm.ts", "../src/rubedo/lib/Form/utils.ts", "../src/rubedo/lib/Command/Command.ts", "../src/rubedo/lang/text.ts", "../src/rubedo/lib/Form/Models/ActionForm.ts", "../src/rubedo/lib/Form/Models/ModelForm.ts", "../src/rubedo/lib/Form/Models/FormCallback.ts", "../src/vendor/Anti-Cheat/modules/commands/ban.ts", "../src/vendor/Anti-Cheat/modules/commands/database.ts", "../src/vendor/Anti-Cheat/modules/commands/ecwipe.ts", "../src/vendor/Anti-Cheat/modules/models/Freeze.ts", "../src/vendor/Anti-Cheat/modules/commands/freeze.ts", "../src/vendor/Anti-Cheat/modules/commands/help.ts", "../src/vendor/Anti-Cheat/modules/commands/lockdown.ts", "../src/vendor/Anti-Cheat/modules/models/Mute.ts", "../src/vendor/Anti-Cheat/modules/commands/mute.ts", "../src/vendor/Anti-Cheat/modules/commands/npc.ts", "../src/vendor/Anti-Cheat/modules/models/Npc.ts", "../src/vendor/Anti-Cheat/modules/commands/ping.ts", "../src/vendor/Anti-Cheat/modules/commands/region.ts", "../src/vendor/Anti-Cheat/types.ts", "../src/vendor/Anti-Cheat/modules/commands/role.ts", "../src/vendor/Anti-Cheat/modules/forms/settings.ts", "../src/vendor/Anti-Cheat/modules/forms/automod.ts", "../src/vendor/Anti-Cheat/modules/forms/home.ts", "../src/vendor/Anti-Cheat/modules/commands/settings.ts", "../src/vendor/Anti-Cheat/modules/commands/vanish.ts", "../src/rubedo/config/app.ts", "../src/vendor/Anti-Cheat/modules/commands/version.ts", "../src/vendor/Anti-Cheat/modules/commands/kick.ts", "../src/vendor/Anti-Cheat/modules/models/Log.ts", "../src/vendor/Anti-Cheat/modules/commands/log.ts", "../src/vendor/Anti-Cheat/modules/commands/teleport.ts", "../src/rubedo/lib/Events/forEachPlayer.ts", "../src/vendor/Anti-Cheat/modules/managers/ban.ts", "../src/vendor/Anti-Cheat/modules/managers/freeze.ts", "../src/rubedo/lib/Events/beforeChat.ts", "../src/vendor/Anti-Cheat/modules/managers/mute.ts", "../src/vendor/Anti-Cheat/modules/managers/region.ts", "../src/vendor/Anti-Cheat/modules/events/playerJoin.ts", "../src/vendor/Anti-Cheat/modules/pages/see.ts", "../src/vendor/Anti-Cheat/modules/protections/cbe.ts", "../src/vendor/Anti-Cheat/modules/models/Protection.ts", "../src/vendor/Anti-Cheat/modules/protections/crasher.ts", "../src/vendor/Anti-Cheat/modules/protections/gamemode.ts", "../src/rubedo/database/types/PlayerLog.ts", "../src/rubedo/lib/Events/beforeBlockBreak.ts", "../src/vendor/Anti-Cheat/modules/protections/nuker.ts", "../src/vendor/Anti-Cheat/modules/protections/spam.ts", "../src/vendor/Anti-Cheat/modules/protections/unobtainable.ts", "../src/vendor/Anti-Cheat/modules/protections/nbt.ts", "../src/vendor/Anti-Cheat/modules/protections/movement.ts", "../src/rubedo/lib/Events/onPlayerMove.ts", "../src/vendor/Anti-Cheat/config/movement.ts", "../src/vendor/Anti-Cheat/modules/events/beforeDataDrivenEntityTriggerEvent.ts", "../src/vendor/Anti-Cheat/modules/events/worldInitialize.ts", "../src/rubedo/config/objectives.ts", "../src/vendor/Anti-Cheat/index.ts", "../src/vendor/import.ts"], - "sourcesContent": ["import { system } from \"@minecraft/server\";\nimport \"./rubedo/lib/Command/index\";\nimport \"./rubedo/lib/Chest GUI/index\";\nimport \"./rubedo/database/index\";\nimport \"./rubedo/lib/Containers/index\";\nimport \"./vendor/import\";\n\nsystem.events.beforeWatchdogTerminate.subscribe((data) => {\n data.cancel = true;\n console.warn(`WATCHDOG TRIED TO CRASH = ${data.terminateReason}`);\n});\n", "import { BeforeChatEvent, world } from \"@minecraft/server\";\r\nimport { PREFIX } from \"../../config/commands\";\r\nimport type { Command } from \"./Command\";\r\nimport {\r\n commandNotFound,\r\n commandSyntaxFail,\r\n getChatAugments,\r\n noPerm,\r\n sendCallback,\r\n} from \"./utils\";\r\n\r\n/**\r\n * An array of all active commands\r\n */\r\nexport const COMMANDS: Command[] = [];\r\n\r\nworld.events.beforeChat.subscribe((data) => {\r\n if (!data.message.startsWith(PREFIX)) return; // This is not a command\r\n data.cancel = true;\r\n const args = getChatAugments(data.message, PREFIX);\r\n const command = COMMANDS.find(\r\n (c) =>\r\n c.depth == 0 &&\r\n (c.data.name == args[0] || c.data?.aliases?.includes(args[0]))\r\n );\r\n const event = {\r\n message: data.message,\r\n sendToTargets: data.sendToTargets,\r\n sender: data.sender,\r\n targets: data.targets,\r\n } as BeforeChatEvent;\r\n if (!command) return commandNotFound(data.sender, args[0]);\r\n if (!command.data?.requires(data.sender))\r\n return noPerm(event.sender, command);\r\n args.shift(); // Remove first command so we can look at args\r\n // Check Args/SubCommands for errors\r\n const verifiedCommands: Command[] = [];\r\n const getArg = (start: Command, i: number): string => {\r\n if (start.children.length > 0) {\r\n const arg = start.children.find((v) => v.type.matches(args[i]).success);\r\n if (!arg && !args[i] && start.callback) return;\r\n if (!arg)\r\n return commandSyntaxFail(event.sender, command, start, args, i), \"fail\";\r\n if (!arg.data?.requires(event.sender))\r\n return noPerm(event.sender, arg), \"fail\";\r\n verifiedCommands.push(arg);\r\n return getArg(arg, i + 1);\r\n }\r\n };\r\n let v = getArg(command, 0);\r\n if (v == \"fail\") return;\r\n sendCallback(args, verifiedCommands, event, command);\r\n});\r\n", "/*\n|--------------------------------------------------------------------------\n| Command Prefix\n|--------------------------------------------------------------------------\n|\n| This is the prefix of the commands that are send in chat\n| changing this changes what people have to type in before using\n| a command for instance: -help. (-) is the command prefix.\n|\n*/\nexport const PREFIX = \"-\";\n", "import { Player, world } from \"@minecraft/server\";\r\nimport { Database } from \"../../database/Database\";\r\n\r\n/**\r\n * Fetch an online players data\r\n */\r\nexport function fetch(playerName: string): Player | null {\r\n return [...world.getPlayers()].find((player) => player.name === playerName);\r\n}\r\n\r\nexport interface IArgumentReturnData {\r\n /**\r\n * If this argument matches the value\r\n */\r\n success: boolean;\r\n /**\r\n * The parsed value that should be passed in command callback\r\n * if there is no return type this will be null\r\n */\r\n value?: T;\r\n}\r\n\r\nexport abstract class IArgumentType {\r\n /**\r\n * The return type\r\n */\r\n type: any;\r\n /**\r\n * The name that the help for this command will see\r\n * @example \"string\"\r\n * @example \"Location\"\r\n * @example \"int\"\r\n * @example \"number\"\r\n * @example \"UnitType\"\r\n */\r\n typeName: string;\r\n /**\r\n * The name this argument is\r\n */\r\n name: string = \"name\";\r\n /**\r\n * Checks if a value matches this argument type, also\r\n * returns the corresponding type\r\n */\r\n matches(value: string): IArgumentReturnData {\r\n return { success: true };\r\n }\r\n /**\r\n * the fail message that should be sent if player fails to meet the matches criteria\r\n * @param value value that was sent\r\n * @returns what would happen if you didn't enter the right value\r\n */\r\n fail(value: string): string {\r\n return `Value must be of type string!`;\r\n }\r\n constructor(name: string = \"any\") {}\r\n}\r\n\r\nexport class LiteralArgumentType implements IArgumentType {\r\n type: null;\r\n typeName = \"literal\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: this.name == value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `${value} should be ${this.name}!`;\r\n }\r\n constructor(public name: string = \"literal\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class StringArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"string\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: value && value != \"\",\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `Value must be of type string!`;\r\n }\r\n constructor(public name: string = \"string\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class IntegerArgumentType implements IArgumentType {\r\n type: number;\r\n typeName = \"int\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: !isNaN(value as any),\r\n value: parseInt(value),\r\n };\r\n }\r\n fail(value: string): string {\r\n return `Value must be valid number!`;\r\n }\r\n constructor(public name: string = \"integer\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class FloatArgumentType implements IArgumentType {\r\n type: number;\r\n typeName = \"float\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: Boolean(value?.match(/^\\d+\\.\\d+$/)?.[0]),\r\n value: parseInt(value),\r\n };\r\n }\r\n fail(value: string): string {\r\n return `Value must be valid float!`;\r\n }\r\n constructor(public name: string = \"float\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class LocationArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"location\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: /^([~^]{0,1}(-\\d)?(\\d*)?(\\.(\\d+))?)$/.test(value),\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `Value needs to be a valid number, value can include: [~,^]`;\r\n }\r\n constructor(public name: string = \"location\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class BooleanArgumentType implements IArgumentType {\r\n type: boolean;\r\n typeName = \"boolean\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: Boolean(value?.match(/^(true|false)$/)?.[0]),\r\n value: value == \"true\" ? true : false,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `\"${value}\" can be either \"true\" or \"false\"`;\r\n }\r\n constructor(public name: string = \"boolean\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class PlayerArgumentType implements IArgumentType {\r\n type: Player;\r\n typeName = \"Player\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: fetch(value) ? true : false,\r\n value: fetch(value),\r\n };\r\n }\r\n fail(value: string): string {\r\n return `player: \"${value}\", is not in this world`;\r\n }\r\n constructor(public name: string = \"player\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class TargetArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"Target\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: Boolean(value?.match(/^(@.|\"[\\s\\S]+\")$/)?.[0]),\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `${value} is not a valid target`;\r\n }\r\n constructor(public name: string = \"target\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class ArrayArgumentType>\r\n implements IArgumentType\r\n{\r\n type: T[number];\r\n typeName = \"string\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: this.types.includes(value),\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `\"${value}\" must be one of these values: ${this.types.join(\" | \")}`;\r\n }\r\n constructor(public name: string = \"array\", public types: T) {\r\n this.name = name;\r\n this.types = types;\r\n\r\n this.typeName = types.join(\" | \").replace(/(.{25})..+/, \"$1...\");\r\n }\r\n}\r\n\r\nexport class DurationArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"Duration\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: /^(\\d+[hdysmw],?)+$/.test(value),\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `\"${value}\" must be a value like \"10d\" or \"3s\" the first part is the length second is unit`;\r\n }\r\n constructor(public name: string) {}\r\n}\r\n\r\nexport class PlayerNameArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"playerName\";\r\n matches(value: string): IArgumentReturnData {\r\n const db = new Database(\"ids\");\r\n const player = db.get(value);\r\n return {\r\n success: player ? true : false,\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `player: \"${value}\" has never played this world before! Tip: if the name has spaces in it use quotes around name!`;\r\n }\r\n constructor(public name: string = \"playerName\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport const ArgumentTypes = {\r\n string: StringArgumentType,\r\n int: IntegerArgumentType,\r\n float: FloatArgumentType,\r\n location: LocationArgumentType,\r\n boolean: BooleanArgumentType,\r\n player: PlayerArgumentType,\r\n target: TargetArgumentType,\r\n array: ArrayArgumentType,\r\n duration: DurationArgumentType,\r\n playerName: PlayerNameArgumentType,\r\n};\r\n", "import { Entity, ItemStack, MinecraftItemTypes } from \"@minecraft/server\";\nimport {\n ENTITY_IDENTIFIER,\n ENTITY_LOCATION,\n INVENTORY_SIZE,\n MAX_DATABASE_STRING_SIZE,\n} from \"../config/database\";\nimport { EntitiesLoad } from \"../lib/Events/EntitiesLoad\";\nimport { DIMENSIONS, chunkString } from \"../../utils\";\n\nexport class Database {\n /**\n * Creates a table entity that is used for data storage\n * @param tableName\n * @param index if not specified no index will be set\n * @returns\n */\n static createTableEntity(tableName: string, index?: number): Entity {\n const entity = DIMENSIONS.overworld.spawnEntity(\n ENTITY_IDENTIFIER,\n ENTITY_LOCATION\n );\n entity.setDynamicProperty(\"tableName\", tableName);\n entity.nameTag = `\u00A7aDatabase Table: ${tableName}\u00A7r`;\n if (index) entity.setDynamicProperty(\"index\", index);\n return entity;\n }\n\n /**\n * Gets all table Entities associated with this tableName\n * @param tableName\n * @returns\n */\n static getTableEntities(tableName: string): Entity[] {\n return DIMENSIONS.overworld\n .getEntitiesAtBlockLocation(ENTITY_LOCATION)\n .filter(\n (e) =>\n e.typeId == ENTITY_IDENTIFIER &&\n e.getDynamicProperty(\"tableName\") == tableName\n );\n }\n\n /**\n * Data saved in memory\n */\n private MEMORY: { [key in Key]: Value } | null;\n\n /**\n * List of queued tasks on this table\n */\n private QUEUE: Array<() => void>;\n\n constructor(public tableName: string) {\n this.tableName = tableName;\n this.MEMORY = null;\n this.QUEUE = [];\n EntitiesLoad.subscribe(async () => {\n await this.initData();\n this.QUEUE.forEach((v) => v());\n });\n }\n\n /**\n * Adds a queue task to be awaited\n * @returns once its this items time to run in queue\n */\n private async addQueueTask(): Promise {\n return new Promise((resolve) => {\n this.QUEUE.push(resolve);\n });\n }\n\n /**\n * Saves data into this database\n * @param data\n * @returns once data is saved\n */\n private async saveData(): Promise {\n if (!this.MEMORY) await this.addQueueTask();\n\n let entities = Database.getTableEntities(this.tableName);\n /**\n * The split chunks of the stringified data, This is done because we can\n * only store {@link MAX_DATABASE_STRING_SIZE} chars in a single nameTag\n */\n let chunks = chunkString(\n JSON.stringify(this.MEMORY),\n MAX_DATABASE_STRING_SIZE\n );\n /**\n * The amount of entities that is needed to store {@link chunks} data\n */\n const entitiesNeeded =\n Math.ceil(chunks.length / INVENTORY_SIZE) - entities.length;\n if (entitiesNeeded > 0) {\n for (let i = 0; i < entitiesNeeded; i++) {\n entities.push(Database.createTableEntity(this.tableName));\n }\n }\n\n let chunkIndex = 0;\n for (const [i, entity] of entities.entries()) {\n const inventory = entity.getComponent(\"inventory\").container;\n while (chunkIndex < chunks.length && inventory.size > 0) {\n let item = new ItemStack(MinecraftItemTypes.acaciaBoat);\n item.nameTag = chunks[chunkIndex];\n inventory.setItem(i, item);\n chunkIndex++;\n }\n // Set all unUsed slots to air\n for (let i = inventory.size; i < INVENTORY_SIZE; i++) {\n inventory.setItem(i, new ItemStack(MinecraftItemTypes.stick, 0));\n }\n entity.setDynamicProperty(\"index\", i);\n }\n // Check for unUsed entities and despawn them\n for (let i = entities.length - 1; i >= chunkIndex / INVENTORY_SIZE; i--) {\n entities[i].triggerEvent(\"despawn\");\n }\n }\n\n /**\n * Grabs Data and should only be used on worldLoad\n * @returns\n */\n private async initData(): Promise<{ [key in Key]: Value }> {\n let entities = Database.getTableEntities(this.tableName).sort(\n (a, b) =>\n (a.getDynamicProperty(\"index\") as number) -\n (b.getDynamicProperty(\"index\") as number)\n );\n let stringifiedData: string = \"\";\n for (const entity of entities) {\n const inventory = entity.getComponent(\"inventory\").container;\n for (let i = 0; i < inventory.size; i++) {\n const item = inventory.getItem(i);\n if (!item) continue;\n stringifiedData = stringifiedData + item.nameTag;\n }\n }\n const data = stringifiedData == \"\" ? {} : JSON.parse(stringifiedData);\n this.MEMORY = data;\n return data;\n }\n\n /**\n * Sets a key to a value in this table\n * @param key\n * @param value\n */\n async set(key: Key, value: Value): Promise {\n this.MEMORY[key] = value;\n return this.saveData();\n }\n\n /**\n * Gets a value from this table\n * @param key\n * @returns the keys corresponding key\n */\n get(key: Key): Value {\n if (!this.MEMORY)\n throw new Error(\n \"Entities not loaded! Consider using `getAsync` instead!\"\n );\n return this.MEMORY[key];\n }\n\n /**\n * Gets a value async from this table, this should be used on calls from like\n * entityCreate, system.runSchedule or things that could be before database entities spawn\n * @param key\n * @returns\n */\n async getSync(key: Key): Promise {\n if (this.MEMORY) return this.get(key);\n await this.addQueueTask();\n return this.MEMORY[key];\n }\n\n /**\n * Get all the keys in the table\n * @returns\n */\n keys(): Key[] {\n if (!this.MEMORY)\n throw new Error(\n \"Entities not loaded! Consider using `keysSync` instead!\"\n );\n return Object.keys(this.MEMORY) as Key[];\n }\n\n /**\n * Get all the keys in the table async, this should be used on world load\n * @returns\n */\n async keysSync(): Promise {\n if (this.MEMORY) return this.keys();\n await this.addQueueTask();\n return Object.keys(this.MEMORY) as Key[];\n }\n\n /**\n * Get all the values in the table\n * @returns\n */\n values(): Value[] {\n if (!this.MEMORY)\n throw new Error(\n \"Entities not loaded! Consider using `valuesSync` instead!\"\n );\n return Object.values(this.MEMORY) as Value[];\n }\n\n /**\n * Get all the values in the table async, this should be used on world load\n * @returns\n */\n async valuesSync(): Promise {\n if (this.MEMORY) return this.values();\n await this.addQueueTask();\n return Object.values(this.MEMORY) as Value[];\n }\n\n /**\n * Check if the key exists in the table\n * @param key the key to test\n * @returns\n */\n has(key: Key): boolean {\n if (!this.MEMORY)\n throw new Error(\"Entities not loaded! Consider using `hasSync` instead!\");\n return (Object.keys(this.MEMORY) as Key[]).includes(key);\n }\n\n /**\n * Check if the key exists in the table async, this should be used on worldLoad\n * @param key the key to test\n * @returns\n */\n async hasSync(key: Key): Promise {\n if (this.MEMORY) return this.has(key);\n await this.addQueueTask();\n return (Object.keys(this.MEMORY) as Key[]).includes(key);\n }\n\n /**\n * Gets all the keys and values\n * @returns\n */\n collection(): { [key in Key]: Value } {\n if (!this.MEMORY)\n throw new Error(\n \"Entities not loaded! Consider using `collectionSync` instead!\"\n );\n return this.MEMORY;\n }\n\n /**\n * Gets all the keys and values async, this should be used for grabbingCollection on world load\n * @returns\n */\n async collectionSync(): Promise<{ [key in Key]: Value }> {\n if (this.MEMORY) return this.collection();\n await this.addQueueTask();\n return this.MEMORY;\n }\n\n /**\n * Delete the key from the table\n * @param key the key to delete\n * @returns\n */\n async delete(key: Key): Promise {\n const status = delete this.MEMORY[key];\n await this.saveData();\n return status;\n }\n\n /**\n * Clear everything in the table\n */\n async clear(): Promise {\n this.MEMORY = {} as { [key in Key]: Value };\n return this.saveData();\n }\n}\n", "import { BlockLocation } from \"@minecraft/server\";\n\n/*\n|--------------------------------------------------------------------------\n| Max Database string size\n|--------------------------------------------------------------------------\n|\n| Here is the max database save size meaning when a save gets made\n| it tests the size of that save and splits up the save depending on this\n| Size. It's related to Minecraft's 32k bit limit.\n|\n*/\nexport const MAX_DATABASE_STRING_SIZE = 32000;\n\n/*\n|--------------------------------------------------------------------------\n| Entity Id\n|--------------------------------------------------------------------------\n|\n| This is the entity id of the database this is what stores the information\n| of the database on its nameTag\n|\n*/\nexport const ENTITY_IDENTIFIER = \"rubedo:database\";\n\n/*\n|--------------------------------------------------------------------------\n| Entity Spawn Location\n|--------------------------------------------------------------------------\n|\n| This is the spawn location of the database entities there will be\n| Multiple entities at this location for each chunk\n|\n*/\nexport const ENTITY_LOCATION = new BlockLocation(0, -64, 0);\n\n/*\n|--------------------------------------------------------------------------\n| Entity's INVENTORY_SIZE\n|--------------------------------------------------------------------------\n|\n| The max amount of items this entity can store in its inventory\n|\n*/\nexport const INVENTORY_SIZE = 128;\n", "import { system, world } from \"@minecraft/server\";\r\nimport { DIMENSIONS } from \"../../../utils\";\r\n\r\nconst CALLBACKS: {\r\n [key: number]: () => void;\r\n} = {};\r\n\r\n/**\r\n * If the world is loaded or not\r\n */\r\nexport let ENTITIES_LOADED = false;\r\n\r\nsystem.run(async () => {\r\n try {\r\n await DIMENSIONS.overworld.runCommandAsync(`testfor @a`);\r\n ENTITIES_LOADED = true;\r\n for (const [i, callback] of Object.entries(CALLBACKS)) {\r\n callback();\r\n delete CALLBACKS[i as unknown as number];\r\n }\r\n } catch (error) {\r\n let e = world.events.entityCreate.subscribe((data) => {\r\n system.run(() => {\r\n ENTITIES_LOADED = true;\r\n for (const [i, callback] of Object.entries(CALLBACKS)) {\r\n callback();\r\n delete CALLBACKS[i as unknown as number];\r\n }\r\n world.events.entityCreate.unsubscribe(e);\r\n });\r\n });\r\n }\r\n});\r\n\r\nexport class EntitiesLoad {\r\n static async awaitLoad(): Promise {\r\n if (ENTITIES_LOADED) return;\r\n return new Promise((resolve) => {\r\n EntitiesLoad.subscribe(resolve);\r\n });\r\n }\r\n static subscribe(callback: () => void): number {\r\n if (ENTITIES_LOADED) {\r\n callback();\r\n return;\r\n }\r\n const key = Object.keys(CALLBACKS).length;\r\n CALLBACKS[key] = callback;\r\n return key;\r\n }\r\n\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n", "import {\r\n BlockLocation,\r\n Entity,\r\n Location,\r\n MinecraftDimensionTypes,\r\n system,\r\n Vector3,\r\n world,\r\n} from \"@minecraft/server\";\r\n\r\n/**\r\n * This is to reduce lag when grabbing dimensions keep them set and pre-defined\r\n */\r\nexport const DIMENSIONS = {\r\n overworld: world.getDimension(MinecraftDimensionTypes.overworld),\r\n nether: world.getDimension(MinecraftDimensionTypes.nether),\r\n theEnd: world.getDimension(MinecraftDimensionTypes.theEnd),\r\n \"minecraft:overworld\": world.getDimension(MinecraftDimensionTypes.overworld),\r\n \"minecraft:nether\": world.getDimension(MinecraftDimensionTypes.nether),\r\n \"minecraft:the_end\": world.getDimension(MinecraftDimensionTypes.theEnd),\r\n};\r\n\r\n/**\r\n * Get score of an entity\r\n * @example getScore(Entity, 'Money');\r\n */\r\nexport function getScore(entity: Entity, objective: string): number {\r\n try {\r\n return world.scoreboard.getObjective(objective).getScore(entity.scoreboard);\r\n } catch (error) {\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * sets the score of a name\r\n * @example setScore(\"Smell of curry\", 'Money');\r\n */\r\nexport function setScore(\r\n entityName: string,\r\n objective: string,\r\n value: Number\r\n): void {\r\n try {\r\n DIMENSIONS.overworld.runCommandAsync(\r\n `scoreboard players set \"${entityName}\" ${objective} ${value}`\r\n );\r\n } catch (error) {\r\n console.warn(error + error.stack);\r\n }\r\n}\r\n\r\n/**\r\n * Duration converter\r\n * @param duration time to convert\r\n * @example ```\r\n * durationToMs(\"10s\")\r\n * durationToMs(\"10d,2y\")\r\n * durationToMs(\"5m\")\r\n * durationToMs(\"23ms,10s\")\r\n * ```\r\n */\r\nconst durations: { [unit: string]: number } = {\r\n y: 3.17098e-11,\r\n w: 6.048e8,\r\n d: 8.64e7,\r\n h: 3.6e6,\r\n m: 60000,\r\n s: 1000,\r\n ms: 1,\r\n};\r\n\r\nexport function durationToMs(duration: string): number {\r\n const values: string[] = duration.split(\",\");\r\n let ms = 0;\r\n for (const value of values) {\r\n const length = parseInt(value.match(/\\d+/)[0]);\r\n const unit = value.match(/[a-zA-Z]+/)[0];\r\n if (!durations[unit]) {\r\n throw new Error(`Invalid duration unit: ${unit}`);\r\n }\r\n ms += durations[unit] * length;\r\n }\r\n return ms;\r\n}\r\n\r\n/**\r\n * Converts a date stored in ms to a Date string\r\n * @param duration milliseconds to convert\r\n * @returns Date as a string\r\n */\r\nexport function msToTime(duration: number) {\r\n return new Date(duration).toString();\r\n}\r\n\r\n/**\r\n * Converts a location to a block location\r\n */\r\nexport function vector3ToBlockLocation(loc: Vector3): BlockLocation {\r\n return new BlockLocation(\r\n Math.floor(loc.x),\r\n Math.floor(loc.y),\r\n Math.floor(loc.z)\r\n );\r\n}\r\n\r\n/**\r\n * Sleeps your code\r\n * @param {number} tick time in ticks you want the return to occur\r\n * @returns {Promise}\r\n */\r\nexport function sleep(tick: number): Promise {\r\n return new Promise((resolve) => {\r\n let runScheduleId = system.runSchedule(() => {\r\n resolve();\r\n system.clearRunSchedule(runScheduleId);\r\n }, tick);\r\n });\r\n}\r\n\r\n/**\r\n * Checks if a location equals another location\r\n * @param a first location\r\n * @param b location to test against first\r\n * @returns {boolean} if they locations are the same\r\n */\r\nexport function LocationEquals(\r\n a: Vector3 | Location | BlockLocation,\r\n b: Vector3 | Location | BlockLocation\r\n): boolean {\r\n if (a instanceof BlockLocation || b instanceof BlockLocation) {\r\n return ~~a.x === ~~b.x && ~~a.y === ~~b.y && ~~a.z === ~~b.z;\r\n }\r\n return a.x === b.x && a.y === b.y && a.z === b.z;\r\n}\r\n\r\n/**\r\n * Sorts 3D vectors to a min and max vector\r\n * @param vector1\r\n * @param vector2\r\n * @returns {[Vector3, Vector3]}\r\n */\r\nexport function sort3DVectors(\r\n vector1: Vector3,\r\n vector2: Vector3\r\n): [Vector3, Vector3] {\r\n [vector1.x, vector2.x] = [\r\n Math.min(vector1.x, vector2.x),\r\n Math.max(vector1.x, vector2.x),\r\n ];\r\n [vector1.y, vector2.y] = [\r\n Math.min(vector1.y, vector2.y),\r\n Math.max(vector1.y, vector2.y),\r\n ];\r\n [vector1.z, vector2.z] = [\r\n Math.min(vector1.z, vector2.z),\r\n Math.max(vector1.z, vector2.z),\r\n ];\r\n return [vector1, vector2];\r\n}\r\n/**\r\n * Checks if a target vector is between two vectors\r\n * @param target\r\n * @param vector1\r\n * @param vector2\r\n * @returns\r\n */\r\nexport function betweenVector3(\r\n target: Vector3,\r\n vector1: Vector3,\r\n vector2: Vector3\r\n): boolean {\r\n const [minVector, maxVector] = sort3DVectors(vector1, vector2);\r\n const { x, y, z } = target;\r\n return (\r\n x >= minVector.x &&\r\n x <= maxVector.x &&\r\n y >= minVector.y &&\r\n y <= maxVector.y &&\r\n z >= minVector.z &&\r\n z <= maxVector.z\r\n );\r\n}\r\n\r\n/**\r\n * Splits a string into chunk sizes\r\n */\r\nexport function chunkString(str: string, length: number): string[] {\r\n return str.match(new RegExp(\".{1,\" + length + \"}\", \"g\"));\r\n}\r\n", "import { BeforeChatEvent, Player } from \"@minecraft/server\";\r\n\r\nexport class CommandCallback {\r\n data: BeforeChatEvent;\r\n sender: Player;\r\n\r\n /**\r\n * Returns a commands callback\r\n * @param data chat data that was used\r\n */\r\n constructor(data: BeforeChatEvent) {\r\n this.data = data;\r\n this.sender = data.sender;\r\n }\r\n /**\r\n * Replies to the sender of a command callback\r\n * @param text Message or a lang code\r\n * @example ctx.reply('Hello World!');\r\n */\r\n reply(text: string) {\r\n this.sender.tell(text);\r\n }\r\n}\r\n", "import { BeforeChatEvent, Player, Vector, Vector3 } from \"@minecraft/server\";\nimport { PREFIX } from \"../../config/commands\";\nimport { LiteralArgumentType, LocationArgumentType } from \"./ArgumentTypes\";\nimport { CommandCallback } from \"./Callback\";\nimport type { Command } from \"./Command\";\n\n/**\n * Returns a Before chat events augments\n * @example this.getChatAugments(BeforeChatEvent)\n */\nexport function getChatAugments(\n message: string,\n prefix: string\n): Array {\n try {\n return message\n .slice(prefix.length)\n .trim()\n .match(/\"[^\"]+\"|[^\\s]+/g)\n .map((e) => e.replace(/\"(.+)\"/, \"$1\").toString());\n } catch (error) {\n return [];\n }\n}\n\n/**\n * Sends a command not found message to a player\n * @param player player to send message to\n */\nexport function commandNotFound(player: Player, command: string) {\n player.tell({\n rawtext: [\n {\n text: `\u00A7c`,\n },\n {\n translate: `commands.generic.unknown`,\n with: [`${command}`],\n },\n ],\n });\n}\n\n/**\n * Sends a command not found message to a player\n * @param player player to send message to\n */\nexport function noPerm(player: Player, command: Command) {\n player.tell({\n rawtext: [\n {\n text: command.data.invalidPermission\n ? command.data.invalidPermission\n : `\u00A7cYou do not have permission to use \"${command.data.name}\"`,\n },\n ],\n });\n}\n\n/**\n * Sends a syntax failure message to player\n * @param player\n * @param command\n * @param args\n * @param i\n */\nexport function commandSyntaxFail(\n player: Player,\n baseCommand: Command,\n command: Command,\n args: string[],\n i: number\n) {\n player.tell({\n rawtext: [\n {\n text: `\u00A7c`,\n },\n {\n translate: `commands.generic.syntax`,\n with: [\n `${PREFIX}${baseCommand.data.name} ${args.slice(0, i).join(\" \")}`,\n args[i] ?? \" \",\n args.slice(i + 1).join(\" \"),\n ],\n },\n ],\n });\n if (command.children.length > 1 || !args[i]) {\n // this type could be many things\n const types = command.children.map((c) =>\n c.type instanceof LiteralArgumentType ? c.type.name : c.type?.typeName\n );\n player.tell(\n `\u00A7c\"${args[i] ?? \"undefined\"}\" is not valid! Argument \"${\n [...new Set(command.children.map((c) => c.type.name))][0]\n }\" can be typeof: \"${types.join('\", \"')}\"`\n );\n } else {\n // this type is only 1 thing\n player.tell(`\u00A7c${command.children[0]?.type?.fail(args[i])}`);\n }\n}\n\n/**\n * Returns a location of the inputted argument\n * @example parseLocationArgs([\"~1\", \"3\", \"^7\"], { location: [1,2,3] , viewVector: [1,2,3] })\n */\nexport function parseLocationArgs(\n [x, y, z]: [x: string, y: string, z: string],\n { location, viewVector }: { location: Vector3; viewVector: Vector }\n): Vector3 {\n if (!x || !y || !x) return null;\n const locations = [location.x, location.y, location.z];\n const viewVectors = [viewVector.x, viewVector.y, viewVector.z];\n const a = [x, y, z].map((arg) => {\n const r = parseFloat(arg);\n return isNaN(r) ? 0 : r;\n });\n const b = [x, y, z].map((arg, index) => {\n return arg.includes(\"~\")\n ? a[index] + locations[index]\n : arg.includes(\"^\")\n ? a[index] + viewVectors[index]\n : a[index];\n });\n return { x: b[0], y: b[1], z: b[2] };\n}\n\n/**\n * Sends a callback back to the command\n * @param cmdArgs the args that the command used\n * @param args args to use\n */\nexport function sendCallback(\n cmdArgs: string[],\n args: Command[],\n event: BeforeChatEvent,\n baseCommand: Command\n) {\n const lastArg = args[args.length - 1] ?? baseCommand;\n const argsToReturn: any[] = [];\n for (const [i, arg] of args.entries()) {\n if (arg.type.name.endsWith(\"*\")) continue;\n if (arg.type instanceof LocationArgumentType) {\n argsToReturn.push(\n parseLocationArgs(\n [cmdArgs[i], cmdArgs[i + 1], cmdArgs[i + 2]],\n event.sender\n )\n );\n continue;\n }\n if (arg.type instanceof LiteralArgumentType) continue;\n argsToReturn.push(arg.type.matches(cmdArgs[i]).value ?? cmdArgs[i]);\n }\n lastArg.callback(new CommandCallback(event), ...argsToReturn);\n}\n", "import {\r\n ItemStack,\r\n MinecraftItemTypes,\r\n system,\r\n world,\r\n} from \"@minecraft/server\";\r\nimport { ENTITY_INVENTORY, GUI_ITEM } from \"../../config/chest\";\r\nimport { ChestGUI } from \"./Models/EntityChest\";\r\nimport { CHESTGUIS, getHeldItem } from \"./utils.js\";\r\nimport \"./pages/home\";\r\nimport { DIMENSIONS } from \"../../../utils.js\";\r\nimport { EntitiesLoad } from \"../Events/EntitiesLoad\";\r\nimport { getRole } from \"../../../vendor/Anti-Cheat/utils\";\r\n\r\nexport const AIR = new ItemStack(MinecraftItemTypes.acaciaBoat, 0);\r\n\r\nEntitiesLoad.subscribe(() => {\r\n system.runSchedule(() => {\r\n for (const player of world.getPlayers()) {\r\n /**\r\n * Loop through all players, check if player has a chest gui\r\n * if not create them one\r\n * Once all players are checked verify there are no false entities\r\n */\r\n if (getHeldItem(player)?.typeId != GUI_ITEM) {\r\n if (CHESTGUIS[player.name]) CHESTGUIS[player.name].despawn();\r\n continue;\r\n }\r\n // Player has a item Held we need to verify that they have a gui\r\n if (Object.keys(CHESTGUIS).includes(player?.name)) continue;\r\n // Player does not have a chest gui spawn them in one\r\n if (getRole(player) != \"admin\") continue;\r\n CHESTGUIS[player.name] = new ChestGUI(player);\r\n }\r\n }, 10);\r\n});\r\n\r\n/**\r\n * This system will detect false entities and kill them to\r\n * reduce lag and eliminate broken/left players/entities\r\n */\r\nsystem.runSchedule(() => {\r\n const validIds = Object.values(CHESTGUIS).map((c) => c.entity.id);\r\n for (const entity of DIMENSIONS.overworld.getEntities({\r\n type: ENTITY_INVENTORY,\r\n })) {\r\n if (validIds.includes(entity.id)) continue;\r\n // This entity is not valid so we despawn it\r\n entity.triggerEvent(\"despawn\");\r\n }\r\n}, 100);\r\n", "/*\n|--------------------------------------------------------------------------\n| Gui item\n|--------------------------------------------------------------------------\n|\n| This is the GUI item that is used to open up the gui\n| this is set to the identifier of item.json and is used to find the item\n| in the gui template\n|\n*/\nexport const GUI_ITEM = \"rubedo:gui\";\n\n/*\n|--------------------------------------------------------------------------\n| Entity Inventory\n|--------------------------------------------------------------------------\n|\n| The id of the entity inventory\n| this is found in the entities file\n| this will be updated if inventory entity is changed\n|\n*/\nexport const ENTITY_INVENTORY = \"rubedo:inventory\";\n\n/*\n|--------------------------------------------------------------------------\n| Default Static Page id\n|--------------------------------------------------------------------------\n|\n| This is the default static page id of what is open by default\n| when you click on the gui, this can be changed but it probably shouldn't\n| because static pages will need to be changed\n|\n*/\nexport const DEFAULT_STATIC_PAGE_ID = \"home\";\n", "import { Entity, Player, system } from \"@minecraft/server\";\r\nimport { AIR } from \"../index\";\r\nimport { ENTITY_INVENTORY } from \"../../../config/chest\";\r\nimport {\r\n ISlotChangeReturn,\r\n onEntityInventorySlotChange,\r\n} from \"../../Events/onSlotChange\";\r\nimport {\r\n CHESTGUIS,\r\n clearPlayersPointer,\r\n getItemAtSlot,\r\n PAGES,\r\n} from \"../utils.js\";\r\nimport { ItemGrabbedCallback } from \"./ItemGrabbedCallback\";\r\nimport { ISlot, Page } from \"./Page.js\";\r\n\r\nexport class ChestGUI {\r\n /**\r\n * The connected player to this gui\r\n */\r\n player: Player;\r\n /**\r\n * The entity that this chest gui is associated to\r\n */\r\n entity: Entity;\r\n /**\r\n * The event that is registered on this gui\r\n */\r\n runScheduleId: number;\r\n\r\n /**\r\n * The page that this gui is currently viewing\r\n */\r\n page: Page;\r\n\r\n /**\r\n * The event that is used to test for changes in inventory\r\n */\r\n slotChangeEvent: number;\r\n\r\n /**\r\n * if the player has a chest open\r\n */\r\n hasChestOpen: boolean;\r\n\r\n /**\r\n * Spawns a entity to be attached to the player\r\n * @param player player this entity will be attached to\r\n */\r\n static spawnEntity(player: Player): Entity {\r\n try {\r\n return player.dimension.spawnEntity(\r\n ENTITY_INVENTORY,\r\n player.headLocation\r\n );\r\n } catch (error) {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Links a new chest gui to a player\r\n * @param player player to link\r\n */\r\n constructor(player: Player) {\r\n this.player = player;\r\n this.entity = ChestGUI.spawnEntity(player);\r\n if (this.entity) {\r\n this.hasChestOpen = false;\r\n this.setPage(\"home\");\r\n }\r\n this.runScheduleId = system.runSchedule(() => {\r\n if (!this.entity) return this.despawn();\r\n if (this.player.getComponent(\"mark_variant\").value == 1) {\r\n if (!this.hasChestOpen) {\r\n // Player has this inventory open run checks for changes\r\n this.slotChangeEvent = onEntityInventorySlotChange.subscribe(\r\n { type: ENTITY_INVENTORY },\r\n (entity, change) => {\r\n if (entity.id != this.entity.id) return;\r\n this.onSlotChange(change);\r\n }\r\n );\r\n }\r\n this.hasChestOpen = true;\r\n } else {\r\n // Player does not have inventory open but item is held\r\n try {\r\n this.entity.teleport(\r\n this.player.headLocation,\r\n this.player.dimension,\r\n this.player.rotation.x,\r\n this.player.rotation.y,\r\n true\r\n );\r\n } catch (error) {\r\n this.despawn();\r\n }\r\n }\r\n }, 5);\r\n }\r\n\r\n /**\r\n * Sets this gui to a page of items\r\n * @param pageId page to set this gui too\r\n */\r\n setPage(pageId: string, extras?: any) {\r\n const c = this.entity.getComponent(\"inventory\").container;\r\n for (let i = 0; i < c.size; i++) {\r\n c.setItem(i, AIR);\r\n }\r\n if (!Object.keys(PAGES).includes(pageId))\r\n throw new Error(`pageId ${pageId} does not exist!`);\r\n const page = PAGES[pageId];\r\n this.page = page;\r\n\r\n page.fillType(this.entity, page, extras);\r\n this.entity.nameTag = `size:54`;\r\n }\r\n\r\n /**\r\n * This runs when a slot gets changed in the chest inventory\r\n */\r\n onSlotChange(change: ISlotChangeReturn) {\r\n /**\r\n * The guiItem that was changed\r\n */\r\n const slot: ISlot = this.page.slots[change.slot];\r\n\r\n if (!slot) {\r\n // item was added to page that is not a valid slot so set that slot back to air\r\n this.entity.getComponent(\"inventory\").container.setItem(change.slot, AIR);\r\n } else if (change.changeType == \"delete\") {\r\n // item was taken from this page\r\n if (slot.item) clearPlayersPointer(this.player, change.item);\r\n /**\r\n * if the slot has a item that returns when something is grabbed, this checks\r\n * if there is a item put into the slot to return, if not it will not send a\r\n * callback by returning before\r\n */\r\n if (!slot.item && !getItemAtSlot(this.entity, change.slot)) return;\r\n slot.action(new ItemGrabbedCallback(this, slot, change));\r\n }\r\n }\r\n\r\n /**\r\n * Deletes this gui and despawn its entity\r\n */\r\n despawn() {\r\n try {\r\n this.entity?.triggerEvent(\"despawn\");\r\n } catch (error) {}\r\n try {\r\n delete CHESTGUIS[this.player.name];\r\n } catch (error) {}\r\n if (this.runScheduleId) system.clearRunSchedule(this.runScheduleId);\r\n if (this.slotChangeEvent)\r\n onEntityInventorySlotChange.unsubscribe(this.slotChangeEvent);\r\n }\r\n}\r\n", "import {\r\n Entity,\r\n EntityQueryOptions,\r\n ItemStack,\r\n PlayerInventoryComponentContainer,\r\n system,\r\n} from \"@minecraft/server\";\r\nimport { DIMENSIONS } from \"../../../utils.js\";\r\n\r\ntype onSlotChangeCallback = (entity: Entity, change: ISlotChangeReturn) => void;\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: onSlotChangeCallback;\r\n entities: EntityQueryOptions;\r\n };\r\n} = {};\r\n\r\nconst MAPPED_INVENTORIES: { [key: string]: Array } = {};\r\nexport const PREVIOUS_CHANGE: { [key: string]: ISlotChangeReturn } = {};\r\n\r\nexport interface ISlotChangeReturn {\r\n /**\r\n * Slot that changed\r\n */\r\n slot: number;\r\n /**\r\n * The uid of this item\r\n */\r\n uid: string;\r\n /**\r\n * The old uid of this item\r\n */\r\n oldUid?: string;\r\n /**\r\n * the item that was grabbed / put\r\n */\r\n item: ItemStack;\r\n /**\r\n * The old itemStack that was in this slot\r\n */\r\n oldItem?: ItemStack;\r\n /**\r\n * How the inventory has changed\r\n */\r\n changeType: \"delete\" | \"put\" | \"swap\" | \"fluctuation\" | \"move\";\r\n}\r\n\r\ninterface IMappedInventoryItem {\r\n /**\r\n * a unique id for a itemStack\r\n */\r\n uid: string;\r\n /**\r\n * the item\r\n */\r\n item: ItemStack;\r\n}\r\n\r\n/**\r\n * Finds and returns a slot change in a inventory\r\n */\r\nfunction getSlotChanges(\r\n entity: Entity,\r\n oldInv: Array,\r\n newInv: Array\r\n): Array {\r\n if (oldInv.length != newInv.length) return [];\r\n const changes: Array = [];\r\n for (let i = 0; i < newInv.length; i++) {\r\n if (\r\n oldInv[i]?.item?.amount < newInv[i]?.item?.amount ||\r\n (oldInv[i]?.item?.amount > newInv[i]?.item?.amount &&\r\n oldInv[i]?.item?.amount != 0)\r\n ) {\r\n // Checks if the item is the same but checks if the amount has changed\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: newInv[i].uid,\r\n oldUid: oldInv[i].uid,\r\n item: newInv[i].item,\r\n oldItem: oldInv[i].item,\r\n changeType: \"fluctuation\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n continue;\r\n }\r\n if (newInv[i].uid == oldInv[i].uid) continue; // no change\r\n if (oldInv[i]?.item && newInv[i]?.item) {\r\n // Checks if there was a new item but a new slot was not taken up\r\n // Meaning that the item got used like using a bucket on a cow\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: newInv[i].uid,\r\n oldUid: oldInv[i].uid,\r\n item: newInv[i].item,\r\n oldItem: oldInv[i].item,\r\n changeType: \"swap\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n } else if (!newInv[i]?.item) {\r\n // There is no more item in this slot\r\n // Meaning the item has been moved across slots or been thrown out\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: oldInv[i].uid,\r\n item: oldInv[i].item,\r\n changeType: \"delete\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n } else if (newInv[i]?.item) {\r\n // New item has been added in this slot\r\n if (\r\n PREVIOUS_CHANGE[entity.id]?.changeType == \"delete\" &&\r\n PREVIOUS_CHANGE[entity.id]?.uid == newInv[i].uid\r\n ) {\r\n // item has been moved across slots\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: newInv[i].uid,\r\n item: newInv[i].item,\r\n changeType: \"move\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n continue;\r\n } else {\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: newInv[i].uid,\r\n item: newInv[i].item,\r\n changeType: \"put\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n }\r\n }\r\n }\r\n return changes;\r\n}\r\n\r\n/**\r\n * Converts a itemStack to a unique id\r\n * @param {ItemStack} item\r\n * @returns {string}\r\n */\r\nexport function getItemUid(item: ItemStack): string {\r\n if (!item) return \"\";\r\n const data = [];\r\n data.push(item.typeId);\r\n data.push(item.nameTag);\r\n data.push(item.data);\r\n data.push(item.getLore().join(\"\"));\r\n return data.join(\"\");\r\n}\r\n\r\n/**\r\n * Gets an entity's inventory but with mapped data\r\n */\r\nfunction mapInventory(\r\n container: PlayerInventoryComponentContainer\r\n): Array {\r\n const inventory = [];\r\n\r\n for (let i = 0; i < container.size; i++) {\r\n let item = container.getItem(i);\r\n inventory[i] = {\r\n uid: getItemUid(item),\r\n item: item,\r\n };\r\n }\r\n return inventory;\r\n}\r\n\r\nsystem.runSchedule(() => {\r\n for (const callback of Object.values(CALLBACKS)) {\r\n for (const entity of DIMENSIONS.overworld.getEntities(callback.entities)) {\r\n const inventory = mapInventory(\r\n entity.getComponent(\"inventory\").container\r\n );\r\n const changes = getSlotChanges(\r\n entity,\r\n MAPPED_INVENTORIES[entity.id] ?? inventory,\r\n inventory\r\n );\r\n MAPPED_INVENTORIES[entity.id] = inventory;\r\n if (changes.length == 0) continue;\r\n if (entity.hasTag(\"skipCheck\")) {\r\n entity.removeTag(\"skipCheck\");\r\n delete PREVIOUS_CHANGE[entity.id];\r\n continue;\r\n }\r\n for (const change of changes) {\r\n callback.callback(entity, change);\r\n }\r\n }\r\n }\r\n}, 5);\r\n\r\nexport class onEntityInventorySlotChange {\r\n /**\r\n * Subscribes to a callback to get notified when a entities inventory changes\r\n * @param callback what to be called when one of these entities inventory's changes\r\n * @param entities the entity's to grab from\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(\r\n entities: EntityQueryOptions,\r\n callback: onSlotChangeCallback\r\n ): number {\r\n const key = Date.now();\r\n CALLBACKS[key] = { callback: callback, entities: entities };\r\n return key;\r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n", "import { Entity, ItemStack, Location, Player } from \"@minecraft/server\";\r\nimport type { ChestGUI } from \"./Models/EntityChest\";\r\nimport type { Page } from \"./Models/Page\";\r\n\r\n/**\r\n * This will link a players name to a chest gui instance\r\n */\r\nexport const CHESTGUIS: { [key: string]: ChestGUI } = {};\r\n\r\n/**\r\n * This will link a players name to a chest gui instance\r\n */\r\nexport const PAGES: { [key: string]: Page } = {};\r\n\r\n/**\r\n * Gets a players held item\r\n */\r\nexport function getHeldItem(player: Player): ItemStack {\r\n const inventory = player.getComponent(\"minecraft:inventory\").container;\r\n return inventory.getItem(player.selectedSlot);\r\n}\r\n\r\n/**\r\n * Clears the player of a item in there pointer slot\r\n */\r\nexport async function clearPlayersPointer(\r\n player: Player,\r\n ItemToClear: ItemStack\r\n) {\r\n try {\r\n const inventory = player.getComponent(\"minecraft:inventory\").container;\r\n let itemsToLoad = [];\r\n for (let i = 0; i < inventory.size; i++) {\r\n const item = inventory.getItem(i);\r\n if (!item) continue;\r\n if (item?.typeId == ItemToClear?.typeId) {\r\n itemsToLoad.push({ slot: i, item: item });\r\n inventory.setItem;\r\n if (i < 9) {\r\n player.runCommandAsync(`replaceitem entity @s slot.hotbar ${i} air`);\r\n } else {\r\n player.runCommandAsync(\r\n `replaceitem entity @s slot.inventory ${i - 9} air`\r\n );\r\n }\r\n }\r\n }\r\n await player.runCommandAsync(\r\n `clear @s ${ItemToClear?.typeId} ${ItemToClear.data} ${ItemToClear.amount}`\r\n );\r\n for (const item of itemsToLoad) {\r\n inventory.setItem(item.slot, item.item);\r\n }\r\n } catch (error) {\r\n // the item couldn't be cleared that means\r\n // they now have a item witch is really BAD\r\n [\r\n ...player.dimension.getEntities({\r\n type: \"minecraft:item\",\r\n location: new Location(\r\n player.location.x,\r\n player.location.y,\r\n player.location.z\r\n ),\r\n maxDistance: 2,\r\n closest: 1,\r\n }),\r\n ].forEach((e) => e.kill());\r\n }\r\n}\r\n\r\n/**\r\n * Gets an item at slot\r\n */\r\nexport function getItemAtSlot(entity: Entity, slot: number): ItemStack | null {\r\n const inventory = entity.getComponent(\"minecraft:inventory\").container;\r\n return inventory.getItem(slot);\r\n}\r\n", "import {\n ActionFormData,\n MessageFormData,\n ModalFormData,\n ActionFormResponse,\n ModalFormResponse,\n MessageFormResponse,\n} from \"@minecraft/server-ui\";\nimport { ChestGUI } from \"./EntityChest\";\nimport { ItemStack } from \"@minecraft/server\";\nimport type { ISlot } from \"./Page\";\nimport type { ISlotChangeReturn } from \"../../Events/onSlotChange\";\nimport { sleep } from \"../../../../utils\";\nimport { ItemDatabase } from \"../../../database/types/Item\";\n\ntype FormActionReturn = T extends ActionFormData\n ? Promise\n : T extends ModalFormData\n ? Promise\n : Promise;\n\nexport class ItemGrabbedCallback {\n gui: ChestGUI;\n slot: ISlot;\n change: ISlotChangeReturn;\n /**\n * New Callback\n */\n constructor(gui: ChestGUI, slot: ISlot, change: ISlotChangeReturn) {\n this.gui = gui;\n this.slot = slot;\n this.change = change;\n }\n\n /**\n * Messages to the owner of this gui\n * @example ctx.reply('Hello World!');\n */\n message(text: string) {\n this.gui.player.tell(text);\n }\n\n /**\n * Gets the item added\n */\n getItemAdded(): ItemStack | null {\n if (this.slot.item) return null;\n return this.gui.entity\n .getComponent(\"minecraft:inventory\")\n .container.getItem(this.change.slot);\n }\n\n /**\n * Gives the player the item the grabbed\n */\n GiveAction(item: ItemStack = this.slot.item.itemStack) {\n this.gui.player.getComponent(\"minecraft:inventory\").container.addItem(item);\n }\n\n /**\n * Gives the player the item that was grabbed also removes this item from the gui + db\n * @param db the item database to remove this item from\n */\n TakeAction(db: ItemDatabase = null) {\n this.gui.player\n .getComponent(\"minecraft:inventory\")\n .container.addItem(this.slot.item.itemStack);\n this.gui.page.slots[this.change.slot] = null;\n if (!db) return;\n db.delete(this.slot.item.components.dbKey);\n }\n\n /**\n * Changes the page of the chestGui when this item is grabbed\n * @param page page to send to\n * @param extras stuff to be passed onto the page\n */\n PageAction(page: string, extras?: any) {\n this.gui.setPage(page, extras);\n }\n\n /**\n * Closes the chest GUI when this item is grabbed\n */\n CloseAction() {\n this.gui.despawn();\n }\n\n /**\n * Sets the item back\n */\n SetAction() {\n const container = this.gui.entity.getComponent(\n \"minecraft:inventory\"\n ).container;\n container.setItem(this.change.slot, this.slot.item.itemStack);\n }\n\n /**\n * Opens a form to the player\n * @param {ActionFormData | ModalFormData | MessageFormData} form form to load\n * @returns {Promise}\n */\n async FormAction(\n form: T\n ): Promise> {\n this.CloseAction();\n await sleep(5);\n // @ts-ignore\n return await form.show(this.gui.player);\n }\n}\n", "import {\r\n Enchantment,\r\n EnchantmentList,\r\n ItemStack,\r\n ItemType,\r\n} from \"@minecraft/server\";\r\n\r\ninterface IPageItemComponents {\r\n /**\r\n * Number of the items in the stack. Valid values range between 0 and 64.\r\n */\r\n amount?: number;\r\n /**\r\n * A data value used to configure alternate states of the item.\r\n */\r\n data?: number;\r\n /**\r\n * Given name of this stack of items.\r\n */\r\n nameTag?: string;\r\n /**\r\n * a secondary display string - for an ItemStack.\r\n */\r\n loreList?: string[];\r\n /**\r\n * a collection of the enchantments on this item\r\n */\r\n enchantments?: Enchantment[];\r\n /**\r\n * A key that could be on this item, meaning its connect to database\r\n */\r\n dbKey?: string;\r\n}\r\n\r\nexport class PageItem {\r\n /**\r\n * The item type this item has\r\n */\r\n itemType: ItemType;\r\n /**\r\n * The components that this item\r\n * this stores information such as data, enchantments etc\r\n */\r\n components: IPageItemComponents;\r\n\r\n /**\r\n * The itemStack that was set at item creation\r\n */\r\n setItemStack: ItemStack | null;\r\n\r\n constructor(\r\n itemType: ItemType,\r\n components: IPageItemComponents = {},\r\n itemStack?: ItemStack\r\n ) {\r\n this.itemType = itemType;\r\n this.components = components;\r\n this.setItemStack = itemStack;\r\n }\r\n /**\r\n * gets itemStack that this PageItem is associated with\r\n */\r\n get itemStack(): ItemStack {\r\n if (this.setItemStack) return this.setItemStack;\r\n const itemStack = new ItemStack(this.itemType);\r\n if (this.components) {\r\n itemStack.amount = this.components?.amount ?? 1;\r\n itemStack.data = this.components?.data ?? 0;\r\n itemStack.nameTag = this.components?.nameTag;\r\n itemStack.setLore(this.components?.loreList ?? []);\r\n const enchantments: EnchantmentList =\r\n itemStack.getComponent(\"enchantments\").enchantments;\r\n for (const enchantment of this.components?.enchantments ?? []) {\r\n enchantments.addEnchantment(enchantment);\r\n }\r\n itemStack.getComponent(\"enchantments\").enchantments = enchantments;\r\n }\r\n return itemStack;\r\n }\r\n}\r\n", "import { Entity } from \"@minecraft/server\";\nimport { AIR } from \"../index\";\nimport { Page } from \"./Page.js\";\n\nexport type FillTypeCallback = (\n entity: Entity,\n page: Page,\n extras: any\n) => void;\n\n/**\n * Fills a entity with desired items\n */\nexport function DefaultFill(entity: Entity, page: Page, extras: any) {\n const container = entity.getComponent(\"minecraft:inventory\").container;\n for (let i = 0; i < container.size; i++) {\n const slot = page.slots[i];\n if (!slot || !slot.item) {\n container.setItem(i, AIR);\n continue;\n }\n container.setItem(i, slot.item.itemStack);\n }\n}\n", "import { PAGES } from \"../utils.js\";\r\nimport { DefaultFill, FillTypeCallback } from \"./FillTypes\";\r\nimport { ItemGrabbedCallback } from \"./ItemGrabbedCallback.js\";\r\nimport type { PageItem } from \"./PageItem\";\r\n\r\nexport interface ISlot {\r\n /**\r\n * The item that should be in this slot\r\n */\r\n item: PageItem;\r\n /**\r\n * What happens when there is a change in this slot\r\n */\r\n action: (ctx: ItemGrabbedCallback) => void;\r\n}\r\n\r\nexport class Page {\r\n /**\r\n * The id this page has\r\n */\r\n id: string;\r\n /**\r\n * How this page fills, these can be custom or kept default\r\n */\r\n fillType: FillTypeCallback;\r\n\r\n /**\r\n * The slots in this gui\r\n */\r\n slots: ISlot[];\r\n\r\n constructor(id: string, fillType: FillTypeCallback = DefaultFill) {\r\n if (Object.keys(PAGES).includes(id))\r\n throw new Error(`Page: ${id}, Already exists!`);\r\n this.id = id;\r\n this.fillType = fillType;\r\n this.slots = [];\r\n PAGES[id] = this;\r\n }\r\n\r\n /**\r\n * Sets slots in this page\r\n */\r\n setSlots(\r\n slot: Array,\r\n item: PageItem,\r\n action: (ctx: ItemGrabbedCallback) => void\r\n ): Page {\r\n const data = item ? { item: item, action: action } : null;\r\n for (const i of slot) {\r\n this.slots[i] = data;\r\n }\r\n return this;\r\n }\r\n}\r\n", "import { PageItem } from \"../Models/PageItem.js\";\r\nimport { Page } from \"../Models/Page.js\";\r\nimport { MinecraftItemTypes } from \"@minecraft/server\";\r\n\r\n/**\r\n * The Home page of this GUI this is the most important because\r\n * when the GUI is opened it will open up here, any plugin can\r\n * change this but this is the default screen\r\n */\r\nexport let HOME_PAGE = new Page(\"home\")\r\n .setSlots(\r\n [22],\r\n new PageItem(MinecraftItemTypes.enderChest, {\r\n nameTag: \"\u00A7l\u00A7bInventory Viewer\",\r\n }),\r\n (ctx) => {\r\n ctx.PageAction(\"moderation:see\");\r\n }\r\n )\r\n .setSlots(\r\n [54],\r\n new PageItem(MinecraftItemTypes.barrier, { nameTag: \"\u00A7cClose GUI\" }),\r\n (ctx) => {\r\n ctx.CloseAction();\r\n }\r\n );\r\n", "import {\n world,\n Player,\n BlockLocation,\n MinecraftBlockTypes,\n Enchantment,\n GameMode,\n} from \"@minecraft/server\";\nimport type { ConfigType, ROLES } from \"./types\";\nimport { Region } from \"./modules/models/Region.js\";\nimport { ChangePlayerRoleTask } from \"./modules/models/Task\";\nimport { APPEAL_LINK, BANNED_BLOCKS, BANNED_ITEMS } from \"./config/moderation\";\nimport { ENCHANTMENTS } from \"./config/enchantments\";\nimport { DIMENSIONS } from \"../../utils.js\";\nimport { TABLES } from \"./tables.js\";\n\n/**\n * Kicks a player\n * @param player player who should be kicked\n * @param message the message that should be show to player\n * @param onFail this needs to be used for loops to unregister\n */\nexport function kick(\n player: Player,\n message: Array = [],\n onFail?: () => void\n): void {\n if (isServerOwner(player)) {\n console.warn(`[WARNING]: TRIED TO KICK OWNER`);\n player.tell(`You have been tried to kick, but you cant!`);\n return onFail?.();\n }\n try {\n player.runCommandAsync(`kick \"${player.name}\" \u00A7r${message.join(\"\\n\")}`);\n player.triggerEvent(\"kick\");\n } catch (error) {\n player.triggerEvent(\"kick\");\n if (!/\"statusCode\":-2147352576/.test(error)) return;\n // This function just tried to kick the owner\n if (onFail) onFail();\n }\n}\n\n/**\n * Gets the role of this player\n * @param player player to get role from\n * @example getRole(\"Smell of curry\")\n */\nexport function getRole(player: Player | string): keyof typeof ROLES {\n if (player instanceof Player) {\n return TABLES.roles.get(player.name) ?? \"member\";\n } else {\n return TABLES.roles.get(player) ?? \"member\";\n }\n}\n\n/**\n * Sets the role of this player\n * @example setRole(\"Smell of curry\", \"admin\")\n */\nexport function setRole(\n player: Player | string,\n value: keyof typeof ROLES\n): void {\n if (typeof player == \"string\") {\n // we need to create a task that will update the role for\n // that player when they join\n // also we need to set there db_role back\n TABLES.roles.set(player, value);\n /**\n * If the player is in the game just set it now\n * if they are not in the game we will need to create a task\n * to set there role when they join\n */\n const inGamePlayer = [...world.getPlayers()].find((p) => p.name == player);\n if (inGamePlayer) {\n inGamePlayer.setDynamicProperty(\"role\", value);\n } else {\n new ChangePlayerRoleTask(player, value);\n }\n } else {\n // just change both of them no need for task\n TABLES.roles.set(player.name, value);\n player.setDynamicProperty(\"role\", value);\n }\n}\n\n/**\n * Checks if a player is the owner of this world that was set using `/function`\n * @param player player to test\n * @returns if player is owner\n */\nexport function isServerOwner(player: Player): boolean {\n return world.getDynamicProperty(\"worldsOwner\") == player.id;\n}\n\n/**\n * Gets the server owner\n * @returns server owners id\n */\nexport function getServerOwner(): string | null {\n const id = world.getDynamicProperty(\"worldsOwner\") as string;\n if (!id || id == \"\") return null;\n return id;\n}\n\n/**\n * Gets the server owners name\n * @returns server owners name\n */\nexport function getServerOwnerName(): string | null {\n const ownerId = getServerOwner();\n if (!ownerId) return null;\n const ids = TABLES.ids.collection();\n return Object.keys(ids).find((key) => ids[key] === ownerId);\n}\n\n/**\n * Sets the server owner\n * @param player player to set the server owner too\n */\nexport function setServerOwner(player: Player) {\n if (!player) return world.setDynamicProperty(\"worldsOwner\", \"\");\n world.setDynamicProperty(\"worldsOwner\", player.id.toString());\n}\n\n/**\n * Checks if the server is locked down\n */\nexport function isLockedDown(): boolean {\n return (world.getDynamicProperty(\"isLockDown\") ?? false) as boolean;\n}\n\n/**\n * Sets the server's lock down status\n * @param val if the server is locked down or not\n */\nexport function setLockDown(val: boolean) {\n world.setDynamicProperty(\"isLockDown\", val);\n}\n\n/**\n * Sets Deny blocks at bottom of region every 5 mins\n */\nexport function loadRegionDenys() {\n for (const region of Region.getAllRegions()) {\n const loc1 = new BlockLocation(\n region.from.x,\n region.dimensionId == \"minecraft:overworld\" ? -64 : 0,\n region.from.z\n );\n const loc2 = new BlockLocation(\n region.to.x,\n region.dimensionId == \"minecraft:overworld\" ? -64 : 0,\n region.to.z\n );\n for (const blockLocation of loc1.blocksBetween(loc2)) {\n DIMENSIONS[region.dimensionId as keyof typeof DIMENSIONS]\n .getBlock(blockLocation)\n ?.setType(MinecraftBlockTypes.deny);\n }\n }\n}\n\n/**\n * Grabs config data from the database\n * @param id id to grab\n */\nexport function getConfigId(id: T): ConfigType[T] {\n switch (id) {\n case \"banned_items\":\n return TABLES.config.get(\"banned_items\") ?? BANNED_ITEMS;\n case \"banned_blocks\":\n return TABLES.config.get(\"banned_blocks\") ?? BANNED_BLOCKS;\n case \"enchantments\":\n return TABLES.config.get(\"enchantments\") ?? ENCHANTMENTS;\n case \"appealLink\":\n return TABLES.config.get(\"appealLink\") ?? APPEAL_LINK;\n }\n}\n\n/**\n * Sets a config id\n * @param key key to set\n * @param value value to set key to\n */\nexport function setConfigId(\n key: T,\n value: ConfigType[T]\n) {\n TABLES.config.set(key, value);\n}\n\n/**\n * Gets the max level of a enchantment\n * @param enchantment enchantment to get\n * @returns max level\n * @example ```\n * getMaxLevel(MinecraftEnchantmentTypes.sharpness): 5\n * ```\n */\nexport function getMaxEnchantmentLevel(enchantment: Enchantment): number {\n const MAX_ENCHANTMENTS = getConfigId(\"enchantments\");\n return (\n MAX_ENCHANTMENTS[enchantment.type.id as keyof typeof ENCHANTMENTS] ??\n enchantment.type.maxLevel\n );\n}\n\n/**\n * Gets the Gamemode of a player\n * @param {Player} player player to get\n * @returns {keyof typeof GameMode}\n * @example if (getGamemode(player) == \"creative\") return;\n */\nexport function getGamemode(player: Player): keyof typeof GameMode {\n return Object.values(GameMode).find(\n (g) => [...world.getPlayers({ name: player.name, gameMode: g })].length\n );\n}\n", "import { BlockLocation, Entity, MinecraftBlockTypes } from \"@minecraft/server\";\nimport { DEFAULT_REGION_PERMISSIONS } from \"../../config/region\";\nimport { TABLES } from \"../../tables.js\";\nimport type { IRegionCords, IRegionPermissions } from \"../../types\";\nimport { loadRegionDenys } from \"../../utils.js\";\nimport { betweenVector3, DIMENSIONS } from \"../../../../utils\";\n\n/**\n * Holds all regions in memory so its not grabbing them so much\n */\nexport let REGIONS: Array = [];\n\n/**\n * If the regions have been grabbed if not it will grab them and set this to true\n */\nlet REGIONS_HAVE_BEEN_GRABBED: boolean = false;\n\n/**\n * The Lowest Y value in minecraft\n */\nconst LOWEST_Y_VALUE: number = -64;\n\n/**\n * The HIGHEST Y value in minecraft\n */\nconst HIGHEST_Y_VALUE: number = 320;\n\nexport class Region {\n dimensionId: string;\n from: IRegionCords;\n to: IRegionCords;\n key: string;\n permissions: IRegionPermissions;\n\n /**\n * Gets all regions\n */\n static async getAllRegionsSync(): Promise> {\n if (REGIONS_HAVE_BEEN_GRABBED) return REGIONS;\n const regions = (await TABLES.regions.valuesSync()).map(\n (region) =>\n new Region(\n region.from,\n region.to,\n region.dimensionId,\n region.permissions,\n region.key\n )\n );\n regions.forEach((r) => {\n REGIONS.push(r);\n });\n REGIONS_HAVE_BEEN_GRABBED = true;\n return regions;\n }\n\n static getAllRegions(): Array {\n if (REGIONS_HAVE_BEEN_GRABBED) return REGIONS;\n const regions = TABLES.regions\n .values()\n .map(\n (region) =>\n new Region(\n region.from,\n region.to,\n region.dimensionId,\n region.permissions,\n region.key\n )\n );\n regions.forEach((r) => {\n REGIONS.push(r);\n });\n REGIONS_HAVE_BEEN_GRABBED = true;\n return regions;\n }\n\n /**\n * Checks if a block location is in region\n */\n static blockLocationInRegion(\n blockLocation: BlockLocation,\n dimensionId: string\n ): Region | undefined {\n return this.getAllRegions().find(\n (region) =>\n region.dimensionId == dimensionId &&\n betweenVector3(\n blockLocation,\n { x: region.from.x, y: LOWEST_Y_VALUE, z: region.from.z },\n { x: region.to.x, y: HIGHEST_Y_VALUE, z: region.to.z }\n )\n );\n }\n\n /**\n * Checks if a block location is in region\n */\n static async blockLocationInRegionSync(\n blockLocation: BlockLocation,\n dimensionId: string\n ): Promise {\n return (await this.getAllRegionsSync()).find(\n (region) =>\n region.dimensionId == dimensionId &&\n betweenVector3(\n blockLocation,\n { x: region.from.x, y: LOWEST_Y_VALUE, z: region.from.z },\n { x: region.to.x, y: HIGHEST_Y_VALUE, z: region.to.z }\n )\n );\n }\n\n /**\n * Removes a region at a block Location\n * @param dimensionId the id of this dimension\n * @returns if the region was removed or not\n */\n static async removeRegionAtBlockLocation(\n blockLocation: BlockLocation,\n dimensionId: string\n ): Promise {\n const region = this.blockLocationInRegion(blockLocation, dimensionId);\n if (!region) return false;\n return TABLES.regions.delete(region.key);\n }\n /**\n * Creates a new Region to store in db\n */\n constructor(\n from: IRegionCords,\n to: IRegionCords,\n dimensionId: string,\n permissions?: IRegionPermissions,\n key?: string\n ) {\n this.from = from;\n this.to = to;\n this.dimensionId = dimensionId;\n this.permissions = permissions ?? DEFAULT_REGION_PERMISSIONS;\n this.key = key ? key : Date.now().toString();\n\n if (!key) {\n this.update().then(() => {\n loadRegionDenys();\n REGIONS.push(this);\n });\n }\n }\n\n /**\n * Updates this region in the database\n */\n async update(): Promise {\n return TABLES.regions.set(this.key, {\n key: this.key,\n from: this.from,\n dimensionId: this.dimensionId,\n permissions: this.permissions,\n to: this.to,\n });\n }\n\n /**\n * removes this region\n * @returns if the region was removed successfully\n */\n async delete(): Promise {\n const region = TABLES.regions.get(this.key);\n const loc1 = new BlockLocation(\n region.from.x,\n region.dimensionId == \"minecraft:overworld\" ? -64 : 0,\n region.from.z\n );\n const loc2 = new BlockLocation(\n region.to.x,\n region.dimensionId == \"minecraft:overworld\" ? -64 : 0,\n region.to.z\n );\n for (const blockLocation of loc1.blocksBetween(loc2)) {\n DIMENSIONS[region.dimensionId as keyof typeof DIMENSIONS]\n .getBlock(blockLocation)\n ?.setType(MinecraftBlockTypes.bedrock);\n }\n REGIONS = REGIONS.filter((r) => r.key != this.key);\n return TABLES.regions.delete(this.key);\n }\n\n /**\n * Checks if a player is in this region\n * @returns if a entity is in this region or not\n */\n entityInRegion(entity: Entity): Boolean {\n return (\n this.dimensionId == entity.dimension.id &&\n betweenVector3(\n entity.location,\n { x: this.from.x, y: LOWEST_Y_VALUE, z: this.from.z },\n { x: this.to.x, y: HIGHEST_Y_VALUE, z: this.to.z }\n )\n );\n }\n\n /**\n * Changes a permission to on or off\n */\n changePermission(\n key: T,\n value: IRegionPermissions[T]\n ): void {\n this.permissions[key] = value;\n this.update();\n }\n}\n", "/**\n * The default permissions for all regions made\n */\nexport const DEFAULT_REGION_PERMISSIONS = {\n /**\n * If players in this region can use doors, trapdoors, and switches like buttons and levers\n */\n doorsAndSwitches: true,\n /**\n * If players in this region can open containers, this is like chests, furnaces, hoppers, etc\n */\n openContainers: true,\n /**\n * If the players in this region can fight each other\n */\n pvp: false,\n /**\n * the entities allowed in this region\n */\n allowedEntities: [\n \"minecraft:player\",\n \"minecraft:npc\",\n \"minecraft:item\",\n \"rubedo:inventory\",\n \"rubedo:database\",\n ],\n};\n\n/**\n * All doors and switches in minecraft\n */\nexport const DOORS_SWITCHES = [\n \"minecraft:acacia_door\",\n \"minecraft:acacia_trapdoor\",\n \"minecraft:acacia_button\",\n \"minecraft:birch_door\",\n \"minecraft:birch_trapdoor\",\n \"minecraft:birch_button\",\n \"minecraft:crimson_door\",\n \"minecraft:crimson_trapdoor\",\n \"minecraft:crimson_button\",\n \"minecraft:dark_oak_door\",\n \"minecraft:dark_oak_trapdoor\",\n \"minecraft:dark_oak_button\",\n \"minecraft:jungle_door\",\n \"minecraft:jungle_trapdoor\",\n \"minecraft:jungle_button\",\n \"minecraft:mangrove_door\",\n \"minecraft:mangrove_trapdoor\",\n \"minecraft:mangrove_button\",\n \"minecraft:spruce_door\",\n \"minecraft:spruce_trapdoor\",\n \"minecraft:spruce_button\",\n \"minecraft:warped_door\",\n \"minecraft:warped_trapdoor\",\n \"minecraft:warped_button\",\n \"minecraft:wooden_door\",\n \"minecraft:wooden_button\",\n \"minecraft:trapdoor\",\n \"minecraft:iron_door\",\n \"minecraft:iron_trapdoor\",\n \"minecraft:polished_blackstone_button\",\n \"minecraft:lever\",\n];\n\n/**\n * A List of all containers a item could be in\n */\nexport const BLOCK_CONTAINERS = [\n \"minecraft:chest\",\n \"minecraft:ender_chest\",\n \"minecraft:barrel\",\n \"minecraft:trapped_chest\",\n \"minecraft:dispenser\",\n \"minecraft:dropper\",\n \"minecraft:furnace\",\n \"minecraft:blast_furnace\",\n \"minecraft:lit_furnace\",\n \"minecraft:lit_blast_furnace\",\n \"minecraft:hopper\",\n \"minecraft:shulker_box\",\n \"minecraft:undyed_shulker_box\",\n \"minecraft:lit_smoker\",\n \"minecraft:smoker\",\n];\n", "import { Database } from \"../../rubedo/database/Database\";\r\nimport {\r\n IBanData,\r\n IFreezeData,\r\n IMuteData,\r\n INpcLocation,\r\n IProtectionsConfig,\r\n IRegionDB,\r\n LogData,\r\n ROLES,\r\n} from \"./types\";\r\n\r\nexport const TABLES = {\r\n config: new Database(\"config\"),\r\n freezes: new Database(\"freezes\"),\r\n mutes: new Database(\"mutes\"),\r\n bans: new Database(\"bans\"),\r\n regions: new Database(\"regions\"),\r\n roles: new Database(\"roles\"),\r\n tasks: new Database(\"tasks\"),\r\n npcs: new Database(\"npcs\"),\r\n ids: new Database(\"ids\"),\r\n logs: new Database(\"logs\"),\r\n protections: new Database(\"protections\"),\r\n};\r\n", "import { TABLES } from \"../../tables.js\";\r\nimport type { IChangePlayerRoleData } from \"../../../../types\";\r\nimport type { ROLES } from \"../../types.js\";\r\n\r\nexport class ChangePlayerRoleTask {\r\n /**\r\n * The name of the player\r\n */\r\n playerName: string;\r\n /**\r\n * The role that the player should be set to\r\n */\r\n role: keyof typeof ROLES;\r\n\r\n /**\r\n * gets all tasks that are present\r\n * @returns all tasks\r\n */\r\n static getTasks(): Array {\r\n return TABLES.tasks.get(\"changePlayerRole\") ?? [];\r\n }\r\n\r\n /**\r\n * Gets the role this player needs to be set to\r\n * @param playerName name\r\n */\r\n static getPlayersRoleToSet(playerName: string): keyof typeof ROLES | null {\r\n const tasks = ChangePlayerRoleTask.getTasks();\r\n return tasks.find((t) => t.playerName == playerName)?.role;\r\n }\r\n\r\n constructor(playerName: string, role: keyof typeof ROLES) {\r\n let tasks = ChangePlayerRoleTask.getTasks();\r\n tasks.push({ playerName: playerName, role: role });\r\n TABLES.tasks.set(\"changePlayerRole\", tasks);\r\n }\r\n}\r\n", "import { MinecraftBlockTypes, MinecraftItemTypes } from \"@minecraft/server\";\n\n/*\n|--------------------------------------------------------------------------\n| Appeal Link\n|--------------------------------------------------------------------------\n|\n| This is the appeal link that gets showed when someone gets banned\n| this link pops up at the bottom of the ban message to show\n| where they can appeal there ban.\n|\n*/\nexport const APPEAL_LINK = \"https://discord.gg/dMa3A5UYKX\";\n\n/**\n * Items that simply get removed from inventory but will not ban\n */\nexport const FORBIDDEN_ITEMS = [\n // Common CBE Items\n MinecraftItemTypes.beehive.id,\n MinecraftItemTypes.beeNest.id,\n MinecraftItemTypes.axolotlBucket.id,\n MinecraftItemTypes.codBucket.id,\n MinecraftItemTypes.tadpoleBucket.id,\n MinecraftItemTypes.tropicalFishBucket.id,\n MinecraftItemTypes.salmonBucket.id,\n MinecraftItemTypes.pufferfishBucket.id,\n];\n\n/**\n * List of items that if you hold you will be automatically banned\n */\nexport const BANNED_ITEMS = [\n // Op Only Items\n MinecraftItemTypes.allow.id,\n MinecraftItemTypes.barrier.id,\n MinecraftItemTypes.borderBlock.id,\n MinecraftItemTypes.debugStick?.id ?? \"minecraft:debug_stick\",\n MinecraftItemTypes.deny.id,\n MinecraftItemTypes.jigsaw.id,\n MinecraftItemTypes.lightBlock.id,\n MinecraftItemTypes.commandBlock.id,\n MinecraftItemTypes.repeatingCommandBlock.id,\n MinecraftItemTypes.chainCommandBlock.id,\n MinecraftItemTypes.commandBlockMinecart.id,\n MinecraftItemTypes.structureBlock.id,\n MinecraftItemTypes.structureVoid.id,\n\n // Not Normal Items\n MinecraftItemTypes.bedrock.id,\n MinecraftItemTypes.endPortalFrame.id,\n\n // Server Movement Blocks\n \"minecraft:info_update\",\n \"minecraft:info_update2\",\n \"minecraft:reserved3\",\n \"minecraft:reserved4\",\n \"minecraft:reserved6\",\n \"minecraft:movingBlock\",\n \"minecraft:moving_block\",\n \"minecraft:movingblock\",\n \"minecraft:piston_arm_collision\",\n \"minecraft:piston_arm_collision\",\n \"minecraft:pistonarmcollision\",\n \"minecraft:stickyPistonArmCollision\",\n \"minecraft:sticky_piston_arm_collision\",\n \"minecraft:unknown\",\n\n // Common Hacked Items\n \"minecraft:glowingobsidian\",\n \"minecraft:invisible_bedrock\",\n \"minecraft:invisiblebedrock\",\n \"minecraft:netherreactor\",\n \"minecraft:portal\",\n \"minecraft:fire\",\n \"minecraft:water\",\n \"minecraft:lava\",\n \"minecraft:flowing_lava\",\n \"minecraft:flowing_water\",\n \"minecraft:soul_fire\",\n];\n\n/**\n * Blocks in this list are forbidden from being placed but will not ban the placer\n */\nexport const FORBIDDEN_BLOCKS = [\n // Common CBE Blocks\n MinecraftBlockTypes.dispenser.id,\n];\n\n/**\n * List of blocks that cannot be placed down\n */\nexport const BANNED_BLOCKS = [\n // Should Not be Placed\n MinecraftBlockTypes.bedrock.id,\n MinecraftBlockTypes.barrier.id,\n \"minecraft:invisiblebedrock\",\n \"minecraft:movingBlock\",\n \"minecraft:movingblock\",\n \"minecraft:moving_block\",\n];\n\n/**\n * A List of containers\n */\nexport const CONTAINERS = [\n MinecraftItemTypes.chest.id,\n MinecraftItemTypes.trappedChest.id,\n MinecraftItemTypes.barrel.id,\n MinecraftItemTypes.dispenser.id,\n MinecraftItemTypes.dropper.id,\n MinecraftItemTypes.furnace.id,\n \"minecraft:lit_furnace\",\n MinecraftItemTypes.blastFurnace.id,\n \"minecraft:lit_blast_furnace\",\n MinecraftItemTypes.smoker.id,\n \"minecraft:lit_smoker\",\n MinecraftItemTypes.hopper.id,\n MinecraftItemTypes.shulkerBox.id,\n MinecraftItemTypes.undyedShulkerBox.id,\n];\n\n\n", "/*\n|--------------------------------------------------------------------------\n| Enchantments\n|--------------------------------------------------------------------------\n|\n| This is the default enchantments that can be added to items\n| each enchantment is set to its desired max level this can be changed here\n| or in game using -config enchantments set \"enchantment\" value\n|\n*/\nexport const ENCHANTMENTS = {\n aquaAffinity: 1,\n baneOfArthropods: 5,\n binding: 1,\n blastProtection: 4,\n channeling: 1,\n depthStrider: 3,\n efficiency: 5,\n featherFalling: 4,\n fireAspect: 2,\n fireProtection: 4,\n flame: 1,\n fortune: 3,\n frostWalker: 2,\n impaling: 5,\n infinity: 1,\n knockback: 2,\n looting: 3,\n loyalty: 4,\n luckOfTheSea: 3,\n lure: 3,\n mending: 1,\n multishot: 1,\n piercing: 4,\n power: 5,\n projectileProtection: 4,\n protection: 4,\n punch: 2,\n quickCharge: 3,\n respiration: 3,\n riptide: 3,\n sharpness: 5,\n silkTouch: 1,\n smite: 5,\n soulSpeed: 3,\n swiftSneak: 4,\n thorns: 3,\n unbreaking: 3,\n vanishing: 1,\n};\n", "import {\r\n DynamicPropertiesDefinition,\r\n EntityTypes,\r\n world,\r\n} from \"@minecraft/server\";\r\nimport { ENTITY_IDENTIFIER, ENTITY_LOCATION } from \"../config/database\";\r\nimport { DIMENSIONS } from \"../../utils.js\";\r\n\r\nworld.events.worldInitialize.subscribe(({ propertyRegistry }) => {\r\n /**\r\n * Loads Ticking Area\r\n */\r\n DIMENSIONS.overworld.runCommandAsync(\r\n `tickingarea add ${ENTITY_LOCATION.x} ${ENTITY_LOCATION.y} ${ENTITY_LOCATION.z} ${ENTITY_LOCATION.x} ${ENTITY_LOCATION.y} ${ENTITY_LOCATION.z} db true`\r\n );\r\n\r\n let def = new DynamicPropertiesDefinition();\r\n def.defineString(\"tableName\", 30);\r\n def.defineNumber(\"index\");\r\n propertyRegistry.registerEntityTypeDynamicProperties(\r\n def,\r\n EntityTypes.get(ENTITY_IDENTIFIER)\r\n );\r\n});\r\n", "import { system, world } from \"@minecraft/server\";\r\nimport { API_CONTAINERS, CHECK_SIZE } from \"../../config/containers\";\r\nimport { Container } from \"./Container\";\r\nimport { vector3ToBlockLocation } from \"../../../utils\";\r\nimport type { IContainerLocation } from \"../../../types\";\r\n\r\n/**\r\n * storage of all container locations in the world\r\n */\r\nexport let CONTAINER_LOCATIONS: IContainerLocation = {};\r\n\r\nsystem.runSchedule(() => {\r\n CONTAINER_LOCATIONS = {};\r\n for (const player of world.getPlayers()) {\r\n if (player.dimension.id != \"minecraft:overworld\") continue;\r\n const blockLoc = vector3ToBlockLocation(player.location);\r\n const pos1 = blockLoc.offset(CHECK_SIZE.x, CHECK_SIZE.y, CHECK_SIZE.z);\r\n const pos2 = blockLoc.offset(-CHECK_SIZE.x, -CHECK_SIZE.y, -CHECK_SIZE.z);\r\n\r\n for (const location of pos1.blocksBetween(pos2)) {\r\n if (location.y < -64) continue;\r\n const block = player.dimension.getBlock(location);\r\n if (!block) continue;\r\n if (!API_CONTAINERS.includes(block.typeId)) continue;\r\n CONTAINER_LOCATIONS[JSON.stringify(location)] = new Container(\r\n block.getComponent(\"inventory\").container\r\n );\r\n }\r\n }\r\n}, 100);\r\n", "import { MinecraftBlockTypes } from \"@minecraft/server\";\r\n\r\n/**\r\n * The currently supported block containers by script api\r\n */\r\nexport const API_CONTAINERS = [\r\n MinecraftBlockTypes.chest.id,\r\n MinecraftBlockTypes.trappedChest.id,\r\n];\r\n\r\n/**\r\n * The block size to check for blockContainers\r\n */\r\nexport const CHECK_SIZE = { x: 7, y: 7, z: 7 };\r\n", "import { BlockInventoryComponentContainer, ItemStack } from \"@minecraft/server\";\r\n\r\nexport class Container {\r\n emptySlotsCount: number;\r\n size: number;\r\n items: Array;\r\n /**\r\n * Coverts a blockInventoryComponentContainer and saves it\r\n * @param {BlockInventoryComponentContainer} inventory\r\n */\r\n constructor(inventory: BlockInventoryComponentContainer) {\r\n this.emptySlotsCount = inventory.emptySlotsCount;\r\n this.size = inventory.size;\r\n this.items = [];\r\n for (let i = 0; i < this.size; i++) {\r\n this.items[i] = inventory.getItem(i);\r\n }\r\n }\r\n\r\n /**\r\n * Loads this inventory onto a BlockInventoryComponentContainer\r\n * @param {BlockInventoryComponentContainer} block block to load on\r\n */\r\n load(block: BlockInventoryComponentContainer) {\r\n for (let i = 0; i < block.size; i++) {\r\n if (!this.items[i]) continue;\r\n block.setItem(i, this.items[i]);\r\n }\r\n }\r\n}\r\n", "import { system } from \"@minecraft/server\";\r\nimport { EntitiesLoad } from \"../../rubedo/lib/Events/EntitiesLoad\";\r\nimport type { Protection } from \"./modules/models/Protection\";\r\n\r\n/**\r\n * All protections in this anti-cheat\r\n */\r\nexport const PROTECTIONS: { [key: string]: Protection } = {};\r\n\r\nEntitiesLoad.subscribe(() => {\r\n system.run(() => {\r\n for (const protection of Object.values(PROTECTIONS)) {\r\n if (!protection.getConfig().enabled ?? protection.isEnabledByDefault)\r\n continue;\r\n protection.enable();\r\n }\r\n });\r\n});\r\n", "import { Player } from \"@minecraft/server\";\nimport { TABLES } from \"../../tables.js\";\nimport type { IBanData } from \"../../types.js\";\nimport { durationToMs } from \"../../../../utils.js\";\n\nfunction setBan(\n player: string | Player,\n id: string,\n duration?: string,\n reason: string = \"No Reason\",\n by: string = \"Rubedo Auto Mod\"\n) {\n const data: IBanData = {\n key: id,\n playerName: player instanceof Player ? player.name : player,\n date: Date.now(),\n duration: duration ? durationToMs(duration) : null,\n expire: duration ? durationToMs(duration) + Date.now() : null,\n reason: reason,\n by: by,\n };\n TABLES.bans.set(id, data);\n}\n\nexport class Ban {\n /**\n * Ban a player for a set length\n */\n constructor(\n player: string | Player,\n duration?: string,\n reason: string = \"No Reason\",\n by: string = \"Rubedo Auto Mod\"\n ) {\n if (player instanceof Player) {\n setBan(player, player.id, duration, reason, by);\n } else {\n setBan(player, TABLES.ids.get(player), duration, reason, by);\n }\n }\n}\n", "import { Player } from \"@minecraft/server\";\r\nimport { MessageFormData } from \"@minecraft/server-ui\";\r\nimport { TIMEOUT_THRESHOLD } from \"../../../config/form\";\r\nimport type { ButtonCallback, IMessageFormButton } from \"../types\";\r\n\r\nexport class MessageForm {\r\n /**\r\n * the title that this form should have\r\n */\r\n title?: string;\r\n /**\r\n * extra text that should be displayed in the form\r\n */\r\n body?: string;\r\n /**\r\n * The default minecraft form this form is based on\r\n */\r\n private form: MessageFormData;\r\n /**\r\n * the first button of the dialog.\r\n */\r\n private button1: IMessageFormButton;\r\n /**\r\n * the second button of the dialog.\r\n */\r\n private button2: IMessageFormButton;\r\n /**\r\n * The amount of times it takes to show this form in ms\r\n * if this value goes above 200 it will time out\r\n */\r\n private triedToShow: number;\r\n\r\n /**\r\n * Creates a new form to be shown to a player\r\n * @param title the title that this form should have\r\n * @param body extra text that should be displayed in the form\r\n */\r\n constructor(title?: string, body?: string) {\r\n this.title = title;\r\n this.body = body;\r\n this.form = new MessageFormData();\r\n\r\n if (title) this.form.title(title);\r\n if (body) this.form.body(body);\r\n\r\n this.triedToShow = 0;\r\n }\r\n\r\n /**\r\n * Method that sets the text for the first button of the dialog.\r\n * @param text text to show on this button\r\n * @param callback what happens when this button is clicked\r\n * @example ```\r\n * setButton1(\"settings\", () => {})\r\n * ```\r\n */\r\n setButton1(text: string, callback?: ButtonCallback): MessageForm {\r\n this.button1 = { text: text, callback: callback };\r\n this.form.button1(text);\r\n return this;\r\n }\r\n\r\n /**\r\n * Method that sets the text for the second button of the dialog.\r\n * @param text text to show on this button\r\n * @param callback what happens when this button is clicked\r\n * @example ```\r\n * setButton2(\"settings\", () => {})\r\n * ```\r\n */\r\n setButton2(text: string, callback?: ButtonCallback): MessageForm {\r\n this.button2 = { text: text, callback: callback };\r\n this.form.button2(text);\r\n return this;\r\n }\r\n\r\n /**\r\n * Shows this form to the player\r\n * @param player player to show to\r\n */\r\n show(player: Player): void {\r\n this.form.show(player).then((response) => {\r\n if (response.canceled) {\r\n if (response.cancelationReason == \"userBusy\") {\r\n // check time and reshow form\r\n if (this.triedToShow > TIMEOUT_THRESHOLD)\r\n return player.tell(\r\n `\u00A7cForm Timeout: tried to show form, but you were busy (close chat after running command)`\r\n );\r\n this.triedToShow++;\r\n this.show(player);\r\n }\r\n return;\r\n }\r\n if (response.selection == 1) this.button1?.callback?.();\r\n if (response.selection == 0) this.button2?.callback?.();\r\n });\r\n }\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport { MessageForm } from \"./Models/MessageForm\";\r\n\r\n/**\r\n * Sends a confirmation message to a player to confirm a action\r\n * @param action action message to confirm\r\n * @param onConfirm callback to run when a player confirms the action\r\n * @param onCancel callback to run when a player cancels the action, this can be null\r\n * @example ```\r\n * confirmAction(\"Ban Smell of curry\", () => {\r\n * new Ban(\"Smell of curry\")\r\n * })\r\n * ```\r\n */\r\nexport function confirmAction(\r\n player: Player,\r\n action: string,\r\n onConfirm: () => void,\r\n onCancel: () => void = () => {}\r\n ) {\r\n new MessageForm(\"Confirm To Continue\", action)\r\n .setButton1(\"Confirm\", onConfirm)\r\n .setButton2(\"Never Mind\", onCancel)\r\n .show(player);\r\n }\r\n ", "import { Location, Player } from \"@minecraft/server\";\r\nimport {\r\n LiteralArgumentType,\r\n IArgumentType,\r\n LocationArgumentType,\r\n StringArgumentType,\r\n IntegerArgumentType,\r\n ArrayArgumentType,\r\n BooleanArgumentType,\r\n} from \"./ArgumentTypes.js\";\r\nimport { CommandCallback } from \"./Callback.js\";\r\nimport { COMMANDS } from \"./index.js\";\r\nimport type { AppendArgument, ICommandData, ArgReturn } from \"./types\";\r\nexport { ArgumentTypes } from \"./ArgumentTypes\";\r\n\r\nexport class Command<\r\n Callback extends Function = (ctx: CommandCallback) => void\r\n> {\r\n /**\r\n * The Arguments on this command\r\n */\r\n children: Command[];\r\n\r\n /**\r\n * Function to run when this command is called\r\n */\r\n callback: Callback;\r\n\r\n constructor(\r\n public data: ICommandData,\r\n public type?: IArgumentType,\r\n public depth: number = 0,\r\n public parent?: Command\r\n ) {\r\n if (!data.requires) data.requires = (player: Player) => true;\r\n this.data = data;\r\n this.type = type ?? new LiteralArgumentType(this.data.name);\r\n this.children = [];\r\n this.depth = depth;\r\n this.parent = parent;\r\n this.callback = null;\r\n\r\n COMMANDS.push(this);\r\n }\r\n\r\n /**\r\n * Adds a ranch to this command of your own type\r\n * @param type a special type to be added\r\n * @returns new branch to this command\r\n */\r\n argument(type: T): ArgReturn {\r\n const cmd = new Command>(\r\n this.data,\r\n type,\r\n this.depth + 1,\r\n this\r\n );\r\n this.children.push(cmd);\r\n return cmd;\r\n }\r\n\r\n /**\r\n * Adds a branch to this command of type string\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n string(name: string): ArgReturn {\r\n return this.argument(new StringArgumentType(name));\r\n }\r\n\r\n /**\r\n * Adds a branch to this command of type string\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n int(name: string): ArgReturn {\r\n return this.argument(new IntegerArgumentType(name));\r\n }\r\n\r\n /**\r\n * Adds a branch to this command of type string\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n array>(\r\n name: string,\r\n types: T\r\n ): ArgReturn {\r\n return this.argument(new ArrayArgumentType(name, types));\r\n }\r\n\r\n /**\r\n * Adds a branch to this command of type string\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n boolean(name: string): ArgReturn {\r\n return this.argument(new BooleanArgumentType(name));\r\n }\r\n\r\n /**\r\n * Adds a argument to this command to add 3 parameters with location types and to return a Location\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n location(name: string): ArgReturn {\r\n const cmd = this.argument(new LocationArgumentType(name));\r\n if (!name.endsWith(\"*\")) {\r\n const newArg = cmd.location(name + \"_y*\").location(name + \"_z*\");\r\n //@ts-ignore\r\n return newArg;\r\n }\r\n //@ts-ignore\r\n return cmd;\r\n }\r\n\r\n /**\r\n * Adds a subCommand to this argument\r\n * @param name name this literal should have\r\n * @returns new branch to this command\r\n */\r\n literal(data: ICommandData): Command {\r\n const cmd = new Command(\r\n data,\r\n new LiteralArgumentType(data.name),\r\n this.depth + 1,\r\n this\r\n );\r\n this.children.push(cmd);\r\n return cmd;\r\n }\r\n\r\n /**\r\n * Registers this command and its appending arguments\r\n * @param callback what to run when this command gets called\r\n */\r\n executes(callback: Callback): Command {\r\n this.callback = callback;\r\n return this;\r\n }\r\n}\r\n", "export const text = {\n \"api.name\": () => \"Smelly API\",\n \"api.error.unknown\": () => \"An unknown error has occurred.\",\n \"api.database.error.table_name\": (a: string, b: number) =>\n `The display name ${a} is too long for an objective, it can be at most ${b} characters long`,\n \"api.utilities.formatter.error.ms\": (a: string) =>\n `${a} is not a string or a number`,\n \"api.Providers.form.invalidType\": (a: string, b: string) =>\n `Type ${a} is not a valid type to add a ${b}`,\n \"modules.protections.cps.clickingToFast\": () =>\n `You are clicking to fast! Please click slower!`,\n \"modules.managers.mute.isMuted\": () =>\n `\u00A7cYou've been temporarily muted in chat.`,\n \"modules.commands.ban.reply\": (\n playerName: string,\n duration: string,\n reason: string = \"\"\n ) =>\n `\u00A7cBanned \u00A7f\"\u00A7a${playerName}\u00A7f\" \u00A7cfor ${duration} Because: \"${\n reason ?? \"No reason Provided\"\n }\" \u00A7aSuccessfully`,\n \"lockdown.kick.message\": () => [\n `\u00A7cYou have been kicked!`,\n `\u00A7aReason: \u00A7fServer is currently under LockDown`,\n `\u00A7fServer will be up soon, Try to join later`,\n ],\n \"commands.ban.list.player\": (name: string, reason: string, expire: string) =>\n `- \"${name}\" Because: ${reason}, Expiry ${expire}`,\n \"commands.freeze.list.player\": (name: string, reason: string) =>\n `- \"${name}\" Because: ${reason}`,\n \"commands.mutes.list.player\": (\n name: string,\n reason: string,\n expire: string\n ) => `- \"${name}\" Because: ${reason}, Expiry: ${expire}`,\n \"commands.lockdown.confirm\":\n \"Are you sure you want to lockdown the server, this will kick all active players and all players who try to join who are not admin\",\n};\n", "import { Player } from \"@minecraft/server\";\r\nimport { ActionFormData } from \"@minecraft/server-ui\";\r\nimport { TIMEOUT_THRESHOLD } from \"../../../config/form\";\r\nimport type { ButtonCallback, IActionFormButton } from \"../types\";\r\n\r\nexport class ActionForm {\r\n /**\r\n * the title that this form should have\r\n */\r\n title?: string;\r\n /**\r\n * extra text that should be displayed in the form\r\n */\r\n body?: string;\r\n /**\r\n * The buttons this form has\r\n */\r\n private buttons: IActionFormButton[];\r\n\r\n /**\r\n * The default minecraft form this form is based on\r\n */\r\n private form: ActionFormData;\r\n\r\n /**\r\n * The amount of times it takes to show this form in ms\r\n * if this value goes above 200 it will time out\r\n */\r\n private triedToShow: number;\r\n\r\n /**\r\n * Creates a new form to be shown to a player\r\n * @param title the title that this form should have\r\n * @param body extra text that should be displayed in the form\r\n */\r\n constructor(title?: string, body?: string) {\r\n this.title = title;\r\n this.body = body;\r\n this.form = new ActionFormData();\r\n\r\n if (title) this.form.title(title);\r\n if (body) this.form.body(body);\r\n\r\n this.buttons = [];\r\n\r\n this.triedToShow = 0;\r\n }\r\n\r\n /**\r\n * Adds a button to this form\r\n * @param text text to show on this button\r\n * @param iconPath the path this button shows\r\n * @param callback what happens when this button is clicked\r\n * @example ```\r\n * addButton(\"settings\", \"textures/items/sum\")\r\n * ```\r\n */\r\n addButton(\r\n text: string,\r\n iconPath: string = null,\r\n callback: ButtonCallback\r\n ): ActionForm {\r\n this.buttons.push({\r\n text: text,\r\n iconPath: iconPath,\r\n callback: callback,\r\n });\r\n this.form.button(text, iconPath);\r\n return this;\r\n }\r\n\r\n /**\r\n * Shows this form to the player\r\n * @param player player to show to\r\n */\r\n show(player: Player): void {\r\n this.form.show(player).then((response) => {\r\n if (response.canceled) {\r\n if (response.cancelationReason == \"userBusy\") {\r\n // check time and reshow form\r\n if (this.triedToShow > TIMEOUT_THRESHOLD)\r\n return player.tell(\r\n `\u00A7cForm Timeout: tried to show form, but you were busy (close chat after running command)`\r\n );\r\n this.triedToShow++;\r\n this.show(player);\r\n }\r\n return;\r\n }\r\n this.buttons[response.selection].callback?.();\r\n });\r\n }\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport { ModalFormData } from \"@minecraft/server-ui\";\r\nimport { TIMEOUT_THRESHOLD } from \"../../../config/form\";\r\nimport type { AppendFormField, IModalFormArg, Range } from \"../types\";\r\nimport { FormCallback } from \"./FormCallback\";\r\n\r\nexport class ModalForm<\r\n Callback extends Function = (ctx: FormCallback) => void\r\n> {\r\n /**\r\n * the title that this form should have\r\n */\r\n title?: string;\r\n\r\n /**\r\n * The default minecraft form this form is based on\r\n */\r\n private form: ModalFormData;\r\n\r\n /**\r\n * The arguments this form has\r\n */\r\n private args: IModalFormArg[];\r\n\r\n /**\r\n * Creates a new form to be shown to a player\r\n * @param title the title that this form should have\r\n */\r\n constructor(title?: string) {\r\n this.title = title;\r\n this.form = new ModalFormData();\r\n\r\n if (title) this.form.title(title);\r\n\r\n this.args = [];\r\n }\r\n\r\n /**\r\n * Adds a dropdown to this form\r\n * @param label label to show on dropdown\r\n * @param options the available options for this dropdown\r\n * @param defaultValueIndex the default value index\r\n * @returns this\r\n */\r\n addDropdown>(\r\n label: string,\r\n options: T,\r\n defaultValueIndex?: number\r\n ): ModalForm> {\r\n // @ts-ignore\r\n this.args.push({ type: \"dropdown\", options: options });\r\n // @ts-ignore\r\n this.form.dropdown(label, options, defaultValueIndex);\r\n // @ts-ignore\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a slider to this form\r\n * @param label label to be shown on this slider\r\n * @param minimumValue the smallest value this can be\r\n * @param maximumValue the maximum value this can be\r\n * @param valueStep how this slider increments\r\n * @param defaultValue the default value in slider\r\n * @returns this\r\n */\r\n addSlider(\r\n label: string,\r\n minimumValue: T,\r\n maximumValue: U,\r\n valueStep: number,\r\n defaultValue?: number\r\n ): ModalForm>> {\r\n this.args.push({ type: \"slider\" });\r\n this.form.slider(\r\n label,\r\n minimumValue,\r\n maximumValue,\r\n valueStep,\r\n defaultValue\r\n );\r\n // @ts-ignore\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a toggle to this form\r\n * @param label the name of this toggle\r\n * @param defaultValue the default toggle value could be true or false\r\n * @returns\r\n */\r\n addToggle(\r\n label: string,\r\n defaultValue?: boolean\r\n ): ModalForm> {\r\n this.args.push({ type: \"toggle\" });\r\n this.form.toggle(label, defaultValue);\r\n // @ts-ignore\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a text field to this form\r\n * @param label label for this textField\r\n * @param placeholderText the text that shows on this field\r\n * @param defaultValue the default value that this field has\r\n */\r\n addTextField(\r\n label: string,\r\n placeholderText: string,\r\n defaultValue?: string\r\n ): ModalForm> {\r\n this.args.push({ type: \"textField\" });\r\n this.form.textField(label, placeholderText, defaultValue);\r\n // @ts-ignore\r\n return this;\r\n }\r\n\r\n /**\r\n * Shows this form to a player\r\n * @param player player to show to\r\n * @param callback sends a callback when this form is submitted\r\n */\r\n async show(player: Player, callback: Callback) {\r\n for (let i = 0; i < TIMEOUT_THRESHOLD; i++) {\r\n let response = await this.form.show(player);\r\n if (response.cancelationReason == \"userBusy\") continue;\r\n callback(\r\n new FormCallback(this, player, callback),\r\n ...response.formValues.map((v, i) =>\r\n this.args[i].type == \"dropdown\" ? this.args[i].options[v] : v\r\n )\r\n );\r\n return;\r\n }\r\n return player.tell(\r\n `\u00A7cForm Timeout: tried to show form, but you were busy (close chat after running command)`\r\n );\r\n }\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport { ActionForm } from \"./ActionForm\";\r\nimport { MessageForm } from \"./MessageForm\";\r\nimport { ModalForm } from \"./ModelForm\";\r\n\r\nexport class FormCallback {\r\n /**\r\n * form that was used in this call\r\n */\r\n private form: ActionForm | MessageForm | ModalForm;\r\n /**\r\n * player that this form used\r\n */\r\n private player: Player;\r\n\r\n /**\r\n * the function that was called\r\n */\r\n private callback: () => void;\r\n\r\n /**\r\n * Creates a new form callback instance that can be used by\r\n * buttons, and args to run various functions\r\n * @param form form that is used in this call\r\n */\r\n constructor(\r\n form: ActionForm | MessageForm | ModalForm,\r\n player: Player,\r\n callback: any\r\n ) {\r\n this.form = form;\r\n this.player = player;\r\n this.callback = callback;\r\n }\r\n\r\n /**\r\n * Reshow the form and shows the user a error message\r\n * @param message error message to show\r\n */\r\n error(message: string) {\r\n new MessageForm(\"Error\", message)\r\n .setButton1(\"Return to form\", () => {\r\n this.form.show(this.player, this.callback);\r\n })\r\n .setButton2(\"Cancel\", null)\r\n .show(this.player);\r\n }\r\n}\r\n", "import { TABLES } from \"../../tables.js\";\nimport { msToTime } from \"../../../../utils.js\";\nimport { getRole } from \"../../utils.js\";\nimport { Ban } from \"../models/Ban.js\";\nimport { confirmAction } from \"../../../../rubedo/lib/Form/utils.js\";\nimport {\n ArgumentTypes,\n Command,\n} from \"../../../../rubedo/lib/Command/Command.js\";\nimport { text } from \"../../../../rubedo/lang/text.js\";\nimport type { CommandCallback } from \"../../../../rubedo/lib/Command/Callback.js\";\nimport { ActionForm } from \"../../../../rubedo/lib/Form/Models/ActionForm.js\";\nimport { ModalForm } from \"../../../../rubedo/lib/Form/Models/ModelForm.js\";\n\nfunction ban(\n ctx: CommandCallback,\n player: string,\n duration: string,\n reason: string,\n by: string\n) {\n if (TABLES.bans.get(TABLES.ids.get(player)))\n return ctx.reply(`\u00A7c${player} is already banned`);\n ctx.reply(`\u00A7aClose chat to confirm`);\n confirmAction(\n ctx.sender,\n `Are you sure you want to ban ${player}, for ${duration ?? \"forever\"}`,\n () => {\n new Ban(player, duration, reason, ctx.sender.name);\n ctx.reply(text[\"modules.commands.ban.reply\"](player, duration, reason));\n }\n );\n}\n\nconst root = new Command({\n name: \"ban\",\n description: \"Manage bans\",\n requires: (player) => [\"admin\", \"moderator\"].includes(getRole(player)),\n});\n\nroot\n .literal({\n name: \"add\",\n description: \"Bans a player\",\n })\n .argument(new ArgumentTypes.playerName())\n .executes((ctx, player) => {\n ban(ctx, player, null, null, ctx.sender.name);\n })\n .argument(new ArgumentTypes.duration(\"duration\"))\n .executes((ctx, player, duration) => {\n ban(ctx, player, duration, null, ctx.sender.name);\n })\n .string(\"reason\")\n .executes((ctx, player, duration, reason) => {\n ban(ctx, player, duration, reason, ctx.sender.name);\n });\n\nroot\n .literal({\n name: \"remove\",\n description: \"un-bans a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .executes((ctx, playerName) => {\n const banData = TABLES.bans\n .values()\n .find((ban) => ban.playerName == playerName);\n if (!banData) return ctx.reply(`${playerName} is not banned`);\n if (TABLES.bans.delete(banData.key)) {\n ctx.reply(`\u00A7a${playerName}\u00A7r has been Unbanned!`);\n } else {\n ctx.reply(`\u00A7cFailed to un-ban ${playerName}`);\n }\n });\n\nroot\n .literal({\n name: \"list\",\n description: \"Lists all bans\",\n })\n .executes((ctx) => {\n const bans = TABLES.bans.values();\n if (bans.length == 0) return ctx.sender.tell(`\u00A7cNo one is banned!`);\n ctx.sender.tell(`\u00A72--- Showing Bans (${bans.length}) ---`);\n for (const ban of bans) {\n ctx.sender.tell(\n text[\"commands.ban.list.player\"](\n ban.playerName,\n ban.reason,\n ban.expire ? msToTime(ban.duration) : \"Forever\"\n )\n );\n }\n });\n\nroot\n .literal({\n name: \"test\",\n description: \"sdhsd\",\n })\n .executes((ctx) => {\n new ActionForm(\"Manage Bans\")\n .addButton(\"Ban a Player\", \"textures/ui/hammer_r\", () => {\n new ModalForm(\"Ban a Player\")\n .addDropdown(\"Player Name:\", TABLES.ids.keys())\n .addTextField(\"Duration\", \"10d, 5h, 2s\", \"null\")\n .addTextField(\"Ban Reason\", \"\", \"No Reason Provided\")\n .show(ctx.sender, (ctx, playerName, duration, reason) => {\n console.warn(playerName, duration, reason);\n });\n })\n .addButton(\"Revoke a Ban\", \"textures/ui/hammer_r_disabled\", () => {\n console.warn(`Revoke a player`);\n })\n .addButton(\"View Current Bans\", \"textures/ui/store_sort_icon\", () => {\n console.warn(`Revoke a player`);\n })\n .show(ctx.sender);\n });\n", "import { Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { getRole } from \"../../utils\";\n\nconst root = new Command({\n name: \"database\",\n description: \"Interacts with SA Database\",\n aliases: [\"db\"],\n requires: (player) => getRole(player) == \"admin\",\n});\n\nroot\n .literal({\n name: \"get\",\n })\n .string(\"table\")\n .string(\"key\")\n .executes((ctx, table, key) => {\n try {\n const data = TABLES[table as keyof typeof TABLES].get(key);\n if (data) {\n ctx.reply(JSON.stringify(data));\n } else {\n ctx.reply(`No data could be found for key ${key}`);\n }\n } catch (error) {\n ctx.reply(error + error.stack);\n }\n });\n\nroot\n .literal({\n name: \"set\",\n })\n .string(\"table\")\n .string(\"key\")\n .string(\"value\")\n .executes((ctx, table, key, value) => {\n try {\n TABLES[table as keyof typeof TABLES].set(key, value);\n ctx.reply(`Set Key: \"${key}\", to value: \"${value}\" on table: \"${table}\"`);\n } catch (error) {\n ctx.reply(error + error.stack);\n }\n });\n\nroot\n .literal({\n name: \"clear\",\n })\n .string(\"table\")\n .executes((ctx, table) => {\n try {\n TABLES[table as keyof typeof TABLES].clear();\n ctx.reply(`Cleared Table ${table}`);\n } catch (error) {\n ctx.reply(error + error.stack);\n }\n });\n\nroot\n .literal({\n name: \"keys\",\n description: \"Returns all keys on a database\",\n })\n .string(\"table\")\n .executes((ctx, table) => {\n try {\n const keys = TABLES[table as keyof typeof TABLES].keys();\n ctx.reply(`Keys on database: ${table}: ${keys}`);\n } catch (error) {\n ctx.reply(error + error.stack);\n }\n });\n\nroot\n .literal({\n name: \"values\",\n description: \"Returns all values on a database\",\n })\n .string(\"table\")\n .executes((ctx, table) => {\n try {\n const values = TABLES[table as keyof typeof TABLES].values();\n ctx.reply(\n `Values on database: ${table}: ${JSON.stringify(values, null, 2)}`\n );\n } catch (error) {\n // likely occurs when table is empty\n if (error instanceof TypeError) {\n ctx.reply(`No values on database ${table}`);\n } else {\n ctx.reply(error + error.stack);\n }\n }\n });\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { getRole } from \"../../utils.js\";\n\nnew Command({\n name: \"ecwipe\",\n description: \"Clears a players ender chest\",\n requires: (player) => getRole(player) == \"admin\",\n})\n .argument(new ArgumentTypes.player(\"player\"))\n .executes((ctx, player) => {\n for (let i = 0; i < 27; i++) {\n player.runCommandAsync(`replaceitem entity @s slot.enderchest ${i} air`);\n }\n ctx.reply(`\u00A7aCleared \"${player.name}\"'s Ender chest!`);\n });\n", "import { Player } from \"@minecraft/server\";\nimport { TABLES } from \"../../tables.js\";\nimport type { IFreezeData } from \"../../types.js\";\n\nexport class Freeze {\n /**\n * Freeze a player\n */\n constructor(player: Player, reason: string = \"No Reason\") {\n const data: IFreezeData = {\n playerName: player.name,\n key: player.id,\n reason: reason,\n location: {\n x: player.location.x,\n y: player.location.y,\n z: player.location.z,\n dimension: player.dimension.id,\n },\n };\n TABLES.freezes.set(player.id, data);\n }\n}\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { Freeze } from \"../models/Freeze.js\";\nimport { getRole } from \"../../utils.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { text } from \"../../../../rubedo/lang/text.js\";\n\nconst root = new Command({\n name: \"freeze\",\n description: \"Manage Freezes\",\n requires: (player) => [\"admin\", \"moderator\"].includes(getRole(player)),\n});\n\nroot\n .literal({\n name: \"add\",\n description: \"Freezes a player\",\n })\n .argument(new ArgumentTypes.player(\"player\"))\n .string(\"reason\")\n .executes((ctx, player, reason) => {\n new Freeze(player, reason);\n ctx.reply(\n `\u00A7cFroze \u00A7f\"\u00A7a${player.name}\u00A7f\" Because: \"${reason}\" \u00A7aSuccessfully`\n );\n ctx.sender.tell(\n `\u00A7cYou have been frozen by \u00A7f\"\u00A7a${ctx.sender.name}\u00A7f\" Because: \"${reason}\"`\n );\n });\n\nroot\n .literal({\n name: \"remove\",\n description: \"unfreezes a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .executes((ctx, playerName) => {\n const freeze = TABLES.freezes\n .values()\n .find((freeze) => freeze.playerName == playerName);\n if (!freeze) return ctx.reply(`${playerName} is not frozen`);\n\n TABLES.freezes.delete(freeze.key);\n\n ctx.reply(`\u00A7a${playerName}\u00A7r has been UnFrozen!`);\n });\n\nroot\n .literal({\n name: \"list\",\n description: \"Lists all freezes\",\n })\n .executes((ctx) => {\n const freezes = TABLES.freezes.values();\n if (freezes.length == 0) return ctx.sender.tell(`\u00A7cNo one is frozen!`);\n ctx.sender.tell(`\u00A72--- Showing Freezes (${freezes.length}) ---`);\n for (const freeze of freezes) {\n ctx.sender.tell(\n text[\"commands.freeze.list.player\"](freeze.playerName, freeze.reason)\n );\n }\n });\n", "import { Player } from \"@minecraft/server\";\nimport { PREFIX } from \"../../../../rubedo/config/commands.js\";\nimport type {\n IArgumentType,\n IArgumentReturnData,\n} from \"../../../../rubedo/lib/Command/ArgumentTypes.js\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { COMMANDS } from \"../../../../rubedo/lib/Command/index.js\";\n\nclass CommandNameArgumentType implements IArgumentType {\n type: string;\n typeName = \"CommandName\";\n matches(value: string): IArgumentReturnData {\n return {\n success: Boolean(\n COMMANDS.find((c) => c.depth == 0 && c.data.name == value)\n ),\n value: value,\n };\n }\n fail(value: string): string {\n return `\"${value}\" is not a valid command`;\n }\n constructor(public name: string) {}\n}\n\n/**\n * Sends text in chat relation to the args in the command to player\n */\nfunction sendCommandType(\n baseCommand: Command,\n args: Command[],\n player: Player\n) {\n player.tell(\n `${PREFIX}${baseCommand.data.name} ${args\n .map((a) =>\n a.type.typeName == \"literal\"\n ? a.data.name\n : `<${a.type.name}: ${a.type.typeName}>`\n )\n .join(\" \")}`\n );\n}\n\nfunction sendArguments(bc: Command, c: Command, args: Command[], p: Player) {\n if (!c.data?.requires(p)) return;\n if (c.callback) {\n // command has a callback\n sendCommandType(bc, c.depth == 0 ? args : args.concat(c), p);\n }\n if (c.children.length > 0) {\n // cmd has arguments\n for (const child of c.children) {\n sendArguments(bc, child, c.depth == 0 ? args : args.concat(c), p);\n }\n }\n}\n\nfunction sendPageHeader(player: Player, p: number, maxPages: number) {\n player.tell(\n `\u00A72--- Showing help page ${p} of ${maxPages} (${PREFIX}help ) ---`\n );\n}\n\nfunction getCommands(player: Player): Command[] {\n return COMMANDS.filter((c) => {\n return c.depth == 0 && c.data?.requires(player);\n });\n}\n\nfunction getMaxPages(player: Player): number {\n const commands = getCommands(player);\n if (commands.length == 0) return 0;\n return Math.ceil(commands.length / 5);\n}\n\nconst root = new Command({\n name: \"help\",\n description: \"Provides help/list of commands.\",\n aliases: [\"?\", \"h\"],\n}).executes((ctx) => {\n // show page 1\n const maxPages = getMaxPages(ctx.sender);\n const commands = getCommands(ctx.sender).slice(1 * 5 - 5, 1 * 5);\n sendPageHeader(ctx.sender, 1, maxPages);\n for (const cmd of commands) {\n sendArguments(cmd, cmd, [], ctx.sender);\n }\n});\n\nroot.int(\"page\").executes((ctx, p) => {\n // shows page\n const maxPages = getMaxPages(ctx.sender);\n if (p > maxPages) p = maxPages;\n const commands = getCommands(ctx.sender).slice(p * 5 - 5, p * 5);\n sendPageHeader(ctx.sender, p, maxPages);\n for (const cmd of commands) {\n sendArguments(cmd, cmd, [], ctx.sender);\n }\n});\n\nroot\n .argument(new CommandNameArgumentType(\"command\"))\n .executes((ctx, command) => {\n // shows command\n const cmd = COMMANDS.filter(\n (c) => c.depth == 0 && c.data.name == command\n )[0];\n ctx.sender.tell(\n `\u00A7e${cmd.data.name}: ${\n cmd.data.aliases ? `aliases (${cmd.data.aliases.join(\", \")})` : \"\"\n }`\n );\n ctx.sender.tell(`\u00A7e${cmd.data.description}`);\n ctx.sender.tell(`Usage:`);\n sendArguments(cmd, cmd, [], ctx.sender);\n });\n", "import { world } from \"@minecraft/server\";\r\nimport { text } from \"../../../../rubedo/lang/text.js\";\r\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { confirmAction } from \"../../../../rubedo/lib/Form/utils.js\";\r\nimport { getRole, isLockedDown, kick, setLockDown } from \"../../utils.js\";\r\n\r\nnew Command({\r\n name: \"lockdown\",\r\n description: \"Toggles the servers lockdown, meaning no one can join\",\r\n requires: (player) => getRole(player) == \"admin\",\r\n}).executes((ctx) => {\r\n if (isLockedDown()) {\r\n setLockDown(false);\r\n ctx.sender.tell(`\u00A7aUnlocked the server!`);\r\n } else {\r\n ctx.reply(`\u00A7aClose chat to confirm lockdown`);\r\n confirmAction(ctx.sender, text[\"commands.lockdown.confirm\"], () => {\r\n setLockDown(true);\r\n for (const player of world.getPlayers()) {\r\n if (getRole(player) == \"admin\") continue;\r\n kick(player, text[\"lockdown.kick.message\"]());\r\n }\r\n world.say(`\u00A7l\u00A7cServer is now LOCKED!`);\r\n });\r\n }\r\n});\r\n", "import { Player } from \"@minecraft/server\";\nimport { TABLES } from \"../../tables.js\";\nimport type { IMuteData } from \"../../types.js\";\nimport { durationToMs } from \"../../../../utils.js\";\n\nexport class Mute {\n length: number;\n /**\n * Gets the mute data for this player\n */\n static getMuteData(player: Player): IMuteData {\n return TABLES.mutes.get(player.name);\n }\n /**\n * Mutes a player for a length\n */\n constructor(\n player: Player,\n duration?: string,\n reason: string = \"No Reason\",\n by: string = \"Rubedo Auto Mod\"\n ) {\n const msLength = duration ? durationToMs(duration) : null;\n const data: IMuteData = {\n playerName: player.name,\n date: Date.now(),\n duration: msLength,\n expire: msLength ? msLength + Date.now() : null,\n reason: reason,\n by: by,\n };\n TABLES.mutes.set(player.name, data);\n }\n}\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { Mute } from \"../models/Mute.js\";\nimport { getRole } from \"../../utils.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { msToTime } from \"../../../../utils.js\";\nimport { text } from \"../../../../rubedo/lang/text.js\";\n\nconst root = new Command({\n name: \"mute\",\n description: \"Manage Mutes\",\n requires: (player) => [\"admin\", \"moderator\"].includes(getRole(player)),\n});\n\nroot\n .literal({\n name: \"add\",\n description: \"Mutes a player\",\n })\n .argument(new ArgumentTypes.player(\"player\"))\n .argument(new ArgumentTypes.duration(\"duration\"))\n .string(\"reason\")\n .executes((ctx, player, duration, reason) => {\n new Mute(player, duration, reason, ctx.sender.name);\n ctx.reply(\n `\u00A7cMuted \u00A7f\"\u00A7a${player.name}\u00A7f\" \u00A7cfor ${duration} Because: \"${reason}\" \u00A7aSuccessfully`\n );\n player.tell(\n `\u00A7cYou have been muted by \u00A7f\"${ctx.sender.name}\" \u00A7cfor ${duration} Because: \"${reason}\"`\n );\n });\n\nroot\n .literal({\n name: \"remove\",\n description: \"un-mutes a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .executes((ctx, playerName) => {\n const mute = TABLES.mutes\n .values()\n .find((mute) => mute.playerName == playerName);\n if (!mute) return ctx.reply(`${playerName} is not muted!`);\n\n TABLES.mutes.delete(mute.playerName);\n try {\n ctx.sender.runCommandAsync(`ability \"${playerName}\" mute false`);\n } catch (error) {}\n ctx.reply(`\u00A7a${playerName}\u00A7r has been UnMuted!`);\n });\n\nroot\n .literal({\n name: \"list\",\n description: \"Lists all freezes\",\n })\n .executes((ctx) => {\n const mutes = TABLES.mutes.values();\n if (mutes.length == 0) return ctx.sender.tell(`\u00A7cNo one is muted!`);\n ctx.sender.tell(`\u00A72--- Showing Mutes (${mutes.length}) ---`);\n for (const mute of mutes) {\n ctx.sender.tell(\n text[\"commands.mutes.list.player\"](\n mute.playerName,\n mute.reason,\n mute.expire ? msToTime(mute.expire) : \"Forever\"\n )\n );\n }\n });\n", "import { Location } from \"@minecraft/server\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { getRole } from \"../../utils.js\";\nimport { Npc } from \"../models/Npc.js\";\n\nnew Command({\n name: \"npc\",\n description: \"Spawns a npc at your coordinates\",\n requires: (player) => getRole(player) == \"admin\",\n}).executes((ctx) => {\n const { x, y, z } = ctx.sender.location;\n new Npc(new Location(x, y, z), ctx.sender.dimension);\n ctx.reply(`Spawned a verified npc at your current location`);\n});\n", "import { Dimension, Entity, Location } from \"@minecraft/server\";\r\nimport { clearNpcLocations, NPC_LOCATIONS } from \"../../index.js\";\r\nimport { TABLES } from \"../../tables.js\";\r\nimport type { INpcLocation } from \"../../types.js\";\r\nimport { LocationEquals } from \"../../../../utils.js\";\r\n\r\nexport class Npc {\r\n /**\r\n * Checks if a entity is a valid npc\r\n * @param entity npc\r\n */\r\n static isValid(entity: Entity): boolean {\r\n if (entity.typeId != \"minecraft:npc\") return false;\r\n if (NPC_LOCATIONS.find((l) => LocationEquals(l, entity.location)))\r\n return true;\r\n return TABLES.npcs.keys().find((key) => entity.id == key) ? true : false;\r\n }\r\n /**\r\n * Adds a new verified npc to the world\r\n */\r\n constructor(location: Location, dimension: Dimension) {\r\n NPC_LOCATIONS.push(location);\r\n const entity = dimension.spawnEntity(\"minecraft:npc\", location);\r\n\r\n const data: INpcLocation = {\r\n dimension: entity.dimension.id,\r\n x: entity.location.x,\r\n y: entity.location.y,\r\n z: entity.location.z,\r\n };\r\n TABLES.npcs.set(entity.id, data);\r\n clearNpcLocations();\r\n }\r\n}\r\n", "import { system } from \"@minecraft/server\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command\";\n\nasync function getServerTPS(): Promise {\n let startTime = Date.now();\n let ticks = 0;\n return new Promise((resolve) => {\n let s = system.runSchedule(() => {\n if (Date.now() - startTime < 1000) {\n ticks++;\n } else {\n system.clearRunSchedule(s);\n resolve(ticks);\n }\n });\n });\n}\n\nnew Command({\n name: \"ping\",\n description: \"Returns the current Ticks Per Second of the servers ping\",\n}).executes(async (ctx) => {\n let ticks = await getServerTPS();\n ctx.reply(\n `\u00A7aCurrent Ticks Per Second: ${\n ticks > 18 ? \"\u00A7f{ \u00A7aGood\" : ticks > 13 ? \"\u00A7f{ \u00A7eOk\" : \"\u00A7f{ \u00A7cSevere\"\n } ${ticks} \u00A7f}`\n );\n});\n", "import { BlockLocation } from \"@minecraft/server\";\nimport { Region } from \"../models/Region.js\";\nimport { getRole } from \"../../utils.js\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\n\nconst command = new Command({\n name: \"region\",\n description: \"Create a Region\",\n requires: (player) => getRole(player) == \"admin\",\n});\n\ncommand\n .literal({\n name: \"add\",\n description: \"Adds a new protection region\",\n })\n .int(\"from_x\")\n .int(\"from_z\")\n .int(\"to_x\")\n .int(\"to_z\")\n .executes((ctx, from_x, from_z, to_x, to_z) => {\n new Region(\n { x: from_x, z: from_z },\n { x: to_x, z: to_z },\n ctx.sender.dimension.id\n );\n ctx.reply(\n `Created Region From ${from_x} -64 ${from_z} ${to_x} 320 ${to_z}`\n );\n });\n\ncommand\n .literal({\n name: \"remove\",\n description: \"Removes a region at the players current position\",\n })\n .executes((ctx) => {\n const loc = new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n );\n const r = Region.removeRegionAtBlockLocation(loc, ctx.sender.dimension.id);\n if (r) {\n ctx.reply(`Removed Region at ${loc.x} ${loc.y} ${loc.z}`);\n } else {\n ctx.reply(`Failed to find/remove region at ${loc.x} ${loc.y} ${loc.z}`);\n }\n });\n\ncommand\n .literal({\n name: \"removeAll\",\n description: \"Removes all regions\",\n })\n .executes((ctx) => {\n Region.getAllRegions().forEach((r) => r.delete());\n ctx.reply(`Removed All regions`);\n });\n\ncommand\n .literal({\n name: \"list\",\n description: \"Lists all regions and positions\",\n })\n .executes((ctx) => {\n const regions = Region.getAllRegions();\n for (const region of regions) {\n ctx.reply(\n `Region from ${region.from.x}, ${region.from.z} to ${region.to.x}, ${region.to.z} in dimension ${region.dimensionId}`\n );\n }\n if (regions.length == 0) return ctx.reply(`No regions have been made yet`);\n });\n\nconst permission = command.literal({\n name: \"permission\",\n description: \"Handles permissions for regions\",\n});\n\npermission\n .literal({\n name: \"set\",\n description:\n \"Sets a certain permission on the region the player is currently in to a value\",\n })\n .array(\"key\", [\"doorsAndSwitches\", \"openContainers\", \"pvp\"] as const)\n .boolean(\"value\")\n .executes((ctx, key, value) => {\n const region = Region.blockLocationInRegion(\n new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n ),\n ctx.sender.dimension.id\n );\n if (!region) return ctx.reply(`You are not in a region`);\n region.changePermission(key, value);\n ctx.reply(`Changed permission ${key} to ${value}`);\n });\n\npermission\n .literal({\n name: \"list\",\n description: \"Lists the permissions for the current region\",\n })\n .executes((ctx) => {\n const region = Region.blockLocationInRegion(\n new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n ),\n ctx.sender.dimension.id\n );\n if (!region) return ctx.reply(`You are not in a region`);\n ctx.reply(\n `Current region permissions ${JSON.stringify(region.permissions)}`\n );\n });\n\nconst entityCommands = permission.literal({\n name: \"entities\",\n description: \"Holds the subCommands for adding or removing allowedEntities\",\n});\n\nentityCommands\n .literal({\n name: \"add\",\n description: \"Adds a entity to the allowed entities list\",\n })\n .string(\"entity\")\n .executes((ctx, entity) => {\n const region = Region.blockLocationInRegion(\n new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n ),\n ctx.sender.dimension.id\n );\n if (!region) return ctx.reply(`You are not in a region`);\n const currentAllowedEntities = region.permissions.allowedEntities;\n currentAllowedEntities.push(entity);\n region.changePermission(\"allowedEntities\", currentAllowedEntities);\n ctx.reply(\n `Added entity ${entity} to the allowed entities of the region your currently standing in`\n );\n });\n\nentityCommands\n .literal({\n name: \"remove\",\n description: \"Removes a entity from the allowed entities in the region\",\n })\n .string(\"entity\")\n .executes((ctx, entity) => {\n const region = Region.blockLocationInRegion(\n new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n ),\n ctx.sender.dimension.id\n );\n if (!region) return ctx.reply(`You are not in a region`);\n let currentAllowedEntities = region.permissions.allowedEntities;\n if (!currentAllowedEntities.includes(entity))\n return ctx.reply(\n `The entity ${entity} is not allowed to enter the region`\n );\n currentAllowedEntities = currentAllowedEntities.filter((v) => v != entity);\n region.changePermission(\"allowedEntities\", currentAllowedEntities);\n ctx.reply(\n `Removed entity ${entity} to the allowed entities of the region your currently standing in`\n );\n });\n", "import { Events } from \"@minecraft/server\";\r\nimport { ENCHANTMENTS } from \"./config/enchantments\";\r\n\r\n/**\r\n * The roles that are in this server\r\n */\r\nexport enum ROLES {\r\n member,\r\n admin,\r\n moderator,\r\n builder,\r\n}\r\n\r\nexport type ConfigType = {\r\n /**\r\n * {@link BANNED_ITEMS}\r\n */\r\n banned_items: string[];\r\n /**\r\n * {@link BANNED_BLOCKS}\r\n */\r\n banned_blocks: string[];\r\n /**\r\n * {@link ENCHANTMENTS}\r\n */\r\n enchantments: {\r\n [Property in keyof typeof ENCHANTMENTS]: number;\r\n };\r\n /**\r\n * Appeal Link for the server\r\n */\r\n appealLink: string;\r\n};\r\n\r\nexport interface LogData {\r\n /**\r\n * An optional playerName who is associated with this log\r\n * @example \"Smell of curry\"\r\n */\r\n playerName?: string;\r\n /**\r\n * The message for this log\r\n * @example \"Smell of curry is bad\"\r\n */\r\n message: string;\r\n /**\r\n * An optional property to list what protection this was from\r\n */\r\n protection?: string;\r\n}\r\n\r\nexport type EventsReturnType = (\r\n arg: Parameters[0]>[0]\r\n) => void;\r\n\r\nexport type IProtectionsConfig = {\r\n [key: string]: boolean | string | number;\r\n /**\r\n * If this protection is enabled\r\n */\r\n enabled: boolean;\r\n};\r\n\r\nexport interface IBanData {\r\n /**\r\n * The unique id of this ban\r\n */\r\n key: string;\r\n /**\r\n * The playersName of who was banned\r\n * @example \"Smell of curry\"\r\n */\r\n playerName: string;\r\n /**\r\n * The date in MS when this player was banned\r\n */\r\n date: number;\r\n /**\r\n * The duration in ms that this ban will be for\r\n * if null player is banned forever\r\n */\r\n duration?: number;\r\n /**\r\n * When this ban will expire, if null it will never expire meaning player is banned forever\r\n */\r\n expire?: number;\r\n /**\r\n * The reason for why this player was banned\r\n * @example \"Hacking\"\r\n */\r\n reason?: string;\r\n /**\r\n * Who banned this player\r\n * @example \"Smell of curry\"\r\n * @example \"Rubedo Anti Cheat\"\r\n */\r\n by?: string;\r\n}\r\n\r\nexport interface IFreezeData {\r\n /**\r\n * Players name of who was banned\r\n */\r\n playerName: string;\r\n /**\r\n * Unique id of this freeze instance\r\n */\r\n key: string;\r\n /**\r\n * The reason for this freeze\r\n */\r\n reason?: string;\r\n /**\r\n * The location of this freeze\r\n */\r\n location: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n dimension: string;\r\n };\r\n}\r\n\r\nexport interface IMuteData {\r\n /**\r\n * Players name of who is muted\r\n * @example \"Smell of curry\"\r\n */\r\n playerName: string;\r\n /**\r\n * The date this player got muted\r\n */\r\n date: number;\r\n /**\r\n * The duration of this mute in ms\r\n * if null player is muted forever\r\n */\r\n duration?: number;\r\n /**\r\n * When this players mute will expire in ms\r\n * if null this mute will never expire\r\n */\r\n expire?: number;\r\n /**\r\n * Why this player is muted\r\n * @example \"Spamming\"\r\n */\r\n reason?: string;\r\n /**\r\n * Who muted this player\r\n * @example \"Smell of curry\"\r\n * @example \"Rubedo Anti Cheat\"\r\n */\r\n by?: string;\r\n}\r\n\r\nexport interface INpcLocation {\r\n dimension: string;\r\n x: number;\r\n y: number;\r\n z: number;\r\n}\r\n\r\nexport interface IRegionDB {\r\n dimensionId: string;\r\n from: IRegionCords;\r\n to: IRegionCords;\r\n key: string;\r\n permissions: IRegionPermissions;\r\n}\r\n\r\nexport interface IRegionCords {\r\n x: number;\r\n z: number;\r\n}\r\n\r\nexport interface IRegionPermissions {\r\n /**\r\n * if the player can use chests, default: true\r\n */\r\n doorsAndSwitches: Boolean;\r\n /**\r\n * if the player can use doors, default: true\r\n */\r\n openContainers: Boolean;\r\n /**\r\n * if players can fight, default: false\r\n */\r\n pvp: Boolean;\r\n /**\r\n * the entities allowed in this region\r\n */\r\n allowedEntities: Array;\r\n}\r\n", "import {\n ArgumentTypes,\n Command,\n} from \"../../../../rubedo/lib/Command/Command.js\";\nimport {\n getRole,\n getServerOwner,\n isServerOwner,\n setRole,\n setServerOwner,\n} from \"../../utils.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { confirmAction } from \"../../../../rubedo/lib/Form/utils\";\nimport { ROLES } from \"../../types\";\n\n// Helper\nconst StringIsNumber = (value: any) => isNaN(Number(value)) === false;\n\n// Turn enum into array\nfunction ToArray(enumme: any) {\n return (\n Object.keys(enumme)\n // @ts-ignore\n .filter(StringIsNumber)\n .map((key) => enumme[key])\n );\n}\n\nconst root = new Command({\n name: \"role\",\n description: \"Changes the role for a player\",\n requires: (player) => getRole(player) == \"admin\" || isServerOwner(player),\n});\n\nroot\n .literal({\n name: \"set\",\n description: \"Sets the role for a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .argument(new ArgumentTypes.array(\"role\", ToArray(ROLES) as string[]))\n .executes((ctx, playerName, role) => {\n setRole(playerName, role as keyof typeof ROLES);\n ctx.reply(`Changed role of ${playerName} to ${role}`);\n });\n\nroot\n .literal({\n name: \"get\",\n description: \"Gets the role of a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .executes((ctx, playerName) => {\n const role = getRole(playerName);\n ctx.reply(`${playerName} has role: ${role}`);\n });\n\nconst ownerRoot = root.literal({\n name: \"owner\",\n description: \"Manages the owner\",\n});\n\nownerRoot\n .literal({\n name: \"get\",\n description: \"Gets the owner of the world\",\n })\n .executes((ctx) => {\n const ownerId = getServerOwner();\n const ids = TABLES.ids.collection();\n const ownerName = Object.keys(ids).find((key) => ids[key] === ownerId);\n ctx.reply(`\u00A7aServer Owner: ${ownerName} (id: ${ownerId})`);\n });\n\nownerRoot\n .literal({\n name: \"transfer\",\n description: \"Transfers the owner of the world\",\n requires: (player) => isServerOwner(player),\n })\n .argument(new ArgumentTypes.player())\n .executes((ctx, player) => {\n confirmAction(\n ctx.sender,\n `Are you sure you want to transfer the server ownership to ${player.name}, this action is not reversible!`,\n () => {\n setServerOwner(player);\n ctx.reply(\n `\u00A7aSet the server Owner to: ${player.name} (id: ${player.id})`\n );\n }\n );\n ctx.reply(`\u00A7aClose chat to confirm`);\n });\n\nownerRoot\n .literal({\n name: \"clear\",\n description: \"clear's the owner of the world\",\n requires: (player) => isServerOwner(player),\n })\n .executes((ctx) => {\n confirmAction(\n ctx.sender,\n \"Are you sure you want to clear the server owner, this action is not reversible!\",\n () => {\n setServerOwner(null);\n ctx.reply(\n `\u00A7aCleared the server owner! run \"/reload\" or reload world to run \"/function start\" again!`\n );\n }\n );\n ctx.reply(`\u00A7aClose chat to confirm`);\n });\n", "import { Player } from \"@minecraft/server\";\r\nimport { ENCHANTMENTS } from \"../../config/enchantments\";\r\nimport { getConfigId, setConfigId } from \"../../utils\";\r\nimport { APPEAL_LINK } from \"../../config/moderation\";\r\nimport { ActionForm } from \"../../../../rubedo/lib/Form/Models/ActionForm\";\r\nimport { ModalForm } from \"../../../../rubedo/lib/Form/Models/ModelForm\";\r\n\r\nexport function manageBannedItemsForm(player: Player) {\r\n new ActionForm(\"Manage Banned Items\")\r\n .addButton(\"Remove a Banned Item\", null, () => {\r\n removeBannedItemForm(player);\r\n })\r\n .addButton(\"Ban an item\", null, () => {\r\n addBannedItemForm(player);\r\n })\r\n .show(player);\r\n}\r\nexport function removeBannedItemForm(player: Player) {\r\n new ModalForm(\"Remove Banned Items\")\r\n .addDropdown(\"Select item to remove\", getConfigId(\"banned_items\"))\r\n .show(player, (ctx, item) => {\r\n let items = getConfigId(\"banned_items\");\r\n items = items.filter((p) => p != item);\r\n setConfigId(\"banned_items\", items);\r\n player.tell(`Removed Banned item \"${item}\"`);\r\n });\r\n}\r\n\r\nexport function addBannedItemForm(player: Player) {\r\n new ModalForm(\"Add Banned Item\")\r\n .addTextField(\"Item Id\", \"minecraft:string\")\r\n .show(player, (ctx, item) => {\r\n let items = getConfigId(\"banned_items\");\r\n if (items.includes(item))\r\n return ctx.error(`\u00A7cItem \"${item}\" is already banned`);\r\n items.push(item);\r\n setConfigId(\"banned_items\", items);\r\n player.tell(`Banned the item \"${item}\"`);\r\n });\r\n}\r\n\r\nexport function manageBannedBlocksForm(player: Player) {\r\n new ActionForm(\"Manage Banned Blocks\")\r\n .addButton(\"Remove a Banned Block\", null, () => {\r\n removeBannedBlockForm(player);\r\n })\r\n .addButton(\"Ban an block\", null, () => {\r\n addBannedBlockForm(player);\r\n })\r\n .show(player);\r\n}\r\n\r\nexport function removeBannedBlockForm(player: Player) {\r\n new ModalForm(\"Remove Banned Block\")\r\n .addDropdown(\"Select block to remove\", getConfigId(\"banned_blocks\"))\r\n .show(player, (ctx, block) => {\r\n let blocks = getConfigId(\"banned_blocks\");\r\n blocks = blocks.filter((p) => p != block);\r\n setConfigId(\"banned_blocks\", blocks);\r\n player.tell(`Removed Banned block \"${block}\"`);\r\n });\r\n}\r\n\r\nexport function addBannedBlockForm(player: Player) {\r\n new ModalForm(\"Add Banned Block\")\r\n .addTextField(\"Block Id\", \"minecraft:barrier\")\r\n .show(player, (ctx, block) => {\r\n let blocks = getConfigId(\"banned_blocks\");\r\n if (blocks.includes(block))\r\n return ctx.error(`\u00A7cBlock \"${block}\" is already banned`);\r\n blocks.push(block);\r\n setConfigId(\"banned_blocks\", blocks);\r\n player.tell(`Banned the block \"${block}\"`);\r\n });\r\n}\r\n\r\nexport function manageEnchantmentLevelsForm(player: Player) {\r\n new ModalForm(\"Manage Enchantment Levels\")\r\n .addDropdown(\"Enchantment to change\", Object.keys(ENCHANTMENTS), 0)\r\n .addTextField(\"Level (number)\", \"5\")\r\n .show(player, (ctx, enchantment, levelString) => {\r\n if (isNaN(levelString as any))\r\n return ctx.error(\r\n `\u00A7c\"${levelString}\" is not a number, please enter a value like, \"3\", \"9\", etc.`\r\n );\r\n const level = parseInt(levelString);\r\n let enchants = getConfigId(\"enchantments\");\r\n enchants[enchantment as keyof typeof ENCHANTMENTS] = level;\r\n setConfigId(\"enchantments\", enchants);\r\n player.tell(`Set max level for ${enchantment} to ${level}`);\r\n });\r\n}\r\n\r\nexport function manageAppealLinkForm(player: Player) {\r\n new ModalForm(\"Manage Appeal Link\")\r\n .addTextField(\"Appeal Link\", APPEAL_LINK)\r\n .show(player, (ctx, link) => {\r\n setConfigId(\"appealLink\", link);\r\n player.tell(`Changed the servers appeal link to ${link}`);\r\n });\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport type { IProtectionsConfig } from \"../../types\";\r\nimport { PROTECTIONS } from \"../../protections\";\r\nimport { Protection } from \"../models/Protection\";\r\nimport { showHomeForm } from \"./home\";\r\nimport { ModalForm } from \"../../../../rubedo/lib/Form/Models/ModelForm\";\r\nimport { ActionForm } from \"../../../../rubedo/lib/Form/Models/ActionForm\";\r\n\r\nexport function showAutoModHomeForm(player: Player) {\r\n const form = new ActionForm(\"Manage Protections\");\r\n\r\n for (const protection of Object.values(PROTECTIONS)) {\r\n form.addButton(protection.name, protection.iconPath, () => {\r\n showProtectionConfig(protection, player);\r\n });\r\n }\r\n form\r\n .addButton(\"Back\", \"textures/ui/arrow_dark_left_stretch.png\", () => {\r\n showHomeForm(player);\r\n })\r\n .show(player);\r\n}\r\n\r\nexport function showProtectionConfig(protection: Protection, player: Player) {\r\n const data = protection.getConfig();\r\n const form = new ModalForm(\r\n `Manage ${protection.name} Protection Config`\r\n ).addToggle(\"Enabled\", data[\"enabled\"]);\r\n let keys: string[] = [];\r\n for (const [key, value] of Object.entries(protection.configDefault)) {\r\n keys.push(key);\r\n if (typeof value.defaultValue == \"boolean\") {\r\n form.addToggle(value.description, data[key] as boolean);\r\n } else if (typeof value.defaultValue == \"number\") {\r\n form.addSlider(value.description, 0, 100, 1, data[key] as number);\r\n } else {\r\n form.addTextField(value.description, null, data[key] as string);\r\n }\r\n }\r\n form.show(player, (ctx, enabled, ...keys) => {\r\n if (enabled != data[\"enabled\"]) {\r\n if (enabled) protection.enable();\r\n if (!enabled) protection.disable();\r\n }\r\n let config: IProtectionsConfig = {\r\n enabled: enabled,\r\n };\r\n for (const [i, key] of Object.keys(protection.configDefault).entries()) {\r\n config[key] = keys[i];\r\n }\r\n protection.setConfig(config);\r\n player.tell(`Updated config for ${protection.name}!`);\r\n });\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport * as settings from \"./settings\";\r\nimport * as automod from \"./automod\";\r\nimport { ActionForm } from \"../../../../rubedo/lib/Form/Models/ActionForm\";\r\n\r\nexport function showHomeForm(player: Player) {\r\n new ActionForm(\"Rubedo Settings\")\r\n .addButton(\"Auto Mod\", \"textures/ui/permissions_op_crown.png\", () => {\r\n automod.showAutoModHomeForm(player);\r\n })\r\n .addButton(\"Banned items\", \"textures/blocks/sculk_shrieker_top.png\", () => {\r\n settings.manageBannedItemsForm(player);\r\n })\r\n .addButton(\"Banned blocks\", \"textures/blocks/barrier.png\", () => {\r\n settings.manageBannedBlocksForm(player);\r\n })\r\n .addButton(\"Enchantments\", \"textures/items/book_enchanted.png\", () => {\r\n settings.manageEnchantmentLevelsForm(player);\r\n })\r\n .addButton(\"Appeal Link\", \"textures/ui/Feedback.png\", () => {\r\n settings.manageAppealLinkForm(player);\r\n })\r\n .show(player);\r\n}\r\n", "import { Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { getRole } from \"../../utils.js\";\r\nimport { showHomeForm } from \"../forms/home.js\";\r\n\r\nnew Command({\r\n name: \"settings\",\r\n description: \"Opens up the settings menu for the player\",\r\n requires: (player) => [\"admin\", \"moderator\"].includes(getRole(player)),\r\n}).executes((ctx) => {\r\n showHomeForm(ctx.sender);\r\n ctx.sender.tell(`\u00A7aForm request sent, close chat to continue!`);\r\n});\r\n", "import { Player, world } from \"@minecraft/server\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { getRole } from \"../../utils.js\";\n\nfunction vanish(player: Player, say: boolean) {\n if (player.hasTag(`spectator`)) {\n player.runCommandAsync(`gamemode c`);\n player.triggerEvent(`removeSpectator`);\n player.removeTag(`spectator`);\n if (!say) return;\n world.say({\n rawtext: [\n {\n translate: \"multiplayer.player.joined\",\n with: [`\u00A7e${player.name}`],\n },\n ],\n });\n } else {\n player.runCommandAsync(`gamemode spectator`);\n player.triggerEvent(`addSpectator`);\n player.addTag(`spectator`);\n if (!say) return;\n world.say({\n rawtext: [\n {\n translate: \"multiplayer.player.left\",\n with: [`\u00A7e${player.name}`],\n },\n ],\n });\n }\n}\n\nnew Command({\n name: \"vanish\",\n description: \"Toggles Vanish Mode on the sender\",\n requires: (player) => getRole(player) == \"admin\",\n})\n .executes((ctx) => {\n vanish(ctx.sender, false);\n })\n .boolean(\"say\")\n .executes((ctx, say) => {\n vanish(ctx.sender, say);\n });\n", "/*\r\n|--------------------------------------------------------------------------\r\n| Version\r\n|--------------------------------------------------------------------------\r\n|\r\n| This is the version of rubedo recommended to NOT CHANGE could cause bugs.\r\n|\r\n*/\r\nexport const VERSION = \"2.6.7-beta\";\r\n\r\n/*\r\n|--------------------------------------------------------------------------\r\n| Game Version\r\n|--------------------------------------------------------------------------\r\n|\r\n| This is the version of minecraft that this version of rubedo\r\n| was made for its a simple constant to tell creators what version\r\n| this gametest api is supposed to work perfectly for.\r\n|\r\n*/\r\nexport const GAME_VERSION = \"1.19.50\";\r\n", "import { VERSION } from \"../../../../rubedo/config/app\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command\";\n\nnew Command({\n name: \"version\",\n description: \"Get Current Rubedo Version\",\n aliases: [\"v\"],\n}).executes((ctx) => {\n ctx.reply(`Current Rubedo Version: ${VERSION}`);\n});\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { getRole, kick } from \"../../utils\";\r\n\r\nnew Command({\r\n name: \"kick\",\r\n description: \"Kicks a player from the game\",\r\n requires: (player) => getRole(player) == \"admin\",\r\n})\r\n .argument(new ArgumentTypes.player())\r\n .string(\"reason\")\r\n .executes((ctx, player, reason) => {\r\n kick(player, [reason]);\r\n ctx.reply(`\u00A7aKicked ${player.name} from world`);\r\n });\r\n", "import { TABLES } from \"../../tables.js\";\r\nimport type { LogData } from \"../../types\";\r\n\r\nexport class Log {\r\n /**\r\n * The data on this Log\r\n */\r\n data: LogData;\r\n constructor(data: LogData) {\r\n this.data = data;\r\n console.warn(`[LOG]: ${data.message}`);\r\n TABLES.logs.set(Date.now().toString(), data);\r\n }\r\n}\r\n", "import { PREFIX } from \"../../../../rubedo/config/commands.js\";\r\nimport { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { TABLES } from \"../../tables.js\";\r\nimport { getRole } from \"../../utils\";\r\nimport { Log } from \"../models/Log\";\r\n\r\nfunction timeDifference(previous: number) {\r\n var msPerMinute = 60 * 1000;\r\n var msPerHour = msPerMinute * 60;\r\n var msPerDay = msPerHour * 24;\r\n var msPerMonth = msPerDay * 30;\r\n var msPerYear = msPerDay * 365;\r\n\r\n var elapsed = Date.now() - previous;\r\n\r\n if (elapsed < msPerMinute) {\r\n return Math.round(elapsed / 1000) + \" seconds ago\";\r\n } else if (elapsed < msPerHour) {\r\n return Math.round(elapsed / msPerMinute) + \" minutes ago\";\r\n } else if (elapsed < msPerDay) {\r\n return Math.round(elapsed / msPerHour) + \" hours ago\";\r\n } else if (elapsed < msPerMonth) {\r\n return \"approximately \" + Math.round(elapsed / msPerDay) + \" days ago\";\r\n } else if (elapsed < msPerYear) {\r\n return \"approximately \" + Math.round(elapsed / msPerMonth) + \" months ago\";\r\n } else {\r\n return \"approximately \" + Math.round(elapsed / msPerYear) + \" years ago\";\r\n }\r\n}\r\n\r\nconst root = new Command({\r\n name: \"log\",\r\n description: \"Manages the log command\",\r\n requires: (player) => getRole(player) == \"admin\",\r\n});\r\n\r\nroot\r\n .literal({\r\n name: \"add\",\r\n description: \"Adds a new log\",\r\n })\r\n .string(\"message\")\r\n .executes((ctx, message) => {\r\n new Log({ message: message });\r\n ctx.reply(`\u00A7aAdded new log: ${message}`);\r\n });\r\n\r\nroot\r\n .literal({\r\n name: \"getAll\",\r\n description: \"Gets all logs sorted in descending\",\r\n })\r\n .int(\"page\")\r\n .array(\"order\", [\"ascending\", \"descending\"] as const)\r\n .executes((ctx, page, order) => {\r\n const allLogs = Object.entries(TABLES.logs.collection()).sort((a, b) =>\r\n order == \"ascending\"\r\n ? parseInt(b[0]) - parseInt(a[0])\r\n : parseInt(a[0]) - parseInt(b[0])\r\n );\r\n if (allLogs.length == 0) return ctx.reply(`\u00A7cNo Logs have been made!`);\r\n const maxPages = Math.ceil(allLogs.length / 8);\r\n if (page > maxPages) page = maxPages;\r\n ctx.reply(\r\n `\u00A72--- Showing logs page ${page} of ${maxPages} (${PREFIX}log getAll ) ---`\r\n );\r\n\r\n for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) {\r\n ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`);\r\n }\r\n });\r\n\r\nroot\r\n .literal({\r\n name: \"getPlayersLogs\",\r\n description: \"Gets all logs associated with a player\",\r\n })\r\n .argument(new ArgumentTypes.playerName())\r\n .int(\"page\")\r\n .array(\"order\", [\"ascending\", \"descending\"] as const)\r\n .executes((ctx, playerName, page, order) => {\r\n const allLogs = Object.entries(TABLES.logs.collection())\r\n .filter((v) => v[1].playerName == playerName)\r\n .sort((a, b) =>\r\n order == \"ascending\"\r\n ? parseInt(b[0]) - parseInt(a[0])\r\n : parseInt(a[0]) - parseInt(b[0])\r\n );\r\n if (allLogs.length == 0)\r\n return ctx.reply(`\u00A7cNo Logs exists for \"${playerName}\"!`);\r\n const maxPages = Math.ceil(allLogs.length / 8);\r\n if (page > maxPages) page = maxPages;\r\n ctx.reply(\r\n `\u00A72--- Showing logs for \"${playerName}\" page ${page} of ${maxPages} ---`\r\n );\r\n\r\n for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) {\r\n ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`);\r\n }\r\n });\r\n\r\nroot\r\n .literal({\r\n name: \"getProtectionLogs\",\r\n description: \"Gets all logs associated with a protection\",\r\n })\r\n .string(\"protection\")\r\n .int(\"page\")\r\n .array(\"order\", [\"ascending\", \"descending\"] as const)\r\n .executes((ctx, protection, page, order) => {\r\n const allLogs = Object.entries(TABLES.logs.collection())\r\n .filter((v) => v[1].protection == protection)\r\n .sort((a, b) =>\r\n order == \"ascending\"\r\n ? parseInt(b[0]) - parseInt(a[0])\r\n : parseInt(a[0]) - parseInt(b[0])\r\n );\r\n if (allLogs.length == 0)\r\n return ctx.reply(`\u00A7cNo Logs exists for protection: \"${protection}\"!`);\r\n const maxPages = Math.ceil(allLogs.length / 8);\r\n if (page > maxPages) page = maxPages;\r\n ctx.reply(\r\n `\u00A72--- Showing logs for Protection: \"${protection}\" page ${page} of ${maxPages} ---`\r\n );\r\n\r\n for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) {\r\n ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`);\r\n }\r\n });\r\n\r\nroot\r\n .literal({\r\n name: \"clearAll\",\r\n description: \"Clears all logs\",\r\n })\r\n .executes((ctx) => {\r\n TABLES.logs.clear();\r\n ctx.reply(`\u00A7aCleared All logs!`);\r\n });\r\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { getRole } from \"../../utils\";\r\n\r\nconst root = new Command({\r\n name: \"teleport\",\r\n description: \"Teleports entities (players, mobs, etc.).\",\r\n aliases: [\"tp\"],\r\n requires: (player) => getRole(player) == \"admin\",\r\n});\r\n\r\nroot\r\n .argument(new ArgumentTypes.player())\r\n .location(\"destination\")\r\n .executes((ctx, player, destination) => {\r\n player.addTag(\"skip-movement-check\");\r\n player.teleport(destination, player.dimension, 0, 0);\r\n ctx.reply(\r\n `Teleported ${player.name} to ${destination.x} ${destination.y} ${destination.z}`\r\n );\r\n });\r\n", "import { Player, system, world } from \"@minecraft/server\";\r\nimport { EntitiesLoad } from \"./EntitiesLoad\";\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: (player: Player) => void;\r\n delay: number;\r\n lastCall: number;\r\n };\r\n} = {};\r\n\r\nEntitiesLoad.subscribe(() => {\r\n system.runSchedule(() => {\r\n const players = [...world.getPlayers()];\r\n for (const [i, player] of players.entries()) {\r\n for (const CALLBACK of Object.values(CALLBACKS)) {\r\n if (\r\n CALLBACK.delay != 0 &&\r\n system.currentTick - CALLBACK.lastCall < CALLBACK.delay\r\n )\r\n continue;\r\n CALLBACK.callback(player);\r\n if (i == players.length - 1) CALLBACK.lastCall = system.currentTick;\r\n }\r\n }\r\n });\r\n});\r\n\r\nexport class forEachPlayer {\r\n /**\r\n * Subscribes to a callback that returns every player\r\n * @param callback what to be called for each player\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(\r\n callback: (player: Player) => void,\r\n delay: number = 0\r\n ): number {\r\n const key = Object.keys(CALLBACKS).length;\r\n CALLBACKS[key] = { callback: callback, delay: delay, lastCall: 0 };\r\n return key;\r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n", "import { TABLES } from \"../../tables.js\";\nimport { msToTime } from \"../../../../utils.js\";\nimport { kick, getConfigId } from \"../../utils.js\";\nimport { forEachPlayer } from \"../../../../rubedo/lib/Events/forEachPlayer.js\";\n\nforEachPlayer.subscribe((player) => {\n try {\n const banData = TABLES.bans.get(player.id);\n if (!banData) return;\n if (banData.expire && banData.expire < Date.now())\n return TABLES.bans.delete(player.id);\n kick(\n player,\n [\n `\u00A7cYou have been banned!`,\n `\u00A7aReason: \u00A7f${banData.reason}`,\n `\u00A7fExpiry: \u00A7b${\n banData.expire ? msToTime(banData.expire - Date.now()) : \"Forever\"\n }`,\n `\u00A7fAppeal at: \u00A7b${getConfigId(\"appealLink\")}`,\n ],\n () => {\n console.warn(new Error(\"Failed to kick player\"));\n TABLES.bans.delete(player.id);\n }\n );\n } catch (error) {\n console.warn(error + error.stack);\n }\n}, 20);\n", "import { Location } from \"@minecraft/server\";\nimport { TABLES } from \"../../tables.js\";\nimport { DIMENSIONS } from \"../../../../utils.js\";\nimport { forEachPlayer } from \"../../../../rubedo/lib/Events/forEachPlayer.js\";\n\nforEachPlayer.subscribe((player) => {\n try {\n const freezeData = TABLES.freezes.get(player.id);\n\n if (!freezeData)\n return player.getComponent(\"movement\").resetToDefaultValue();\n player.getComponent(\"movement\").setCurrent(0);\n\n player.teleport(\n new Location(\n freezeData.location.x,\n freezeData.location.y,\n freezeData.location.z\n ),\n DIMENSIONS[freezeData.location.dimension as keyof typeof DIMENSIONS],\n 0,\n 0\n );\n } catch (error) {}\n}, 200);\n", "import { world, BeforeChatEvent } from \"@minecraft/server\";\r\nimport { PREFIX } from \"../../config/commands\";\r\n\r\ntype beforeChatCallback = (arg: BeforeChatEvent) => void;\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: beforeChatCallback;\r\n };\r\n} = {};\r\n\r\nworld.events.beforeChat.subscribe((data) => {\r\n if (data.message.startsWith(PREFIX)) return; // This is a command\r\n for (const callback of Object.values(CALLBACKS)) {\r\n callback.callback(data);\r\n }\r\n});\r\n\r\nexport class beforeChat {\r\n /**\r\n * Subscribes to a callback to get notified when a chat is sent that is not a command\r\n * @param callback what to be called when one of these entity's inventory changes\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(callback: beforeChatCallback): number {\r\n const key = Date.now();\r\n CALLBACKS[key] = { callback: callback };\r\n return key;\r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n", "import { Mute } from \"../models/Mute.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { text } from \"../../../../rubedo/lang/text.js\";\nimport { beforeChat } from \"../../../../rubedo/lib/Events/beforeChat.js\";\n\nbeforeChat.subscribe((data) => {\n const muteData = Mute.getMuteData(data.sender);\n if (!muteData) return;\n if (muteData.expire && muteData.expire < Date.now())\n return TABLES.mutes.delete(data.sender.name);\n data.cancel = true;\n data.sender.tell(text[\"modules.managers.mute.isMuted\"]());\n});\n", "import { BlockLocation, Player, system, world } from \"@minecraft/server\";\nimport { Region } from \"../models/Region.js\";\nimport { getRole, loadRegionDenys } from \"../../utils.js\";\nimport { BLOCK_CONTAINERS, DOORS_SWITCHES } from \"../../config/region.js\";\nimport { DIMENSIONS } from \"../../../../utils.js\";\nimport { EntitiesLoad } from \"../../../../rubedo/lib/Events/EntitiesLoad.js\";\nimport { forEachPlayer } from \"../../../../rubedo/lib/Events/forEachPlayer.js\";\n\n/**\n * Sets Deny blocks at bottom of region every 5 mins\n */\nsystem.runSchedule(() => {\n loadRegionDenys();\n}, 6000);\n\n/**\n * Permissions for region\n */\nworld.events.beforeItemUseOn.subscribe((data) => {\n if ([\"moderator\", \"admin\"].includes(getRole(data.source as Player))) return;\n const region = Region.blockLocationInRegion(\n data.blockLocation,\n data.source.dimension.id\n );\n if (!region) return;\n const block = data.source.dimension.getBlock(data.blockLocation);\n if (\n DOORS_SWITCHES.includes(block.typeId) &&\n region.permissions.doorsAndSwitches\n )\n return;\n if (\n BLOCK_CONTAINERS.includes(block.typeId) &&\n region.permissions.openContainers\n )\n return;\n data.cancel = true;\n});\n\nworld.events.beforeExplosion.subscribe((data) => {\n for (let i = 0; i < data.impactedBlocks.length; i++) {\n const bL = data.impactedBlocks[i];\n let region = Region.blockLocationInRegion(bL, data.dimension.id);\n if (region) return (data.cancel = true);\n }\n});\n\nworld.events.entityCreate.subscribe(async ({ entity }) => {\n const region = await Region.blockLocationInRegionSync(\n new BlockLocation(entity.location.x, entity.location.y, entity.location.z),\n entity.dimension.id\n );\n if (!region) return;\n if (region.permissions.allowedEntities.includes(entity.typeId)) return;\n entity.teleport({ x: 0, y: -64, z: 0 }, entity.dimension, 0, 0);\n entity.kill();\n});\n\nEntitiesLoad.subscribe(() => {\n system.runSchedule(async () => {\n for (const region of await Region.getAllRegionsSync()) {\n for (const entity of DIMENSIONS[\n region.dimensionId as keyof typeof DIMENSIONS\n ].getEntities({ excludeTypes: region.permissions.allowedEntities })) {\n if (!region.entityInRegion(entity)) continue;\n entity.teleport({ x: 0, y: -64, z: 0 }, entity.dimension, 0, 0);\n entity.kill();\n }\n }\n }, 100);\n});\n\n/**\n * Gives player a tag if they are in a region\n */\nforEachPlayer.subscribe((player) => {\n for (const region of Region.getAllRegions()) {\n if (region.entityInRegion(player)) {\n player.addTag(`inRegion`);\n if (!region.permissions.pvp) player.addTag(`region-protected`);\n } else {\n player.removeTag(`inRegion`);\n player.removeTag(`region-protected`);\n }\n }\n}, 5);\n", "import { world } from \"@minecraft/server\";\r\nimport { TABLES } from \"../../tables.js\";\r\nimport { getRole, isLockedDown, kick, setRole } from \"../../utils\";\r\nimport { Mute } from \"../models/Mute\";\r\nimport { ChangePlayerRoleTask } from \"../models/Task\";\r\nimport { text } from \"../../../../rubedo/lang/text.js\";\r\nimport { EntitiesLoad } from \"../../../../rubedo/lib/Events/EntitiesLoad.js\";\r\n\r\nworld.events.playerJoin.subscribe(async ({ player }) => {\r\n await EntitiesLoad.awaitLoad();\r\n if (isLockedDown() && getRole(player) != \"admin\")\r\n return kick(player, text[\"lockdown.kick.message\"]());\r\n // --\r\n if (Mute.getMuteData(player)) player.runCommandAsync(`ability @s mute true`);\r\n if (!TABLES.ids.has(player.name)) {\r\n // Player is new!\r\n TABLES.ids.set(player.name, player.id);\r\n }\r\n /**\r\n * This is a role that was tried to push when the player was offline\r\n * so were setting it now because the player just joined\r\n */\r\n const roleToSet = ChangePlayerRoleTask.getPlayersRoleToSet(player.name);\r\n if (roleToSet) setRole(player, roleToSet);\r\n});\r\n", "import {\n Entity,\n InventoryComponentContainer,\n Items,\n MinecraftItemTypes,\n world,\n} from \"@minecraft/server\";\nimport { AIR } from \"../../../../rubedo/lib/Chest GUI\";\nimport { PageItem } from \"../../../../rubedo/lib/Chest GUI/Models/PageItem\";\nimport { Page } from \"../../../../rubedo/lib/Chest GUI/Models/Page\";\nimport { CHESTGUIS } from \"../../../../rubedo/lib/Chest GUI/utils\";\n\n/**\n * The possible fillable slots where items can be put\n * this is for inventory fill\n */\nconst FILLABLE_SLOTS = [\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,\n 41, 42, 43, 44,\n];\n\n/**\n * Fills the chest Screen with the desired kit\n */\nexport function ViewPlayersFill(entity: Entity, page: Page, extras: any) {\n const container: InventoryComponentContainer = entity.getComponent(\n \"minecraft:inventory\"\n ).container;\n\n for (let i = 0; i < container.size; i++) {\n const slot = page.slots[i];\n if (!slot || !slot.item) {\n container.setItem(i, AIR);\n continue;\n }\n container.setItem(i, slot.item.itemStack);\n }\n for (const [i, player] of [...world.getPlayers()].entries()) {\n const slot = FILLABLE_SLOTS[i];\n const item = new PageItem(MinecraftItemTypes.skull, {\n nameTag: player.name,\n data: 3,\n });\n container.setItem(slot, item.itemStack);\n page.slots[slot] = {\n item: item,\n action: (ctx) => {\n ctx.PageAction(\"moderation:see_inventory\", { name: player.name });\n },\n };\n }\n}\n\n/**\n * Fills the chest Screen with the desired kit\n */\nexport function ViewPlayerInventoryFill(\n entity: Entity,\n page: Page,\n extras: any\n) {\n const container = entity.getComponent(\"minecraft:inventory\").container;\n\n for (let i = 0; i < container.size; i++) {\n const slot = page.slots[i];\n if (!slot || !slot.item) {\n container.setItem(i, AIR);\n continue;\n }\n container.setItem(i, slot.item.itemStack);\n }\n\n const player = [...world.getPlayers()].find((p) => p.name == extras.name);\n if (!player) {\n const gui = Object.values(CHESTGUIS).find((e) => e.entity.id == entity.id);\n gui.despawn();\n player.tell(`\"${extras.name}\" Could not be found, Gui Crashed`);\n }\n const inventory = player.getComponent(\"inventory\").container;\n /**\n * the value of how many slots have been taken\n */\n let used_slots = 0;\n for (let i = 0; i < inventory.size; i++) {\n const item = inventory.getItem(i);\n const slot = FILLABLE_SLOTS[used_slots];\n used_slots++;\n if (!item) {\n container.setItem(slot, AIR);\n continue;\n }\n container.setItem(slot, item);\n page.slots[slot] = {\n item: new PageItem(\n Items.get(item.typeId),\n { amount: item.amount, data: item.data },\n item\n ),\n action: (ctx) => {\n if (i < 9) {\n player.runCommandAsync(`replaceitem entity @s slot.hotbar ${i} air`);\n } else {\n player.runCommandAsync(\n `replaceitem entity @s slot.inventory ${i - 9} air`\n );\n }\n ctx.GiveAction();\n page.slots[slot] = {\n item: null,\n action: (ctx) => {\n inventory.addItem(ctx.getItemAdded());\n },\n };\n },\n };\n }\n}\n\nnew Page(\"moderation:see\", ViewPlayersFill)\n .setSlots(\n [50],\n new PageItem(MinecraftItemTypes.arrow, {\n nameTag: \"\u00A7fBack\",\n }),\n (ctx) => {\n ctx.PageAction(\"home\");\n }\n )\n .setSlots(\n [48],\n new PageItem(MinecraftItemTypes.barrier, { nameTag: \"\u00A7cClose GUI\" }),\n (ctx) => {\n ctx.CloseAction();\n }\n );\n\nnew Page(\"moderation:see_inventory\", ViewPlayerInventoryFill)\n .setSlots(\n [50],\n new PageItem(MinecraftItemTypes.arrow, {\n nameTag: \"\u00A7fBack\",\n }),\n (ctx) => {\n ctx.PageAction(\"moderation:see\");\n }\n )\n .setSlots(\n [48],\n new PageItem(MinecraftItemTypes.barrier, { nameTag: \"\u00A7cClose GUI\" }),\n (ctx) => {\n ctx.CloseAction();\n }\n );\n", "import { Player, MinecraftBlockTypes } from \"@minecraft/server\";\nimport { FORBIDDEN_BLOCKS } from \"../../config/moderation\";\nimport { Npc } from \"../models/Npc\";\nimport { getConfigId, getRole } from \"../../utils\";\nimport { Ban } from \"../models/Ban\";\nimport { Protection } from \"../models/Protection\";\n\n/**\n * Entities that are not allowed to spawn because they can be used by CBE\n */\nconst CBE_ENTITIES = [\"minecraft:command_block_minecart\"];\n\nconst protection = new Protection<{\n entityCreate: boolean;\n banSpawnEggs: boolean;\n}>(\n \"cbe\",\n \"Stops CBE\",\n \"textures/blocks/command_block.png\",\n true\n).setConfigDefault({\n entityCreate: {\n description: \"Adds NPC protection\",\n defaultValue: true,\n },\n banSpawnEggs: {\n description: \"If spawn eggs should be banned\",\n defaultValue: true,\n },\n});\n\nprotection.subscribe(\"entityCreate\", ({ entity }) => {\n const config = protection.getConfig();\n if (!config.entityCreate) return;\n const kill = () => {\n try {\n entity.triggerEvent(\"despawn\");\n entity.kill();\n } catch (error) {\n entity.kill();\n }\n };\n if (CBE_ENTITIES.includes(entity.typeId)) return kill();\n if (entity.typeId == \"minecraft:npc\" && !Npc.isValid(entity)) return kill();\n});\n\nprotection.subscribe(\"beforeItemUseOn\", (data) => {\n if (!(data.source instanceof Player)) return;\n if ([\"admin\", \"moderator\"].includes(getRole(data.source))) return;\n const config = protection.getConfig();\n\n if (data.item.typeId.endsWith(\"spawn_egg\")) {\n if (!config.banSpawnEggs) return;\n const block = data.source.dimension.getBlock(data.blockLocation);\n if (block.typeId == MinecraftBlockTypes.mobSpawner.id) return;\n // Cancel use so players cant use spawnEggs on floor\n data.cancel = true;\n data.source.tell(`\u00A7c[Rubedo]: You cannot place spawnEggs on the floor!`);\n data.source.playSound(`note.bass`);\n } else {\n if (FORBIDDEN_BLOCKS.includes(data.item.typeId)) {\n data.cancel = true;\n return;\n }\n const BANNED_BLOCKS = getConfigId(\"banned_blocks\");\n if (!BANNED_BLOCKS.includes(data.item.typeId)) return;\n data.cancel = true;\n new Ban(data.source, null, \"Placing Banned Blocks\");\n }\n});\n", "import { Events, Player, system, world } from \"@minecraft/server\";\r\nimport { TABLES } from \"../../tables.js\";\r\nimport { EventsReturnType, IProtectionsConfig } from \"../../types.js\";\r\nimport { PROTECTIONS } from \"../../protections.js\";\r\nimport { forEachPlayer } from \"../../../../rubedo/lib/Events/forEachPlayer.js\";\r\n\r\n/**\r\n * A protection instance\r\n */\r\nexport class Protection {\r\n /**\r\n * Events that this is subscribed to\r\n */\r\n private events: {\r\n -readonly [Key in keyof Events]+?: {\r\n /**\r\n * Callback this event is to run.\r\n */\r\n callback: ReturnType;\r\n /**\r\n * If this has been triggered on world.events\r\n */\r\n triggered: boolean;\r\n };\r\n };\r\n\r\n /**\r\n * List of events that this protection is scheduled\r\n */\r\n private schedules: {\r\n /**\r\n * Callback to run\r\n */\r\n callback: () => void;\r\n /**\r\n * Delay in ticks\r\n */\r\n tickInterval: number;\r\n /**\r\n * If null, this event hasn't been registered by {@link system.runSchedule}\r\n * if {@link number}, the event has been registered and this key can be used to {@link system.clearRunSchedule}\r\n */\r\n runScheduleId: number | null;\r\n }[];\r\n\r\n /**\r\n * A list of forEachPlayer keys used to unsubscribe\r\n */\r\n private forEachPlayers: {\r\n /**\r\n * Callback to run\r\n * @param player\r\n * @returns\r\n */\r\n callback: (player: Player) => void;\r\n /**\r\n * Delay in ticks\r\n */\r\n delay: number;\r\n /**\r\n * If null, this event hasn't been registered by {@link forEachPlayer}\r\n * if {@link number}, the event has been registered and this key can be used to unsubscribe\r\n */\r\n key: number | null;\r\n }[];\r\n\r\n /**\r\n * Callback to run on enable\r\n */\r\n private onEnableCallback: () => void | undefined;\r\n\r\n /**\r\n * Callback to run on disable\r\n */\r\n private onDisableCallback: () => void | undefined;\r\n\r\n /**\r\n * If this protection is enabled\r\n */\r\n private isEnabled: boolean;\r\n\r\n /**\r\n * The default config object\r\n */\r\n configDefault:\r\n | {\r\n [key in keyof Config]: {\r\n description: string;\r\n defaultValue: Config[key];\r\n };\r\n }\r\n | {};\r\n\r\n /**\r\n * Creates a new protection module\r\n */\r\n constructor(\r\n public name: string,\r\n public description: string,\r\n public iconPath: string,\r\n public isEnabledByDefault: boolean\r\n ) {\r\n this.name = name;\r\n this.description = description;\r\n this.iconPath = iconPath;\r\n this.configDefault = {};\r\n this.isEnabled = false;\r\n this.isEnabledByDefault = isEnabledByDefault;\r\n // ---- events\r\n this.events = {};\r\n this.schedules = [];\r\n this.forEachPlayers = [];\r\n // Save protection\r\n PROTECTIONS[this.name] = this;\r\n }\r\n\r\n /**\r\n * Sets the config to a typed object\r\n * @param data typed object\r\n * @returns\r\n */\r\n setConfigDefault(data: {\r\n [key in keyof Config]: {\r\n description: string;\r\n defaultValue: Config[key];\r\n };\r\n }): Protection {\r\n this.configDefault = data;\r\n TABLES.protections.hasSync(this.name).then((v) => {\r\n if (v) return;\r\n let saveData: IProtectionsConfig = {\r\n enabled: true,\r\n };\r\n for (const key of Object.keys(data)) {\r\n // @ts-ignore\r\n saveData[key] = data[key as keyof typeof data].defaultValue;\r\n }\r\n TABLES.protections.set(this.name, saveData);\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the config data\r\n * @returns Config\r\n */\r\n getConfig(): Config {\r\n let config = TABLES.protections.get(this.name);\r\n if (!config) config = { enabled: this.isEnabled };\r\n return config as Config;\r\n }\r\n\r\n async setConfig(data: Config) {\r\n return TABLES.protections.set(this.name, data as IProtectionsConfig);\r\n }\r\n\r\n /**\r\n * Triggers a change to a activate this module or not.\r\n * @param enabled if this protection is enabled or not\r\n */\r\n private triggerChange(enabled: boolean) {\r\n if (enabled) {\r\n this.isEnabled = true;\r\n // Enable this protection\r\n this.onEnableCallback?.();\r\n for (const [key, value] of Object.entries(this.events)) {\r\n if (value.triggered) continue;\r\n let callback = world.events[key as keyof Events].subscribe(\r\n // @ts-ignore\r\n value.callback\r\n );\r\n value.triggered = true;\r\n value.callback = callback;\r\n }\r\n for (const v of this.forEachPlayers) {\r\n if (v.key) continue;\r\n let key = forEachPlayer.subscribe(v.callback, v.delay);\r\n v.key = key;\r\n }\r\n for (const v of this.schedules) {\r\n if (v.runScheduleId) continue;\r\n let runScheduleId = system.runSchedule(v.callback);\r\n v.runScheduleId = runScheduleId;\r\n }\r\n } else {\r\n this.isEnabled = false;\r\n // Disable this protection\r\n this.onDisableCallback?.();\r\n for (const [key, value] of Object.entries(this.events)) {\r\n if (!value.triggered) continue;\r\n // @ts-ignore\r\n world.events[key as keyof Events].unsubscribe(value.callback);\r\n value.triggered = false;\r\n }\r\n for (const v of this.forEachPlayers) {\r\n if (!v.key) continue;\r\n forEachPlayer.unsubscribe(v.key);\r\n v.key = null;\r\n }\r\n for (const v of this.schedules) {\r\n if (!v.runScheduleId) continue;\r\n system.clearRunSchedule(v.runScheduleId);\r\n v.runScheduleId = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Runs a callback once this protection is activated\r\n * @param callback function to run\r\n */\r\n onEnable(callback: () => void): Protection {\r\n this.onEnableCallback = callback;\r\n return this;\r\n }\r\n\r\n /**\r\n * Runs a callback once this protection is disabled\r\n * @param callback function to run\r\n */\r\n onDisable(callback: () => void): Protection {\r\n this.onDisableCallback = callback;\r\n return this;\r\n }\r\n\r\n /**\r\n * Subscribes to a worldEvent\r\n * @param id event id to subscribe\r\n * @param callback what to run on event callback\r\n * @returns this\r\n */\r\n subscribe(\r\n id: T,\r\n callback: EventsReturnType\r\n ): Protection {\r\n this.events[id] = {\r\n callback: callback,\r\n triggered: false,\r\n };\r\n return this;\r\n }\r\n\r\n /**\r\n * Schedules a callback to be run every x number of ticks\r\n * @param callback callback\r\n * @param tickInterval ticks\r\n */\r\n runSchedule(callback: () => void, tickInterval?: number): Protection {\r\n this.schedules.push({\r\n callback: callback,\r\n tickInterval: tickInterval,\r\n runScheduleId: null,\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Callback for each valid players\r\n * @param callback\r\n * @param delay\r\n */\r\n forEachPlayer(\r\n callback: (player: Player) => void,\r\n delay: number = 0\r\n ): Protection {\r\n this.forEachPlayers.push({\r\n callback: callback,\r\n delay: delay,\r\n key: null,\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Enables this protection\r\n */\r\n enable() {\r\n this.triggerChange(true);\r\n }\r\n\r\n /**\r\n * Disables this protection\r\n */\r\n disable() {\r\n this.triggerChange(false);\r\n }\r\n}\r\n", "import { getRole } from \"../../utils.js\";\nimport { Ban } from \"../models/Ban.js\";\nimport { Protection } from \"../models/Protection.js\";\n\n/**\n * Minecraft Bedrock Anti Crasher\n * @license MIT\n * @author Smell of curry\n * @version 1.0.0\n * --------------------------------------------------------------------------\n * This anti crasher works by testing if a player has reached a location\n * Horion's crasher teleports the player to 30 Million so we just test for\n * That location and if they are there we kick the player (USES: player.json)\n * --------------------------------------------------------------------------\n */\n\n/**\n * This is the distance where if you go past it will ban you\n */\nconst DISTANCE = 320000;\n\nnew Protection(\n \"crasher\",\n \"Protection against type 1 crasher\",\n \"textures/ui/servers.png\",\n true\n).forEachPlayer((player) => {\n if (getRole(player) == \"admin\") return;\n if (\n Math.abs(player.location.x) > DISTANCE ||\n Math.abs(player.location.y) > DISTANCE ||\n Math.abs(player.location.z) > DISTANCE\n ) {\n new Ban(player, null, \"Crasher detected\");\n }\n});\n", "import { GameMode, world } from \"@minecraft/server\";\nimport { getRole } from \"../../utils.js\";\nimport { Ban } from \"../models/Ban.js\";\nimport { Protection } from \"../models/Protection.js\";\nimport { Log } from \"../models/Log.js\";\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog.js\";\n\n/**\n * The gamemode that you cannot be in unless you have staff tag\n */\nconst ILLEGAL_GAMEMODE = GameMode.creative;\n\n/**\n * Stores per world load violation data for players\n */\nconst ViolationCount = new PlayerLog();\n\nconst protection = new Protection<{\n clearPlayer: boolean;\n setToSurvival: boolean;\n banPlayer: boolean;\n violationCount: number;\n}>(\n \"gamemode\",\n \"Blocks illegal gamemode\",\n \"textures/ui/creative_icon.png\",\n true\n).setConfigDefault({\n clearPlayer: {\n description: \"Whether to clear players inventory.\",\n defaultValue: true,\n },\n setToSurvival: {\n description: \"If player should be set to survival after being flagged.\",\n defaultValue: true,\n },\n banPlayer: {\n description: \"If player should be banned after violation count is met.\",\n defaultValue: false,\n },\n violationCount: {\n description: \"The amount of violations before ban.\",\n defaultValue: 0,\n },\n});\n\nprotection.runSchedule(() => {\n const config = protection.getConfig();\n for (const player of world.getPlayers({ gameMode: ILLEGAL_GAMEMODE })) {\n if ([\"moderator\", \"admin\", \"builder\"].includes(getRole(player))) continue;\n try {\n if (config.setToSurvival) player.runCommandAsync(`gamemode s`);\n if (config.clearPlayer) player.runCommandAsync(`clear @s`);\n } catch (error) {}\n new Log({\n playerName: player.name,\n protection: \"Gamemode\",\n message: `${player.name} has entered into a illegal gamemode!`,\n });\n const count = (ViolationCount.get(player) ?? 0) + 1;\n ViolationCount.set(player, count);\n if (config.banPlayer && count >= config.violationCount)\n new Ban(player, null, \"Illegal Gamemode\");\n }\n}, 20);\n", "import { Player, world } from \"@minecraft/server\";\r\n\r\nexport class PlayerLog {\r\n data: Map;\r\n events: Object;\r\n\r\n constructor() {\r\n this.data = new Map();\r\n this.events = {\r\n playerLeave: world.events.playerLeave.subscribe((data) =>\r\n this.data.delete(data.playerName)\r\n ),\r\n };\r\n }\r\n\r\n /**\r\n * Logs a player to a value\r\n */\r\n set(player: Player, value: T): void {\r\n this.data.set(player.name, value);\r\n }\r\n\r\n /**\r\n * Gets a players value\r\n */\r\n get(player: Player): T | undefined {\r\n return this.data.get(player.name);\r\n }\r\n\r\n /**\r\n * Tests if a player is on this log\r\n * @param player \r\n * @returns \r\n */\r\n has(player: Player): boolean {\r\n return this.data.has(player.name);\r\n }\r\n\r\n /**\r\n * Deletes a player from log\r\n */\r\n delete(player: Player) {\r\n this.data.delete(player.name);\r\n }\r\n\r\n /**\r\n * Clears this Player log\r\n */\r\n clear() {\r\n this.data.clear();\r\n }\r\n\r\n /**\r\n * Gets all the players in the log\r\n */\r\n playerNames(): Array {\r\n return [...this.data.keys()];\r\n }\r\n\r\n /**\r\n * Checks to see if a player is in this list\r\n * @param player player to check\r\n * @returns\r\n */\r\n includes(player: Player): boolean {\r\n return this.playerNames().includes(player.name);\r\n }\r\n}\r\n", "import {\r\n world,\r\n Location,\r\n Block,\r\n BlockPermutation,\r\n Dimension,\r\n Player,\r\n system,\r\n} from \"@minecraft/server\";\r\nimport { API_CONTAINERS } from \"../../config/containers.js\";\r\nimport { CONTAINER_LOCATIONS } from \"../Containers/index.js\";\r\n\r\ntype beforeBlockBreakCallback = (arg0: BeforeBlockBreakEvent) => void;\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: beforeBlockBreakCallback;\r\n };\r\n} = {};\r\n\r\nworld.events.blockBreak.subscribe((data) => {\r\n for (const callback of Object.values(CALLBACKS)) {\r\n callback.callback(\r\n new BeforeBlockBreakEvent(\r\n data.block,\r\n data.brokenBlockPermutation,\r\n data.dimension,\r\n data.player\r\n )\r\n );\r\n }\r\n});\r\n\r\nexport class beforeBlockBreak {\r\n /**\r\n * Subscribes to a callback to get notified when a chat is sent that is not a command\r\n * @param callback what to be called when one of these entities inventory's changes\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(callback: beforeBlockBreakCallback): number {\r\n const key = Date.now();\r\n CALLBACKS[key] = { callback: callback };\r\n return key;\r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n\r\nclass BeforeBlockBreakEvent {\r\n /**\r\n * Contains information regarding an event before a player breaks a block.\r\n * @param block Block broken in this event. Note that because this event fires right after a block is broken, the block you will receive will likely be of type 'minecraft:air'. See the .brokenBlockPermutation property for information on this block before it was broken.\r\n * @param brokenBlockPermutation Returns permutation information about this block before it was broken.\r\n * @param dimension Dimension that contains the block that has been broken in this event.\r\n * @param player Player that broke the block for this event.\r\n */\r\n constructor(\r\n public block: Block,\r\n public brokenBlockPermutation: BlockPermutation,\r\n public dimension: Dimension,\r\n public player: Player\r\n ) {\r\n this.block = block;\r\n this.brokenBlockPermutation = brokenBlockPermutation;\r\n this.dimension = dimension;\r\n this.player = player;\r\n }\r\n\r\n set cancel(value: boolean) {\r\n // setting block back\r\n this.dimension\r\n .getBlock(this.block.location)\r\n .setPermutation(this.brokenBlockPermutation.clone());\r\n // setting chest inventory back\r\n if (API_CONTAINERS.includes(this.brokenBlockPermutation.type.id)) {\r\n const OLD_INVENTORY =\r\n CONTAINER_LOCATIONS[JSON.stringify(this.block.location)];\r\n if (OLD_INVENTORY) {\r\n OLD_INVENTORY.load(this.block.getComponent(\"inventory\").container);\r\n }\r\n }\r\n // killing dropped items\r\n system.run(() => {\r\n [\r\n ...this.dimension.getEntities({\r\n maxDistance: 2,\r\n type: \"minecraft:item\",\r\n location: new Location(\r\n this.block.location.x,\r\n this.block.location.y,\r\n this.block.location.z\r\n ),\r\n }),\r\n ].forEach((e) => e.kill());\r\n });\r\n }\r\n}\r\n", "import { getRole } from \"../../utils.js\";\nimport { Ban } from \"../models/Ban.js\";\nimport { Protection } from \"../models/Protection.js\";\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog.js\";\nimport { beforeBlockBreak } from \"../../../../rubedo/lib/Events/beforeBlockBreak.js\";\n\n/**\n * The log of the players break times\n */\nconst log = new PlayerLog();\n\n/**\n * if a block is broken faster than this time it is considered hacking\n */\nconst IMPOSSIBLE_BREAK_TIME = 15;\n\n/**\n * When breaking vegetation blocks it could cause a false trigger\n * so when a block gets broken and it has one of the block tags\n * it gets skipped and doesn't count in the nuker event\n *\n * @link https://wiki.bedrock.dev/blocks/block-tags.html\n */\nexport const VALID_BLOCK_TAGS = [\n \"snow\",\n \"lush_plants_replaceable\",\n \"azalea_log_replaceable\",\n \"minecraft:crop\",\n \"fertilize_area\",\n \"plant\"\n];\n\n/**\n * A list of all the blocks that are impossible to break unless you have hacks\n */\nconst IMPOSSIBLE_BREAKS = [\n \"minecraft:water\",\n \"minecraft:flowing_water\",\n \"minecraft:lava\",\n \"minecraft:flowing_lava\",\n \"minecraft:bedrock\",\n];\n\n/**\n * Stores per world load violation data for players\n */\nconst ViolationCount = new PlayerLog();\n\nlet beforeBlockBreakKey: number = null;\n\nconst protection = new Protection<{\n banPlayer: boolean;\n violationCount: number;\n}>(\n \"nuker\",\n \"Blocks block breaking too fast\",\n \"textures/blocks/dirt.png\",\n true\n).setConfigDefault({\n banPlayer: {\n description: \"If the player should be banned once violation count is met\",\n defaultValue: false,\n },\n violationCount: {\n description: \"Violations before ban\",\n defaultValue: 0,\n },\n});\n\nprotection\n .onEnable(() => {\n const config = protection.getConfig();\n beforeBlockBreakKey = beforeBlockBreak.subscribe((data) => {\n if ([\"moderator\", \"admin\"].includes(getRole(data.player))) return;\n if (data.block.getTags().some((tag) => VALID_BLOCK_TAGS.includes(tag)))\n return;\n const old = log.get(data.player);\n log.set(data.player, Date.now());\n if (!old) return;\n\n // If block is impossible to break skip check, reduces lag.\n if (!IMPOSSIBLE_BREAKS.includes(data.block.typeId)) {\n if (old < Date.now() - IMPOSSIBLE_BREAK_TIME) return;\n const count = (ViolationCount.get(data.player) ?? 0) + 1;\n ViolationCount.set(data.player, count);\n if (config.banPlayer && count >= config.violationCount)\n new Ban(data.player, null, \"Using Nuker\");\n }\n data.cancel = true;\n });\n })\n .onDisable(() => {\n beforeBlockBreak.unsubscribe(beforeBlockBreakKey);\n });\n", "import { PREFIX } from \"../../../../rubedo/config/commands\";\r\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog\";\r\nimport { getRole } from \"../../utils\";\r\nimport { Mute } from \"../models/Mute\";\r\nimport { Protection } from \"../models/Protection\";\r\n\r\nconst previousMessage = new PlayerLog();\r\n\r\n/**\r\n * Stores per world load violation data for players\r\n */\r\nconst ViolationCount = new PlayerLog();\r\n\r\nconst protection = new Protection<{\r\n permMutePlayer: boolean;\r\n violationCount: number;\r\n repeatedMessages: boolean;\r\n zalgo: boolean;\r\n}>(\r\n \"spam\",\r\n \"Blocks spam in chat\",\r\n \"textures/ui/mute_on.png\",\r\n true\r\n).setConfigDefault({\r\n permMutePlayer: {\r\n description:\r\n \"If player should be permanently muted once violation count is met.\",\r\n defaultValue: false,\r\n },\r\n violationCount: {\r\n description: \"Violation count before permanent mute\",\r\n defaultValue: 0,\r\n },\r\n repeatedMessages: {\r\n description: \"Blocks repeated messages\",\r\n defaultValue: true,\r\n },\r\n zalgo: {\r\n description: \"Blocks zalgo\",\r\n defaultValue: true,\r\n },\r\n});\r\n\r\nprotection.subscribe(\"beforeChat\", (data) => {\r\n try {\r\n if (data.message.startsWith(PREFIX)) return;\r\n if ([\"admin\", \"moderator\"].includes(getRole(data.sender))) return;\r\n const config = protection.getConfig();\r\n const isSpam = () => {\r\n const count = (ViolationCount.get(data.sender) ?? 0) + 1;\r\n ViolationCount.set(data.sender, count);\r\n if (config.permMutePlayer && count >= config.violationCount)\r\n new Mute(data.sender, null, \"Spamming\");\r\n };\r\n if (\r\n config.repeatedMessages &&\r\n previousMessage.get(data.sender) == data.message\r\n ) {\r\n data.cancel = true;\r\n isSpam();\r\n return data.sender.tell(`\u00A7cRepeated message detected!`);\r\n }\r\n if (config.zalgo && /%CC%/g.test(encodeURIComponent(data.message))) {\r\n data.cancel = true;\r\n isSpam();\r\n return data.sender.tell(\r\n `\u00A7cYou message contains some type of zalgo and cannot be sent!`\r\n );\r\n }\r\n previousMessage.set(data.sender, data.message);\r\n } catch (error) {\r\n console.warn(error + error.stack);\r\n }\r\n});\r\n", "import { Player } from \"@minecraft/server\";\r\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog.js\";\r\nimport { AIR } from \"../../../../rubedo/lib/Chest GUI/index.js\";\r\nimport { FORBIDDEN_ITEMS } from \"../../config/moderation.js\";\r\nimport { getConfigId, getMaxEnchantmentLevel, getRole } from \"../../utils\";\r\nimport { Ban } from \"../models/Ban.js\";\r\nimport { Log } from \"../models/Log.js\";\r\nimport { Protection } from \"../models/Protection.js\";\r\n\r\n/**\r\n * Stores violation count for player\r\n */\r\nconst ViolationCount = new PlayerLog();\r\n\r\nconst protection = new Protection<{\r\n clearItem: boolean;\r\n banPlayer: boolean;\r\n violationCount: number;\r\n}>(\r\n \"unobtainable\",\r\n \"Blocks unobtainable items\",\r\n \"textures/blocks/end_portal.png\",\r\n true\r\n)\r\n .setConfigDefault({\r\n clearItem: {\r\n description:\r\n \"If the possessed item should be cleared from there inventory\",\r\n defaultValue: true,\r\n },\r\n banPlayer: {\r\n description: \"If the player should be banned once hit violation count.\",\r\n defaultValue: true,\r\n },\r\n violationCount: {\r\n description:\r\n \"The amount of times this player can posses a banned item before ban.\",\r\n defaultValue: 3,\r\n },\r\n })\r\n .forEachPlayer((player) => {\r\n if (getRole(player) == \"admin\") return;\r\n const BANNED_ITEMS = new Set(getConfigId(\"banned_items\"));\r\n\r\n const inventory = player.getComponent(\"inventory\").container;\r\n for (let i = 0; i < inventory.size; i++) {\r\n const item = inventory.getItem(i);\r\n if (!item) continue;\r\n if (BANNED_ITEMS.has(item.typeId)) return flag(player, i);\r\n if (FORBIDDEN_ITEMS.includes(item.typeId)) {\r\n // Log action\r\n new Log({\r\n playerName: player.name,\r\n message: `${player.name} Has obtained a Forbidden item: ${item.typeId}`,\r\n protection: \"unobtainable\",\r\n });\r\n return inventory.setItem(i, AIR);\r\n }\r\n // Player is allowed to have this itemType\r\n /**\r\n * List of all enchantments that are valid on this item\r\n */\r\n let enchantments = new Set();\r\n for (const enchantment of item.getComponent(\"enchantments\")\r\n .enchantments) {\r\n const MAX_LEVEL = getMaxEnchantmentLevel(enchantment);\r\n if (enchantment.level > MAX_LEVEL) return flag(player, i);\r\n if (enchantment.level < 1) return flag(player, i);\r\n if (enchantments.has(enchantment.type.id)) return flag(player, i);\r\n // Enchantment Is valid\r\n enchantments.add(enchantment.type.id);\r\n }\r\n }\r\n });\r\n\r\n/**\r\n * Flags a player for a item they should not have\r\n * @param player player to flag\r\n * @param index the index of this item in the players inventory\r\n */\r\nfunction flag(player: Player, index: number) {\r\n const inventory = player.getComponent(\"inventory\").container;\r\n const item = inventory.getItem(index);\r\n const data = protection.getConfig();\r\n // Clear Item\r\n if (data.clearItem) inventory.setItem(index, AIR);\r\n // Log action\r\n new Log({\r\n playerName: player.name,\r\n message: `${player.name} Has obtained a unobtainable item: ${item.typeId}`,\r\n protection: \"unobtainable\",\r\n });\r\n // Violation\r\n if (!data.banPlayer) return;\r\n const violations = (ViolationCount.get(player) ?? 0) + 1;\r\n ViolationCount.set(player, violations);\r\n if (violations < data.violationCount) return;\r\n new Ban(player, null, \"Possession of Unobtainable item\");\r\n}\r\n", "import {\r\n ItemStack,\r\n MinecraftBlockTypes,\r\n MinecraftEntityTypes,\r\n MinecraftItemTypes,\r\n Player,\r\n} from \"@minecraft/server\";\r\nimport { AIR } from \"../../../../rubedo/lib/Chest GUI/index.js\";\r\nimport { getGamemode } from \"../../utils.js\";\r\nimport { Protection } from \"../models/Protection.js\";\r\n\r\n/**\r\n * List of blocks to test\r\n */\r\nconst BLOCKS = [\r\n MinecraftBlockTypes.chest.id,\r\n MinecraftBlockTypes.trappedChest.id,\r\n MinecraftBlockTypes.barrel.id,\r\n MinecraftBlockTypes.dispenser.id,\r\n MinecraftBlockTypes.dropper.id,\r\n MinecraftBlockTypes.furnace.id,\r\n MinecraftBlockTypes.litFurnace.id,\r\n MinecraftBlockTypes.blastFurnace.id,\r\n MinecraftBlockTypes.litBlastFurnace.id,\r\n MinecraftBlockTypes.smoker.id,\r\n MinecraftBlockTypes.litSmoker.id,\r\n MinecraftBlockTypes.hopper.id,\r\n MinecraftBlockTypes.beehive.id,\r\n MinecraftBlockTypes.beeNest.id,\r\n MinecraftBlockTypes.mobSpawner.id,\r\n];\r\n\r\n/**\r\n * List of items to test\r\n */\r\nconst CHEST_BOATS = [\r\n MinecraftItemTypes.chestBoat.id,\r\n MinecraftItemTypes.oakChestBoat.id,\r\n MinecraftItemTypes.birchChestBoat.id,\r\n MinecraftItemTypes.acaciaChestBoat.id,\r\n MinecraftItemTypes.jungleChestBoat.id,\r\n MinecraftItemTypes.spruceChestBoat.id,\r\n MinecraftItemTypes.darkOakChestBoat.id,\r\n MinecraftItemTypes.mangroveChestBoat.id,\r\n];\r\n\r\nnew Protection(\r\n \"nbt\",\r\n \"Blocks illegal nbt on items\",\r\n \"textures/ui/icon_random.png\",\r\n true\r\n)\r\n .subscribe(\"blockPlace\", async ({ block }) => {\r\n if (!BLOCKS.includes(block.typeId)) return;\r\n if (\r\n [\r\n MinecraftBlockTypes.chest.id,\r\n MinecraftBlockTypes.trappedChest.id,\r\n ].includes(block.typeId)\r\n ) {\r\n const container = block.getComponent(\"inventory\").container;\r\n for (let i = 0; i < container.size; i++) {\r\n container.setItem(i, new ItemStack(MinecraftItemTypes.acaciaBoat, 0));\r\n }\r\n } else {\r\n const permutation = block.permutation;\r\n await block.dimension.runCommandAsync(\r\n `setblock ${block.x} ${block.y} ${block.z} ${block.typeId}`\r\n );\r\n block.setPermutation(permutation);\r\n }\r\n })\r\n .subscribe(\"beforeItemUseOn\", (data) => {\r\n if (!(data.source instanceof Player)) return;\r\n if (!CHEST_BOATS.includes(data.item.typeId)) return;\r\n data.cancel = true;\r\n data.source.dimension.spawnEntity(\r\n MinecraftEntityTypes.chestBoat.id,\r\n data.blockLocation.above()\r\n );\r\n if (getGamemode(data.source) == \"creative\") return;\r\n data.source\r\n .getComponent(\"inventory\")\r\n .container.setItem(data.source.selectedSlot, AIR);\r\n });\r\n", "import {\r\n MinecraftBlockTypes,\r\n MinecraftEffectTypes,\r\n MinecraftItemTypes,\r\n Player,\r\n system,\r\n Vector3,\r\n} from \"@minecraft/server\";\r\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog\";\r\nimport {\r\n ILocationLog,\r\n onPlayerMove,\r\n} from \"../../../../rubedo/lib/Events/onPlayerMove\";\r\nimport { vector3ToBlockLocation } from \"../../../../utils\";\r\nimport {\r\n ANTI_TP_DISTANCE_THRESHOLD,\r\n DIMENSION_SWITCH_Y,\r\n MOVEMENT_CONSTANTS,\r\n MOVEMENT_DISTANCE_THRESHOLD,\r\n RIPTIDE_TIMEOUT,\r\n SPEED_EFFECT_INCREASE,\r\n TAGS,\r\n} from \"../../config/movement\";\r\nimport { getRole } from \"../../utils\";\r\nimport { Protection } from \"../models/Protection\";\r\nimport { VALID_BLOCK_TAGS } from \"./nuker\";\r\n\r\nconst violations = new PlayerLog();\r\n\r\n/**\r\n * Players that are on riptide timeout for using a trident\r\n */\r\nconst ON_RIPTIDE_TIMEOUT = new PlayerLog();\r\n\r\n/**\r\n * Calculates the distance from loc1 to loc2\r\n * @param {Location} loc1 location 1\r\n * @param {Location} loc2 location 2\r\n * @returns {number}\r\n */\r\nfunction distanceBetween(loc1: Vector3, loc2: Vector3): number {\r\n return Math.hypot(loc2.x - loc1.x, loc2.z - loc1.z);\r\n}\r\n\r\n/**\r\n * Gets the speed offset based on a players SpeedEffect\r\n * @param player player to get\r\n */\r\nfunction getSpeedOffset(player: Player): number {\r\n const speed = player.getEffect(MinecraftEffectTypes.speed)?.amplifier ?? 0;\r\n return speed * SPEED_EFFECT_INCREASE;\r\n}\r\n\r\n/**\r\n * Checks if a distance traveled is big enough to be flagged\r\n * @param distance distance the player has traveled\r\n * @returns if this distance is bad\r\n */\r\nfunction isDistanceFlag(\r\n distance: number,\r\n tick: number,\r\n player: Player\r\n): boolean {\r\n const speedIntensity = getSpeedOffset(player);\r\n /**\r\n * This is the amount of ticks that have passed\r\n */\r\n const ticks = system.currentTick - tick;\r\n const offset =\r\n MOVEMENT_CONSTANTS.run.distance * ticks + MOVEMENT_DISTANCE_THRESHOLD;\r\n return distance > speedIntensity + offset;\r\n}\r\n\r\nfunction flag(player: Player, old: ILocationLog) {\r\n const violationCount = (violations.get(player) ?? 0) + 1;\r\n violations.set(player, violationCount);\r\n onPlayerMove.delete(player); // Reset Players old location\r\n if (violationCount < 3) return;\r\n player.teleport(\r\n old.location,\r\n old.dimension,\r\n player.rotation.x,\r\n player.rotation.y\r\n );\r\n}\r\n\r\nfunction flagPhase(player: Player): boolean {\r\n const blockIn = player.dimension.getBlock(\r\n vector3ToBlockLocation(player.location)\r\n );\r\n if (blockIn.getTags().some((tag) => VALID_BLOCK_TAGS.includes(tag))) return;\r\n if (blockIn.type.id.endsWith(\"grass\")) return;\r\n if (blockIn.type.id.endsWith(\"water\")) return;\r\n if (blockIn.type.id.endsWith(\"lava\")) return;\r\n if (blockIn.type.id.endsWith(\"portal\")) return;\r\n if (blockIn.type.id.endsWith(\"gateway\")) return;\r\n\r\n if (\r\n blockIn.typeId != MinecraftBlockTypes.air.id &&\r\n !blockIn.type.canBeWaterlogged\r\n )\r\n return true;\r\n}\r\n\r\n/**\r\n * The key used to unsubscribe from this event\r\n */\r\nlet onPlayerMoveSubKey: number = null;\r\n\r\nconst protection = new Protection<{\r\n tpCheck: boolean;\r\n}>(\r\n \"movement\",\r\n \"Blocks illegal movements on players\",\r\n \"textures/ui/move.png\",\r\n true\r\n).setConfigDefault({\r\n tpCheck: {\r\n description: \"If teleports should be flagged\",\r\n defaultValue: true,\r\n },\r\n});\r\n\r\nprotection\r\n .onEnable(() => {\r\n const config = protection.getConfig();\r\n onPlayerMoveSubKey = onPlayerMove.subscribe((player, old) => {\r\n if (getRole(player) == \"admin\") return;\r\n if (player.dimension.id != old.dimension.id) return;\r\n if (player.getTags().some((tag) => TAGS.includes(tag))) return;\r\n const distance = distanceBetween(player.location, old.location);\r\n if (player.hasTag(`skip-movement-check`))\r\n return player.removeTag(`skip-movement-check`);\r\n if (old.location.y == DIMENSION_SWITCH_Y) return;\r\n if (ON_RIPTIDE_TIMEOUT.has(player)) return;\r\n if (flagPhase(player)) return flag(player, old);\r\n if (distance > ANTI_TP_DISTANCE_THRESHOLD) {\r\n if (!config.tpCheck) return;\r\n // Anti Tp.\r\n flag(player, old);\r\n } else {\r\n // Anti speed/jet pack\r\n if (!isDistanceFlag(distance, old.currentTick, player)) return;\r\n // Flagged\r\n flag(player, old);\r\n }\r\n });\r\n })\r\n .onDisable(() => {\r\n onPlayerMove.unsubscribe(onPlayerMoveSubKey);\r\n });\r\n\r\nprotection.subscribe(\"dataDrivenEntityTriggerEvent\", (data) => {\r\n if (!(data.entity instanceof Player)) return;\r\n if (data.id != \"on_death\") return;\r\n const player = data.entity;\r\n system.run(() => {\r\n onPlayerMove.delete(player);\r\n }); // Reset Players old location\r\n});\r\n\r\nprotection.subscribe(\"projectileHit\", ({ projectile, source }) => {\r\n if (projectile.typeId != MinecraftItemTypes.enderPearl.id) return;\r\n if (!(source instanceof Player)) return;\r\n onPlayerMove.delete(source); // Reset Players old location\r\n});\r\n\r\nprotection.subscribe(\"itemCompleteCharge\", ({ itemStack, source }) => {\r\n if (itemStack.typeId != MinecraftItemTypes.chorusFruit.id) return;\r\n if (!(source instanceof Player)) return;\r\n onPlayerMove.delete(source); // Reset Players old location\r\n});\r\n\r\nprotection.subscribe(\"itemReleaseCharge\", ({ itemStack, source }) => {\r\n if (itemStack.typeId != MinecraftItemTypes.trident.id) return;\r\n if (!(source instanceof Player)) return;\r\n ON_RIPTIDE_TIMEOUT.set(source, true);\r\n system.runSchedule(() => {\r\n ON_RIPTIDE_TIMEOUT.delete(source);\r\n }, RIPTIDE_TIMEOUT);\r\n});\r\n", "import { Dimension, Player, system, Vector3, world } from \"@minecraft/server\";\r\nimport { PlayerLog } from \"../../database/types/PlayerLog\";\r\n\r\ntype onPlayerMoveCallback = (player: Player, data: ILocationLog) => void;\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: onPlayerMoveCallback;\r\n };\r\n} = {};\r\n\r\nexport interface ILocationLog {\r\n /**\r\n * The Location this is\r\n */\r\n location: Vector3;\r\n /**\r\n * The dimension this location was in\r\n */\r\n dimension: Dimension;\r\n /**\r\n * The tick this was set at\r\n */\r\n currentTick: number\r\n}\r\n\r\n/**\r\n * Checks if two vectors are the same\r\n * @param from first vector\r\n * @param to second vector\r\n */\r\nfunction vector3Equals(from: Vector3, to: Vector3): boolean {\r\n if (from.x != to.x) return false;\r\n if (from.y != to.y) return false;\r\n if (from.z != to.z) return false;\r\n return true;\r\n}\r\n\r\n/**\r\n * Stores Last Previous grounded location\r\n */\r\nexport const playerLocation = new PlayerLog();\r\n\r\nsystem.runSchedule(() => {\r\n const sendCallback = (player: Player, data: ILocationLog) => {\r\n for (const callback of Object.values(CALLBACKS)) {\r\n callback.callback(player, data);\r\n }\r\n };\r\n for (const player of world.getPlayers()) {\r\n const oldLocation = playerLocation.get(player);\r\n if (oldLocation) {\r\n if (vector3Equals(player.location, oldLocation.location)) {\r\n continue;\r\n }\r\n }\r\n playerLocation.set(player, {\r\n location: player.location,\r\n dimension: player.dimension,\r\n currentTick: system.currentTick\r\n });\r\n if (!oldLocation) continue;\r\n sendCallback(player, oldLocation);\r\n }\r\n});\r\n\r\nexport class onPlayerMove {\r\n /**\r\n * Subscribes to a callback to get notified when a player moves\r\n * @param callback what to be called when one of these entity's inventory changes\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(callback: onPlayerMoveCallback): number {\r\n const key = Date.now();\r\n CALLBACKS[key] = { callback: callback };\r\n return key;\r\n \r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n /**\r\n * Clears a players location\r\n * @param player player to clear\r\n */\r\n static delete(player: Player): void {\r\n playerLocation.delete(player);\r\n }\r\n}\r\n", "/**\r\n * The leeway that the distances can be off before it flags\r\n */\r\nexport const MOVEMENT_DISTANCE_THRESHOLD = 0.80;\r\n\r\n/**\r\n * Constant of speeds when players are moving per tick\r\n */\r\nexport const MOVEMENT_CONSTANTS = {\r\n walk: {\r\n velocity: 0.17 as const,\r\n distance: 0.23 as const,\r\n },\r\n run: {\r\n velocity: 0.19 as const,\r\n distance: 0.35 as const,\r\n },\r\n};\r\n\r\n/**\r\n * The distance increase per speed effect increase\r\n */\r\nexport const SPEED_EFFECT_INCREASE = 0.056;\r\n\r\n/**\r\n * if the distance is over this amount the system will automatically flag tp\r\n */\r\nexport const ANTI_TP_DISTANCE_THRESHOLD = 10;\r\n\r\n/**\r\n * If your \r\n */\r\nexport const TAGS = [\"gliding\", \"riding\"];\r\n\r\n/**\r\n * This is a Y value that occurs when you die in another dimension and \r\n * you get teleported twice, this should be ignored\r\n */\r\nexport const DIMENSION_SWITCH_Y = 32767.001953125\r\n\r\n/**\r\n * Time in ticks that a player will be on timeout\r\n * for this check\r\n */\r\nexport const RIPTIDE_TIMEOUT = 60", "import { MinecraftEffectTypes, Player, world } from \"@minecraft/server\";\r\nimport { getServerOwnerName, setRole, setServerOwner } from \"../../utils\";\r\n\r\nlet e = world.events.beforeDataDrivenEntityTriggerEvent.subscribe((data) => {\r\n if (!(data.entity instanceof Player)) return;\r\n if (data.id != \"rubedo:becomeAdmin\") return;\r\n // Rubedo is now verified to be at the top\r\n data.entity.removeTag(\"CHECK_PACK\");\r\n const serverOwnerName = getServerOwnerName();\r\n if (serverOwnerName) {\r\n data.entity.playSound(\"note.bass\");\r\n data.entity.tell(\r\n `\u00A7cFailed to give server owner: \"${serverOwnerName}\" is already owner!`\r\n );\r\n return world.events.beforeDataDrivenEntityTriggerEvent.unsubscribe(e);\r\n }\r\n setRole(data.entity, \"admin\");\r\n setServerOwner(data.entity);\r\n data.entity.addEffect(MinecraftEffectTypes.blindness, 3, 255, true);\r\n data.entity.tell(\r\n `\u00A7aYou have now been set as the \"owner\" of this server. The command \"/function start\" will not do anything anymore, type \"-help\" for more information!`\r\n );\r\n});\r\n", "import {\r\n DynamicPropertiesDefinition,\r\n MinecraftEntityTypes,\r\n world,\r\n} from \"@minecraft/server\";\r\nimport { OBJECTIVES } from \"../../../../rubedo/config/objectives\";\r\n\r\nworld.events.worldInitialize.subscribe(({ propertyRegistry }) => {\r\n let def2 = new DynamicPropertiesDefinition();\r\n def2.defineString(\"role\", 30);\r\n propertyRegistry.registerEntityTypeDynamicProperties(\r\n def2,\r\n MinecraftEntityTypes.player\r\n );\r\n\r\n let def3 = new DynamicPropertiesDefinition();\r\n def3.defineString(\"worldsOwner\", 100);\r\n def3.defineBoolean(\"isLockDown\");\r\n propertyRegistry.registerWorldDynamicProperties(def3);\r\n\r\n for (const obj of OBJECTIVES) {\r\n world.scoreboard.addObjective(obj.objective, obj.displayName ?? \"\");\r\n }\r\n});\r\n", "/*\n|--------------------------------------------------------------------------\n| Objectives\n|--------------------------------------------------------------------------\n|\n| This is a list of all objectives this pack uses\n| please add any objective to this list so it can be added at world creation\n| make sure to add them before sending pack to others and new worlds.\n|\n*/\ninterface IObjective {\n objective: string;\n displayName?: string;\n}\n\nexport const OBJECTIVES: Array = [];\n", "import { Location } from \"@minecraft/server\";\r\nimport \"./tables\";\r\nimport \"./protections\";\r\nimport \"./modules/commands/import\";\r\nimport \"./modules/managers/import\";\r\nimport \"./modules/pages/import\";\r\nimport \"./modules/protections/import\";\r\nimport \"./modules/events/import\";\r\n\r\n/**\r\n * Stores npc locations that are verified to allow NPC's to spawn in\r\n */\r\nexport let NPC_LOCATIONS: Array = [];\r\n\r\nexport function clearNpcLocations() {\r\n NPC_LOCATIONS = [];\r\n}\r\n", "console.warn(`----- Importing Plugins -----`);\r\n\r\nimport \"./Anti-Cheat/index\";\r\n//import \"./ChatRanks/index\";\r\n//import \"./GlobalBans/index\";\r\n"], - "mappings": "AAAA,OAAS,UAAAA,OAAc,oBCAvB,OAA0B,SAAAC,OAAa,oBCUhC,IAAMC,EAAS,ICVtB,OAAiB,SAAAC,OAAa,oBCA9B,OAAiB,aAAAC,GAAW,sBAAAC,OAA0B,oBCAtD,OAAS,iBAAAC,OAAqB,oBAYvB,IAAMC,GAA2B,KAW3BC,GAAoB,kBAWpBC,EAAkB,IAAIH,GAAc,EAAG,IAAK,CAAC,EAU7CI,GAAiB,IC5C9B,OAAS,UAAAC,GAAQ,SAAAC,OAAa,oBCA9B,OACE,iBAAAC,GAGA,2BAAAC,EACA,UAAAC,GAEA,SAAAC,MACK,oBAKA,IAAMC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A,EAAK,OAAO,KACV,sCAAmCE,sBACrC,EACOH,GAAM,OAAO,mCAAmC,YAAYD,EAAC,EAEtEM,GAAQJ,EAAK,OAAQ,OAAO,EAC5BK,GAAeL,EAAK,MAAM,EAC1BA,EAAK,OAAO,UAAUM,GAAqB,UAAW,EAAG,IAAK,EAAI,EAClEN,EAAK,OAAO,KACV,0JACF,CACF,CAAC,ECtBD,OACE,+BAAAO,GACA,wBAAAC,GACA,SAAAC,OACK,oBCWA,IAAMC,GAAgC,CAAC,EDR9CC,GAAM,OAAO,gBAAgB,UAAU,CAAC,CAAE,iBAAAC,CAAiB,IAAM,CAC/D,IAAIC,EAAO,IAAIC,GACfD,EAAK,aAAa,OAAQ,EAAE,EAC5BD,EAAiB,oCACfC,EACAE,GAAqB,MACvB,EAEA,IAAIC,EAAO,IAAIF,GACfE,EAAK,aAAa,cAAe,GAAG,EACpCA,EAAK,cAAc,YAAY,EAC/BJ,EAAiB,+BAA+BI,CAAI,EAEpD,QAAWC,KAAOC,GAChBP,GAAM,WAAW,aAAaM,EAAI,UAAWA,EAAI,aAAe,EAAE,CAEtE,CAAC,EEXM,IAAIE,GAAiC,CAAC,EAEtC,SAASC,IAAoB,CAClCD,GAAgB,CAAC,CACnB,CChBA,QAAQ,KAAK,+BAA+B,E3FO5CE,GAAO,OAAO,wBAAwB,UAAWC,GAAS,CACxDA,EAAK,OAAS,GACd,QAAQ,KAAK,6BAA6BA,EAAK,iBAAiB,CAClE,CAAC", - "names": ["system", "world", "PREFIX", "world", "ItemStack", "MinecraftItemTypes", "BlockLocation", "MAX_DATABASE_STRING_SIZE", "ENTITY_IDENTIFIER", "ENTITY_LOCATION", "INVENTORY_SIZE", "system", "world", "BlockLocation", "MinecraftDimensionTypes", "system", "world", "DIMENSIONS", "durations", "durationToMs", "duration", "values", "ms", "value", "length", "unit", "msToTime", "vector3ToBlockLocation", "loc", "BlockLocation", "sleep", "tick", "resolve", "runScheduleId", "system", "LocationEquals", "a", "b", "sort3DVectors", "vector1", "vector2", "betweenVector3", "target", "minVector", "maxVector", "x", "y", "z", "chunkString", "str", "CALLBACKS", "ENTITIES_LOADED", "system", "DIMENSIONS", "i", "callback", "world", "data", "EntitiesLoad", "resolve", "key", "Database", "tableName", "EntitiesLoad", "v", "index", "entity", "DIMENSIONS", "ENTITY_IDENTIFIER", "ENTITY_LOCATION", "e", "resolve", "entities", "chunks", "chunkString", "MAX_DATABASE_STRING_SIZE", "entitiesNeeded", "INVENTORY_SIZE", "chunkIndex", "inventory", "item", "ItemStack", "MinecraftItemTypes", "i", "a", "b", "stringifiedData", "data", "key", "value", "status", "fetch", "playerName", "world", "player", "LiteralArgumentType", "name", "value", "StringArgumentType", "IntegerArgumentType", "FloatArgumentType", "LocationArgumentType", "BooleanArgumentType", "PlayerArgumentType", "fetch", "TargetArgumentType", "ArrayArgumentType", "types", "DurationArgumentType", "PlayerNameArgumentType", "Database", "ArgumentTypes", "CommandCallback", "data", "text", "getChatAugments", "message", "prefix", "e", "commandNotFound", "player", "command", "noPerm", "commandSyntaxFail", "baseCommand", "args", "i", "PREFIX", "types", "c", "LiteralArgumentType", "parseLocationArgs", "x", "y", "z", "location", "viewVector", "locations", "viewVectors", "a", "arg", "r", "b", "index", "sendCallback", "cmdArgs", "event", "lastArg", "argsToReturn", "LocationArgumentType", "CommandCallback", "COMMANDS", "world", "data", "PREFIX", "args", "getChatAugments", "command", "event", "commandNotFound", "noPerm", "verifiedCommands", "getArg", "start", "i", "arg", "v", "commandSyntaxFail", "sendCallback", "ItemStack", "MinecraftItemTypes", "system", "world", "GUI_ITEM", "ENTITY_INVENTORY", "system", "system", "CALLBACKS", "MAPPED_INVENTORIES", "PREVIOUS_CHANGE", "getSlotChanges", "entity", "oldInv", "newInv", "changes", "i", "change_data", "getItemUid", "item", "data", "mapInventory", "container", "inventory", "system", "callback", "DIMENSIONS", "change", "onEntityInventorySlotChange", "entities", "key", "Location", "CHESTGUIS", "PAGES", "getHeldItem", "player", "clearPlayersPointer", "ItemToClear", "inventory", "itemsToLoad", "i", "item", "e", "getItemAtSlot", "entity", "slot", "ItemGrabbedCallback", "gui", "slot", "change", "text", "item", "db", "page", "extras", "form", "sleep", "ChestGUI", "player", "ENTITY_INVENTORY", "system", "onEntityInventorySlotChange", "entity", "change", "pageId", "extras", "c", "AIR", "PAGES", "page", "slot", "clearPlayersPointer", "getItemAtSlot", "ItemGrabbedCallback", "CHESTGUIS", "ItemStack", "PageItem", "itemType", "components", "itemStack", "enchantments", "enchantment", "DefaultFill", "entity", "page", "extras", "container", "i", "slot", "AIR", "Page", "id", "fillType", "DefaultFill", "PAGES", "slot", "item", "action", "data", "MinecraftItemTypes", "HOME_PAGE", "Page", "PageItem", "ctx", "world", "Player", "BlockLocation", "MinecraftBlockTypes", "GameMode", "BlockLocation", "MinecraftBlockTypes", "DEFAULT_REGION_PERMISSIONS", "DOORS_SWITCHES", "BLOCK_CONTAINERS", "TABLES", "Database", "REGIONS", "REGIONS_HAVE_BEEN_GRABBED", "LOWEST_Y_VALUE", "HIGHEST_Y_VALUE", "Region", "regions", "TABLES", "region", "r", "blockLocation", "dimensionId", "betweenVector3", "from", "to", "permissions", "key", "DEFAULT_REGION_PERMISSIONS", "loadRegionDenys", "loc1", "BlockLocation", "loc2", "DIMENSIONS", "MinecraftBlockTypes", "entity", "value", "ChangePlayerRoleTask", "TABLES", "playerName", "t", "role", "tasks", "MinecraftBlockTypes", "MinecraftItemTypes", "APPEAL_LINK", "FORBIDDEN_ITEMS", "BANNED_ITEMS", "FORBIDDEN_BLOCKS", "BANNED_BLOCKS", "CONTAINERS", "ENCHANTMENTS", "kick", "player", "message", "onFail", "isServerOwner", "error", "getRole", "Player", "TABLES", "setRole", "value", "inGamePlayer", "world", "p", "ChangePlayerRoleTask", "getServerOwner", "id", "getServerOwnerName", "ownerId", "ids", "key", "setServerOwner", "isLockedDown", "setLockDown", "val", "loadRegionDenys", "region", "Region", "loc1", "BlockLocation", "loc2", "blockLocation", "DIMENSIONS", "MinecraftBlockTypes", "getConfigId", "BANNED_ITEMS", "BANNED_BLOCKS", "ENCHANTMENTS", "APPEAL_LINK", "setConfigId", "getMaxEnchantmentLevel", "enchantment", "getGamemode", "GameMode", "g", "AIR", "ItemStack", "MinecraftItemTypes", "EntitiesLoad", "system", "player", "world", "getHeldItem", "GUI_ITEM", "CHESTGUIS", "getRole", "ChestGUI", "validIds", "c", "entity", "DIMENSIONS", "ENTITY_INVENTORY", "DynamicPropertiesDefinition", "EntityTypes", "world", "world", "propertyRegistry", "DIMENSIONS", "ENTITY_LOCATION", "def", "DynamicPropertiesDefinition", "EntityTypes", "ENTITY_IDENTIFIER", "system", "world", "MinecraftBlockTypes", "API_CONTAINERS", "CHECK_SIZE", "Container", "inventory", "i", "block", "CONTAINER_LOCATIONS", "system", "player", "world", "blockLoc", "vector3ToBlockLocation", "pos1", "CHECK_SIZE", "pos2", "location", "block", "API_CONTAINERS", "Container", "system", "PROTECTIONS", "EntitiesLoad", "system", "protection", "Player", "setBan", "player", "id", "duration", "reason", "by", "data", "Player", "durationToMs", "TABLES", "Ban", "MessageFormData", "MessageForm", "title", "body", "MessageFormData", "text", "callback", "player", "response", "confirmAction", "player", "action", "onConfirm", "onCancel", "MessageForm", "Command", "data", "type", "depth", "parent", "player", "LiteralArgumentType", "COMMANDS", "cmd", "name", "StringArgumentType", "IntegerArgumentType", "types", "ArrayArgumentType", "BooleanArgumentType", "LocationArgumentType", "callback", "text", "a", "b", "playerName", "duration", "reason", "name", "expire", "ActionFormData", "ActionForm", "title", "body", "ActionFormData", "text", "iconPath", "callback", "player", "response", "ModalFormData", "FormCallback", "form", "player", "callback", "message", "MessageForm", "ModalForm", "title", "ModalFormData", "label", "options", "defaultValueIndex", "minimumValue", "maximumValue", "valueStep", "defaultValue", "placeholderText", "player", "callback", "i", "response", "FormCallback", "v", "ban", "ctx", "player", "duration", "reason", "by", "TABLES", "confirmAction", "Ban", "text", "root", "Command", "getRole", "ArgumentTypes", "playerName", "banData", "bans", "msToTime", "ActionForm", "ModalForm", "root", "Command", "player", "getRole", "ctx", "table", "key", "data", "TABLES", "error", "value", "keys", "values", "Command", "player", "getRole", "ArgumentTypes", "ctx", "i", "Freeze", "player", "reason", "data", "TABLES", "root", "Command", "player", "getRole", "ArgumentTypes", "ctx", "reason", "Freeze", "playerName", "freeze", "TABLES", "freezes", "text", "CommandNameArgumentType", "name", "value", "COMMANDS", "c", "sendCommandType", "baseCommand", "args", "player", "PREFIX", "a", "sendArguments", "bc", "p", "child", "sendPageHeader", "maxPages", "getCommands", "getMaxPages", "commands", "root", "Command", "ctx", "cmd", "command", "world", "Command", "player", "getRole", "ctx", "isLockedDown", "setLockDown", "confirmAction", "text", "world", "kick", "Mute", "player", "TABLES", "duration", "reason", "by", "msLength", "durationToMs", "data", "root", "Command", "player", "getRole", "ArgumentTypes", "ctx", "duration", "reason", "Mute", "playerName", "mute", "TABLES", "mutes", "text", "msToTime", "Location", "Npc", "entity", "NPC_LOCATIONS", "l", "LocationEquals", "TABLES", "key", "location", "dimension", "data", "clearNpcLocations", "Command", "player", "getRole", "ctx", "x", "y", "z", "Npc", "Location", "system", "getServerTPS", "startTime", "ticks", "resolve", "s", "system", "Command", "ctx", "BlockLocation", "command", "Command", "player", "getRole", "ctx", "from_x", "from_z", "to_x", "to_z", "Region", "loc", "BlockLocation", "r", "regions", "region", "permission", "key", "value", "entityCommands", "entity", "currentAllowedEntities", "v", "ROLES", "StringIsNumber", "value", "ToArray", "enumme", "key", "root", "Command", "player", "getRole", "isServerOwner", "ArgumentTypes", "ROLES", "ctx", "playerName", "role", "setRole", "ownerRoot", "ownerId", "getServerOwner", "ids", "TABLES", "ownerName", "confirmAction", "setServerOwner", "manageBannedItemsForm", "player", "ActionForm", "removeBannedItemForm", "addBannedItemForm", "ModalForm", "getConfigId", "ctx", "item", "items", "p", "setConfigId", "manageBannedBlocksForm", "removeBannedBlockForm", "addBannedBlockForm", "block", "blocks", "manageEnchantmentLevelsForm", "ENCHANTMENTS", "enchantment", "levelString", "level", "enchants", "manageAppealLinkForm", "APPEAL_LINK", "link", "showAutoModHomeForm", "player", "form", "ActionForm", "protection", "PROTECTIONS", "showProtectionConfig", "showHomeForm", "data", "ModalForm", "keys", "key", "value", "ctx", "enabled", "config", "i", "showHomeForm", "player", "ActionForm", "showAutoModHomeForm", "manageBannedItemsForm", "manageBannedBlocksForm", "manageEnchantmentLevelsForm", "manageAppealLinkForm", "Command", "player", "getRole", "ctx", "showHomeForm", "world", "vanish", "player", "say", "world", "Command", "getRole", "ctx", "VERSION", "Command", "ctx", "VERSION", "Command", "player", "getRole", "ArgumentTypes", "ctx", "reason", "kick", "Log", "data", "TABLES", "timeDifference", "previous", "msPerMinute", "msPerHour", "msPerDay", "msPerMonth", "msPerYear", "elapsed", "root", "Command", "player", "getRole", "ctx", "message", "Log", "page", "order", "allLogs", "TABLES", "a", "b", "maxPages", "PREFIX", "key", "value", "ArgumentTypes", "playerName", "v", "protection", "root", "Command", "player", "getRole", "ArgumentTypes", "ctx", "destination", "system", "world", "CALLBACKS", "EntitiesLoad", "system", "players", "world", "i", "player", "CALLBACK", "forEachPlayer", "callback", "delay", "key", "forEachPlayer", "player", "banData", "TABLES", "kick", "msToTime", "getConfigId", "error", "Location", "forEachPlayer", "player", "freezeData", "TABLES", "Location", "DIMENSIONS", "world", "CALLBACKS", "world", "data", "PREFIX", "callback", "beforeChat", "key", "beforeChat", "data", "muteData", "Mute", "TABLES", "text", "BlockLocation", "system", "world", "system", "loadRegionDenys", "world", "data", "getRole", "region", "Region", "block", "DOORS_SWITCHES", "BLOCK_CONTAINERS", "i", "bL", "entity", "BlockLocation", "EntitiesLoad", "DIMENSIONS", "forEachPlayer", "player", "world", "world", "player", "EntitiesLoad", "isLockedDown", "getRole", "kick", "text", "Mute", "TABLES", "roleToSet", "ChangePlayerRoleTask", "setRole", "Items", "MinecraftItemTypes", "world", "FILLABLE_SLOTS", "ViewPlayersFill", "entity", "page", "extras", "container", "i", "slot", "AIR", "player", "world", "item", "PageItem", "MinecraftItemTypes", "ctx", "ViewPlayerInventoryFill", "p", "CHESTGUIS", "e", "inventory", "used_slots", "Items", "Page", "Player", "MinecraftBlockTypes", "system", "world", "Protection", "name", "description", "iconPath", "isEnabledByDefault", "PROTECTIONS", "data", "TABLES", "v", "saveData", "key", "config", "enabled", "value", "callback", "world", "forEachPlayer", "runScheduleId", "system", "id", "tickInterval", "delay", "CBE_ENTITIES", "protection", "Protection", "entity", "kill", "Npc", "data", "Player", "getRole", "config", "MinecraftBlockTypes", "FORBIDDEN_BLOCKS", "getConfigId", "Ban", "DISTANCE", "Protection", "player", "getRole", "Ban", "GameMode", "world", "world", "PlayerLog", "data", "player", "value", "ILLEGAL_GAMEMODE", "GameMode", "ViolationCount", "PlayerLog", "protection", "Protection", "config", "player", "world", "getRole", "Log", "count", "Ban", "world", "Location", "system", "CALLBACKS", "world", "data", "callback", "BeforeBlockBreakEvent", "beforeBlockBreak", "key", "block", "brokenBlockPermutation", "dimension", "player", "value", "API_CONTAINERS", "OLD_INVENTORY", "CONTAINER_LOCATIONS", "system", "Location", "e", "log", "PlayerLog", "IMPOSSIBLE_BREAK_TIME", "VALID_BLOCK_TAGS", "IMPOSSIBLE_BREAKS", "ViolationCount", "beforeBlockBreakKey", "protection", "Protection", "config", "beforeBlockBreak", "data", "getRole", "tag", "old", "count", "Ban", "previousMessage", "PlayerLog", "ViolationCount", "protection", "Protection", "data", "PREFIX", "getRole", "config", "isSpam", "count", "Mute", "error", "ViolationCount", "PlayerLog", "protection", "Protection", "player", "getRole", "BANNED_ITEMS", "getConfigId", "inventory", "i", "item", "flag", "FORBIDDEN_ITEMS", "Log", "AIR", "enchantments", "enchantment", "MAX_LEVEL", "getMaxEnchantmentLevel", "index", "data", "violations", "Ban", "ItemStack", "MinecraftBlockTypes", "MinecraftEntityTypes", "MinecraftItemTypes", "Player", "BLOCKS", "MinecraftBlockTypes", "CHEST_BOATS", "MinecraftItemTypes", "Protection", "block", "container", "i", "ItemStack", "permutation", "data", "Player", "MinecraftEntityTypes", "getGamemode", "AIR", "MinecraftBlockTypes", "MinecraftEffectTypes", "MinecraftItemTypes", "Player", "system", "system", "world", "CALLBACKS", "vector3Equals", "from", "to", "playerLocation", "PlayerLog", "system", "sendCallback", "player", "data", "callback", "world", "oldLocation", "onPlayerMove", "key", "MOVEMENT_CONSTANTS", "SPEED_EFFECT_INCREASE", "ANTI_TP_DISTANCE_THRESHOLD", "TAGS", "DIMENSION_SWITCH_Y", "RIPTIDE_TIMEOUT", "violations", "PlayerLog", "ON_RIPTIDE_TIMEOUT", "distanceBetween", "loc1", "loc2", "getSpeedOffset", "player", "MinecraftEffectTypes", "SPEED_EFFECT_INCREASE", "isDistanceFlag", "distance", "tick", "speedIntensity", "ticks", "system", "offset", "MOVEMENT_CONSTANTS", "flag", "old", "violationCount", "onPlayerMove", "flagPhase", "blockIn", "vector3ToBlockLocation", "tag", "VALID_BLOCK_TAGS", "MinecraftBlockTypes", "onPlayerMoveSubKey", "protection", "Protection", "config", "getRole", "TAGS", "DIMENSION_SWITCH_Y", "ANTI_TP_DISTANCE_THRESHOLD", "data", "Player", "projectile", "source", "MinecraftItemTypes", "itemStack", "RIPTIDE_TIMEOUT", "MinecraftEffectTypes", "Player", "world", "e", "world", "data", "Player", "serverOwnerName", "getServerOwnerName", "setRole", "setServerOwner", "MinecraftEffectTypes", "DynamicPropertiesDefinition", "MinecraftEntityTypes", "world", "OBJECTIVES", "world", "propertyRegistry", "def2", "DynamicPropertiesDefinition", "MinecraftEntityTypes", "def3", "obj", "OBJECTIVES", "NPC_LOCATIONS", "clearNpcLocations", "system", "data"] + "sources": ["../src/index.ts", "../src/rubedo/lib/Command/index.ts", "../src/rubedo/config/commands.ts", "../src/rubedo/lib/Command/ArgumentTypes.ts", "../src/rubedo/database/Database.ts", "../src/rubedo/config/database.ts", "../src/utils.ts", "../src/rubedo/lib/Events/EntitiesLoad.ts", "../src/vendor/Anti-Cheat/tables.ts", "../src/rubedo/lib/Command/Callback.ts", "../src/rubedo/lib/Command/utils.ts", "../src/rubedo/lib/Chest GUI/index.ts", "../src/rubedo/config/chest.ts", "../src/rubedo/lib/Chest GUI/Models/EntityChest.ts", "../src/rubedo/lib/Events/onSlotChange.ts", "../src/rubedo/lib/Chest GUI/utils.ts", "../src/rubedo/lib/Chest GUI/Models/ItemGrabbedCallback.ts", "../src/rubedo/lib/Chest GUI/Models/PageItem.ts", "../src/rubedo/lib/Chest GUI/Models/FillTypes.ts", "../src/rubedo/lib/Chest GUI/Models/Page.ts", "../src/rubedo/lib/Chest GUI/pages/home.ts", "../src/vendor/Anti-Cheat/utils.ts", "../src/vendor/Anti-Cheat/modules/models/Region.ts", "../src/vendor/Anti-Cheat/config/region.ts", "../src/vendor/Anti-Cheat/modules/models/Task.ts", "../src/vendor/Anti-Cheat/config/moderation.ts", "../src/vendor/Anti-Cheat/config/enchantments.ts", "../src/rubedo/database/index.ts", "../src/rubedo/lib/Containers/index.ts", "../src/rubedo/config/containers.ts", "../src/rubedo/lib/Containers/Container.ts", "../src/vendor/Anti-Cheat/protections.ts", "../src/vendor/Anti-Cheat/modules/models/Ban.ts", "../src/rubedo/lib/Form/Models/MessageForm.ts", "../src/rubedo/config/form.ts", "../src/rubedo/lib/Form/utils.ts", "../src/rubedo/lib/Command/Command.ts", "../src/rubedo/lang/text.ts", "../src/vendor/Anti-Cheat/modules/commands/ban.ts", "../src/vendor/Anti-Cheat/modules/commands/database.ts", "../src/vendor/Anti-Cheat/modules/commands/ecwipe.ts", "../src/vendor/Anti-Cheat/modules/models/Freeze.ts", "../src/vendor/Anti-Cheat/modules/commands/freeze.ts", "../src/vendor/Anti-Cheat/modules/commands/help.ts", "../src/vendor/Anti-Cheat/modules/commands/lockdown.ts", "../src/vendor/Anti-Cheat/modules/models/Mute.ts", "../src/vendor/Anti-Cheat/modules/commands/mute.ts", "../src/vendor/Anti-Cheat/modules/commands/npc.ts", "../src/vendor/Anti-Cheat/modules/models/Npc.ts", "../src/vendor/Anti-Cheat/modules/commands/ping.ts", "../src/vendor/Anti-Cheat/modules/commands/region.ts", "../src/vendor/Anti-Cheat/types.ts", "../src/vendor/Anti-Cheat/modules/commands/role.ts", "../src/rubedo/lib/Form/Models/ActionForm.ts", "../src/rubedo/lib/Form/Models/ModelForm.ts", "../src/rubedo/lib/Form/Models/FormCallback.ts", "../src/vendor/Anti-Cheat/modules/forms/settings.ts", "../src/vendor/Anti-Cheat/modules/forms/automod.ts", "../src/vendor/Anti-Cheat/modules/forms/home.ts", "../src/vendor/Anti-Cheat/modules/commands/settings.ts", "../src/vendor/Anti-Cheat/modules/commands/vanish.ts", "../src/rubedo/config/app.ts", "../src/vendor/Anti-Cheat/modules/commands/version.ts", "../src/vendor/Anti-Cheat/modules/commands/kick.ts", "../src/vendor/Anti-Cheat/modules/models/Log.ts", "../src/vendor/Anti-Cheat/modules/commands/log.ts", "../src/vendor/Anti-Cheat/modules/commands/teleport.ts", "../src/rubedo/lib/Events/forEachPlayer.ts", "../src/vendor/Anti-Cheat/modules/managers/ban.ts", "../src/vendor/Anti-Cheat/modules/managers/freeze.ts", "../src/rubedo/lib/Events/beforeChat.ts", "../src/vendor/Anti-Cheat/modules/managers/mute.ts", "../src/vendor/Anti-Cheat/modules/managers/region.ts", "../src/vendor/Anti-Cheat/modules/events/playerSpawn.ts", "../src/vendor/Anti-Cheat/modules/pages/see.ts", "../src/vendor/Anti-Cheat/modules/protections/gamemode.ts", "../src/vendor/Anti-Cheat/modules/models/Protection.ts", "../src/rubedo/database/types/PlayerLog.ts", "../src/vendor/Anti-Cheat/modules/protections/movement.ts", "../src/rubedo/lib/Events/onPlayerMove.ts", "../src/vendor/Anti-Cheat/config/movement.ts", "../src/rubedo/lib/Events/beforeBlockBreak.ts", "../src/vendor/Anti-Cheat/modules/protections/nuker.ts", "../src/vendor/Anti-Cheat/modules/protections/spam.ts", "../src/vendor/Anti-Cheat/modules/events/beforeDataDrivenEntityTriggerEvent.ts", "../src/vendor/Anti-Cheat/modules/events/worldInitialize.ts", "../src/rubedo/config/objectives.ts", "../src/vendor/Anti-Cheat/index.ts", "../src/vendor/import.ts"], + "sourcesContent": ["import { system } from \"@minecraft/server\";\nimport \"./rubedo/lib/Command/index\";\nimport \"./rubedo/lib/Chest GUI/index\";\nimport \"./rubedo/database/index\";\nimport \"./rubedo/lib/Containers/index\";\nimport \"./vendor/import\";\n\nsystem.events.beforeWatchdogTerminate.subscribe((data) => {\n data.cancel = true;\n console.warn(`WATCHDOG TRIED TO CRASH = ${data.terminateReason}`);\n});\n", "import { BeforeChatEvent, world } from \"@minecraft/server\";\r\nimport { PREFIX } from \"../../config/commands\";\r\nimport type { Command } from \"./Command\";\r\nimport {\r\n commandNotFound,\r\n commandSyntaxFail,\r\n getChatAugments,\r\n noPerm,\r\n sendCallback,\r\n} from \"./utils\";\r\n\r\n/**\r\n * An array of all active commands\r\n */\r\nexport const COMMANDS: Command[] = [];\r\n\r\nworld.events.beforeChat.subscribe((data) => {\r\n if (!data.message.startsWith(PREFIX)) return; // This is not a command\r\n data.cancel = true;\r\n const args = getChatAugments(data.message, PREFIX);\r\n const command = COMMANDS.find(\r\n (c) =>\r\n c.depth == 0 &&\r\n (c.data.name == args[0] || c.data?.aliases?.includes(args[0]))\r\n );\r\n const event = {\r\n message: data.message,\r\n sendToTargets: data.sendToTargets,\r\n sender: data.sender,\r\n targets: data.targets,\r\n } as BeforeChatEvent;\r\n if (!command) return commandNotFound(data.sender, args[0]);\r\n if (!command.data?.requires(data.sender))\r\n return noPerm(event.sender, command);\r\n args.shift(); // Remove first command so we can look at args\r\n // Check Args/SubCommands for errors\r\n const verifiedCommands: Command[] = [];\r\n const getArg = (start: Command, i: number): string => {\r\n if (start.children.length > 0) {\r\n const arg = start.children.find((v) => v.type.matches(args[i]).success);\r\n if (!arg && !args[i] && start.callback) return;\r\n if (!arg)\r\n return commandSyntaxFail(event.sender, command, start, args, i), \"fail\";\r\n if (!arg.data?.requires(event.sender))\r\n return noPerm(event.sender, arg), \"fail\";\r\n verifiedCommands.push(arg);\r\n return getArg(arg, i + 1);\r\n }\r\n };\r\n let v = getArg(command, 0);\r\n if (v == \"fail\") return;\r\n sendCallback(args, verifiedCommands, event, command);\r\n});\r\n", "/*\n|--------------------------------------------------------------------------\n| Command Prefix\n|--------------------------------------------------------------------------\n|\n| This is the prefix of the commands that are send in chat\n| changing this changes what people have to type in before using\n| a command for instance: -help. (-) is the command prefix.\n|\n*/\nexport const PREFIX = \"-\";\n", "import { Player, world } from \"@minecraft/server\";\r\nimport { TABLES } from \"../../../vendor/Anti-Cheat/tables\";\r\n\r\n/**\r\n * Fetch an online players data\r\n */\r\nexport function fetch(playerName: string): Player | null {\r\n return [...world.getPlayers()].find((player) => player.name === playerName);\r\n}\r\n\r\nexport interface IArgumentReturnData {\r\n /**\r\n * If this argument matches the value\r\n */\r\n success: boolean;\r\n /**\r\n * The parsed value that should be passed in command callback\r\n * if there is no return type this will be null\r\n */\r\n value?: T;\r\n}\r\n\r\nexport abstract class IArgumentType {\r\n /**\r\n * The return type\r\n */\r\n type: any;\r\n /**\r\n * The name that the help for this command will see\r\n * @example \"string\"\r\n * @example \"Location\"\r\n * @example \"int\"\r\n * @example \"number\"\r\n * @example \"UnitType\"\r\n */\r\n typeName: string;\r\n /**\r\n * The name this argument is\r\n */\r\n name: string = \"name\";\r\n /**\r\n * Checks if a value matches this argument type, also\r\n * returns the corresponding type\r\n */\r\n matches(value: string): IArgumentReturnData {\r\n return { success: true };\r\n }\r\n /**\r\n * the fail message that should be sent if player fails to meet the matches criteria\r\n * @param value value that was sent\r\n * @returns what would happen if you didn't enter the right value\r\n */\r\n fail(value: string): string {\r\n return `Value must be of type string!`;\r\n }\r\n constructor(name: string = \"any\") {}\r\n}\r\n\r\nexport class LiteralArgumentType implements IArgumentType {\r\n type: null;\r\n typeName = \"literal\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: this.name == value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `${value} should be ${this.name}!`;\r\n }\r\n constructor(public name: string = \"literal\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class StringArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"string\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: value && value != \"\",\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `Value must be of type string!`;\r\n }\r\n constructor(public name: string = \"string\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class IntegerArgumentType implements IArgumentType {\r\n type: number;\r\n typeName = \"int\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: !isNaN(value as any),\r\n value: parseInt(value),\r\n };\r\n }\r\n fail(value: string): string {\r\n return `Value must be valid number!`;\r\n }\r\n constructor(public name: string = \"integer\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class FloatArgumentType implements IArgumentType {\r\n type: number;\r\n typeName = \"float\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: Boolean(value?.match(/^\\d+\\.\\d+$/)?.[0]),\r\n value: parseInt(value),\r\n };\r\n }\r\n fail(value: string): string {\r\n return `Value must be valid float!`;\r\n }\r\n constructor(public name: string = \"float\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class LocationArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"location\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: /^([~^]{0,1}(-\\d)?(\\d*)?(\\.(\\d+))?)$/.test(value),\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `Value needs to be a valid number, value can include: [~,^]`;\r\n }\r\n constructor(public name: string = \"location\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class BooleanArgumentType implements IArgumentType {\r\n type: boolean;\r\n typeName = \"boolean\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: Boolean(value?.match(/^(true|false)$/)?.[0]),\r\n value: value == \"true\" ? true : false,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `\"${value}\" can be either \"true\" or \"false\"`;\r\n }\r\n constructor(public name: string = \"boolean\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class PlayerArgumentType implements IArgumentType {\r\n type: Player;\r\n typeName = \"Player\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: fetch(value) ? true : false,\r\n value: fetch(value),\r\n };\r\n }\r\n fail(value: string): string {\r\n return `player: \"${value}\", is not in this world`;\r\n }\r\n constructor(public name: string = \"player\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class TargetArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"Target\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: Boolean(value?.match(/^(@.|\"[\\s\\S]+\")$/)?.[0]),\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `${value} is not a valid target`;\r\n }\r\n constructor(public name: string = \"target\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport class ArrayArgumentType>\r\n implements IArgumentType\r\n{\r\n type: T[number];\r\n typeName = \"string\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: this.types.includes(value),\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `\"${value}\" must be one of these values: ${this.types.join(\" | \")}`;\r\n }\r\n constructor(public name: string = \"array\", public types: T) {\r\n this.name = name;\r\n this.types = types;\r\n\r\n this.typeName = types.join(\" | \").replace(/(.{25})..+/, \"$1...\");\r\n }\r\n}\r\n\r\nexport class DurationArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"Duration\";\r\n matches(value: string): IArgumentReturnData {\r\n return {\r\n success: /^(\\d+[hdysmw],?)+$/.test(value),\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `\"${value}\" must be a value like \"10d\" or \"3s\" the first part is the length second is unit`;\r\n }\r\n constructor(public name: string) {}\r\n}\r\n\r\nexport class PlayerNameArgumentType implements IArgumentType {\r\n type: string;\r\n typeName = \"playerName\";\r\n matches(value: string): IArgumentReturnData {\r\n const player = TABLES.ids.get(value);\r\n return {\r\n success: player ? true : false,\r\n value: value,\r\n };\r\n }\r\n fail(value: string): string {\r\n return `player: \"${value}\" has never played this world before! Tip: if the name has spaces in it use quotes around name!`;\r\n }\r\n constructor(public name: string = \"playerName\") {\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport const ArgumentTypes = {\r\n string: StringArgumentType,\r\n int: IntegerArgumentType,\r\n float: FloatArgumentType,\r\n location: LocationArgumentType,\r\n boolean: BooleanArgumentType,\r\n player: PlayerArgumentType,\r\n target: TargetArgumentType,\r\n array: ArrayArgumentType,\r\n duration: DurationArgumentType,\r\n playerName: PlayerNameArgumentType,\r\n};\r\n", "import { Entity, ItemStack, MinecraftItemTypes } from \"@minecraft/server\";\nimport {\n ENTITY_IDENTIFIER,\n ENTITY_LOCATION,\n INVENTORY_SIZE,\n MAX_DATABASE_STRING_SIZE,\n MAX_LORE_ARRAY_SIZE,\n} from \"../config/database\";\nimport { DIMENSIONS, splitString } from \"../../utils\";\nimport { EntitiesLoad } from \"../lib/Events/EntitiesLoad\";\n\nexport class Database {\n /**\n * Creates a table entity that is used for data storage\n * @param tableName\n * @param index if not specified no index will be set\n * @returns\n */\n static createTableEntity(tableName: string, index?: number): Entity {\n const entity = DIMENSIONS.overworld.spawnEntity(\n ENTITY_IDENTIFIER,\n ENTITY_LOCATION\n );\n entity.setDynamicProperty(\"tableName\", tableName);\n entity.nameTag = `\u00A7aDatabase Table: ${tableName}\u00A7r`;\n if (index) entity.setDynamicProperty(\"index\", index);\n return entity;\n }\n\n /**\n * Gets all table Entities associated with this tableName\n * @param tableName\n * @returns\n */\n static getTableEntities(tableName: string): Entity[] {\n return DIMENSIONS.overworld\n .getEntitiesAtBlockLocation(ENTITY_LOCATION)\n .filter(\n (e) =>\n e.typeId == ENTITY_IDENTIFIER &&\n e.getDynamicProperty(\"tableName\") == tableName\n );\n }\n\n /**\n * Despawn's all database entities\n */\n static despawnTableEntities() {\n return DIMENSIONS.overworld\n .getEntitiesAtBlockLocation(ENTITY_LOCATION)\n .map((e) => e.triggerEvent(\"despawn\"));\n }\n\n /**\n * Data saved in memory\n */\n private MEMORY: { [key in Key]: Value };\n\n /**\n * List of queued tasks on this table\n */\n private QUEUE: Array<() => void>;\n\n private onLoadCallback: (data: Database[\"MEMORY\"]) => void;\n\n /**\n * Creates a new instance of the Database\n * @param tableName - The name of the table\n */\n constructor(public tableName: string) {\n this.tableName = tableName;\n this.MEMORY = null;\n this.QUEUE = [];\n this.onLoadCallback = null;\n EntitiesLoad.subscribe(async () => {\n const data = await this.initData();\n this.onLoadCallback(data);\n this.QUEUE.forEach((v) => v());\n });\n }\n\n /**\n * Adds a queue task to be awaited\n * @returns once its this items time to run in queue\n */\n private async addQueueTask(): Promise {\n return new Promise((resolve) => {\n this.QUEUE.push(resolve);\n });\n }\n\n /**\n * Saves data into this database\n * @returns once data is saved to the database entities\n */\n private async saveData(): Promise {\n if (!this.MEMORY) await this.addQueueTask();\n let entities = Database.getTableEntities(this.tableName);\n let chunks = splitString(\n JSON.stringify(this.MEMORY),\n MAX_DATABASE_STRING_SIZE,\n MAX_LORE_ARRAY_SIZE\n );\n const entitiesNeeded =\n Math.ceil(chunks.length / INVENTORY_SIZE) - entities.length;\n if (entitiesNeeded > 0) {\n for (let i = 0; i < entitiesNeeded; i++) {\n entities.push(Database.createTableEntity(this.tableName));\n }\n }\n let savedChunks = 0;\n let i = 0;\n while (savedChunks < chunks.length) {\n const entity = entities[i];\n if (!entity) continue;\n const inventory = entity.getComponent(\"inventory\").container;\n inventory.clearAll();\n for (let j = 0; j < inventory.size && savedChunks < chunks.length; j++) {\n const chunk = chunks[savedChunks];\n let item = new ItemStack(MinecraftItemTypes.acaciaBoat);\n item.setLore(chunk);\n inventory.setItem(j, item);\n savedChunks++;\n }\n entity.setDynamicProperty(\"index\", i);\n i++;\n }\n entities.slice(i).forEach((e) => e?.triggerEvent(\"despawn\"));\n }\n\n /**\n * Grabs Data and should only be used on worldLoad\n * @returns {Promise<{ [key in Key]: Value }>} The parsed data.\n */\n private async initData(): Promise<{ [key in Key]: Value }> {\n let entities = Database.getTableEntities(this.tableName).sort(\n (a, b) =>\n (a.getDynamicProperty(\"index\") as number) -\n (b.getDynamicProperty(\"index\") as number)\n );\n if (entities.length == 0) {\n console.warn(\n `[Database-Warning]: No data found for table ${this.tableName}!`\n );\n }\n const stringifiedData: string[] = [];\n for (const entity of entities) {\n const inventory = entity.getComponent(\"inventory\").container;\n for (let i = 0; i < inventory.size; i++) {\n const item = inventory.getItem(i);\n if (item) stringifiedData.push(...item.getLore());\n }\n }\n this.MEMORY = JSON.parse(stringifiedData.join(\"\") || \"{}\");\n console.warn(`table ${this.tableName} memor ${this.MEMORY}`);\n return this.MEMORY;\n }\n\n /**\n * Sends a callback once this database has initiated data\n * @param callback\n */\n async onLoad(callback: Database[\"onLoadCallback\"]) {\n this.onLoadCallback = callback;\n }\n\n /**\n * Sets the specified `key` to the given `value` in the database table.\n * @param key - Key to store the value in.\n * @param value - The value to store for the specified key.\n * @returns A promise that resolves once the value has been saved in the database table.\n */\n async set(key: Key, value: Value): Promise {\n this.MEMORY[key] = value;\n return this.saveData();\n }\n\n /**\n * Gets a value from this table\n * @param {Key} key - The key to retrieve the value for.\n * @returns the value associated with the given key in the database table.\n */\n get(key: Key): Value {\n if (!this.MEMORY)\n throw new Error(\n \"Entities not loaded! Consider using `getAsync` instead!\"\n );\n return this.MEMORY[key];\n }\n\n /**\n * Gets a value asynchronously from the database table.\n * @param {Key} key - The key to retrieve the value for.\n * @returns {Promise} A Promise that resolves to the value associated with the given key in the database table.\n */\n async getSync(key: Key): Promise {\n if (this.MEMORY) return this.get(key);\n await this.addQueueTask();\n return this.MEMORY[key];\n }\n\n /**\n * Get all the keys in the table\n * @returns {Key[]} the keys on this table\n */\n keys(): Key[] {\n if (!this.MEMORY)\n throw new Error(\n \"Entities not loaded! Consider using `keysSync` instead!\"\n );\n return Object.keys(this.MEMORY) as Key[];\n }\n\n /**\n * Get all the keys in the table async, this should be used on world load\n * @returns {Promise} the keys on this table\n */\n async keysSync(): Promise {\n if (this.MEMORY) return this.keys();\n await this.addQueueTask();\n return Object.keys(this.MEMORY) as Key[];\n }\n\n /**\n * Get all the values in the table\n * @returns {Value[]} values in this table\n */\n values(): Value[] {\n if (!this.MEMORY)\n throw new Error(\n \"Entities not loaded! Consider using `valuesSync` instead!\"\n );\n return Object.values(this.MEMORY) as Value[];\n }\n\n /**\n * Get all the values in the table async, this should be used on world load\n * @returns {Promise} the values on this table\n */\n async valuesSync(): Promise {\n if (this.MEMORY) return this.values();\n await this.addQueueTask();\n return Object.values(this.MEMORY) as Value[];\n }\n\n /**\n * Check if the key exists in the table\n * @param {Key} key the key to test\n * @returns {boolean} if this key exists on this table\n */\n has(key: Key): boolean {\n if (!this.MEMORY)\n throw new Error(\"Entities not loaded! Consider using `hasSync` instead!\");\n return (Object.keys(this.MEMORY) as Key[]).includes(key);\n }\n\n /**\n * Check if the key exists in the table async\n * @param {Key} key the key to test\n * @returns {Promise} if this table contains this key.\n */\n async hasSync(key: Key): Promise {\n if (this.MEMORY) return this.has(key);\n await this.addQueueTask();\n return (Object.keys(this.MEMORY) as Key[]).includes(key);\n }\n\n /**\n * Gets all the keys and values\n * @returns { [key in Key]: Value } The collection data.\n */\n collection(): { [key in Key]: Value } {\n if (!this.MEMORY)\n throw new Error(\n \"Entities not loaded! Consider using `collectionSync` instead!\"\n );\n return this.MEMORY;\n }\n\n /**\n * Gets all the keys and values async, this should be used for grabbingCollection on world load\n * @returns {Promise<{ [key in Key]: Value }>} The collection data.\n */\n async collectionSync(): Promise<{ [key in Key]: Value }> {\n if (this.MEMORY) return this.collection();\n await this.addQueueTask();\n return this.MEMORY;\n }\n\n /**\n * Delete a key from this table\n * @param key the key to delete\n * @returns if the deletion was successful\n */\n async delete(key: Key): Promise {\n const status = delete this.MEMORY[key];\n await this.saveData();\n return status;\n }\n\n /**\n * Clear everything in the table\n * @returns once this table has been cleared\n */\n async clear(): Promise {\n this.MEMORY = {} as { [key in Key]: Value };\n return await this.saveData();\n }\n}\n", "import { BlockLocation } from \"@minecraft/server\";\n\n/*\n|--------------------------------------------------------------------------\n| Max Database string size\n|--------------------------------------------------------------------------\n|\n| Here is the max database save size meaning when a save gets made\n| it tests the size of that save and splits up the save depending on this\n| Size. It's related to Minecraft's 32k bit limit.\n|\n*/\nexport const MAX_DATABASE_STRING_SIZE = 32000;\n\n/*\n|--------------------------------------------------------------------------\n| Max Lore Array Size\n|--------------------------------------------------------------------------\n|\n| Here is the max database lore size meaning when a save gets made\n| it tests the size of that lore array is bigger than this then splits up\n| the length. It's related to int32 NBT storage of lists.\n|\n*/\nexport const MAX_LORE_ARRAY_SIZE = 2000000;\n\n/*\n|--------------------------------------------------------------------------\n| Entity Id\n|--------------------------------------------------------------------------\n|\n| This is the entity id of the database this is what stores the information\n| of the database on its nameTag\n|\n*/\nexport const ENTITY_IDENTIFIER = \"database:database\";\n\n/*\n|--------------------------------------------------------------------------\n| Entity Spawn Location\n|--------------------------------------------------------------------------\n|\n| This is the spawn location of the database entities there will be\n| Multiple entities at this location for each chunk\n|\n*/\nexport const ENTITY_LOCATION = new BlockLocation(0, -64, 0);\n\n/*\n|--------------------------------------------------------------------------\n| Entity's INVENTORY_SIZE\n|--------------------------------------------------------------------------\n|\n| The max amount of items this entity can store in its inventory\n|\n*/\nexport const INVENTORY_SIZE = 128;\n\n/*\n|--------------------------------------------------------------------------\n| Back Up Name\n|--------------------------------------------------------------------------\n|\n| The structure file name for the backed up data in this database\n|\n*/\nexport const BACKUP_NAME = \"database:entities\";\n", "import {\r\n BlockLocation,\r\n Entity,\r\n Location,\r\n MinecraftDimensionTypes,\r\n system,\r\n Vector3,\r\n world,\r\n} from \"@minecraft/server\";\r\n\r\n/**\r\n * This is to reduce lag when grabbing dimensions keep them set and pre-defined\r\n */\r\nexport const DIMENSIONS = {\r\n overworld: world.getDimension(MinecraftDimensionTypes.overworld),\r\n nether: world.getDimension(MinecraftDimensionTypes.nether),\r\n theEnd: world.getDimension(MinecraftDimensionTypes.theEnd),\r\n \"minecraft:overworld\": world.getDimension(MinecraftDimensionTypes.overworld),\r\n \"minecraft:nether\": world.getDimension(MinecraftDimensionTypes.nether),\r\n \"minecraft:the_end\": world.getDimension(MinecraftDimensionTypes.theEnd),\r\n};\r\n\r\n/**\r\n * Get score of an entity\r\n * @example getScore(Entity, 'Money');\r\n */\r\nexport function getScore(entity: Entity, objective: string): number {\r\n try {\r\n return world.scoreboard.getObjective(objective).getScore(entity.scoreboard);\r\n } catch (error) {\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * sets the score of a name\r\n * @example setScore(\"Smell of curry\", 'Money');\r\n */\r\nexport function setScore(\r\n entityName: string,\r\n objective: string,\r\n value: Number\r\n): void {\r\n try {\r\n DIMENSIONS.overworld.runCommandAsync(\r\n `scoreboard players set \"${entityName}\" ${objective} ${value}`\r\n );\r\n } catch (error) {\r\n console.warn(error + error.stack);\r\n }\r\n}\r\n\r\n/**\r\n * Duration converter\r\n * @param duration time to convert\r\n * @example ```\r\n * durationToMs(\"10s\")\r\n * durationToMs(\"10d,2y\")\r\n * durationToMs(\"5m\")\r\n * durationToMs(\"23ms,10s\")\r\n * ```\r\n */\r\nconst durations: { [unit: string]: number } = {\r\n y: 3.17098e-11,\r\n w: 6.048e8,\r\n d: 8.64e7,\r\n h: 3.6e6,\r\n m: 60000,\r\n s: 1000,\r\n ms: 1,\r\n};\r\n\r\nexport function durationToMs(duration: string): number {\r\n const values: string[] = duration.split(\",\");\r\n let ms = 0;\r\n for (const value of values) {\r\n const length = parseInt(value.match(/\\d+/)[0]);\r\n const unit = value.match(/[a-zA-Z]+/)[0];\r\n if (!durations[unit]) {\r\n throw new Error(`Invalid duration unit: ${unit}`);\r\n }\r\n ms += durations[unit] * length;\r\n }\r\n return ms;\r\n}\r\n\r\n/**\r\n * Converts a date stored in ms to a Date string\r\n * @param duration milliseconds to convert\r\n * @returns Date as a string\r\n */\r\nexport function msToTime(duration: number) {\r\n return new Date(duration).toString();\r\n}\r\n\r\n/**\r\n * Converts a location to a block location\r\n */\r\nexport function vector3ToBlockLocation(loc: Vector3): BlockLocation {\r\n return new BlockLocation(\r\n Math.floor(loc.x),\r\n Math.floor(loc.y),\r\n Math.floor(loc.z)\r\n );\r\n}\r\n\r\n/**\r\n * Sleeps your code\r\n * @param {number} tick time in ticks you want the return to occur\r\n * @returns {Promise}\r\n */\r\nexport function sleep(tick: number): Promise {\r\n return new Promise((resolve) => {\r\n let runScheduleId = system.runSchedule(() => {\r\n resolve();\r\n system.clearRunSchedule(runScheduleId);\r\n }, tick);\r\n });\r\n}\r\n\r\n/**\r\n * Checks if a location equals another location\r\n * @param a first location\r\n * @param b location to test against first\r\n * @returns {boolean} if they locations are the same\r\n */\r\nexport function LocationEquals(\r\n a: Vector3 | Location | BlockLocation,\r\n b: Vector3 | Location | BlockLocation\r\n): boolean {\r\n if (a instanceof BlockLocation || b instanceof BlockLocation) {\r\n return ~~a.x === ~~b.x && ~~a.y === ~~b.y && ~~a.z === ~~b.z;\r\n }\r\n return a.x === b.x && a.y === b.y && a.z === b.z;\r\n}\r\n\r\n/**\r\n * Sorts 3D vectors to a min and max vector\r\n * @param vector1\r\n * @param vector2\r\n * @returns {[Vector3, Vector3]}\r\n */\r\nexport function sort3DVectors(\r\n vector1: Vector3,\r\n vector2: Vector3\r\n): [Vector3, Vector3] {\r\n [vector1.x, vector2.x] = [\r\n Math.min(vector1.x, vector2.x),\r\n Math.max(vector1.x, vector2.x),\r\n ];\r\n [vector1.y, vector2.y] = [\r\n Math.min(vector1.y, vector2.y),\r\n Math.max(vector1.y, vector2.y),\r\n ];\r\n [vector1.z, vector2.z] = [\r\n Math.min(vector1.z, vector2.z),\r\n Math.max(vector1.z, vector2.z),\r\n ];\r\n return [vector1, vector2];\r\n}\r\n/**\r\n * Checks if a target vector is between two vectors\r\n * @param target\r\n * @param vector1\r\n * @param vector2\r\n * @returns\r\n */\r\nexport function betweenVector3(\r\n target: Vector3,\r\n vector1: Vector3,\r\n vector2: Vector3\r\n): boolean {\r\n const [minVector, maxVector] = sort3DVectors(vector1, vector2);\r\n const { x, y, z } = target;\r\n return (\r\n x >= minVector.x &&\r\n x <= maxVector.x &&\r\n y >= minVector.y &&\r\n y <= maxVector.y &&\r\n z >= minVector.z &&\r\n z <= maxVector.z\r\n );\r\n}\r\n\r\n/**\r\n * Splits a string into chunk sizes\r\n */\r\nexport function chunkString(str: string, length: number): string[] {\r\n return str.match(new RegExp(\".{1,\" + length + \"}\", \"g\"));\r\n}\r\n\r\n/**\r\n * Splits a string into an array of arrays of strings with a maximum length of 32767 characters per string in the innermost array.\r\n * @param str The input string to split.\r\n * @param maxLength Max Length of the 1st array\r\n * @param subArraysMaxLength Max Length of the strings in the 2d array\r\n * @returns A two-dimensional array of strings, where each inner array has a maximum length of 2147483647.\r\n */\r\nexport function splitString(\r\n str: string,\r\n maxLength: number,\r\n subArraysMaxLength: number\r\n): string[][] {\r\n const subStrings: string[] = [];\r\n for (let i = 0; i < str.length; i += maxLength) {\r\n subStrings.push(str.slice(i, i + maxLength));\r\n }\r\n\r\n const subArrays: string[][] = [];\r\n for (const subString of subStrings) {\r\n subArrays.push(\r\n Array.from(\r\n { length: Math.ceil(subString.length / subArraysMaxLength) },\r\n (_, i) =>\r\n subString.slice(i * subArraysMaxLength, (i + 1) * subArraysMaxLength)\r\n )\r\n );\r\n }\r\n\r\n return subArrays;\r\n}", "import { system, world } from \"@minecraft/server\";\r\nimport { DIMENSIONS } from \"../../../utils\";\r\n\r\n/**\r\n * Callbacks that are called when the entities are loaded\r\n */\r\nconst CALLBACKS: {\r\n [key: number]: () => void;\r\n} = {};\r\n\r\n/**\r\n * If the world is loaded or not\r\n */\r\nexport let ENTITIES_LOADED = false;\r\n\r\n/**\r\n * Sets the world as loaded in, meaning entities are now able to be grabbed\r\n */\r\nfunction setEntitiesLoaded() {\r\n ENTITIES_LOADED = true;\r\n for (const [i, callback] of Object.entries(CALLBACKS)) {\r\n callback();\r\n delete CALLBACKS[i as unknown as number];\r\n }\r\n}\r\n\r\nsystem.run(async () => {\r\n try {\r\n await DIMENSIONS.overworld.runCommandAsync(`testfor @a`);\r\n setEntitiesLoaded();\r\n } catch (error) {\r\n let e = world.events.playerSpawn.subscribe(() => {\r\n setEntitiesLoaded();\r\n world.events.playerSpawn.unsubscribe(e);\r\n });\r\n }\r\n});\r\n\r\n/**\r\n * Class that exposes methods to subscribe to or wait for entities to be loaded.\r\n */\r\nexport class EntitiesLoad {\r\n /**\r\n * Returns a Promise that resolves when the entities are loaded.\r\n * @returns {Promise} A Promise that resolves when the entities are loaded.\r\n */\r\n static async awaitLoad(): Promise {\r\n if (ENTITIES_LOADED) return;\r\n return new Promise((resolve) => {\r\n EntitiesLoad.subscribe(resolve);\r\n });\r\n }\r\n /**\r\n * Subscribe a callback to be called when the entities are loaded.\r\n * @param {() => void} callback The function to be called when the entities are loaded.\r\n * @returns {number} The key associated with this subscription.\r\n */\r\n static subscribe(callback: () => void): number {\r\n const key = Object.keys(CALLBACKS).length;\r\n if (ENTITIES_LOADED) {\r\n callback();\r\n return key;\r\n }\r\n CALLBACKS[key] = callback;\r\n return key;\r\n }\r\n\r\n /**\r\n * Unsubscribe a callback from being called when the entities are loaded.\r\n * @param {number} key The key associated with the subscription to be unsubscribed.\r\n */\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n", "import { Database } from \"../../rubedo/database/Database\";\r\nimport {\r\n IBanData,\r\n IFreezeData,\r\n IMuteData,\r\n INpcLocation,\r\n IProtectionsConfig,\r\n IRegionDB,\r\n LogData,\r\n ROLES,\r\n} from \"./types\";\r\n\r\nexport const TABLES = {\r\n config: new Database(\"config\"),\r\n freezes: new Database(\"freezes\"),\r\n mutes: new Database(\"mutes\"),\r\n bans: new Database(\"bans\"),\r\n regions: new Database(\"regions\"),\r\n roles: new Database(\"roles\"),\r\n tasks: new Database(\"tasks\"),\r\n npcs: new Database(\"npcs\"),\r\n ids: new Database(\"ids\"),\r\n logs: new Database(\"logs\"),\r\n protections: new Database(\"protections\"),\r\n};\r\n", "import { BeforeChatEvent, Player } from \"@minecraft/server\";\r\n\r\nexport class CommandCallback {\r\n data: BeforeChatEvent;\r\n sender: Player;\r\n\r\n /**\r\n * Returns a commands callback\r\n * @param data chat data that was used\r\n */\r\n constructor(data: BeforeChatEvent) {\r\n this.data = data;\r\n this.sender = data.sender;\r\n }\r\n /**\r\n * Replies to the sender of a command callback\r\n * @param text Message or a lang code\r\n * @example ctx.reply('Hello World!');\r\n */\r\n reply(text: string) {\r\n this.sender.tell(text);\r\n }\r\n}\r\n", "import { BeforeChatEvent, Player, Vector3 } from \"@minecraft/server\";\nimport { PREFIX } from \"../../config/commands\";\nimport { LiteralArgumentType, LocationArgumentType } from \"./ArgumentTypes\";\nimport { CommandCallback } from \"./Callback\";\nimport type { Command } from \"./Command\";\n\n/**\n * Returns a Before chat events augments\n * @example this.getChatAugments(BeforeChatEvent)\n */\nexport function getChatAugments(\n message: string,\n prefix: string\n): Array {\n try {\n return message\n .slice(prefix.length)\n .trim()\n .match(/\"[^\"]+\"|[^\\s]+/g)\n .map((e) => e.replace(/\"(.+)\"/, \"$1\").toString());\n } catch (error) {\n return [];\n }\n}\n\n/**\n * Sends a command not found message to a player\n * @param player player to send message to\n */\nexport function commandNotFound(player: Player, command: string) {\n player.tell({\n rawtext: [\n {\n text: `\u00A7c`,\n },\n {\n translate: `commands.generic.unknown`,\n with: [`${command}`],\n },\n ],\n });\n}\n\n/**\n * Sends a command not found message to a player\n * @param player player to send message to\n */\nexport function noPerm(player: Player, command: Command) {\n player.tell({\n rawtext: [\n {\n text: command.data.invalidPermission\n ? command.data.invalidPermission\n : `\u00A7cYou do not have permission to use \"${command.data.name}\"`,\n },\n ],\n });\n}\n\n/**\n * Sends a syntax failure message to player\n * @param player\n * @param command\n * @param args\n * @param i\n */\nexport function commandSyntaxFail(\n player: Player,\n baseCommand: Command,\n command: Command,\n args: string[],\n i: number\n) {\n player.tell({\n rawtext: [\n {\n text: `\u00A7c`,\n },\n {\n translate: `commands.generic.syntax`,\n with: [\n `${PREFIX}${baseCommand.data.name} ${args.slice(0, i).join(\" \")}`,\n args[i] ?? \" \",\n args.slice(i + 1).join(\" \"),\n ],\n },\n ],\n });\n if (command.children.length > 1 || !args[i]) {\n // this type could be many things\n const types = command.children.map((c) =>\n c.type instanceof LiteralArgumentType ? c.type.name : c.type?.typeName\n );\n player.tell(\n `\u00A7c\"${args[i] ?? \"undefined\"}\" is not valid! Argument \"${\n [...new Set(command.children.map((c) => c.type.name))][0]\n }\" can be typeof: \"${types.join('\", \"')}\"`\n );\n } else {\n // this type is only 1 thing\n player.tell(`\u00A7c${command.children[0]?.type?.fail(args[i])}`);\n }\n}\n\n/**\n * Returns a location of the inputted argument\n * @example parseLocationArgs([\"~1\", \"3\", \"^7\"], { location: [1,2,3] , viewVector: [1,2,3] })\n */\nexport function parseLocationArgs(\n [x, y, z]: [x: string, y: string, z: string],\n { location, viewDirection }: { location: Vector3; viewDirection: Vector3 }\n): Vector3 {\n if (!x || !y || !x) return null;\n const locations = [location.x, location.y, location.z];\n const viewVectors = [viewDirection.x, viewDirection.y, viewDirection.z];\n const a = [x, y, z].map((arg) => {\n const r = parseFloat(arg);\n return isNaN(r) ? 0 : r;\n });\n const b = [x, y, z].map((arg, index) => {\n return arg.includes(\"~\")\n ? a[index] + locations[index]\n : arg.includes(\"^\")\n ? a[index] + viewVectors[index]\n : a[index];\n });\n return { x: b[0], y: b[1], z: b[2] };\n}\n\n/**\n * Sends a callback back to the command\n * @param cmdArgs the args that the command used\n * @param args args to use\n */\nexport function sendCallback(\n cmdArgs: string[],\n args: Command[],\n event: BeforeChatEvent,\n baseCommand: Command\n) {\n const lastArg = args[args.length - 1] ?? baseCommand;\n const argsToReturn: any[] = [];\n for (const [i, arg] of args.entries()) {\n if (arg.type.name.endsWith(\"*\")) continue;\n if (arg.type instanceof LocationArgumentType) {\n argsToReturn.push(\n parseLocationArgs(\n [cmdArgs[i], cmdArgs[i + 1], cmdArgs[i + 2]],\n event.sender\n )\n );\n continue;\n }\n if (arg.type instanceof LiteralArgumentType) continue;\n argsToReturn.push(arg.type.matches(cmdArgs[i]).value ?? cmdArgs[i]);\n }\n lastArg.callback(new CommandCallback(event), ...argsToReturn);\n}\n", "import {\r\n ItemStack,\r\n MinecraftItemTypes,\r\n system,\r\n world,\r\n} from \"@minecraft/server\";\r\nimport { ENTITY_INVENTORY, GUI_ITEM } from \"../../config/chest\";\r\nimport { ChestGUI } from \"./Models/EntityChest\";\r\nimport { CHESTGUIS, getHeldItem } from \"./utils.js\";\r\nimport \"./pages/home\";\r\nimport { DIMENSIONS } from \"../../../utils.js\";\r\nimport { EntitiesLoad } from \"../Events/EntitiesLoad\";\r\nimport { getRole } from \"../../../vendor/Anti-Cheat/utils\";\r\n\r\nexport const AIR = new ItemStack(MinecraftItemTypes.acaciaBoat, 0);\r\n\r\nEntitiesLoad.subscribe(() => {\r\n system.runSchedule(() => {\r\n for (const player of world.getPlayers()) {\r\n /**\r\n * Loop through all players, check if player has a chest gui\r\n * if not create them one\r\n * Once all players are checked verify there are no false entities\r\n */\r\n if (getHeldItem(player)?.typeId != GUI_ITEM) {\r\n if (CHESTGUIS[player.name]) CHESTGUIS[player.name].despawn();\r\n continue;\r\n }\r\n // Player has a item Held we need to verify that they have a gui\r\n if (Object.keys(CHESTGUIS).includes(player?.name)) continue;\r\n // Player does not have a chest gui spawn them in one\r\n if (getRole(player) != \"admin\") continue;\r\n CHESTGUIS[player.name] = new ChestGUI(player);\r\n }\r\n }, 10);\r\n});\r\n\r\n/**\r\n * This system will detect false entities and kill them to\r\n * reduce lag and eliminate broken/left players/entities\r\n */\r\nsystem.runSchedule(() => {\r\n const validIds = Object.values(CHESTGUIS).map((c) => c.entity.id);\r\n for (const entity of DIMENSIONS.overworld.getEntities({\r\n type: ENTITY_INVENTORY,\r\n })) {\r\n if (validIds.includes(entity.id)) continue;\r\n // This entity is not valid so we despawn it\r\n entity.triggerEvent(\"despawn\");\r\n }\r\n}, 100);\r\n", "/*\n|--------------------------------------------------------------------------\n| Gui item\n|--------------------------------------------------------------------------\n|\n| This is the GUI item that is used to open up the gui\n| this is set to the identifier of item.json and is used to find the item\n| in the gui template\n|\n*/\nexport const GUI_ITEM = \"rubedo:gui\";\n\n/*\n|--------------------------------------------------------------------------\n| Entity Inventory\n|--------------------------------------------------------------------------\n|\n| The id of the entity inventory\n| this is found in the entities file\n| this will be updated if inventory entity is changed\n|\n*/\nexport const ENTITY_INVENTORY = \"rubedo:inventory\";\n\n/*\n|--------------------------------------------------------------------------\n| Default Static Page id\n|--------------------------------------------------------------------------\n|\n| This is the default static page id of what is open by default\n| when you click on the gui, this can be changed but it probably shouldn't\n| because static pages will need to be changed\n|\n*/\nexport const DEFAULT_STATIC_PAGE_ID = \"home\";\n", "import { Entity, Player, system } from \"@minecraft/server\";\r\nimport { AIR } from \"../index\";\r\nimport { ENTITY_INVENTORY } from \"../../../config/chest\";\r\nimport {\r\n ISlotChangeReturn,\r\n onEntityInventorySlotChange,\r\n} from \"../../Events/onSlotChange\";\r\nimport {\r\n CHESTGUIS,\r\n clearPlayersPointer,\r\n getItemAtSlot,\r\n PAGES,\r\n} from \"../utils.js\";\r\nimport { ItemGrabbedCallback } from \"./ItemGrabbedCallback\";\r\nimport { ISlot, Page } from \"./Page.js\";\r\n\r\nexport class ChestGUI {\r\n /**\r\n * The connected player to this gui\r\n */\r\n player: Player;\r\n /**\r\n * The entity that this chest gui is associated to\r\n */\r\n entity: Entity;\r\n /**\r\n * The event that is registered on this gui\r\n */\r\n runScheduleId: number;\r\n\r\n /**\r\n * The page that this gui is currently viewing\r\n */\r\n page: Page;\r\n\r\n /**\r\n * The event that is used to test for changes in inventory\r\n */\r\n slotChangeEvent: number;\r\n\r\n /**\r\n * if the player has a chest open\r\n */\r\n hasChestOpen: boolean;\r\n\r\n /**\r\n * Spawns a entity to be attached to the player\r\n * @param player player this entity will be attached to\r\n */\r\n static spawnEntity(player: Player): Entity {\r\n try {\r\n return player.dimension.spawnEntity(\r\n ENTITY_INVENTORY,\r\n player.headLocation\r\n );\r\n } catch (error) {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Links a new chest gui to a player\r\n * @param player player to link\r\n */\r\n constructor(player: Player) {\r\n this.player = player;\r\n this.entity = ChestGUI.spawnEntity(player);\r\n if (this.entity) {\r\n this.hasChestOpen = false;\r\n this.setPage(\"home\");\r\n }\r\n this.runScheduleId = system.runSchedule(() => {\r\n if (!this.entity) return this.despawn();\r\n if (this.player.getComponent(\"mark_variant\").value == 1) {\r\n if (!this.hasChestOpen) {\r\n // Player has this inventory open run checks for changes\r\n this.slotChangeEvent = onEntityInventorySlotChange.subscribe(\r\n { type: ENTITY_INVENTORY },\r\n (entity, change) => {\r\n if (entity.id != this.entity.id) return;\r\n this.onSlotChange(change);\r\n }\r\n );\r\n }\r\n this.hasChestOpen = true;\r\n } else {\r\n // Player does not have inventory open but item is held\r\n try {\r\n this.entity.teleport(\r\n this.player.headLocation,\r\n this.player.dimension,\r\n this.player.rotation.x,\r\n this.player.rotation.y,\r\n true\r\n );\r\n } catch (error) {\r\n this.despawn();\r\n }\r\n }\r\n }, 5);\r\n }\r\n\r\n /**\r\n * Sets this gui to a page of items\r\n * @param pageId page to set this gui too\r\n */\r\n setPage(pageId: string, extras?: any) {\r\n const c = this.entity.getComponent(\"inventory\").container;\r\n for (let i = 0; i < c.size; i++) {\r\n c.setItem(i, AIR);\r\n }\r\n if (!Object.keys(PAGES).includes(pageId))\r\n throw new Error(`pageId ${pageId} does not exist!`);\r\n const page = PAGES[pageId];\r\n this.page = page;\r\n\r\n page.fillType(this.entity, page, extras);\r\n this.entity.nameTag = `size:54`;\r\n }\r\n\r\n /**\r\n * This runs when a slot gets changed in the chest inventory\r\n */\r\n onSlotChange(change: ISlotChangeReturn) {\r\n /**\r\n * The guiItem that was changed\r\n */\r\n const slot: ISlot = this.page.slots[change.slot];\r\n\r\n if (!slot) {\r\n // item was added to page that is not a valid slot so set that slot back to air\r\n this.entity.getComponent(\"inventory\").container.setItem(change.slot, AIR);\r\n } else if (change.changeType == \"delete\") {\r\n // item was taken from this page\r\n if (slot.item) clearPlayersPointer(this.player, change.item);\r\n /**\r\n * if the slot has a item that returns when something is grabbed, this checks\r\n * if there is a item put into the slot to return, if not it will not send a\r\n * callback by returning before\r\n */\r\n if (!slot.item && !getItemAtSlot(this.entity, change.slot)) return;\r\n slot.action(new ItemGrabbedCallback(this, slot, change));\r\n }\r\n }\r\n\r\n /**\r\n * Deletes this gui and despawn its entity\r\n */\r\n despawn() {\r\n try {\r\n this.entity?.triggerEvent(\"despawn\");\r\n } catch (error) {}\r\n try {\r\n delete CHESTGUIS[this.player.name];\r\n } catch (error) {}\r\n if (this.runScheduleId) system.clearRunSchedule(this.runScheduleId);\r\n if (this.slotChangeEvent)\r\n onEntityInventorySlotChange.unsubscribe(this.slotChangeEvent);\r\n }\r\n}\r\n", "import {\r\n Entity,\r\n EntityQueryOptions,\r\n ItemStack,\r\n PlayerInventoryComponentContainer,\r\n system,\r\n} from \"@minecraft/server\";\r\nimport { DIMENSIONS } from \"../../../utils.js\";\r\n\r\ntype onSlotChangeCallback = (entity: Entity, change: ISlotChangeReturn) => void;\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: onSlotChangeCallback;\r\n entities: EntityQueryOptions;\r\n };\r\n} = {};\r\n\r\nconst MAPPED_INVENTORIES: { [key: string]: Array } = {};\r\nexport const PREVIOUS_CHANGE: { [key: string]: ISlotChangeReturn } = {};\r\n\r\nexport interface ISlotChangeReturn {\r\n /**\r\n * Slot that changed\r\n */\r\n slot: number;\r\n /**\r\n * The uid of this item\r\n */\r\n uid: string;\r\n /**\r\n * The old uid of this item\r\n */\r\n oldUid?: string;\r\n /**\r\n * the item that was grabbed / put\r\n */\r\n item: ItemStack;\r\n /**\r\n * The old itemStack that was in this slot\r\n */\r\n oldItem?: ItemStack;\r\n /**\r\n * How the inventory has changed\r\n */\r\n changeType: \"delete\" | \"put\" | \"swap\" | \"fluctuation\" | \"move\";\r\n}\r\n\r\ninterface IMappedInventoryItem {\r\n /**\r\n * a unique id for a itemStack\r\n */\r\n uid: string;\r\n /**\r\n * the item\r\n */\r\n item: ItemStack;\r\n}\r\n\r\n/**\r\n * Finds and returns a slot change in a inventory\r\n */\r\nfunction getSlotChanges(\r\n entity: Entity,\r\n oldInv: Array,\r\n newInv: Array\r\n): Array {\r\n if (oldInv.length != newInv.length) return [];\r\n const changes: Array = [];\r\n for (let i = 0; i < newInv.length; i++) {\r\n if (\r\n oldInv[i]?.item?.amount < newInv[i]?.item?.amount ||\r\n (oldInv[i]?.item?.amount > newInv[i]?.item?.amount &&\r\n oldInv[i]?.item?.amount != 0)\r\n ) {\r\n // Checks if the item is the same but checks if the amount has changed\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: newInv[i].uid,\r\n oldUid: oldInv[i].uid,\r\n item: newInv[i].item,\r\n oldItem: oldInv[i].item,\r\n changeType: \"fluctuation\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n continue;\r\n }\r\n if (newInv[i].uid == oldInv[i].uid) continue; // no change\r\n if (oldInv[i]?.item && newInv[i]?.item) {\r\n // Checks if there was a new item but a new slot was not taken up\r\n // Meaning that the item got used like using a bucket on a cow\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: newInv[i].uid,\r\n oldUid: oldInv[i].uid,\r\n item: newInv[i].item,\r\n oldItem: oldInv[i].item,\r\n changeType: \"swap\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n } else if (!newInv[i]?.item) {\r\n // There is no more item in this slot\r\n // Meaning the item has been moved across slots or been thrown out\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: oldInv[i].uid,\r\n item: oldInv[i].item,\r\n changeType: \"delete\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n } else if (newInv[i]?.item) {\r\n // New item has been added in this slot\r\n if (\r\n PREVIOUS_CHANGE[entity.id]?.changeType == \"delete\" &&\r\n PREVIOUS_CHANGE[entity.id]?.uid == newInv[i].uid\r\n ) {\r\n // item has been moved across slots\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: newInv[i].uid,\r\n item: newInv[i].item,\r\n changeType: \"move\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n continue;\r\n } else {\r\n const change_data: ISlotChangeReturn = {\r\n slot: i,\r\n uid: newInv[i].uid,\r\n item: newInv[i].item,\r\n changeType: \"put\",\r\n };\r\n changes.push(change_data);\r\n PREVIOUS_CHANGE[entity.id] = change_data;\r\n }\r\n }\r\n }\r\n return changes;\r\n}\r\n\r\n/**\r\n * Converts a itemStack to a unique id\r\n * @param {ItemStack} item\r\n * @returns {string}\r\n */\r\nexport function getItemUid(item: ItemStack): string {\r\n if (!item) return \"\";\r\n const data = [];\r\n data.push(item.typeId);\r\n data.push(item.nameTag);\r\n data.push(item.data);\r\n data.push(item.getLore().join(\"\"));\r\n return data.join(\"\");\r\n}\r\n\r\n/**\r\n * Gets an entity's inventory but with mapped data\r\n */\r\nfunction mapInventory(\r\n container: PlayerInventoryComponentContainer\r\n): Array {\r\n const inventory = [];\r\n\r\n for (let i = 0; i < container.size; i++) {\r\n let item = container.getItem(i);\r\n inventory[i] = {\r\n uid: getItemUid(item),\r\n item: item,\r\n };\r\n }\r\n return inventory;\r\n}\r\n\r\nsystem.runSchedule(() => {\r\n for (const callback of Object.values(CALLBACKS)) {\r\n for (const entity of DIMENSIONS.overworld.getEntities(callback.entities)) {\r\n const inventory = mapInventory(\r\n entity.getComponent(\"inventory\").container\r\n );\r\n const changes = getSlotChanges(\r\n entity,\r\n MAPPED_INVENTORIES[entity.id] ?? inventory,\r\n inventory\r\n );\r\n MAPPED_INVENTORIES[entity.id] = inventory;\r\n if (changes.length == 0) continue;\r\n if (entity.hasTag(\"skipCheck\")) {\r\n entity.removeTag(\"skipCheck\");\r\n delete PREVIOUS_CHANGE[entity.id];\r\n continue;\r\n }\r\n for (const change of changes) {\r\n callback.callback(entity, change);\r\n }\r\n }\r\n }\r\n}, 5);\r\n\r\nexport class onEntityInventorySlotChange {\r\n /**\r\n * Subscribes to a callback to get notified when a entities inventory changes\r\n * @param callback what to be called when one of these entities inventory's changes\r\n * @param entities the entity's to grab from\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(\r\n entities: EntityQueryOptions,\r\n callback: onSlotChangeCallback\r\n ): number {\r\n const key = Date.now();\r\n CALLBACKS[key] = { callback: callback, entities: entities };\r\n return key;\r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n", "import { Entity, ItemStack, Location, Player } from \"@minecraft/server\";\r\nimport type { ChestGUI } from \"./Models/EntityChest\";\r\nimport type { Page } from \"./Models/Page\";\r\n\r\n/**\r\n * This will link a players name to a chest gui instance\r\n */\r\nexport const CHESTGUIS: { [key: string]: ChestGUI } = {};\r\n\r\n/**\r\n * This will link a players name to a chest gui instance\r\n */\r\nexport const PAGES: { [key: string]: Page } = {};\r\n\r\n/**\r\n * Gets a players held item\r\n */\r\nexport function getHeldItem(player: Player): ItemStack {\r\n const inventory = player.getComponent(\"minecraft:inventory\").container;\r\n return inventory.getItem(player.selectedSlot);\r\n}\r\n\r\n/**\r\n * Clears the player of a item in there pointer slot\r\n */\r\nexport async function clearPlayersPointer(\r\n player: Player,\r\n ItemToClear: ItemStack\r\n) {\r\n try {\r\n const inventory = player.getComponent(\"minecraft:inventory\").container;\r\n let itemsToLoad = [];\r\n for (let i = 0; i < inventory.size; i++) {\r\n const item = inventory.getItem(i);\r\n if (!item) continue;\r\n if (item?.typeId == ItemToClear?.typeId) {\r\n itemsToLoad.push({ slot: i, item: item });\r\n inventory.setItem;\r\n if (i < 9) {\r\n player.runCommandAsync(`replaceitem entity @s slot.hotbar ${i} air`);\r\n } else {\r\n player.runCommandAsync(\r\n `replaceitem entity @s slot.inventory ${i - 9} air`\r\n );\r\n }\r\n }\r\n }\r\n await player.runCommandAsync(\r\n `clear @s ${ItemToClear?.typeId} ${ItemToClear.data} ${ItemToClear.amount}`\r\n );\r\n for (const item of itemsToLoad) {\r\n inventory.setItem(item.slot, item.item);\r\n }\r\n } catch (error) {\r\n // the item couldn't be cleared that means\r\n // they now have a item witch is really BAD\r\n [\r\n ...player.dimension.getEntities({\r\n type: \"minecraft:item\",\r\n location: new Location(\r\n player.location.x,\r\n player.location.y,\r\n player.location.z\r\n ),\r\n maxDistance: 2,\r\n closest: 1,\r\n }),\r\n ].forEach((e) => e.kill());\r\n }\r\n}\r\n\r\n/**\r\n * Gets an item at slot\r\n */\r\nexport function getItemAtSlot(entity: Entity, slot: number): ItemStack | null {\r\n const inventory = entity.getComponent(\"minecraft:inventory\").container;\r\n return inventory.getItem(slot);\r\n}\r\n", "import {\n ActionFormData,\n MessageFormData,\n ModalFormData,\n ActionFormResponse,\n ModalFormResponse,\n MessageFormResponse,\n} from \"@minecraft/server-ui\";\nimport { ChestGUI } from \"./EntityChest\";\nimport { ItemStack } from \"@minecraft/server\";\nimport type { ISlot } from \"./Page\";\nimport type { ISlotChangeReturn } from \"../../Events/onSlotChange\";\nimport { sleep } from \"../../../../utils\";\nimport { ItemDatabase } from \"../../../database/types/Item\";\n\ntype FormActionReturn = T extends ActionFormData\n ? Promise\n : T extends ModalFormData\n ? Promise\n : Promise;\n\nexport class ItemGrabbedCallback {\n gui: ChestGUI;\n slot: ISlot;\n change: ISlotChangeReturn;\n /**\n * New Callback\n */\n constructor(gui: ChestGUI, slot: ISlot, change: ISlotChangeReturn) {\n this.gui = gui;\n this.slot = slot;\n this.change = change;\n }\n\n /**\n * Messages to the owner of this gui\n * @example ctx.reply('Hello World!');\n */\n message(text: string) {\n this.gui.player.tell(text);\n }\n\n /**\n * Gets the item added\n */\n getItemAdded(): ItemStack | null {\n if (this.slot.item) return null;\n return this.gui.entity\n .getComponent(\"minecraft:inventory\")\n .container.getItem(this.change.slot);\n }\n\n /**\n * Gives the player the item the grabbed\n */\n GiveAction(item: ItemStack = this.slot.item.itemStack) {\n this.gui.player.getComponent(\"minecraft:inventory\").container.addItem(item);\n }\n\n /**\n * Gives the player the item that was grabbed also removes this item from the gui + db\n * @param db the item database to remove this item from\n */\n TakeAction(db: ItemDatabase = null) {\n this.gui.player\n .getComponent(\"minecraft:inventory\")\n .container.addItem(this.slot.item.itemStack);\n this.gui.page.slots[this.change.slot] = null;\n if (!db) return;\n db.delete(this.slot.item.components.dbKey);\n }\n\n /**\n * Changes the page of the chestGui when this item is grabbed\n * @param page page to send to\n * @param extras stuff to be passed onto the page\n */\n PageAction(page: string, extras?: any) {\n this.gui.setPage(page, extras);\n }\n\n /**\n * Closes the chest GUI when this item is grabbed\n */\n CloseAction() {\n this.gui.despawn();\n }\n\n /**\n * Sets the item back\n */\n SetAction() {\n const container = this.gui.entity.getComponent(\n \"minecraft:inventory\"\n ).container;\n container.setItem(this.change.slot, this.slot.item.itemStack);\n }\n\n /**\n * Opens a form to the player\n * @param {ActionFormData | ModalFormData | MessageFormData} form form to load\n * @returns {Promise}\n */\n async FormAction(\n form: T\n ): Promise> {\n this.CloseAction();\n await sleep(5);\n // @ts-ignore\n return await form.show(this.gui.player);\n }\n}\n", "import {\r\n Enchantment,\r\n EnchantmentList,\r\n ItemStack,\r\n ItemType,\r\n} from \"@minecraft/server\";\r\n\r\ninterface IPageItemComponents {\r\n /**\r\n * Number of the items in the stack. Valid values range between 0 and 64.\r\n */\r\n amount?: number;\r\n /**\r\n * A data value used to configure alternate states of the item.\r\n */\r\n data?: number;\r\n /**\r\n * Given name of this stack of items.\r\n */\r\n nameTag?: string;\r\n /**\r\n * a secondary display string - for an ItemStack.\r\n */\r\n loreList?: string[];\r\n /**\r\n * a collection of the enchantments on this item\r\n */\r\n enchantments?: Enchantment[];\r\n /**\r\n * A key that could be on this item, meaning its connect to database\r\n */\r\n dbKey?: string;\r\n}\r\n\r\nexport class PageItem {\r\n /**\r\n * The item type this item has\r\n */\r\n itemType: ItemType;\r\n /**\r\n * The components that this item\r\n * this stores information such as data, enchantments etc\r\n */\r\n components: IPageItemComponents;\r\n\r\n /**\r\n * The itemStack that was set at item creation\r\n */\r\n setItemStack: ItemStack | null;\r\n\r\n constructor(\r\n itemType: ItemType,\r\n components: IPageItemComponents = {},\r\n itemStack?: ItemStack\r\n ) {\r\n this.itemType = itemType;\r\n this.components = components;\r\n this.setItemStack = itemStack;\r\n }\r\n /**\r\n * gets itemStack that this PageItem is associated with\r\n */\r\n get itemStack(): ItemStack {\r\n if (this.setItemStack) return this.setItemStack;\r\n const itemStack = new ItemStack(this.itemType);\r\n if (this.components) {\r\n itemStack.amount = this.components?.amount ?? 1;\r\n itemStack.data = this.components?.data ?? 0;\r\n itemStack.nameTag = this.components?.nameTag;\r\n itemStack.setLore(this.components?.loreList ?? []);\r\n const enchantments: EnchantmentList =\r\n itemStack.getComponent(\"enchantments\").enchantments;\r\n for (const enchantment of this.components?.enchantments ?? []) {\r\n enchantments.addEnchantment(enchantment);\r\n }\r\n itemStack.getComponent(\"enchantments\").enchantments = enchantments;\r\n }\r\n return itemStack;\r\n }\r\n}\r\n", "import { Entity } from \"@minecraft/server\";\nimport { AIR } from \"../index\";\nimport { Page } from \"./Page.js\";\n\nexport type FillTypeCallback = (\n entity: Entity,\n page: Page,\n extras: any\n) => void;\n\n/**\n * Fills a entity with desired items\n */\nexport function DefaultFill(entity: Entity, page: Page, extras: any) {\n const container = entity.getComponent(\"minecraft:inventory\").container;\n for (let i = 0; i < container.size; i++) {\n const slot = page.slots[i];\n if (!slot || !slot.item) {\n container.setItem(i, AIR);\n continue;\n }\n container.setItem(i, slot.item.itemStack);\n }\n}\n", "import { PAGES } from \"../utils.js\";\r\nimport { DefaultFill, FillTypeCallback } from \"./FillTypes\";\r\nimport { ItemGrabbedCallback } from \"./ItemGrabbedCallback.js\";\r\nimport type { PageItem } from \"./PageItem\";\r\n\r\nexport interface ISlot {\r\n /**\r\n * The item that should be in this slot\r\n */\r\n item: PageItem;\r\n /**\r\n * What happens when there is a change in this slot\r\n */\r\n action: (ctx: ItemGrabbedCallback) => void;\r\n}\r\n\r\nexport class Page {\r\n /**\r\n * The id this page has\r\n */\r\n id: string;\r\n /**\r\n * How this page fills, these can be custom or kept default\r\n */\r\n fillType: FillTypeCallback;\r\n\r\n /**\r\n * The slots in this gui\r\n */\r\n slots: ISlot[];\r\n\r\n constructor(id: string, fillType: FillTypeCallback = DefaultFill) {\r\n if (Object.keys(PAGES).includes(id))\r\n throw new Error(`Page: ${id}, Already exists!`);\r\n this.id = id;\r\n this.fillType = fillType;\r\n this.slots = [];\r\n PAGES[id] = this;\r\n }\r\n\r\n /**\r\n * Sets slots in this page\r\n */\r\n setSlots(\r\n slot: Array,\r\n item: PageItem,\r\n action: (ctx: ItemGrabbedCallback) => void\r\n ): Page {\r\n const data = item ? { item: item, action: action } : null;\r\n for (const i of slot) {\r\n this.slots[i] = data;\r\n }\r\n return this;\r\n }\r\n}\r\n", "import { PageItem } from \"../Models/PageItem.js\";\r\nimport { Page } from \"../Models/Page.js\";\r\nimport { MinecraftItemTypes } from \"@minecraft/server\";\r\n\r\n/**\r\n * The Home page of this GUI this is the most important because\r\n * when the GUI is opened it will open up here, any plugin can\r\n * change this but this is the default screen\r\n */\r\nexport let HOME_PAGE = new Page(\"home\")\r\n .setSlots(\r\n [22],\r\n new PageItem(MinecraftItemTypes.enderChest, {\r\n nameTag: \"\u00A7l\u00A7bInventory Viewer\",\r\n }),\r\n (ctx) => {\r\n ctx.PageAction(\"moderation:see\");\r\n }\r\n )\r\n .setSlots(\r\n [54],\r\n new PageItem(MinecraftItemTypes.barrier, { nameTag: \"\u00A7cClose GUI\" }),\r\n (ctx) => {\r\n ctx.CloseAction();\r\n }\r\n );\r\n", "import {\n world,\n Player,\n BlockLocation,\n MinecraftBlockTypes,\n Enchantment,\n GameMode,\n} from \"@minecraft/server\";\nimport type { ConfigType, ROLES } from \"./types\";\nimport { Region } from \"./modules/models/Region.js\";\nimport { ChangePlayerRoleTask } from \"./modules/models/Task\";\nimport { APPEAL_LINK, BANNED_BLOCKS, BANNED_ITEMS } from \"./config/moderation\";\nimport { ENCHANTMENTS } from \"./config/enchantments\";\nimport { DIMENSIONS } from \"../../utils.js\";\nimport { TABLES } from \"./tables.js\";\n\n/**\n * Kicks a player\n * @param player player who should be kicked\n * @param message the message that should be show to player\n * @param onFail this needs to be used for loops to unregister\n */\nexport function kick(\n player: Player,\n message: Array = [],\n onFail?: () => void\n): void {\n if (isServerOwner(player)) {\n console.warn(`[WARNING]: TRIED TO KICK OWNER`);\n player.tell(`You have been tried to kick, but you cant!`);\n return onFail?.();\n }\n try {\n player.runCommandAsync(`kick \"${player.name}\" \u00A7r${message.join(\"\\n\")}`);\n player.triggerEvent(\"kick\");\n } catch (error) {\n player.triggerEvent(\"kick\");\n if (!/\"statusCode\":-2147352576/.test(error)) return;\n // This function just tried to kick the owner\n if (onFail) onFail();\n }\n}\n\n/**\n * Gets the role of this player\n * @param player player to get role from\n * @example getRole(\"Smell of curry\")\n */\nexport function getRole(player: Player | string): keyof typeof ROLES {\n if (player instanceof Player) {\n return TABLES.roles.get(player.name) ?? \"member\";\n } else {\n return TABLES.roles.get(player) ?? \"member\";\n }\n}\n\n/**\n * Sets the role of this player\n * @example setRole(\"Smell of curry\", \"admin\")\n */\nexport function setRole(\n player: Player | string,\n value: keyof typeof ROLES\n): void {\n if (typeof player == \"string\") {\n // we need to create a task that will update the role for\n // that player when they join\n // also we need to set there db_role back\n TABLES.roles.set(player, value);\n /**\n * If the player is in the game just set it now\n * if they are not in the game we will need to create a task\n * to set there role when they join\n */\n const inGamePlayer = [...world.getPlayers()].find((p) => p.name == player);\n if (inGamePlayer) {\n inGamePlayer.setDynamicProperty(\"role\", value);\n } else {\n new ChangePlayerRoleTask(player, value);\n }\n } else {\n // just change both of them no need for task\n TABLES.roles.set(player.name, value);\n player.setDynamicProperty(\"role\", value);\n }\n}\n\n/**\n * Checks if a player is the owner of this world that was set using `/function`\n * @param player player to test\n * @returns if player is owner\n */\nexport function isServerOwner(player: Player): boolean {\n return world.getDynamicProperty(\"worldsOwner\") == player.id;\n}\n\n/**\n * Gets the server owner\n * @returns server owners id\n */\nexport function getServerOwner(): string | null {\n const id = world.getDynamicProperty(\"worldsOwner\") as string;\n if (!id || id == \"\") return null;\n return id;\n}\n\n/**\n * Gets the server owners name\n * @returns server owners name\n */\nexport function getServerOwnerName(): string | null {\n const ownerId = getServerOwner();\n if (!ownerId) return null;\n const ids = TABLES.ids.collection();\n return Object.keys(ids).find((key) => ids[key] === ownerId);\n}\n\n/**\n * Sets the server owner\n * @param player player to set the server owner too\n */\nexport function setServerOwner(player: Player) {\n if (!player) return world.setDynamicProperty(\"worldsOwner\", \"\");\n world.setDynamicProperty(\"worldsOwner\", player.id.toString());\n}\n\n/**\n * Checks if the server is locked down\n */\nexport function isLockedDown(): boolean {\n return (world.getDynamicProperty(\"isLockDown\") ?? false) as boolean;\n}\n\n/**\n * Sets the server's lock down status\n * @param val if the server is locked down or not\n */\nexport function setLockDown(val: boolean) {\n world.setDynamicProperty(\"isLockDown\", val);\n}\n\n/**\n * Sets Deny blocks at bottom of region every 5 mins\n */\nexport function loadRegionDenys() {\n for (const region of Region.getAllRegions()) {\n const loc1 = new BlockLocation(\n region.from.x,\n region.dimensionId == \"minecraft:overworld\" ? -64 : 0,\n region.from.z\n );\n const loc2 = new BlockLocation(\n region.to.x,\n region.dimensionId == \"minecraft:overworld\" ? -64 : 0,\n region.to.z\n );\n for (const blockLocation of loc1.blocksBetween(loc2)) {\n DIMENSIONS[region.dimensionId as keyof typeof DIMENSIONS]\n .getBlock(blockLocation)\n ?.setType(MinecraftBlockTypes.deny);\n }\n }\n}\n\n/**\n * Grabs config data from the database\n * @param id id to grab\n */\nexport function getConfigId(id: T): ConfigType[T] {\n switch (id) {\n case \"banned_items\":\n return TABLES.config.get(\"banned_items\") ?? BANNED_ITEMS;\n case \"banned_blocks\":\n return TABLES.config.get(\"banned_blocks\") ?? BANNED_BLOCKS;\n case \"enchantments\":\n return TABLES.config.get(\"enchantments\") ?? ENCHANTMENTS;\n case \"appealLink\":\n return TABLES.config.get(\"appealLink\") ?? APPEAL_LINK;\n }\n}\n\n/**\n * Sets a config id\n * @param key key to set\n * @param value value to set key to\n */\nexport function setConfigId(\n key: T,\n value: ConfigType[T]\n) {\n TABLES.config.set(key, value);\n}\n\n/**\n * Gets the max level of a enchantment\n * @param enchantment enchantment to get\n * @returns max level\n * @example ```\n * getMaxLevel(MinecraftEnchantmentTypes.sharpness): 5\n * ```\n */\nexport function getMaxEnchantmentLevel(enchantment: Enchantment): number {\n const MAX_ENCHANTMENTS = getConfigId(\"enchantments\");\n return (\n MAX_ENCHANTMENTS[enchantment.type.id as keyof typeof ENCHANTMENTS] ??\n enchantment.type.maxLevel\n );\n}\n\n/**\n * Gets the Gamemode of a player\n * @param {Player} player player to get\n * @returns {keyof typeof GameMode}\n * @example if (getGamemode(player) == \"creative\") return;\n */\nexport function getGamemode(player: Player): keyof typeof GameMode {\n return Object.values(GameMode).find(\n (g) => [...world.getPlayers({ name: player.name, gameMode: g })].length\n );\n}\n", "import { BlockLocation, Entity, MinecraftBlockTypes } from \"@minecraft/server\";\nimport { DEFAULT_REGION_PERMISSIONS } from \"../../config/region\";\nimport { TABLES } from \"../../tables.js\";\nimport type { IRegionCords, IRegionPermissions } from \"../../types\";\nimport { loadRegionDenys } from \"../../utils.js\";\nimport { betweenVector3, DIMENSIONS } from \"../../../../utils\";\n\n/**\n * Holds all regions in memory so its not grabbing them so much\n */\nexport let REGIONS: Array = [];\n\n/**\n * If the regions have been grabbed if not it will grab them and set this to true\n */\nlet REGIONS_HAVE_BEEN_GRABBED: boolean = false;\n\n/**\n * The Lowest Y value in minecraft\n */\nconst LOWEST_Y_VALUE: number = -64;\n\n/**\n * The HIGHEST Y value in minecraft\n */\nconst HIGHEST_Y_VALUE: number = 320;\n\nexport class Region {\n dimensionId: string;\n from: IRegionCords;\n to: IRegionCords;\n key: string;\n permissions: IRegionPermissions;\n\n /**\n * Gets all regions\n */\n static async getAllRegionsSync(): Promise> {\n if (REGIONS_HAVE_BEEN_GRABBED) return REGIONS;\n const regions = (await TABLES.regions.valuesSync()).map(\n (region) =>\n new Region(\n region.from,\n region.to,\n region.dimensionId,\n region.permissions,\n region.key\n )\n );\n regions.forEach((r) => {\n REGIONS.push(r);\n });\n REGIONS_HAVE_BEEN_GRABBED = true;\n return regions;\n }\n\n static getAllRegions(): Array {\n if (REGIONS_HAVE_BEEN_GRABBED) return REGIONS;\n const regions = TABLES.regions\n .values()\n .map(\n (region) =>\n new Region(\n region.from,\n region.to,\n region.dimensionId,\n region.permissions,\n region.key\n )\n );\n regions.forEach((r) => {\n REGIONS.push(r);\n });\n REGIONS_HAVE_BEEN_GRABBED = true;\n return regions;\n }\n\n /**\n * Checks if a block location is in region\n */\n static blockLocationInRegion(\n blockLocation: BlockLocation,\n dimensionId: string\n ): Region | undefined {\n return this.getAllRegions().find(\n (region) =>\n region.dimensionId == dimensionId &&\n betweenVector3(\n blockLocation,\n { x: region.from.x, y: LOWEST_Y_VALUE, z: region.from.z },\n { x: region.to.x, y: HIGHEST_Y_VALUE, z: region.to.z }\n )\n );\n }\n\n /**\n * Checks if a block location is in region\n */\n static async blockLocationInRegionSync(\n blockLocation: BlockLocation,\n dimensionId: string\n ): Promise {\n return (await this.getAllRegionsSync()).find(\n (region) =>\n region.dimensionId == dimensionId &&\n betweenVector3(\n blockLocation,\n { x: region.from.x, y: LOWEST_Y_VALUE, z: region.from.z },\n { x: region.to.x, y: HIGHEST_Y_VALUE, z: region.to.z }\n )\n );\n }\n\n /**\n * Removes a region at a block Location\n * @param dimensionId the id of this dimension\n * @returns if the region was removed or not\n */\n static async removeRegionAtBlockLocation(\n blockLocation: BlockLocation,\n dimensionId: string\n ): Promise {\n const region = this.blockLocationInRegion(blockLocation, dimensionId);\n if (!region) return false;\n return TABLES.regions.delete(region.key);\n }\n /**\n * Creates a new Region to store in db\n */\n constructor(\n from: IRegionCords,\n to: IRegionCords,\n dimensionId: string,\n permissions?: IRegionPermissions,\n key?: string\n ) {\n this.from = from;\n this.to = to;\n this.dimensionId = dimensionId;\n this.permissions = permissions ?? DEFAULT_REGION_PERMISSIONS;\n this.key = key ? key : Date.now().toString();\n\n if (!key) {\n this.update().then(() => {\n loadRegionDenys();\n REGIONS.push(this);\n });\n }\n }\n\n /**\n * Updates this region in the database\n */\n async update(): Promise {\n return TABLES.regions.set(this.key, {\n key: this.key,\n from: this.from,\n dimensionId: this.dimensionId,\n permissions: this.permissions,\n to: this.to,\n });\n }\n\n /**\n * removes this region\n * @returns if the region was removed successfully\n */\n async delete(): Promise {\n const region = TABLES.regions.get(this.key);\n const loc1 = new BlockLocation(\n region.from.x,\n region.dimensionId == \"minecraft:overworld\" ? -64 : 0,\n region.from.z\n );\n const loc2 = new BlockLocation(\n region.to.x,\n region.dimensionId == \"minecraft:overworld\" ? -64 : 0,\n region.to.z\n );\n for (const blockLocation of loc1.blocksBetween(loc2)) {\n DIMENSIONS[region.dimensionId as keyof typeof DIMENSIONS]\n .getBlock(blockLocation)\n ?.setType(MinecraftBlockTypes.bedrock);\n }\n REGIONS = REGIONS.filter((r) => r.key != this.key);\n return TABLES.regions.delete(this.key);\n }\n\n /**\n * Checks if a player is in this region\n * @returns if a entity is in this region or not\n */\n entityInRegion(entity: Entity): Boolean {\n return (\n this.dimensionId == entity.dimension.id &&\n betweenVector3(\n entity.location,\n { x: this.from.x, y: LOWEST_Y_VALUE, z: this.from.z },\n { x: this.to.x, y: HIGHEST_Y_VALUE, z: this.to.z }\n )\n );\n }\n\n /**\n * Changes a permission to on or off\n */\n changePermission(\n key: T,\n value: IRegionPermissions[T]\n ): void {\n this.permissions[key] = value;\n this.update();\n }\n}\n", "/**\n * The default permissions for all regions made\n */\nexport const DEFAULT_REGION_PERMISSIONS = {\n /**\n * If players in this region can use doors, trapdoors, and switches like buttons and levers\n */\n doorsAndSwitches: true,\n /**\n * If players in this region can open containers, this is like chests, furnaces, hoppers, etc\n */\n openContainers: true,\n /**\n * If the players in this region can fight each other\n */\n pvp: false,\n /**\n * the entities allowed in this region\n */\n allowedEntities: [\n \"minecraft:player\",\n \"minecraft:npc\",\n \"minecraft:item\",\n \"rubedo:inventory\",\n \"rubedo:database\",\n ],\n};\n\n/**\n * All doors and switches in minecraft\n */\nexport const DOORS_SWITCHES = [\n \"minecraft:acacia_door\",\n \"minecraft:acacia_trapdoor\",\n \"minecraft:acacia_button\",\n \"minecraft:birch_door\",\n \"minecraft:birch_trapdoor\",\n \"minecraft:birch_button\",\n \"minecraft:crimson_door\",\n \"minecraft:crimson_trapdoor\",\n \"minecraft:crimson_button\",\n \"minecraft:dark_oak_door\",\n \"minecraft:dark_oak_trapdoor\",\n \"minecraft:dark_oak_button\",\n \"minecraft:jungle_door\",\n \"minecraft:jungle_trapdoor\",\n \"minecraft:jungle_button\",\n \"minecraft:mangrove_door\",\n \"minecraft:mangrove_trapdoor\",\n \"minecraft:mangrove_button\",\n \"minecraft:spruce_door\",\n \"minecraft:spruce_trapdoor\",\n \"minecraft:spruce_button\",\n \"minecraft:warped_door\",\n \"minecraft:warped_trapdoor\",\n \"minecraft:warped_button\",\n \"minecraft:wooden_door\",\n \"minecraft:wooden_button\",\n \"minecraft:trapdoor\",\n \"minecraft:iron_door\",\n \"minecraft:iron_trapdoor\",\n \"minecraft:polished_blackstone_button\",\n \"minecraft:lever\",\n];\n\n/**\n * A List of all containers a item could be in\n */\nexport const BLOCK_CONTAINERS = [\n \"minecraft:chest\",\n \"minecraft:ender_chest\",\n \"minecraft:barrel\",\n \"minecraft:trapped_chest\",\n \"minecraft:dispenser\",\n \"minecraft:dropper\",\n \"minecraft:furnace\",\n \"minecraft:blast_furnace\",\n \"minecraft:lit_furnace\",\n \"minecraft:lit_blast_furnace\",\n \"minecraft:hopper\",\n \"minecraft:shulker_box\",\n \"minecraft:undyed_shulker_box\",\n \"minecraft:lit_smoker\",\n \"minecraft:smoker\",\n];\n", "import { TABLES } from \"../../tables.js\";\r\nimport type { IChangePlayerRoleData } from \"../../../../types\";\r\nimport type { ROLES } from \"../../types.js\";\r\n\r\nexport class ChangePlayerRoleTask {\r\n /**\r\n * The name of the player\r\n */\r\n playerName: string;\r\n /**\r\n * The role that the player should be set to\r\n */\r\n role: keyof typeof ROLES;\r\n\r\n /**\r\n * gets all tasks that are present\r\n * @returns all tasks\r\n */\r\n static getTasks(): Array {\r\n return TABLES.tasks.get(\"changePlayerRole\") ?? [];\r\n }\r\n\r\n /**\r\n * Gets the role this player needs to be set to\r\n * @param playerName name\r\n */\r\n static getPlayersRoleToSet(playerName: string): keyof typeof ROLES | null {\r\n const tasks = ChangePlayerRoleTask.getTasks();\r\n return tasks.find((t) => t.playerName == playerName)?.role;\r\n }\r\n\r\n constructor(playerName: string, role: keyof typeof ROLES) {\r\n let tasks = ChangePlayerRoleTask.getTasks();\r\n tasks.push({ playerName: playerName, role: role });\r\n TABLES.tasks.set(\"changePlayerRole\", tasks);\r\n }\r\n}\r\n", "import { MinecraftBlockTypes, MinecraftItemTypes } from \"@minecraft/server\";\n\n/*\n|--------------------------------------------------------------------------\n| Appeal Link\n|--------------------------------------------------------------------------\n|\n| This is the appeal link that gets showed when someone gets banned\n| this link pops up at the bottom of the ban message to show\n| where they can appeal there ban.\n|\n*/\nexport const APPEAL_LINK = \"https://discord.gg/dMa3A5UYKX\";\n\n/**\n * Items that simply get removed from inventory but will not ban\n */\nexport const FORBIDDEN_ITEMS = [\n // Common CBE Items\n MinecraftItemTypes.beehive.id,\n MinecraftItemTypes.beeNest.id,\n MinecraftItemTypes.axolotlBucket.id,\n MinecraftItemTypes.codBucket.id,\n MinecraftItemTypes.tadpoleBucket.id,\n MinecraftItemTypes.tropicalFishBucket.id,\n MinecraftItemTypes.salmonBucket.id,\n MinecraftItemTypes.pufferfishBucket.id,\n];\n\n/**\n * List of items that if you hold you will be automatically banned\n */\nexport const BANNED_ITEMS = [\n // Op Only Items\n MinecraftItemTypes.allow.id,\n MinecraftItemTypes.barrier.id,\n MinecraftItemTypes.borderBlock.id,\n MinecraftItemTypes.debugStick?.id ?? \"minecraft:debug_stick\",\n MinecraftItemTypes.deny.id,\n MinecraftItemTypes.jigsaw.id,\n MinecraftItemTypes.lightBlock.id,\n MinecraftItemTypes.commandBlock.id,\n MinecraftItemTypes.repeatingCommandBlock.id,\n MinecraftItemTypes.chainCommandBlock.id,\n MinecraftItemTypes.commandBlockMinecart.id,\n MinecraftItemTypes.structureBlock.id,\n MinecraftItemTypes.structureVoid.id,\n\n // Not Normal Items\n MinecraftItemTypes.bedrock.id,\n MinecraftItemTypes.endPortalFrame.id,\n\n // Server Movement Blocks\n \"minecraft:info_update\",\n \"minecraft:info_update2\",\n \"minecraft:reserved3\",\n \"minecraft:reserved4\",\n \"minecraft:reserved6\",\n \"minecraft:movingBlock\",\n \"minecraft:moving_block\",\n \"minecraft:movingblock\",\n \"minecraft:piston_arm_collision\",\n \"minecraft:piston_arm_collision\",\n \"minecraft:pistonarmcollision\",\n \"minecraft:stickyPistonArmCollision\",\n \"minecraft:sticky_piston_arm_collision\",\n \"minecraft:unknown\",\n\n // Common Hacked Items\n \"minecraft:glowingobsidian\",\n \"minecraft:invisible_bedrock\",\n \"minecraft:invisiblebedrock\",\n \"minecraft:netherreactor\",\n \"minecraft:portal\",\n \"minecraft:fire\",\n \"minecraft:water\",\n \"minecraft:lava\",\n \"minecraft:flowing_lava\",\n \"minecraft:flowing_water\",\n \"minecraft:soul_fire\",\n];\n\n/**\n * Blocks in this list are forbidden from being placed but will not ban the placer\n */\nexport const FORBIDDEN_BLOCKS = [\n // Common CBE Blocks\n MinecraftBlockTypes.dispenser.id,\n];\n\n/**\n * List of blocks that cannot be placed down\n */\nexport const BANNED_BLOCKS = [\n // Should Not be Placed\n MinecraftBlockTypes.bedrock.id,\n MinecraftBlockTypes.barrier.id,\n \"minecraft:invisiblebedrock\",\n \"minecraft:movingBlock\",\n \"minecraft:movingblock\",\n \"minecraft:moving_block\",\n];\n\n/**\n * A List of containers\n */\nexport const CONTAINERS = [\n MinecraftItemTypes.chest.id,\n MinecraftItemTypes.trappedChest.id,\n MinecraftItemTypes.barrel.id,\n MinecraftItemTypes.dispenser.id,\n MinecraftItemTypes.dropper.id,\n MinecraftItemTypes.furnace.id,\n \"minecraft:lit_furnace\",\n MinecraftItemTypes.blastFurnace.id,\n \"minecraft:lit_blast_furnace\",\n MinecraftItemTypes.smoker.id,\n \"minecraft:lit_smoker\",\n MinecraftItemTypes.hopper.id,\n MinecraftItemTypes.shulkerBox.id,\n MinecraftItemTypes.undyedShulkerBox.id,\n];\n\n\n", "/*\n|--------------------------------------------------------------------------\n| Enchantments\n|--------------------------------------------------------------------------\n|\n| This is the default enchantments that can be added to items\n| each enchantment is set to its desired max level this can be changed here\n| or in game using -config enchantments set \"enchantment\" value\n|\n*/\nexport const ENCHANTMENTS = {\n aquaAffinity: 1,\n baneOfArthropods: 5,\n binding: 1,\n blastProtection: 4,\n channeling: 1,\n depthStrider: 3,\n efficiency: 5,\n featherFalling: 4,\n fireAspect: 2,\n fireProtection: 4,\n flame: 1,\n fortune: 3,\n frostWalker: 2,\n impaling: 5,\n infinity: 1,\n knockback: 2,\n looting: 3,\n loyalty: 4,\n luckOfTheSea: 3,\n lure: 3,\n mending: 1,\n multishot: 1,\n piercing: 4,\n power: 5,\n projectileProtection: 4,\n protection: 4,\n punch: 2,\n quickCharge: 3,\n respiration: 3,\n riptide: 3,\n sharpness: 5,\n silkTouch: 1,\n smite: 5,\n soulSpeed: 3,\n swiftSneak: 4,\n thorns: 3,\n unbreaking: 3,\n vanishing: 1,\n};\n", "import {\r\n DynamicPropertiesDefinition,\r\n EntityTypes,\r\n world,\r\n} from \"@minecraft/server\";\r\nimport { ENTITY_IDENTIFIER, ENTITY_LOCATION } from \"../config/database\";\r\nimport { DIMENSIONS } from \"../../utils.js\";\r\n\r\nworld.events.worldInitialize.subscribe(({ propertyRegistry }) => {\r\n /**\r\n * Loads Ticking Area\r\n */\r\n DIMENSIONS.overworld.runCommandAsync(\r\n `tickingarea add ${ENTITY_LOCATION.x} ${ENTITY_LOCATION.y} ${ENTITY_LOCATION.z} ${ENTITY_LOCATION.x} ${ENTITY_LOCATION.y} ${ENTITY_LOCATION.z} db true`\r\n );\r\n\r\n let def = new DynamicPropertiesDefinition();\r\n def.defineString(\"tableName\", 30);\r\n def.defineNumber(\"index\");\r\n propertyRegistry.registerEntityTypeDynamicProperties(\r\n def,\r\n EntityTypes.get(ENTITY_IDENTIFIER)\r\n );\r\n});\r\n", "import { system, world } from \"@minecraft/server\";\r\nimport { API_CONTAINERS, CHECK_SIZE } from \"../../config/containers\";\r\nimport { Container } from \"./Container\";\r\nimport { vector3ToBlockLocation } from \"../../../utils\";\r\nimport type { IContainerLocation } from \"../../../types\";\r\n\r\n/**\r\n * storage of all container locations in the world\r\n */\r\nexport let CONTAINER_LOCATIONS: IContainerLocation = {};\r\n\r\nsystem.runSchedule(() => {\r\n CONTAINER_LOCATIONS = {};\r\n for (const player of world.getPlayers()) {\r\n if (player.dimension.id != \"minecraft:overworld\") continue;\r\n const blockLoc = vector3ToBlockLocation(player.location);\r\n const pos1 = blockLoc.offset(CHECK_SIZE.x, CHECK_SIZE.y, CHECK_SIZE.z);\r\n const pos2 = blockLoc.offset(-CHECK_SIZE.x, -CHECK_SIZE.y, -CHECK_SIZE.z);\r\n\r\n for (const location of pos1.blocksBetween(pos2)) {\r\n if (location.y < -64) continue;\r\n const block = player.dimension.getBlock(location);\r\n if (!block) continue;\r\n if (!API_CONTAINERS.includes(block.typeId)) continue;\r\n CONTAINER_LOCATIONS[JSON.stringify(location)] = new Container(\r\n block.getComponent(\"inventory\").container\r\n );\r\n }\r\n }\r\n}, 100);\r\n", "import { MinecraftBlockTypes } from \"@minecraft/server\";\r\n\r\n/**\r\n * The currently supported block containers by script api\r\n */\r\nexport const API_CONTAINERS = [\r\n MinecraftBlockTypes.chest.id,\r\n MinecraftBlockTypes.trappedChest.id,\r\n];\r\n\r\n/**\r\n * The block size to check for blockContainers\r\n */\r\nexport const CHECK_SIZE = { x: 7, y: 7, z: 7 };\r\n", "import { BlockInventoryComponentContainer, ItemStack } from \"@minecraft/server\";\r\n\r\nexport class Container {\r\n emptySlotsCount: number;\r\n size: number;\r\n items: Array;\r\n /**\r\n * Coverts a blockInventoryComponentContainer and saves it\r\n * @param {BlockInventoryComponentContainer} inventory\r\n */\r\n constructor(inventory: BlockInventoryComponentContainer) {\r\n this.emptySlotsCount = inventory.emptySlotsCount;\r\n this.size = inventory.size;\r\n this.items = [];\r\n for (let i = 0; i < this.size; i++) {\r\n this.items[i] = inventory.getItem(i);\r\n }\r\n }\r\n\r\n /**\r\n * Loads this inventory onto a BlockInventoryComponentContainer\r\n * @param {BlockInventoryComponentContainer} block block to load on\r\n */\r\n load(block: BlockInventoryComponentContainer) {\r\n for (let i = 0; i < block.size; i++) {\r\n if (!this.items[i]) continue;\r\n block.setItem(i, this.items[i]);\r\n }\r\n }\r\n}\r\n", "import type { Protection } from \"./modules/models/Protection\";\r\nimport { TABLES } from \"./tables\";\r\n\r\n/**\r\n * All protections in this anti-cheat\r\n */\r\nexport const PROTECTIONS: { [key: string]: Protection } = {};\r\n\r\nTABLES.protections.onLoad(() => {\r\n for (const protection of Object.values(PROTECTIONS)) {\r\n if (!protection.getConfig().enabled ?? protection.isEnabledByDefault)\r\n continue;\r\n protection.enable();\r\n }\r\n});\r\n", "import { Player } from \"@minecraft/server\";\nimport { TABLES } from \"../../tables.js\";\nimport type { IBanData } from \"../../types.js\";\nimport { durationToMs } from \"../../../../utils.js\";\n\nfunction setBan(\n player: string | Player,\n id: string,\n duration?: string,\n reason: string = \"No Reason\",\n by: string = \"Rubedo Auto Mod\"\n) {\n const data: IBanData = {\n key: id,\n playerName: player instanceof Player ? player.name : player,\n date: Date.now(),\n duration: duration ? durationToMs(duration) : null,\n expire: duration ? durationToMs(duration) + Date.now() : null,\n reason: reason,\n by: by,\n };\n TABLES.bans.set(id, data);\n}\n\nexport class Ban {\n /**\n * Ban a player for a set length\n */\n constructor(\n player: string | Player,\n duration?: string,\n reason: string = \"No Reason\",\n by: string = \"Rubedo Auto Mod\"\n ) {\n if (player instanceof Player) {\n setBan(player, player.id, duration, reason, by);\n } else {\n setBan(player, TABLES.ids.get(player), duration, reason, by);\n }\n }\n}\n", "import { Player } from \"@minecraft/server\";\r\nimport { MessageFormData } from \"@minecraft/server-ui\";\r\nimport { TIMEOUT_THRESHOLD } from \"../../../config/form\";\r\nimport type { ButtonCallback, IMessageFormButton } from \"../types\";\r\n\r\nexport class MessageForm {\r\n /**\r\n * the title that this form should have\r\n */\r\n title?: string;\r\n /**\r\n * extra text that should be displayed in the form\r\n */\r\n body?: string;\r\n /**\r\n * The default minecraft form this form is based on\r\n */\r\n private form: MessageFormData;\r\n /**\r\n * the first button of the dialog.\r\n */\r\n private button1: IMessageFormButton;\r\n /**\r\n * the second button of the dialog.\r\n */\r\n private button2: IMessageFormButton;\r\n /**\r\n * The amount of times it takes to show this form in ms\r\n * if this value goes above 200 it will time out\r\n */\r\n private triedToShow: number;\r\n\r\n /**\r\n * Creates a new form to be shown to a player\r\n * @param title the title that this form should have\r\n * @param body extra text that should be displayed in the form\r\n */\r\n constructor(title?: string, body?: string) {\r\n this.title = title;\r\n this.body = body;\r\n this.form = new MessageFormData();\r\n\r\n if (title) this.form.title(title);\r\n if (body) this.form.body(body);\r\n\r\n this.triedToShow = 0;\r\n }\r\n\r\n /**\r\n * Method that sets the text for the first button of the dialog.\r\n * @param text text to show on this button\r\n * @param callback what happens when this button is clicked\r\n * @example ```\r\n * setButton1(\"settings\", () => {})\r\n * ```\r\n */\r\n setButton1(text: string, callback?: ButtonCallback): MessageForm {\r\n this.button1 = { text: text, callback: callback };\r\n this.form.button1(text);\r\n return this;\r\n }\r\n\r\n /**\r\n * Method that sets the text for the second button of the dialog.\r\n * @param text text to show on this button\r\n * @param callback what happens when this button is clicked\r\n * @example ```\r\n * setButton2(\"settings\", () => {})\r\n * ```\r\n */\r\n setButton2(text: string, callback?: ButtonCallback): MessageForm {\r\n this.button2 = { text: text, callback: callback };\r\n this.form.button2(text);\r\n return this;\r\n }\r\n\r\n /**\r\n * Shows this form to the player\r\n * @param player player to show to\r\n */\r\n show(player: Player): void {\r\n this.form.show(player).then((response) => {\r\n if (response.canceled) {\r\n if (response.cancelationReason == \"userBusy\") {\r\n // check time and reshow form\r\n if (this.triedToShow > TIMEOUT_THRESHOLD)\r\n return player.tell(\r\n `\u00A7cForm Timeout: tried to show form, but you were busy (close chat after running command)`\r\n );\r\n this.triedToShow++;\r\n this.show(player);\r\n }\r\n return;\r\n }\r\n if (response.selection == 1) this.button1?.callback?.();\r\n if (response.selection == 0) this.button2?.callback?.();\r\n });\r\n }\r\n}\r\n", "/**\r\n * If a form tries to show for longer than this value\r\n * the form will stop trying to show. this is used for a timeout\r\n * because if someone tries to open a form but doesn't close chat\r\n */\r\nexport const TIMEOUT_THRESHOLD = 200;\r\n", "import { Player } from \"@minecraft/server\";\r\nimport { MessageForm } from \"./Models/MessageForm\";\r\n\r\n/**\r\n * Sends a confirmation message to a player to confirm a action\r\n * @param action action message to confirm\r\n * @param onConfirm callback to run when a player confirms the action\r\n * @param onCancel callback to run when a player cancels the action, this can be null\r\n * @example ```\r\n * confirmAction(\"Ban Smell of curry\", () => {\r\n * new Ban(\"Smell of curry\")\r\n * })\r\n * ```\r\n */\r\nexport function confirmAction(\r\n player: Player,\r\n action: string,\r\n onConfirm: () => void,\r\n onCancel: () => void = () => {}\r\n ) {\r\n new MessageForm(\"Confirm To Continue\", action)\r\n .setButton1(\"Confirm\", onConfirm)\r\n .setButton2(\"Never Mind\", onCancel)\r\n .show(player);\r\n }\r\n ", "import { Location, Player } from \"@minecraft/server\";\r\nimport {\r\n LiteralArgumentType,\r\n IArgumentType,\r\n LocationArgumentType,\r\n StringArgumentType,\r\n IntegerArgumentType,\r\n ArrayArgumentType,\r\n BooleanArgumentType,\r\n} from \"./ArgumentTypes.js\";\r\nimport { CommandCallback } from \"./Callback.js\";\r\nimport { COMMANDS } from \"./index.js\";\r\nimport type { AppendArgument, ICommandData, ArgReturn } from \"./types\";\r\nexport { ArgumentTypes } from \"./ArgumentTypes\";\r\n\r\nexport class Command<\r\n Callback extends Function = (ctx: CommandCallback) => void\r\n> {\r\n /**\r\n * The Arguments on this command\r\n */\r\n children: Command[];\r\n\r\n /**\r\n * Function to run when this command is called\r\n */\r\n callback: Callback;\r\n\r\n constructor(\r\n public data: ICommandData,\r\n public type?: IArgumentType,\r\n public depth: number = 0,\r\n public parent?: Command\r\n ) {\r\n if (!data.requires) data.requires = (player: Player) => true;\r\n this.data = data;\r\n this.type = type ?? new LiteralArgumentType(this.data.name);\r\n this.children = [];\r\n this.depth = depth;\r\n this.parent = parent;\r\n this.callback = null;\r\n\r\n COMMANDS.push(this);\r\n }\r\n\r\n /**\r\n * Adds a ranch to this command of your own type\r\n * @param type a special type to be added\r\n * @returns new branch to this command\r\n */\r\n argument(type: T): ArgReturn {\r\n const cmd = new Command>(\r\n this.data,\r\n type,\r\n this.depth + 1,\r\n this\r\n );\r\n this.children.push(cmd);\r\n return cmd;\r\n }\r\n\r\n /**\r\n * Adds a branch to this command of type string\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n string(name: string): ArgReturn {\r\n return this.argument(new StringArgumentType(name));\r\n }\r\n\r\n /**\r\n * Adds a branch to this command of type string\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n int(name: string): ArgReturn {\r\n return this.argument(new IntegerArgumentType(name));\r\n }\r\n\r\n /**\r\n * Adds a branch to this command of type string\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n array>(\r\n name: string,\r\n types: T\r\n ): ArgReturn {\r\n return this.argument(new ArrayArgumentType(name, types));\r\n }\r\n\r\n /**\r\n * Adds a branch to this command of type string\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n boolean(name: string): ArgReturn {\r\n return this.argument(new BooleanArgumentType(name));\r\n }\r\n\r\n /**\r\n * Adds a argument to this command to add 3 parameters with location types and to return a Location\r\n * @param name name this argument should have\r\n * @returns new branch to this command\r\n */\r\n location(name: string): ArgReturn {\r\n const cmd = this.argument(new LocationArgumentType(name));\r\n if (!name.endsWith(\"*\")) {\r\n const newArg = cmd.location(name + \"_y*\").location(name + \"_z*\");\r\n //@ts-ignore\r\n return newArg;\r\n }\r\n //@ts-ignore\r\n return cmd;\r\n }\r\n\r\n /**\r\n * Adds a subCommand to this argument\r\n * @param name name this literal should have\r\n * @returns new branch to this command\r\n */\r\n literal(data: ICommandData): Command {\r\n const cmd = new Command(\r\n data,\r\n new LiteralArgumentType(data.name),\r\n this.depth + 1,\r\n this\r\n );\r\n this.children.push(cmd);\r\n return cmd;\r\n }\r\n\r\n /**\r\n * Registers this command and its appending arguments\r\n * @param callback what to run when this command gets called\r\n */\r\n executes(callback: Callback): Command {\r\n this.callback = callback;\r\n return this;\r\n }\r\n}\r\n", "export const text = {\n \"api.name\": () => \"Smelly API\",\n \"api.error.unknown\": () => \"An unknown error has occurred.\",\n \"api.database.error.table_name\": (a: string, b: number) =>\n `The display name ${a} is too long for an objective, it can be at most ${b} characters long`,\n \"api.utilities.formatter.error.ms\": (a: string) =>\n `${a} is not a string or a number`,\n \"api.Providers.form.invalidType\": (a: string, b: string) =>\n `Type ${a} is not a valid type to add a ${b}`,\n \"modules.protections.cps.clickingToFast\": () =>\n `You are clicking to fast! Please click slower!`,\n \"modules.managers.mute.isMuted\": () =>\n `\u00A7cYou've been temporarily muted in chat.`,\n \"modules.commands.ban.reply\": (\n playerName: string,\n duration: string,\n reason: string = \"\"\n ) =>\n `\u00A7cBanned \u00A7f\"\u00A7a${playerName}\u00A7f\" \u00A7cfor ${duration} Because: \"${\n reason ?? \"No reason Provided\"\n }\" \u00A7aSuccessfully`,\n \"lockdown.kick.message\": () => [\n `\u00A7cYou have been kicked!`,\n `\u00A7aReason: \u00A7fServer is currently under LockDown`,\n `\u00A7fServer will be up soon, Try to join later`,\n ],\n \"commands.ban.list.player\": (name: string, reason: string, expire: string) =>\n `- \"${name}\" Because: ${reason}, Expiry ${expire}`,\n \"commands.freeze.list.player\": (name: string, reason: string) =>\n `- \"${name}\" Because: ${reason}`,\n \"commands.mutes.list.player\": (\n name: string,\n reason: string,\n expire: string\n ) => `- \"${name}\" Because: ${reason}, Expiry: ${expire}`,\n \"commands.lockdown.confirm\":\n \"Are you sure you want to lockdown the server, this will kick all active players and all players who try to join who are not admin\",\n};\n", "import { TABLES } from \"../../tables.js\";\nimport { msToTime } from \"../../../../utils.js\";\nimport { getRole } from \"../../utils.js\";\nimport { Ban } from \"../models/Ban.js\";\nimport { confirmAction } from \"../../../../rubedo/lib/Form/utils.js\";\nimport {\n ArgumentTypes,\n Command,\n} from \"../../../../rubedo/lib/Command/Command.js\";\nimport { text } from \"../../../../rubedo/lang/text.js\";\nimport type { CommandCallback } from \"../../../../rubedo/lib/Command/Callback.js\";\n\nfunction ban(\n ctx: CommandCallback,\n player: string,\n duration: string,\n reason: string,\n by: string\n) {\n if (TABLES.bans.get(TABLES.ids.get(player)))\n return ctx.reply(`\u00A7c${player} is already banned`);\n ctx.reply(`\u00A7aClose chat to confirm`);\n confirmAction(\n ctx.sender,\n `Are you sure you want to ban ${player}, for ${duration ?? \"forever\"}`,\n () => {\n new Ban(player, duration, reason, ctx.sender.name);\n ctx.reply(text[\"modules.commands.ban.reply\"](player, duration, reason));\n }\n );\n}\n\nconst root = new Command({\n name: \"ban\",\n description: \"Manage bans\",\n requires: (player) => [\"admin\", \"moderator\"].includes(getRole(player)),\n});\n\nroot\n .literal({\n name: \"add\",\n description: \"Bans a player\",\n })\n .argument(new ArgumentTypes.playerName())\n .executes((ctx, player) => {\n ban(ctx, player, null, null, ctx.sender.name);\n })\n .argument(new ArgumentTypes.duration(\"duration\"))\n .executes((ctx, player, duration) => {\n ban(ctx, player, duration, null, ctx.sender.name);\n })\n .string(\"reason\")\n .executes((ctx, player, duration, reason) => {\n ban(ctx, player, duration, reason, ctx.sender.name);\n });\n\nroot\n .literal({\n name: \"remove\",\n description: \"un-bans a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .executes((ctx, playerName) => {\n const banData = TABLES.bans\n .values()\n .find((ban) => ban.playerName == playerName);\n if (!banData) return ctx.reply(`${playerName} is not banned`);\n if (TABLES.bans.delete(banData.key)) {\n ctx.reply(`\u00A7a${playerName}\u00A7r has been Unbanned!`);\n } else {\n ctx.reply(`\u00A7cFailed to un-ban ${playerName}`);\n }\n });\n\nroot\n .literal({\n name: \"list\",\n description: \"Lists all bans\",\n })\n .executes((ctx) => {\n const bans = TABLES.bans.values();\n if (bans.length == 0) return ctx.sender.tell(`\u00A7cNo one is banned!`);\n ctx.sender.tell(`\u00A72--- Showing Bans (${bans.length}) ---`);\n for (const ban of bans) {\n ctx.sender.tell(\n text[\"commands.ban.list.player\"](\n ban.playerName,\n ban.reason,\n ban.expire ? msToTime(ban.duration) : \"Forever\"\n )\n );\n }\n });", "import { Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { getRole } from \"../../utils\";\n\nconst root = new Command({\n name: \"database\",\n description: \"Interacts with SA Database\",\n aliases: [\"db\"],\n requires: (player) => getRole(player) == \"admin\",\n});\n\nroot\n .literal({\n name: \"get\",\n })\n .string(\"table\")\n .string(\"key\")\n .executes((ctx, table, key) => {\n try {\n const data = TABLES[table as keyof typeof TABLES].get(key);\n if (data) {\n ctx.reply(JSON.stringify(data));\n } else {\n ctx.reply(`No data could be found for key ${key}`);\n }\n } catch (error) {\n ctx.reply(error + error.stack);\n }\n });\n\nroot\n .literal({\n name: \"set\",\n })\n .string(\"table\")\n .string(\"key\")\n .string(\"value\")\n .executes((ctx, table, key, value) => {\n try {\n TABLES[table as keyof typeof TABLES].set(key, value);\n ctx.reply(`Set Key: \"${key}\", to value: \"${value}\" on table: \"${table}\"`);\n } catch (error) {\n ctx.reply(error + error.stack);\n }\n });\n\nroot\n .literal({\n name: \"clear\",\n })\n .string(\"table\")\n .executes((ctx, table) => {\n try {\n TABLES[table as keyof typeof TABLES].clear();\n ctx.reply(`Cleared Table ${table}`);\n } catch (error) {\n ctx.reply(error + error.stack);\n }\n });\n\nroot\n .literal({\n name: \"keys\",\n description: \"Returns all keys on a database\",\n })\n .string(\"table\")\n .executes((ctx, table) => {\n try {\n const keys = TABLES[table as keyof typeof TABLES].keys();\n ctx.reply(`Keys on database: ${table}: ${keys}`);\n } catch (error) {\n ctx.reply(error + error.stack);\n }\n });\n\nroot\n .literal({\n name: \"values\",\n description: \"Returns all values on a database\",\n })\n .string(\"table\")\n .executes((ctx, table) => {\n try {\n const values = TABLES[table as keyof typeof TABLES].values();\n ctx.reply(\n `Values on database: ${table}: ${JSON.stringify(values, null, 2)}`\n );\n } catch (error) {\n // likely occurs when table is empty\n if (error instanceof TypeError) {\n ctx.reply(`No values on database ${table}`);\n } else {\n ctx.reply(error + error.stack);\n }\n }\n });\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { getRole } from \"../../utils.js\";\n\nnew Command({\n name: \"ecwipe\",\n description: \"Clears a players ender chest\",\n requires: (player) => getRole(player) == \"admin\",\n})\n .argument(new ArgumentTypes.player(\"player\"))\n .executes((ctx, player) => {\n for (let i = 0; i < 27; i++) {\n player.runCommandAsync(`replaceitem entity @s slot.enderchest ${i} air`);\n }\n ctx.reply(`\u00A7aCleared \"${player.name}\"'s Ender chest!`);\n });\n", "import { Player } from \"@minecraft/server\";\nimport { TABLES } from \"../../tables.js\";\nimport type { IFreezeData } from \"../../types.js\";\n\nexport class Freeze {\n /**\n * Freeze a player\n */\n constructor(player: Player, reason: string = \"No Reason\") {\n const data: IFreezeData = {\n playerName: player.name,\n key: player.id,\n reason: reason,\n location: {\n x: player.location.x,\n y: player.location.y,\n z: player.location.z,\n dimension: player.dimension.id,\n },\n };\n TABLES.freezes.set(player.id, data);\n }\n}\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { Freeze } from \"../models/Freeze.js\";\nimport { getRole } from \"../../utils.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { text } from \"../../../../rubedo/lang/text.js\";\n\nconst root = new Command({\n name: \"freeze\",\n description: \"Manage Freezes\",\n requires: (player) => [\"admin\", \"moderator\"].includes(getRole(player)),\n});\n\nroot\n .literal({\n name: \"add\",\n description: \"Freezes a player\",\n })\n .argument(new ArgumentTypes.player(\"player\"))\n .string(\"reason\")\n .executes((ctx, player, reason) => {\n new Freeze(player, reason);\n ctx.reply(\n `\u00A7cFroze \u00A7f\"\u00A7a${player.name}\u00A7f\" Because: \"${reason}\" \u00A7aSuccessfully`\n );\n ctx.sender.tell(\n `\u00A7cYou have been frozen by \u00A7f\"\u00A7a${ctx.sender.name}\u00A7f\" Because: \"${reason}\"`\n );\n });\n\nroot\n .literal({\n name: \"remove\",\n description: \"unfreezes a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .executes((ctx, playerName) => {\n const freeze = TABLES.freezes\n .values()\n .find((freeze) => freeze.playerName == playerName);\n if (!freeze) return ctx.reply(`${playerName} is not frozen`);\n\n TABLES.freezes.delete(freeze.key);\n\n ctx.reply(`\u00A7a${playerName}\u00A7r has been UnFrozen!`);\n });\n\nroot\n .literal({\n name: \"list\",\n description: \"Lists all freezes\",\n })\n .executes((ctx) => {\n const freezes = TABLES.freezes.values();\n if (freezes.length == 0) return ctx.sender.tell(`\u00A7cNo one is frozen!`);\n ctx.sender.tell(`\u00A72--- Showing Freezes (${freezes.length}) ---`);\n for (const freeze of freezes) {\n ctx.sender.tell(\n text[\"commands.freeze.list.player\"](freeze.playerName, freeze.reason)\n );\n }\n });\n", "import { Player } from \"@minecraft/server\";\nimport { PREFIX } from \"../../../../rubedo/config/commands.js\";\nimport type {\n IArgumentType,\n IArgumentReturnData,\n} from \"../../../../rubedo/lib/Command/ArgumentTypes.js\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { COMMANDS } from \"../../../../rubedo/lib/Command/index.js\";\n\nclass CommandNameArgumentType implements IArgumentType {\n type: string;\n typeName = \"CommandName\";\n matches(value: string): IArgumentReturnData {\n return {\n success: Boolean(\n COMMANDS.find((c) => c.depth == 0 && c.data.name == value)\n ),\n value: value,\n };\n }\n fail(value: string): string {\n return `\"${value}\" is not a valid command`;\n }\n constructor(public name: string) {}\n}\n\n/**\n * Sends text in chat relation to the args in the command to player\n */\nfunction sendCommandType(\n baseCommand: Command,\n args: Command[],\n player: Player\n) {\n player.tell(\n `${PREFIX}${baseCommand.data.name} ${args\n .map((a) =>\n a.type.typeName == \"literal\"\n ? a.data.name\n : `<${a.type.name}: ${a.type.typeName}>`\n )\n .join(\" \")}`\n );\n}\n\nfunction sendArguments(bc: Command, c: Command, args: Command[], p: Player) {\n if (!c.data?.requires(p)) return;\n if (c.callback) {\n // command has a callback\n sendCommandType(bc, c.depth == 0 ? args : args.concat(c), p);\n }\n if (c.children.length > 0) {\n // cmd has arguments\n for (const child of c.children) {\n sendArguments(bc, child, c.depth == 0 ? args : args.concat(c), p);\n }\n }\n}\n\nfunction sendPageHeader(player: Player, p: number, maxPages: number) {\n player.tell(\n `\u00A72--- Showing help page ${p} of ${maxPages} (${PREFIX}help ) ---`\n );\n}\n\nfunction getCommands(player: Player): Command[] {\n return COMMANDS.filter((c) => {\n return c.depth == 0 && c.data?.requires(player);\n });\n}\n\nfunction getMaxPages(player: Player): number {\n const commands = getCommands(player);\n if (commands.length == 0) return 0;\n return Math.ceil(commands.length / 5);\n}\n\nconst root = new Command({\n name: \"help\",\n description: \"Provides help/list of commands.\",\n aliases: [\"?\", \"h\"],\n}).executes((ctx) => {\n // show page 1\n const maxPages = getMaxPages(ctx.sender);\n const commands = getCommands(ctx.sender).slice(1 * 5 - 5, 1 * 5);\n sendPageHeader(ctx.sender, 1, maxPages);\n for (const cmd of commands) {\n sendArguments(cmd, cmd, [], ctx.sender);\n }\n});\n\nroot.int(\"page\").executes((ctx, p) => {\n // shows page\n const maxPages = getMaxPages(ctx.sender);\n if (p > maxPages) p = maxPages;\n const commands = getCommands(ctx.sender).slice(p * 5 - 5, p * 5);\n sendPageHeader(ctx.sender, p, maxPages);\n for (const cmd of commands) {\n sendArguments(cmd, cmd, [], ctx.sender);\n }\n});\n\nroot\n .argument(new CommandNameArgumentType(\"command\"))\n .executes((ctx, command) => {\n // shows command\n const cmd = COMMANDS.filter(\n (c) => c.depth == 0 && c.data.name == command\n )[0];\n ctx.sender.tell(\n `\u00A7e${cmd.data.name}: ${\n cmd.data.aliases ? `aliases (${cmd.data.aliases.join(\", \")})` : \"\"\n }`\n );\n ctx.sender.tell(`\u00A7e${cmd.data.description}`);\n ctx.sender.tell(`Usage:`);\n sendArguments(cmd, cmd, [], ctx.sender);\n });\n", "import { world } from \"@minecraft/server\";\r\nimport { text } from \"../../../../rubedo/lang/text.js\";\r\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { confirmAction } from \"../../../../rubedo/lib/Form/utils.js\";\r\nimport { getRole, isLockedDown, kick, setLockDown } from \"../../utils.js\";\r\n\r\nnew Command({\r\n name: \"lockdown\",\r\n description: \"Toggles the servers lockdown, meaning no one can join\",\r\n requires: (player) => getRole(player) == \"admin\",\r\n}).executes((ctx) => {\r\n if (isLockedDown()) {\r\n setLockDown(false);\r\n ctx.sender.tell(`\u00A7aUnlocked the server!`);\r\n } else {\r\n ctx.reply(`\u00A7aClose chat to confirm lockdown`);\r\n confirmAction(ctx.sender, text[\"commands.lockdown.confirm\"], () => {\r\n setLockDown(true);\r\n for (const player of world.getPlayers()) {\r\n if (getRole(player) == \"admin\") continue;\r\n kick(player, text[\"lockdown.kick.message\"]());\r\n }\r\n world.say(`\u00A7l\u00A7cServer is now LOCKED!`);\r\n });\r\n }\r\n});\r\n", "import { Player } from \"@minecraft/server\";\nimport { TABLES } from \"../../tables.js\";\nimport type { IMuteData } from \"../../types.js\";\nimport { durationToMs } from \"../../../../utils.js\";\n\nexport class Mute {\n length: number;\n /**\n * Gets the mute data for this player\n */\n static getMuteData(player: Player): IMuteData {\n return TABLES.mutes.get(player.name);\n }\n /**\n * Mutes a player for a length\n */\n constructor(\n player: Player,\n duration?: string,\n reason: string = \"No Reason\",\n by: string = \"Rubedo Auto Mod\"\n ) {\n const msLength = duration ? durationToMs(duration) : null;\n const data: IMuteData = {\n playerName: player.name,\n date: Date.now(),\n duration: msLength,\n expire: msLength ? msLength + Date.now() : null,\n reason: reason,\n by: by,\n };\n TABLES.mutes.set(player.name, data);\n }\n}\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { Mute } from \"../models/Mute.js\";\nimport { getRole } from \"../../utils.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { msToTime } from \"../../../../utils.js\";\nimport { text } from \"../../../../rubedo/lang/text.js\";\n\nconst root = new Command({\n name: \"mute\",\n description: \"Manage Mutes\",\n requires: (player) => [\"admin\", \"moderator\"].includes(getRole(player)),\n});\n\nroot\n .literal({\n name: \"add\",\n description: \"Mutes a player\",\n })\n .argument(new ArgumentTypes.player(\"player\"))\n .argument(new ArgumentTypes.duration(\"duration\"))\n .string(\"reason\")\n .executes((ctx, player, duration, reason) => {\n new Mute(player, duration, reason, ctx.sender.name);\n ctx.reply(\n `\u00A7cMuted \u00A7f\"\u00A7a${player.name}\u00A7f\" \u00A7cfor ${duration} Because: \"${reason}\" \u00A7aSuccessfully`\n );\n player.tell(\n `\u00A7cYou have been muted by \u00A7f\"${ctx.sender.name}\" \u00A7cfor ${duration} Because: \"${reason}\"`\n );\n });\n\nroot\n .literal({\n name: \"remove\",\n description: \"un-mutes a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .executes((ctx, playerName) => {\n const mute = TABLES.mutes\n .values()\n .find((mute) => mute.playerName == playerName);\n if (!mute) return ctx.reply(`${playerName} is not muted!`);\n\n TABLES.mutes.delete(mute.playerName);\n try {\n ctx.sender.runCommandAsync(`ability \"${playerName}\" mute false`);\n } catch (error) {}\n ctx.reply(`\u00A7a${playerName}\u00A7r has been UnMuted!`);\n });\n\nroot\n .literal({\n name: \"list\",\n description: \"Lists all freezes\",\n })\n .executes((ctx) => {\n const mutes = TABLES.mutes.values();\n if (mutes.length == 0) return ctx.sender.tell(`\u00A7cNo one is muted!`);\n ctx.sender.tell(`\u00A72--- Showing Mutes (${mutes.length}) ---`);\n for (const mute of mutes) {\n ctx.sender.tell(\n text[\"commands.mutes.list.player\"](\n mute.playerName,\n mute.reason,\n mute.expire ? msToTime(mute.expire) : \"Forever\"\n )\n );\n }\n });\n", "import { Location } from \"@minecraft/server\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { getRole } from \"../../utils.js\";\nimport { Npc } from \"../models/Npc.js\";\n\nnew Command({\n name: \"npc\",\n description: \"Spawns a npc at your coordinates\",\n requires: (player) => getRole(player) == \"admin\",\n}).executes((ctx) => {\n const { x, y, z } = ctx.sender.location;\n new Npc(new Location(x, y, z), ctx.sender.dimension);\n ctx.reply(`Spawned a verified npc at your current location`);\n});\n", "import { Dimension, Entity, Location } from \"@minecraft/server\";\r\nimport { clearNpcLocations, NPC_LOCATIONS } from \"../../index.js\";\r\nimport { TABLES } from \"../../tables.js\";\r\nimport type { INpcLocation } from \"../../types.js\";\r\nimport { LocationEquals } from \"../../../../utils.js\";\r\n\r\nexport class Npc {\r\n /**\r\n * Checks if a entity is a valid npc\r\n * @param entity npc\r\n */\r\n static isValid(entity: Entity): boolean {\r\n if (entity.typeId != \"minecraft:npc\") return false;\r\n if (NPC_LOCATIONS.find((l) => LocationEquals(l, entity.location)))\r\n return true;\r\n return TABLES.npcs.keys().find((key) => entity.id == key) ? true : false;\r\n }\r\n /**\r\n * Adds a new verified npc to the world\r\n */\r\n constructor(location: Location, dimension: Dimension) {\r\n NPC_LOCATIONS.push(location);\r\n const entity = dimension.spawnEntity(\"minecraft:npc\", location);\r\n\r\n const data: INpcLocation = {\r\n dimension: entity.dimension.id,\r\n x: entity.location.x,\r\n y: entity.location.y,\r\n z: entity.location.z,\r\n };\r\n TABLES.npcs.set(entity.id, data);\r\n clearNpcLocations();\r\n }\r\n}\r\n", "import { system } from \"@minecraft/server\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command\";\n\nasync function getServerTPS(): Promise {\n let startTime = Date.now();\n let ticks = 0;\n return new Promise((resolve) => {\n let s = system.runSchedule(() => {\n if (Date.now() - startTime < 1000) {\n ticks++;\n } else {\n system.clearRunSchedule(s);\n resolve(ticks);\n }\n });\n });\n}\n\nnew Command({\n name: \"ping\",\n description: \"Returns the current Ticks Per Second of the servers ping\",\n}).executes(async (ctx) => {\n let ticks = await getServerTPS();\n ctx.reply(\n `\u00A7aCurrent Ticks Per Second: ${\n ticks > 18 ? \"\u00A7f{ \u00A7aGood\" : ticks > 13 ? \"\u00A7f{ \u00A7eOk\" : \"\u00A7f{ \u00A7cSevere\"\n } ${ticks} \u00A7f}`\n );\n});\n", "import { BlockLocation } from \"@minecraft/server\";\nimport { Region } from \"../models/Region.js\";\nimport { getRole } from \"../../utils.js\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\n\nconst command = new Command({\n name: \"region\",\n description: \"Create a Region\",\n requires: (player) => getRole(player) == \"admin\",\n});\n\ncommand\n .literal({\n name: \"add\",\n description: \"Adds a new protection region\",\n })\n .int(\"from_x\")\n .int(\"from_z\")\n .int(\"to_x\")\n .int(\"to_z\")\n .executes((ctx, from_x, from_z, to_x, to_z) => {\n new Region(\n { x: from_x, z: from_z },\n { x: to_x, z: to_z },\n ctx.sender.dimension.id\n );\n ctx.reply(\n `Created Region From ${from_x} -64 ${from_z} ${to_x} 320 ${to_z}`\n );\n });\n\ncommand\n .literal({\n name: \"remove\",\n description: \"Removes a region at the players current position\",\n })\n .executes((ctx) => {\n const loc = new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n );\n const r = Region.removeRegionAtBlockLocation(loc, ctx.sender.dimension.id);\n if (r) {\n ctx.reply(`Removed Region at ${loc.x} ${loc.y} ${loc.z}`);\n } else {\n ctx.reply(`Failed to find/remove region at ${loc.x} ${loc.y} ${loc.z}`);\n }\n });\n\ncommand\n .literal({\n name: \"removeAll\",\n description: \"Removes all regions\",\n })\n .executes((ctx) => {\n Region.getAllRegions().forEach((r) => r.delete());\n ctx.reply(`Removed All regions`);\n });\n\ncommand\n .literal({\n name: \"list\",\n description: \"Lists all regions and positions\",\n })\n .executes((ctx) => {\n const regions = Region.getAllRegions();\n for (const region of regions) {\n ctx.reply(\n `Region from ${region.from.x}, ${region.from.z} to ${region.to.x}, ${region.to.z} in dimension ${region.dimensionId}`\n );\n }\n if (regions.length == 0) return ctx.reply(`No regions have been made yet`);\n });\n\nconst permission = command.literal({\n name: \"permission\",\n description: \"Handles permissions for regions\",\n});\n\npermission\n .literal({\n name: \"set\",\n description:\n \"Sets a certain permission on the region the player is currently in to a value\",\n })\n .array(\"key\", [\"doorsAndSwitches\", \"openContainers\", \"pvp\"] as const)\n .boolean(\"value\")\n .executes((ctx, key, value) => {\n const region = Region.blockLocationInRegion(\n new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n ),\n ctx.sender.dimension.id\n );\n if (!region) return ctx.reply(`You are not in a region`);\n region.changePermission(key, value);\n ctx.reply(`Changed permission ${key} to ${value}`);\n });\n\npermission\n .literal({\n name: \"list\",\n description: \"Lists the permissions for the current region\",\n })\n .executes((ctx) => {\n const region = Region.blockLocationInRegion(\n new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n ),\n ctx.sender.dimension.id\n );\n if (!region) return ctx.reply(`You are not in a region`);\n ctx.reply(\n `Current region permissions ${JSON.stringify(region.permissions)}`\n );\n });\n\nconst entityCommands = permission.literal({\n name: \"entities\",\n description: \"Holds the subCommands for adding or removing allowedEntities\",\n});\n\nentityCommands\n .literal({\n name: \"add\",\n description: \"Adds a entity to the allowed entities list\",\n })\n .string(\"entity\")\n .executes((ctx, entity) => {\n const region = Region.blockLocationInRegion(\n new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n ),\n ctx.sender.dimension.id\n );\n if (!region) return ctx.reply(`You are not in a region`);\n const currentAllowedEntities = region.permissions.allowedEntities;\n currentAllowedEntities.push(entity);\n region.changePermission(\"allowedEntities\", currentAllowedEntities);\n ctx.reply(\n `Added entity ${entity} to the allowed entities of the region your currently standing in`\n );\n });\n\nentityCommands\n .literal({\n name: \"remove\",\n description: \"Removes a entity from the allowed entities in the region\",\n })\n .string(\"entity\")\n .executes((ctx, entity) => {\n const region = Region.blockLocationInRegion(\n new BlockLocation(\n ctx.sender.location.x,\n ctx.sender.location.y,\n ctx.sender.location.z\n ),\n ctx.sender.dimension.id\n );\n if (!region) return ctx.reply(`You are not in a region`);\n let currentAllowedEntities = region.permissions.allowedEntities;\n if (!currentAllowedEntities.includes(entity))\n return ctx.reply(\n `The entity ${entity} is not allowed to enter the region`\n );\n currentAllowedEntities = currentAllowedEntities.filter((v) => v != entity);\n region.changePermission(\"allowedEntities\", currentAllowedEntities);\n ctx.reply(\n `Removed entity ${entity} to the allowed entities of the region your currently standing in`\n );\n });\n", "import { Events } from \"@minecraft/server\";\r\nimport { ENCHANTMENTS } from \"./config/enchantments\";\r\n\r\n/**\r\n * The roles that are in this server\r\n */\r\nexport enum ROLES {\r\n member,\r\n admin,\r\n moderator,\r\n builder,\r\n}\r\n\r\nexport type ConfigType = {\r\n /**\r\n * {@link BANNED_ITEMS}\r\n */\r\n banned_items: string[];\r\n /**\r\n * {@link BANNED_BLOCKS}\r\n */\r\n banned_blocks: string[];\r\n /**\r\n * {@link ENCHANTMENTS}\r\n */\r\n enchantments: {\r\n [Property in keyof typeof ENCHANTMENTS]: number;\r\n };\r\n /**\r\n * Appeal Link for the server\r\n */\r\n appealLink: string;\r\n};\r\n\r\nexport interface LogData {\r\n /**\r\n * An optional playerName who is associated with this log\r\n * @example \"Smell of curry\"\r\n */\r\n playerName?: string;\r\n /**\r\n * The message for this log\r\n * @example \"Smell of curry is bad\"\r\n */\r\n message: string;\r\n /**\r\n * An optional property to list what protection this was from\r\n */\r\n protection?: string;\r\n}\r\n\r\nexport type EventsReturnType = (\r\n arg: Parameters[0]>[0]\r\n) => void;\r\n\r\nexport type IProtectionsConfig = {\r\n [key: string]: boolean | string | number;\r\n /**\r\n * If this protection is enabled\r\n */\r\n enabled: boolean;\r\n};\r\n\r\nexport interface IBanData {\r\n /**\r\n * The unique id of this ban\r\n */\r\n key: string;\r\n /**\r\n * The playersName of who was banned\r\n * @example \"Smell of curry\"\r\n */\r\n playerName: string;\r\n /**\r\n * The date in MS when this player was banned\r\n */\r\n date: number;\r\n /**\r\n * The duration in ms that this ban will be for\r\n * if null player is banned forever\r\n */\r\n duration?: number;\r\n /**\r\n * When this ban will expire, if null it will never expire meaning player is banned forever\r\n */\r\n expire?: number;\r\n /**\r\n * The reason for why this player was banned\r\n * @example \"Hacking\"\r\n */\r\n reason?: string;\r\n /**\r\n * Who banned this player\r\n * @example \"Smell of curry\"\r\n * @example \"Rubedo Anti Cheat\"\r\n */\r\n by?: string;\r\n}\r\n\r\nexport interface IFreezeData {\r\n /**\r\n * Players name of who was banned\r\n */\r\n playerName: string;\r\n /**\r\n * Unique id of this freeze instance\r\n */\r\n key: string;\r\n /**\r\n * The reason for this freeze\r\n */\r\n reason?: string;\r\n /**\r\n * The location of this freeze\r\n */\r\n location: {\r\n x: number;\r\n y: number;\r\n z: number;\r\n dimension: string;\r\n };\r\n}\r\n\r\nexport interface IMuteData {\r\n /**\r\n * Players name of who is muted\r\n * @example \"Smell of curry\"\r\n */\r\n playerName: string;\r\n /**\r\n * The date this player got muted\r\n */\r\n date: number;\r\n /**\r\n * The duration of this mute in ms\r\n * if null player is muted forever\r\n */\r\n duration?: number;\r\n /**\r\n * When this players mute will expire in ms\r\n * if null this mute will never expire\r\n */\r\n expire?: number;\r\n /**\r\n * Why this player is muted\r\n * @example \"Spamming\"\r\n */\r\n reason?: string;\r\n /**\r\n * Who muted this player\r\n * @example \"Smell of curry\"\r\n * @example \"Rubedo Anti Cheat\"\r\n */\r\n by?: string;\r\n}\r\n\r\nexport interface INpcLocation {\r\n dimension: string;\r\n x: number;\r\n y: number;\r\n z: number;\r\n}\r\n\r\nexport interface IRegionDB {\r\n dimensionId: string;\r\n from: IRegionCords;\r\n to: IRegionCords;\r\n key: string;\r\n permissions: IRegionPermissions;\r\n}\r\n\r\nexport interface IRegionCords {\r\n x: number;\r\n z: number;\r\n}\r\n\r\nexport interface IRegionPermissions {\r\n /**\r\n * if the player can use chests, default: true\r\n */\r\n doorsAndSwitches: Boolean;\r\n /**\r\n * if the player can use doors, default: true\r\n */\r\n openContainers: Boolean;\r\n /**\r\n * if players can fight, default: false\r\n */\r\n pvp: Boolean;\r\n /**\r\n * the entities allowed in this region\r\n */\r\n allowedEntities: Array;\r\n}\r\n", "import {\n ArgumentTypes,\n Command,\n} from \"../../../../rubedo/lib/Command/Command.js\";\nimport {\n getRole,\n getServerOwner,\n isServerOwner,\n setRole,\n setServerOwner,\n} from \"../../utils.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { confirmAction } from \"../../../../rubedo/lib/Form/utils\";\nimport { ROLES } from \"../../types\";\n\n// Helper\nconst StringIsNumber = (value: any) => isNaN(Number(value)) === false;\n\n// Turn enum into array\nfunction ToArray(enumme: any) {\n return (\n Object.keys(enumme)\n // @ts-ignore\n .filter(StringIsNumber)\n .map((key) => enumme[key])\n );\n}\n\nconst root = new Command({\n name: \"role\",\n description: \"Changes the role for a player\",\n requires: (player) => getRole(player) == \"admin\" || isServerOwner(player),\n});\n\nroot\n .literal({\n name: \"set\",\n description: \"Sets the role for a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .argument(new ArgumentTypes.array(\"role\", ToArray(ROLES) as string[]))\n .executes((ctx, playerName, role) => {\n setRole(playerName, role as keyof typeof ROLES);\n ctx.reply(`Changed role of ${playerName} to ${role}`);\n });\n\nroot\n .literal({\n name: \"get\",\n description: \"Gets the role of a player\",\n })\n .argument(new ArgumentTypes.playerName(\"playerName\"))\n .executes((ctx, playerName) => {\n const role = getRole(playerName);\n ctx.reply(`${playerName} has role: ${role}`);\n });\n\nconst ownerRoot = root.literal({\n name: \"owner\",\n description: \"Manages the owner\",\n});\n\nownerRoot\n .literal({\n name: \"get\",\n description: \"Gets the owner of the world\",\n })\n .executes((ctx) => {\n const ownerId = getServerOwner();\n const ids = TABLES.ids.collection();\n const ownerName = Object.keys(ids).find((key) => ids[key] === ownerId);\n ctx.reply(`\u00A7aServer Owner: ${ownerName} (id: ${ownerId})`);\n });\n\nownerRoot\n .literal({\n name: \"transfer\",\n description: \"Transfers the owner of the world\",\n requires: (player) => isServerOwner(player),\n })\n .argument(new ArgumentTypes.player())\n .executes((ctx, player) => {\n confirmAction(\n ctx.sender,\n `Are you sure you want to transfer the server ownership to ${player.name}, this action is not reversible!`,\n () => {\n setServerOwner(player);\n ctx.reply(\n `\u00A7aSet the server Owner to: ${player.name} (id: ${player.id})`\n );\n }\n );\n ctx.reply(`\u00A7aClose chat to confirm`);\n });\n\nownerRoot\n .literal({\n name: \"clear\",\n description: \"clear's the owner of the world\",\n requires: (player) => isServerOwner(player),\n })\n .executes((ctx) => {\n confirmAction(\n ctx.sender,\n \"Are you sure you want to clear the server owner, this action is not reversible!\",\n () => {\n setServerOwner(null);\n ctx.reply(\n `\u00A7aCleared the server owner! run \"/reload\" or reload world to run \"/function start\" again!`\n );\n }\n );\n ctx.reply(`\u00A7aClose chat to confirm`);\n });\n", "import { Player } from \"@minecraft/server\";\r\nimport { ActionFormData } from \"@minecraft/server-ui\";\r\nimport { TIMEOUT_THRESHOLD } from \"../../../config/form\";\r\nimport type { ButtonCallback, IActionFormButton } from \"../types\";\r\n\r\nexport class ActionForm {\r\n /**\r\n * the title that this form should have\r\n */\r\n title?: string;\r\n /**\r\n * extra text that should be displayed in the form\r\n */\r\n body?: string;\r\n /**\r\n * The buttons this form has\r\n */\r\n private buttons: IActionFormButton[];\r\n\r\n /**\r\n * The default minecraft form this form is based on\r\n */\r\n private form: ActionFormData;\r\n\r\n /**\r\n * The amount of times it takes to show this form in ms\r\n * if this value goes above 200 it will time out\r\n */\r\n private triedToShow: number;\r\n\r\n /**\r\n * Creates a new form to be shown to a player\r\n * @param title the title that this form should have\r\n * @param body extra text that should be displayed in the form\r\n */\r\n constructor(title?: string, body?: string) {\r\n this.title = title;\r\n this.body = body;\r\n this.form = new ActionFormData();\r\n\r\n if (title) this.form.title(title);\r\n if (body) this.form.body(body);\r\n\r\n this.buttons = [];\r\n\r\n this.triedToShow = 0;\r\n }\r\n\r\n /**\r\n * Adds a button to this form\r\n * @param text text to show on this button\r\n * @param iconPath the path this button shows\r\n * @param callback what happens when this button is clicked\r\n * @example ```\r\n * addButton(\"settings\", \"textures/items/sum\")\r\n * ```\r\n */\r\n addButton(\r\n text: string,\r\n iconPath: string = null,\r\n callback: ButtonCallback\r\n ): ActionForm {\r\n this.buttons.push({\r\n text: text,\r\n iconPath: iconPath,\r\n callback: callback,\r\n });\r\n this.form.button(text, iconPath);\r\n return this;\r\n }\r\n\r\n /**\r\n * Shows this form to the player\r\n * @param player player to show to\r\n */\r\n show(player: Player): void {\r\n this.form.show(player).then((response) => {\r\n if (response.canceled) {\r\n if (response.cancelationReason == \"userBusy\") {\r\n // check time and reshow form\r\n if (this.triedToShow > TIMEOUT_THRESHOLD)\r\n return player.tell(\r\n `\u00A7cForm Timeout: tried to show form, but you were busy (close chat after running command)`\r\n );\r\n this.triedToShow++;\r\n this.show(player);\r\n }\r\n return;\r\n }\r\n this.buttons[response.selection].callback?.();\r\n });\r\n }\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport { ModalFormData } from \"@minecraft/server-ui\";\r\nimport { TIMEOUT_THRESHOLD } from \"../../../config/form\";\r\nimport type { AppendFormField, IModalFormArg, Range } from \"../types\";\r\nimport { FormCallback } from \"./FormCallback\";\r\n\r\nexport class ModalForm<\r\n Callback extends Function = (ctx: FormCallback) => void\r\n> {\r\n /**\r\n * the title that this form should have\r\n */\r\n title?: string;\r\n\r\n /**\r\n * The default minecraft form this form is based on\r\n */\r\n private form: ModalFormData;\r\n\r\n /**\r\n * The arguments this form has\r\n */\r\n private args: IModalFormArg[];\r\n\r\n /**\r\n * Creates a new form to be shown to a player\r\n * @param title the title that this form should have\r\n */\r\n constructor(title?: string) {\r\n this.title = title;\r\n this.form = new ModalFormData();\r\n\r\n if (title) this.form.title(title);\r\n\r\n this.args = [];\r\n }\r\n\r\n /**\r\n * Adds a dropdown to this form\r\n * @param label label to show on dropdown\r\n * @param options the available options for this dropdown\r\n * @param defaultValueIndex the default value index\r\n * @returns this\r\n */\r\n addDropdown>(\r\n label: string,\r\n options: T,\r\n defaultValueIndex?: number\r\n ): ModalForm> {\r\n // @ts-ignore\r\n this.args.push({ type: \"dropdown\", options: options });\r\n // @ts-ignore\r\n this.form.dropdown(label, options, defaultValueIndex);\r\n // @ts-ignore\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a slider to this form\r\n * @param label label to be shown on this slider\r\n * @param minimumValue the smallest value this can be\r\n * @param maximumValue the maximum value this can be\r\n * @param valueStep how this slider increments\r\n * @param defaultValue the default value in slider\r\n * @returns this\r\n */\r\n addSlider(\r\n label: string,\r\n minimumValue: T,\r\n maximumValue: U,\r\n valueStep: number,\r\n defaultValue?: number\r\n ): ModalForm>> {\r\n this.args.push({ type: \"slider\" });\r\n this.form.slider(\r\n label,\r\n minimumValue,\r\n maximumValue,\r\n valueStep,\r\n defaultValue\r\n );\r\n // @ts-ignore\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a toggle to this form\r\n * @param label the name of this toggle\r\n * @param defaultValue the default toggle value could be true or false\r\n * @returns\r\n */\r\n addToggle(\r\n label: string,\r\n defaultValue?: boolean\r\n ): ModalForm> {\r\n this.args.push({ type: \"toggle\" });\r\n this.form.toggle(label, defaultValue);\r\n // @ts-ignore\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a text field to this form\r\n * @param label label for this textField\r\n * @param placeholderText the text that shows on this field\r\n * @param defaultValue the default value that this field has\r\n */\r\n addTextField(\r\n label: string,\r\n placeholderText: string,\r\n defaultValue?: string\r\n ): ModalForm> {\r\n this.args.push({ type: \"textField\" });\r\n this.form.textField(label, placeholderText, defaultValue);\r\n // @ts-ignore\r\n return this;\r\n }\r\n\r\n /**\r\n * Shows this form to a player\r\n * @param player player to show to\r\n * @param callback sends a callback when this form is submitted\r\n */\r\n async show(player: Player, callback: Callback) {\r\n for (let i = 0; i < TIMEOUT_THRESHOLD; i++) {\r\n let response = await this.form.show(player);\r\n if (response.cancelationReason == \"userBusy\") continue;\r\n callback(\r\n new FormCallback(this, player, callback),\r\n ...response.formValues.map((v, i) =>\r\n this.args[i].type == \"dropdown\" ? this.args[i].options[v] : v\r\n )\r\n );\r\n return;\r\n }\r\n return player.tell(\r\n `\u00A7cForm Timeout: tried to show form, but you were busy (close chat after running command)`\r\n );\r\n }\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport { ActionForm } from \"./ActionForm\";\r\nimport { MessageForm } from \"./MessageForm\";\r\nimport { ModalForm } from \"./ModelForm\";\r\n\r\nexport class FormCallback {\r\n /**\r\n * form that was used in this call\r\n */\r\n private form: ActionForm | MessageForm | ModalForm;\r\n /**\r\n * player that this form used\r\n */\r\n private player: Player;\r\n\r\n /**\r\n * the function that was called\r\n */\r\n private callback: () => void;\r\n\r\n /**\r\n * Creates a new form callback instance that can be used by\r\n * buttons, and args to run various functions\r\n * @param form form that is used in this call\r\n */\r\n constructor(\r\n form: ActionForm | MessageForm | ModalForm,\r\n player: Player,\r\n callback: any\r\n ) {\r\n this.form = form;\r\n this.player = player;\r\n this.callback = callback;\r\n }\r\n\r\n /**\r\n * Reshow the form and shows the user a error message\r\n * @param message error message to show\r\n */\r\n error(message: string) {\r\n new MessageForm(\"Error\", message)\r\n .setButton1(\"Return to form\", () => {\r\n this.form.show(this.player, this.callback);\r\n })\r\n .setButton2(\"Cancel\", null)\r\n .show(this.player);\r\n }\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport { ENCHANTMENTS } from \"../../config/enchantments\";\r\nimport { getConfigId, setConfigId } from \"../../utils\";\r\nimport { APPEAL_LINK } from \"../../config/moderation\";\r\nimport { ActionForm } from \"../../../../rubedo/lib/Form/Models/ActionForm\";\r\nimport { ModalForm } from \"../../../../rubedo/lib/Form/Models/ModelForm\";\r\n\r\nexport function manageBannedItemsForm(player: Player) {\r\n new ActionForm(\"Manage Banned Items\")\r\n .addButton(\"Remove a Banned Item\", null, () => {\r\n removeBannedItemForm(player);\r\n })\r\n .addButton(\"Ban an item\", null, () => {\r\n addBannedItemForm(player);\r\n })\r\n .show(player);\r\n}\r\nexport function removeBannedItemForm(player: Player) {\r\n new ModalForm(\"Remove Banned Items\")\r\n .addDropdown(\"Select item to remove\", getConfigId(\"banned_items\"))\r\n .show(player, (ctx, item) => {\r\n let items = getConfigId(\"banned_items\");\r\n items = items.filter((p) => p != item);\r\n setConfigId(\"banned_items\", items);\r\n player.tell(`Removed Banned item \"${item}\"`);\r\n });\r\n}\r\n\r\nexport function addBannedItemForm(player: Player) {\r\n new ModalForm(\"Add Banned Item\")\r\n .addTextField(\"Item Id\", \"minecraft:string\")\r\n .show(player, (ctx, item) => {\r\n let items = getConfigId(\"banned_items\");\r\n if (items.includes(item))\r\n return ctx.error(`\u00A7cItem \"${item}\" is already banned`);\r\n items.push(item);\r\n setConfigId(\"banned_items\", items);\r\n player.tell(`Banned the item \"${item}\"`);\r\n });\r\n}\r\n\r\nexport function manageBannedBlocksForm(player: Player) {\r\n new ActionForm(\"Manage Banned Blocks\")\r\n .addButton(\"Remove a Banned Block\", null, () => {\r\n removeBannedBlockForm(player);\r\n })\r\n .addButton(\"Ban an block\", null, () => {\r\n addBannedBlockForm(player);\r\n })\r\n .show(player);\r\n}\r\n\r\nexport function removeBannedBlockForm(player: Player) {\r\n new ModalForm(\"Remove Banned Block\")\r\n .addDropdown(\"Select block to remove\", getConfigId(\"banned_blocks\"))\r\n .show(player, (ctx, block) => {\r\n let blocks = getConfigId(\"banned_blocks\");\r\n blocks = blocks.filter((p) => p != block);\r\n setConfigId(\"banned_blocks\", blocks);\r\n player.tell(`Removed Banned block \"${block}\"`);\r\n });\r\n}\r\n\r\nexport function addBannedBlockForm(player: Player) {\r\n new ModalForm(\"Add Banned Block\")\r\n .addTextField(\"Block Id\", \"minecraft:barrier\")\r\n .show(player, (ctx, block) => {\r\n let blocks = getConfigId(\"banned_blocks\");\r\n if (blocks.includes(block))\r\n return ctx.error(`\u00A7cBlock \"${block}\" is already banned`);\r\n blocks.push(block);\r\n setConfigId(\"banned_blocks\", blocks);\r\n player.tell(`Banned the block \"${block}\"`);\r\n });\r\n}\r\n\r\nexport function manageEnchantmentLevelsForm(player: Player) {\r\n new ModalForm(\"Manage Enchantment Levels\")\r\n .addDropdown(\"Enchantment to change\", Object.keys(ENCHANTMENTS), 0)\r\n .addTextField(\"Level (number)\", \"5\")\r\n .show(player, (ctx, enchantment, levelString) => {\r\n if (isNaN(levelString as any))\r\n return ctx.error(\r\n `\u00A7c\"${levelString}\" is not a number, please enter a value like, \"3\", \"9\", etc.`\r\n );\r\n const level = parseInt(levelString);\r\n let enchants = getConfigId(\"enchantments\");\r\n enchants[enchantment as keyof typeof ENCHANTMENTS] = level;\r\n setConfigId(\"enchantments\", enchants);\r\n player.tell(`Set max level for ${enchantment} to ${level}`);\r\n });\r\n}\r\n\r\nexport function manageAppealLinkForm(player: Player) {\r\n new ModalForm(\"Manage Appeal Link\")\r\n .addTextField(\"Appeal Link\", APPEAL_LINK)\r\n .show(player, (ctx, link) => {\r\n setConfigId(\"appealLink\", link);\r\n player.tell(`Changed the servers appeal link to ${link}`);\r\n });\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport type { IProtectionsConfig } from \"../../types\";\r\nimport { PROTECTIONS } from \"../../protections\";\r\nimport { Protection } from \"../models/Protection\";\r\nimport { showHomeForm } from \"./home\";\r\nimport { ModalForm } from \"../../../../rubedo/lib/Form/Models/ModelForm\";\r\nimport { ActionForm } from \"../../../../rubedo/lib/Form/Models/ActionForm\";\r\n\r\nexport function showAutoModHomeForm(player: Player) {\r\n const form = new ActionForm(\"Manage Protections\");\r\n\r\n for (const protection of Object.values(PROTECTIONS)) {\r\n form.addButton(protection.name, protection.iconPath, () => {\r\n showProtectionConfig(protection, player);\r\n });\r\n }\r\n form\r\n .addButton(\"Back\", \"textures/ui/arrow_dark_left_stretch.png\", () => {\r\n showHomeForm(player);\r\n })\r\n .show(player);\r\n}\r\n\r\nexport function showProtectionConfig(protection: Protection, player: Player) {\r\n const data = protection.getConfig();\r\n const form = new ModalForm(\r\n `Manage ${protection.name} Protection Config`\r\n ).addToggle(\"Enabled\", data[\"enabled\"]);\r\n let keys: string[] = [];\r\n for (const [key, value] of Object.entries(protection.configDefault)) {\r\n keys.push(key);\r\n if (typeof value.defaultValue == \"boolean\") {\r\n form.addToggle(value.description, data[key] as boolean);\r\n } else if (typeof value.defaultValue == \"number\") {\r\n form.addSlider(value.description, 0, 100, 1, data[key] as number);\r\n } else {\r\n form.addTextField(value.description, null, data[key] as string);\r\n }\r\n }\r\n form.show(player, (ctx, enabled, ...keys) => {\r\n if (enabled != data[\"enabled\"]) {\r\n if (enabled) protection.enable();\r\n if (!enabled) protection.disable();\r\n }\r\n let config: IProtectionsConfig = {\r\n enabled: enabled,\r\n };\r\n for (const [i, key] of Object.keys(protection.configDefault).entries()) {\r\n config[key] = keys[i];\r\n }\r\n protection.setConfig(config);\r\n player.tell(`Updated config for ${protection.name}!`);\r\n });\r\n}\r\n", "import { Player } from \"@minecraft/server\";\r\nimport * as settings from \"./settings\";\r\nimport * as automod from \"./automod\";\r\nimport { ActionForm } from \"../../../../rubedo/lib/Form/Models/ActionForm\";\r\n\r\nexport function showHomeForm(player: Player) {\r\n new ActionForm(\"Rubedo Settings\")\r\n .addButton(\"Auto Mod\", \"textures/ui/permissions_op_crown.png\", () => {\r\n automod.showAutoModHomeForm(player);\r\n })\r\n .addButton(\"Banned items\", \"textures/blocks/sculk_shrieker_top.png\", () => {\r\n settings.manageBannedItemsForm(player);\r\n })\r\n .addButton(\"Banned blocks\", \"textures/blocks/barrier.png\", () => {\r\n settings.manageBannedBlocksForm(player);\r\n })\r\n .addButton(\"Enchantments\", \"textures/items/book_enchanted.png\", () => {\r\n settings.manageEnchantmentLevelsForm(player);\r\n })\r\n .addButton(\"Appeal Link\", \"textures/ui/Feedback.png\", () => {\r\n settings.manageAppealLinkForm(player);\r\n })\r\n .show(player);\r\n}\r\n", "import { Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { getRole } from \"../../utils.js\";\r\nimport { showHomeForm } from \"../forms/home.js\";\r\n\r\nnew Command({\r\n name: \"settings\",\r\n description: \"Opens up the settings menu for the player\",\r\n requires: (player) => [\"admin\", \"moderator\"].includes(getRole(player)),\r\n}).executes((ctx) => {\r\n showHomeForm(ctx.sender);\r\n ctx.sender.tell(`\u00A7aForm request sent, close chat to continue!`);\r\n});\r\n", "import { Player, world } from \"@minecraft/server\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command.js\";\nimport { getRole } from \"../../utils.js\";\n\nfunction vanish(player: Player, say: boolean) {\n if (player.hasTag(`spectator`)) {\n player.runCommandAsync(`gamemode c`);\n player.triggerEvent(`removeSpectator`);\n player.removeTag(`spectator`);\n if (!say) return;\n world.say({\n rawtext: [\n {\n translate: \"multiplayer.player.joined\",\n with: [`\u00A7e${player.name}`],\n },\n ],\n });\n } else {\n player.runCommandAsync(`gamemode spectator`);\n player.triggerEvent(`addSpectator`);\n player.addTag(`spectator`);\n if (!say) return;\n world.say({\n rawtext: [\n {\n translate: \"multiplayer.player.left\",\n with: [`\u00A7e${player.name}`],\n },\n ],\n });\n }\n}\n\nnew Command({\n name: \"vanish\",\n description: \"Toggles Vanish Mode on the sender\",\n requires: (player) => getRole(player) == \"admin\",\n})\n .executes((ctx) => {\n vanish(ctx.sender, false);\n })\n .boolean(\"say\")\n .executes((ctx, say) => {\n vanish(ctx.sender, say);\n });\n", "/*\r\n|--------------------------------------------------------------------------\r\n| Version\r\n|--------------------------------------------------------------------------\r\n|\r\n| This is the version of rubedo recommended to NOT CHANGE could cause bugs.\r\n|\r\n*/\r\nexport const VERSION = \"2.6.7-beta\";\r\n\r\n/*\r\n|--------------------------------------------------------------------------\r\n| Game Version\r\n|--------------------------------------------------------------------------\r\n|\r\n| This is the version of minecraft that this version of rubedo\r\n| was made for its a simple constant to tell creators what version\r\n| this gametest api is supposed to work perfectly for.\r\n|\r\n*/\r\nexport const GAME_VERSION = \"1.19.50\";\r\n", "import { VERSION } from \"../../../../rubedo/config/app\";\nimport { Command } from \"../../../../rubedo/lib/Command/Command\";\n\nnew Command({\n name: \"version\",\n description: \"Get Current Rubedo Version\",\n aliases: [\"v\"],\n}).executes((ctx) => {\n ctx.reply(`Current Rubedo Version: ${VERSION}`);\n});\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { getRole, kick } from \"../../utils\";\r\n\r\nnew Command({\r\n name: \"kick\",\r\n description: \"Kicks a player from the game\",\r\n requires: (player) => getRole(player) == \"admin\",\r\n})\r\n .argument(new ArgumentTypes.player())\r\n .string(\"reason\")\r\n .executes((ctx, player, reason) => {\r\n kick(player, [reason]);\r\n ctx.reply(`\u00A7aKicked ${player.name} from world`);\r\n });\r\n", "import { TABLES } from \"../../tables.js\";\r\nimport type { LogData } from \"../../types\";\r\n\r\nexport class Log {\r\n /**\r\n * The data on this Log\r\n */\r\n data: LogData;\r\n constructor(data: LogData) {\r\n this.data = data;\r\n console.warn(`[LOG]: ${data.message}`);\r\n TABLES.logs.set(Date.now().toString(), data);\r\n }\r\n}\r\n", "import { PREFIX } from \"../../../../rubedo/config/commands.js\";\r\nimport { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { TABLES } from \"../../tables.js\";\r\nimport { getRole } from \"../../utils\";\r\nimport { Log } from \"../models/Log\";\r\n\r\nfunction timeDifference(previous: number) {\r\n var msPerMinute = 60 * 1000;\r\n var msPerHour = msPerMinute * 60;\r\n var msPerDay = msPerHour * 24;\r\n var msPerMonth = msPerDay * 30;\r\n var msPerYear = msPerDay * 365;\r\n\r\n var elapsed = Date.now() - previous;\r\n\r\n if (elapsed < msPerMinute) {\r\n return Math.round(elapsed / 1000) + \" seconds ago\";\r\n } else if (elapsed < msPerHour) {\r\n return Math.round(elapsed / msPerMinute) + \" minutes ago\";\r\n } else if (elapsed < msPerDay) {\r\n return Math.round(elapsed / msPerHour) + \" hours ago\";\r\n } else if (elapsed < msPerMonth) {\r\n return \"approximately \" + Math.round(elapsed / msPerDay) + \" days ago\";\r\n } else if (elapsed < msPerYear) {\r\n return \"approximately \" + Math.round(elapsed / msPerMonth) + \" months ago\";\r\n } else {\r\n return \"approximately \" + Math.round(elapsed / msPerYear) + \" years ago\";\r\n }\r\n}\r\n\r\nconst root = new Command({\r\n name: \"log\",\r\n description: \"Manages the log command\",\r\n requires: (player) => getRole(player) == \"admin\",\r\n});\r\n\r\nroot\r\n .literal({\r\n name: \"add\",\r\n description: \"Adds a new log\",\r\n })\r\n .string(\"message\")\r\n .executes((ctx, message) => {\r\n new Log({ message: message });\r\n ctx.reply(`\u00A7aAdded new log: ${message}`);\r\n });\r\n\r\nroot\r\n .literal({\r\n name: \"getAll\",\r\n description: \"Gets all logs sorted in descending\",\r\n })\r\n .int(\"page\")\r\n .array(\"order\", [\"ascending\", \"descending\"] as const)\r\n .executes((ctx, page, order) => {\r\n const allLogs = Object.entries(TABLES.logs.collection()).sort((a, b) =>\r\n order == \"ascending\"\r\n ? parseInt(b[0]) - parseInt(a[0])\r\n : parseInt(a[0]) - parseInt(b[0])\r\n );\r\n if (allLogs.length == 0) return ctx.reply(`\u00A7cNo Logs have been made!`);\r\n const maxPages = Math.ceil(allLogs.length / 8);\r\n if (page > maxPages) page = maxPages;\r\n ctx.reply(\r\n `\u00A72--- Showing logs page ${page} of ${maxPages} (${PREFIX}log getAll ) ---`\r\n );\r\n\r\n for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) {\r\n ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`);\r\n }\r\n });\r\n\r\nroot\r\n .literal({\r\n name: \"getPlayersLogs\",\r\n description: \"Gets all logs associated with a player\",\r\n })\r\n .argument(new ArgumentTypes.playerName())\r\n .int(\"page\")\r\n .array(\"order\", [\"ascending\", \"descending\"] as const)\r\n .executes((ctx, playerName, page, order) => {\r\n const allLogs = Object.entries(TABLES.logs.collection())\r\n .filter((v) => v[1].playerName == playerName)\r\n .sort((a, b) =>\r\n order == \"ascending\"\r\n ? parseInt(b[0]) - parseInt(a[0])\r\n : parseInt(a[0]) - parseInt(b[0])\r\n );\r\n if (allLogs.length == 0)\r\n return ctx.reply(`\u00A7cNo Logs exists for \"${playerName}\"!`);\r\n const maxPages = Math.ceil(allLogs.length / 8);\r\n if (page > maxPages) page = maxPages;\r\n ctx.reply(\r\n `\u00A72--- Showing logs for \"${playerName}\" page ${page} of ${maxPages} ---`\r\n );\r\n\r\n for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) {\r\n ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`);\r\n }\r\n });\r\n\r\nroot\r\n .literal({\r\n name: \"getProtectionLogs\",\r\n description: \"Gets all logs associated with a protection\",\r\n })\r\n .string(\"protection\")\r\n .int(\"page\")\r\n .array(\"order\", [\"ascending\", \"descending\"] as const)\r\n .executes((ctx, protection, page, order) => {\r\n const allLogs = Object.entries(TABLES.logs.collection())\r\n .filter((v) => v[1].protection == protection)\r\n .sort((a, b) =>\r\n order == \"ascending\"\r\n ? parseInt(b[0]) - parseInt(a[0])\r\n : parseInt(a[0]) - parseInt(b[0])\r\n );\r\n if (allLogs.length == 0)\r\n return ctx.reply(`\u00A7cNo Logs exists for protection: \"${protection}\"!`);\r\n const maxPages = Math.ceil(allLogs.length / 8);\r\n if (page > maxPages) page = maxPages;\r\n ctx.reply(\r\n `\u00A72--- Showing logs for Protection: \"${protection}\" page ${page} of ${maxPages} ---`\r\n );\r\n\r\n for (const [key, value] of allLogs.slice(page * 8 - 8, page * 8)) {\r\n ctx.reply(`${timeDifference(parseInt(key))}: ${value.message}`);\r\n }\r\n });\r\n\r\nroot\r\n .literal({\r\n name: \"clearAll\",\r\n description: \"Clears all logs\",\r\n })\r\n .executes((ctx) => {\r\n TABLES.logs.clear();\r\n ctx.reply(`\u00A7aCleared All logs!`);\r\n });\r\n", "import { ArgumentTypes, Command } from \"../../../../rubedo/lib/Command/Command.js\";\r\nimport { getRole } from \"../../utils\";\r\n\r\nconst root = new Command({\r\n name: \"teleport\",\r\n description: \"Teleports entities (players, mobs, etc.).\",\r\n aliases: [\"tp\"],\r\n requires: (player) => getRole(player) == \"admin\",\r\n});\r\n\r\nroot\r\n .argument(new ArgumentTypes.player())\r\n .location(\"destination\")\r\n .executes((ctx, player, destination) => {\r\n player.addTag(\"skip-movement-check\");\r\n player.teleport(destination, player.dimension, 0, 0);\r\n ctx.reply(\r\n `Teleported ${player.name} to ${destination.x} ${destination.y} ${destination.z}`\r\n );\r\n });\r\n", "import { Player, system, world } from \"@minecraft/server\";\r\nimport { EntitiesLoad } from \"./EntitiesLoad\";\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: (player: Player) => void;\r\n delay: number;\r\n lastCall: number;\r\n };\r\n} = {};\r\n\r\nEntitiesLoad.subscribe(() => {\r\n system.runSchedule(() => {\r\n const players = [...world.getPlayers()];\r\n for (const [i, player] of players.entries()) {\r\n for (const CALLBACK of Object.values(CALLBACKS)) {\r\n if (\r\n CALLBACK.delay != 0 &&\r\n system.currentTick - CALLBACK.lastCall < CALLBACK.delay\r\n )\r\n continue;\r\n CALLBACK.callback(player);\r\n if (i == players.length - 1) CALLBACK.lastCall = system.currentTick;\r\n }\r\n }\r\n });\r\n});\r\n\r\nexport class forEachPlayer {\r\n /**\r\n * Subscribes to a callback that returns every player\r\n * @param callback what to be called for each player\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(\r\n callback: (player: Player) => void,\r\n delay: number = 0\r\n ): number {\r\n const key = Object.keys(CALLBACKS).length;\r\n CALLBACKS[key] = { callback: callback, delay: delay, lastCall: 0 };\r\n return key;\r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n", "import { TABLES } from \"../../tables.js\";\nimport { msToTime } from \"../../../../utils.js\";\nimport { kick, getConfigId } from \"../../utils.js\";\nimport { forEachPlayer } from \"../../../../rubedo/lib/Events/forEachPlayer.js\";\n\nTABLES.bans.onLoad(() => {\n forEachPlayer.subscribe((player) => {\n try {\n const banData = TABLES.bans.get(player.id);\n if (!banData) return;\n if (banData.expire && banData.expire < Date.now())\n return TABLES.bans.delete(player.id);\n kick(\n player,\n [\n `\u00A7cYou have been banned!`,\n `\u00A7aReason: \u00A7f${banData.reason}`,\n `\u00A7fExpiry: \u00A7b${\n banData.expire ? msToTime(banData.expire - Date.now()) : \"Forever\"\n }`,\n `\u00A7fAppeal at: \u00A7b${getConfigId(\"appealLink\")}`,\n ],\n () => {\n console.warn(new Error(\"Failed to kick player\"));\n TABLES.bans.delete(player.id);\n }\n );\n } catch (error) {\n console.warn(error + error.stack);\n }\n }, 100);\n});\n", "import { Location } from \"@minecraft/server\";\nimport { TABLES } from \"../../tables.js\";\nimport { DIMENSIONS } from \"../../../../utils.js\";\nimport { forEachPlayer } from \"../../../../rubedo/lib/Events/forEachPlayer.js\";\n\nforEachPlayer.subscribe((player) => {\n try {\n const freezeData = TABLES.freezes.get(player.id);\n\n if (!freezeData)\n return player.getComponent(\"movement\").resetToDefaultValue();\n player.getComponent(\"movement\").setCurrent(0);\n\n player.teleport(\n new Location(\n freezeData.location.x,\n freezeData.location.y,\n freezeData.location.z\n ),\n DIMENSIONS[freezeData.location.dimension as keyof typeof DIMENSIONS],\n 0,\n 0\n );\n } catch (error) {}\n}, 200);\n", "import { world, BeforeChatEvent } from \"@minecraft/server\";\r\nimport { PREFIX } from \"../../config/commands\";\r\n\r\ntype beforeChatCallback = (arg: BeforeChatEvent) => void;\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: beforeChatCallback;\r\n };\r\n} = {};\r\n\r\nworld.events.beforeChat.subscribe((data) => {\r\n if (data.message.startsWith(PREFIX)) return; // This is a command\r\n for (const callback of Object.values(CALLBACKS)) {\r\n callback.callback(data);\r\n }\r\n});\r\n\r\nexport class beforeChat {\r\n /**\r\n * Subscribes to a callback to get notified when a chat is sent that is not a command\r\n * @param callback what to be called when one of these entity's inventory changes\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(callback: beforeChatCallback): number {\r\n const key = Date.now();\r\n CALLBACKS[key] = { callback: callback };\r\n return key;\r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n", "import { Mute } from \"../models/Mute.js\";\nimport { TABLES } from \"../../tables.js\";\nimport { text } from \"../../../../rubedo/lang/text.js\";\nimport { beforeChat } from \"../../../../rubedo/lib/Events/beforeChat.js\";\n\nbeforeChat.subscribe((data) => {\n const muteData = Mute.getMuteData(data.sender);\n if (!muteData) return;\n if (muteData.expire && muteData.expire < Date.now())\n return TABLES.mutes.delete(data.sender.name);\n data.cancel = true;\n data.sender.tell(text[\"modules.managers.mute.isMuted\"]());\n});\n", "import { BlockLocation, Player, system, world } from \"@minecraft/server\";\nimport { Region } from \"../models/Region.js\";\nimport { getRole, loadRegionDenys } from \"../../utils.js\";\nimport { BLOCK_CONTAINERS, DOORS_SWITCHES } from \"../../config/region.js\";\nimport { DIMENSIONS } from \"../../../../utils.js\";\nimport { EntitiesLoad } from \"../../../../rubedo/lib/Events/EntitiesLoad.js\";\nimport { forEachPlayer } from \"../../../../rubedo/lib/Events/forEachPlayer.js\";\nimport { TABLES } from \"../../tables.js\";\n\n/**\n * Sets Deny blocks at bottom of region every 5 mins\n */\nsystem.runSchedule(() => {\n loadRegionDenys();\n}, 6000);\n\n/**\n * Permissions for region\n */\nworld.events.beforeItemUseOn.subscribe((data) => {\n if ([\"moderator\", \"admin\"].includes(getRole(data.source as Player))) return;\n const region = Region.blockLocationInRegion(\n data.blockLocation,\n data.source.dimension.id\n );\n if (!region) return;\n const block = data.source.dimension.getBlock(data.blockLocation);\n if (\n DOORS_SWITCHES.includes(block.typeId) &&\n region.permissions.doorsAndSwitches\n )\n return;\n if (\n BLOCK_CONTAINERS.includes(block.typeId) &&\n region.permissions.openContainers\n )\n return;\n data.cancel = true;\n});\n\nworld.events.beforeExplosion.subscribe((data) => {\n for (let i = 0; i < data.impactedBlocks.length; i++) {\n const bL = data.impactedBlocks[i];\n let region = Region.blockLocationInRegion(bL, data.dimension.id);\n if (region) return (data.cancel = true);\n }\n});\n\nworld.events.entitySpawn.subscribe(async ({ entity }) => {\n const region = await Region.blockLocationInRegionSync(\n new BlockLocation(entity.location.x, entity.location.y, entity.location.z),\n entity.dimension.id\n );\n if (!region) return;\n if (region.permissions.allowedEntities.includes(entity.typeId)) return;\n entity.teleport({ x: 0, y: -64, z: 0 }, entity.dimension, 0, 0);\n entity.kill();\n});\n\nEntitiesLoad.subscribe(() => {\n system.runSchedule(async () => {\n for (const region of await Region.getAllRegionsSync()) {\n for (const entity of DIMENSIONS[\n region.dimensionId as keyof typeof DIMENSIONS\n ].getEntities({ excludeTypes: region.permissions.allowedEntities })) {\n if (!region.entityInRegion(entity)) continue;\n entity.teleport({ x: 0, y: -64, z: 0 }, entity.dimension, 0, 0);\n entity.kill();\n }\n }\n }, 100);\n});\n\n/**\n * Gives player a tag if they are in a region\n */\nTABLES.regions.onLoad(() => {\n forEachPlayer.subscribe((player) => {\n for (const region of Region.getAllRegions()) {\n if (region.entityInRegion(player)) {\n player.addTag(`inRegion`);\n if (!region.permissions.pvp) player.addTag(`region-protected`);\n } else {\n player.removeTag(`inRegion`);\n player.removeTag(`region-protected`);\n }\n }\n }, 5);\n});\n", "import { world } from \"@minecraft/server\";\r\nimport { TABLES } from \"../../tables.js\";\r\nimport { getRole, isLockedDown, kick, setRole } from \"../../utils\";\r\nimport { Mute } from \"../models/Mute\";\r\nimport { ChangePlayerRoleTask } from \"../models/Task\";\r\nimport { text } from \"../../../../rubedo/lang/text.js\";\r\n\r\nworld.events.playerSpawn.subscribe(({ player }) => {\r\n TABLES.ids.onLoad(() => {\r\n if (isLockedDown() && getRole(player) != \"admin\")\r\n return kick(player, text[\"lockdown.kick.message\"]());\r\n // --\r\n if (Mute.getMuteData(player))\r\n player.runCommandAsync(`ability @s mute true`);\r\n if (!TABLES.ids.has(player.name)) {\r\n // Player is new!\r\n TABLES.ids.set(player.name, player.id);\r\n }\r\n /**\r\n * This is a role that was tried to push when the player was offline\r\n * so were setting it now because the player just joined\r\n */\r\n const roleToSet = ChangePlayerRoleTask.getPlayersRoleToSet(player.name);\r\n if (roleToSet) setRole(player, roleToSet);\r\n });\r\n});\r\n", "import {\n Entity,\n InventoryComponentContainer,\n Items,\n MinecraftItemTypes,\n world,\n} from \"@minecraft/server\";\nimport { AIR } from \"../../../../rubedo/lib/Chest GUI\";\nimport { PageItem } from \"../../../../rubedo/lib/Chest GUI/Models/PageItem\";\nimport { Page } from \"../../../../rubedo/lib/Chest GUI/Models/Page\";\nimport { CHESTGUIS } from \"../../../../rubedo/lib/Chest GUI/utils\";\n\n/**\n * The possible fillable slots where items can be put\n * this is for inventory fill\n */\nconst FILLABLE_SLOTS = [\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,\n 41, 42, 43, 44,\n];\n\n/**\n * Fills the chest Screen with the desired kit\n */\nexport function ViewPlayersFill(entity: Entity, page: Page, extras: any) {\n const container: InventoryComponentContainer = entity.getComponent(\n \"minecraft:inventory\"\n ).container;\n\n for (let i = 0; i < container.size; i++) {\n const slot = page.slots[i];\n if (!slot || !slot.item) {\n container.setItem(i, AIR);\n continue;\n }\n container.setItem(i, slot.item.itemStack);\n }\n for (const [i, player] of [...world.getPlayers()].entries()) {\n const slot = FILLABLE_SLOTS[i];\n const item = new PageItem(MinecraftItemTypes.skull, {\n nameTag: player.name,\n data: 3,\n });\n container.setItem(slot, item.itemStack);\n page.slots[slot] = {\n item: item,\n action: (ctx) => {\n ctx.PageAction(\"moderation:see_inventory\", { name: player.name });\n },\n };\n }\n}\n\n/**\n * Fills the chest Screen with the desired kit\n */\nexport function ViewPlayerInventoryFill(\n entity: Entity,\n page: Page,\n extras: any\n) {\n const container = entity.getComponent(\"minecraft:inventory\").container;\n\n for (let i = 0; i < container.size; i++) {\n const slot = page.slots[i];\n if (!slot || !slot.item) {\n container.setItem(i, AIR);\n continue;\n }\n container.setItem(i, slot.item.itemStack);\n }\n\n const player = [...world.getPlayers()].find((p) => p.name == extras.name);\n if (!player) {\n const gui = Object.values(CHESTGUIS).find((e) => e.entity.id == entity.id);\n gui.despawn();\n player.tell(`\"${extras.name}\" Could not be found, Gui Crashed`);\n }\n const inventory = player.getComponent(\"inventory\").container;\n /**\n * the value of how many slots have been taken\n */\n let used_slots = 0;\n for (let i = 0; i < inventory.size; i++) {\n const item = inventory.getItem(i);\n const slot = FILLABLE_SLOTS[used_slots];\n used_slots++;\n if (!item) {\n container.setItem(slot, AIR);\n continue;\n }\n container.setItem(slot, item);\n page.slots[slot] = {\n item: new PageItem(\n Items.get(item.typeId),\n { amount: item.amount, data: item.data },\n item\n ),\n action: (ctx) => {\n if (i < 9) {\n player.runCommandAsync(`replaceitem entity @s slot.hotbar ${i} air`);\n } else {\n player.runCommandAsync(\n `replaceitem entity @s slot.inventory ${i - 9} air`\n );\n }\n ctx.GiveAction();\n page.slots[slot] = {\n item: null,\n action: (ctx) => {\n inventory.addItem(ctx.getItemAdded());\n },\n };\n },\n };\n }\n}\n\nnew Page(\"moderation:see\", ViewPlayersFill)\n .setSlots(\n [50],\n new PageItem(MinecraftItemTypes.arrow, {\n nameTag: \"\u00A7fBack\",\n }),\n (ctx) => {\n ctx.PageAction(\"home\");\n }\n )\n .setSlots(\n [48],\n new PageItem(MinecraftItemTypes.barrier, { nameTag: \"\u00A7cClose GUI\" }),\n (ctx) => {\n ctx.CloseAction();\n }\n );\n\nnew Page(\"moderation:see_inventory\", ViewPlayerInventoryFill)\n .setSlots(\n [50],\n new PageItem(MinecraftItemTypes.arrow, {\n nameTag: \"\u00A7fBack\",\n }),\n (ctx) => {\n ctx.PageAction(\"moderation:see\");\n }\n )\n .setSlots(\n [48],\n new PageItem(MinecraftItemTypes.barrier, { nameTag: \"\u00A7cClose GUI\" }),\n (ctx) => {\n ctx.CloseAction();\n }\n );\n", "import { GameMode, world } from \"@minecraft/server\";\nimport { getRole } from \"../../utils.js\";\nimport { Ban } from \"../models/Ban.js\";\nimport { Protection } from \"../models/Protection.js\";\nimport { Log } from \"../models/Log.js\";\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog.js\";\n\n/**\n * The gamemode that you cannot be in unless you have staff tag\n */\nconst ILLEGAL_GAMEMODE = GameMode.creative;\n\n/**\n * Stores per world load violation data for players\n */\nconst ViolationCount = new PlayerLog();\n\nconst protection = new Protection<{\n clearPlayer: boolean;\n setToSurvival: boolean;\n banPlayer: boolean;\n violationCount: number;\n}>(\n \"gamemode\",\n \"Blocks illegal gamemode\",\n \"textures/ui/creative_icon.png\",\n true\n).setConfigDefault({\n clearPlayer: {\n description: \"Whether to clear players inventory.\",\n defaultValue: true,\n },\n setToSurvival: {\n description: \"If player should be set to survival after being flagged.\",\n defaultValue: true,\n },\n banPlayer: {\n description: \"If player should be banned after violation count is met.\",\n defaultValue: false,\n },\n violationCount: {\n description: \"The amount of violations before ban.\",\n defaultValue: 0,\n },\n});\n\nprotection.runSchedule(() => {\n const config = protection.getConfig();\n for (const player of world.getPlayers({ gameMode: ILLEGAL_GAMEMODE })) {\n if ([\"moderator\", \"admin\", \"builder\"].includes(getRole(player))) continue;\n try {\n if (config.setToSurvival) player.runCommandAsync(`gamemode s`);\n if (config.clearPlayer) player.runCommandAsync(`clear @s`);\n } catch (error) {}\n new Log({\n playerName: player.name,\n protection: \"Gamemode\",\n message: `${player.name} has entered into a illegal gamemode!`,\n });\n const count = (ViolationCount.get(player) ?? 0) + 1;\n ViolationCount.set(player, count);\n if (config.banPlayer && count >= config.violationCount)\n new Ban(player, null, \"Illegal Gamemode\");\n }\n}, 20);\n", "import { Events, Player, system, world } from \"@minecraft/server\";\r\nimport { TABLES } from \"../../tables.js\";\r\nimport { EventsReturnType, IProtectionsConfig } from \"../../types.js\";\r\nimport { PROTECTIONS } from \"../../protections.js\";\r\nimport { forEachPlayer } from \"../../../../rubedo/lib/Events/forEachPlayer.js\";\r\n\r\n/**\r\n * A protection instance\r\n */\r\nexport class Protection {\r\n /**\r\n * Events that this is subscribed to\r\n */\r\n private events: {\r\n -readonly [Key in keyof Events]+?: {\r\n /**\r\n * Callback this event is to run.\r\n */\r\n callback: ReturnType;\r\n /**\r\n * If this has been triggered on world.events\r\n */\r\n triggered: boolean;\r\n };\r\n };\r\n\r\n /**\r\n * List of events that this protection is scheduled\r\n */\r\n private schedules: {\r\n /**\r\n * Callback to run\r\n */\r\n callback: () => void;\r\n /**\r\n * Delay in ticks\r\n */\r\n tickInterval: number;\r\n /**\r\n * If null, this event hasn't been registered by {@link system.runSchedule}\r\n * if {@link number}, the event has been registered and this key can be used to {@link system.clearRunSchedule}\r\n */\r\n runScheduleId: number | null;\r\n }[];\r\n\r\n /**\r\n * A list of forEachPlayer keys used to unsubscribe\r\n */\r\n private forEachPlayers: {\r\n /**\r\n * Callback to run\r\n * @param player\r\n * @returns\r\n */\r\n callback: (player: Player) => void;\r\n /**\r\n * Delay in ticks\r\n */\r\n delay: number;\r\n /**\r\n * If null, this event hasn't been registered by {@link forEachPlayer}\r\n * if {@link number}, the event has been registered and this key can be used to unsubscribe\r\n */\r\n key: number | null;\r\n }[];\r\n\r\n /**\r\n * Callback to run on enable\r\n */\r\n private onEnableCallback: () => void | undefined;\r\n\r\n /**\r\n * Callback to run on disable\r\n */\r\n private onDisableCallback: () => void | undefined;\r\n\r\n /**\r\n * If this protection is enabled\r\n */\r\n private isEnabled: boolean;\r\n\r\n /**\r\n * The default config object\r\n */\r\n configDefault:\r\n | {\r\n [key in keyof Config]: {\r\n description: string;\r\n defaultValue: Config[key];\r\n };\r\n }\r\n | {};\r\n\r\n /**\r\n * Creates a new protection module\r\n */\r\n constructor(\r\n public name: string,\r\n public description: string,\r\n public iconPath: string,\r\n public isEnabledByDefault: boolean\r\n ) {\r\n this.name = name;\r\n this.description = description;\r\n this.iconPath = iconPath;\r\n this.configDefault = {};\r\n this.isEnabled = false;\r\n this.isEnabledByDefault = isEnabledByDefault;\r\n // ---- events\r\n this.events = {};\r\n this.schedules = [];\r\n this.forEachPlayers = [];\r\n // Save protection\r\n PROTECTIONS[this.name] = this;\r\n }\r\n\r\n /**\r\n * Sets the config to a typed object\r\n * @param data typed object\r\n * @returns\r\n */\r\n setConfigDefault(data: {\r\n [key in keyof Config]: {\r\n description: string;\r\n defaultValue: Config[key];\r\n };\r\n }): Protection {\r\n this.configDefault = data;\r\n TABLES.protections.hasSync(this.name).then((v) => {\r\n if (v) return;\r\n let saveData: IProtectionsConfig = {\r\n enabled: true,\r\n };\r\n for (const key of Object.keys(data)) {\r\n // @ts-ignore\r\n saveData[key] = data[key as keyof typeof data].defaultValue;\r\n }\r\n TABLES.protections.set(this.name, saveData);\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the config data\r\n * @returns Config\r\n */\r\n getConfig(): Config {\r\n let config = TABLES.protections.get(this.name);\r\n if (!config) config = { enabled: this.isEnabled };\r\n return config as Config;\r\n }\r\n\r\n async setConfig(data: Config) {\r\n return TABLES.protections.set(this.name, data as IProtectionsConfig);\r\n }\r\n\r\n /**\r\n * Triggers a change to a activate this module or not.\r\n * @param enabled if this protection is enabled or not\r\n */\r\n private triggerChange(enabled: boolean) {\r\n if (enabled) {\r\n this.isEnabled = true;\r\n // Enable this protection\r\n this.onEnableCallback?.();\r\n for (const [key, value] of Object.entries(this.events)) {\r\n if (value.triggered) continue;\r\n let callback = world.events[key as keyof Events].subscribe(\r\n // @ts-ignore\r\n value.callback\r\n );\r\n value.triggered = true;\r\n value.callback = callback;\r\n }\r\n for (const v of this.forEachPlayers) {\r\n if (v.key) continue;\r\n let key = forEachPlayer.subscribe(v.callback, v.delay);\r\n v.key = key;\r\n }\r\n for (const v of this.schedules) {\r\n if (v.runScheduleId) continue;\r\n let runScheduleId = system.runSchedule(v.callback);\r\n v.runScheduleId = runScheduleId;\r\n }\r\n } else {\r\n this.isEnabled = false;\r\n // Disable this protection\r\n this.onDisableCallback?.();\r\n for (const [key, value] of Object.entries(this.events)) {\r\n if (!value.triggered) continue;\r\n // @ts-ignore\r\n world.events[key as keyof Events].unsubscribe(value.callback);\r\n value.triggered = false;\r\n }\r\n for (const v of this.forEachPlayers) {\r\n if (!v.key) continue;\r\n forEachPlayer.unsubscribe(v.key);\r\n v.key = null;\r\n }\r\n for (const v of this.schedules) {\r\n if (!v.runScheduleId) continue;\r\n system.clearRunSchedule(v.runScheduleId);\r\n v.runScheduleId = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Runs a callback once this protection is activated\r\n * @param callback function to run\r\n */\r\n onEnable(callback: () => void): Protection {\r\n this.onEnableCallback = callback;\r\n return this;\r\n }\r\n\r\n /**\r\n * Runs a callback once this protection is disabled\r\n * @param callback function to run\r\n */\r\n onDisable(callback: () => void): Protection {\r\n this.onDisableCallback = callback;\r\n return this;\r\n }\r\n\r\n /**\r\n * Subscribes to a worldEvent\r\n * @param id event id to subscribe\r\n * @param callback what to run on event callback\r\n * @returns this\r\n */\r\n subscribe(\r\n id: T,\r\n callback: EventsReturnType\r\n ): Protection {\r\n this.events[id] = {\r\n callback: callback,\r\n triggered: false,\r\n };\r\n return this;\r\n }\r\n\r\n /**\r\n * Schedules a callback to be run every x number of ticks\r\n * @param callback callback\r\n * @param tickInterval ticks\r\n */\r\n runSchedule(callback: () => void, tickInterval?: number): Protection {\r\n this.schedules.push({\r\n callback: callback,\r\n tickInterval: tickInterval,\r\n runScheduleId: null,\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Callback for each valid players\r\n * @param callback\r\n * @param delay\r\n */\r\n forEachPlayer(\r\n callback: (player: Player) => void,\r\n delay: number = 0\r\n ): Protection {\r\n this.forEachPlayers.push({\r\n callback: callback,\r\n delay: delay,\r\n key: null,\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Enables this protection\r\n */\r\n enable() {\r\n this.triggerChange(true);\r\n }\r\n\r\n /**\r\n * Disables this protection\r\n */\r\n disable() {\r\n this.triggerChange(false);\r\n }\r\n}\r\n", "import { Player, world } from \"@minecraft/server\";\r\n\r\nexport class PlayerLog {\r\n data: Map;\r\n events: Object;\r\n\r\n constructor() {\r\n this.data = new Map();\r\n this.events = {\r\n playerLeave: world.events.playerLeave.subscribe((data) =>\r\n this.data.delete(data.playerName)\r\n ),\r\n };\r\n }\r\n\r\n /**\r\n * Logs a player to a value\r\n */\r\n set(player: Player, value: T): void {\r\n this.data.set(player.name, value);\r\n }\r\n\r\n /**\r\n * Gets a players value\r\n */\r\n get(player: Player): T | undefined {\r\n return this.data.get(player.name);\r\n }\r\n\r\n /**\r\n * Tests if a player is on this log\r\n * @param player \r\n * @returns \r\n */\r\n has(player: Player): boolean {\r\n return this.data.has(player.name);\r\n }\r\n\r\n /**\r\n * Deletes a player from log\r\n */\r\n delete(player: Player) {\r\n this.data.delete(player.name);\r\n }\r\n\r\n /**\r\n * Clears this Player log\r\n */\r\n clear() {\r\n this.data.clear();\r\n }\r\n\r\n /**\r\n * Gets all the players in the log\r\n */\r\n playerNames(): Array {\r\n return [...this.data.keys()];\r\n }\r\n\r\n /**\r\n * Checks to see if a player is in this list\r\n * @param player player to check\r\n * @returns\r\n */\r\n includes(player: Player): boolean {\r\n return this.playerNames().includes(player.name);\r\n }\r\n}\r\n", "import {\r\n MinecraftBlockTypes,\r\n MinecraftEffectTypes,\r\n MinecraftItemTypes,\r\n Player,\r\n system,\r\n Vector3,\r\n} from \"@minecraft/server\";\r\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog\";\r\nimport {\r\n ILocationLog,\r\n onPlayerMove,\r\n} from \"../../../../rubedo/lib/Events/onPlayerMove\";\r\nimport { vector3ToBlockLocation } from \"../../../../utils\";\r\nimport {\r\n ANTI_TP_DISTANCE_THRESHOLD,\r\n DIMENSION_SWITCH_Y,\r\n MOVEMENT_CONSTANTS,\r\n MOVEMENT_DISTANCE_THRESHOLD,\r\n RIPTIDE_TIMEOUT,\r\n SPEED_EFFECT_INCREASE,\r\n TAGS,\r\n} from \"../../config/movement\";\r\nimport { getRole } from \"../../utils\";\r\nimport { Protection } from \"../models/Protection\";\r\nimport { VALID_BLOCK_TAGS } from \"./nuker\";\r\n\r\nconst violations = new PlayerLog();\r\n\r\n/**\r\n * Players that are on riptide timeout for using a trident\r\n */\r\nconst ON_RIPTIDE_TIMEOUT = new PlayerLog();\r\n\r\n/**\r\n * Calculates the distance from loc1 to loc2\r\n * @param {Location} loc1 location 1\r\n * @param {Location} loc2 location 2\r\n * @returns {number}\r\n */\r\nfunction distanceBetween(loc1: Vector3, loc2: Vector3): number {\r\n return Math.hypot(loc2.x - loc1.x, loc2.z - loc1.z);\r\n}\r\n\r\n/**\r\n * Gets the speed offset based on a players SpeedEffect\r\n * @param player player to get\r\n */\r\nfunction getSpeedOffset(player: Player): number {\r\n const speed = player.getEffect(MinecraftEffectTypes.speed)?.amplifier ?? 0;\r\n return speed * SPEED_EFFECT_INCREASE;\r\n}\r\n\r\n/**\r\n * Checks if a distance traveled is big enough to be flagged\r\n * @param distance distance the player has traveled\r\n * @returns if this distance is bad\r\n */\r\nfunction isDistanceFlag(\r\n distance: number,\r\n tick: number,\r\n player: Player\r\n): boolean {\r\n const speedIntensity = getSpeedOffset(player);\r\n /**\r\n * This is the amount of ticks that have passed\r\n */\r\n const ticks = system.currentTick - tick;\r\n const offset = MOVEMENT_CONSTANTS.run.distance + MOVEMENT_DISTANCE_THRESHOLD;\r\n return distance / ticks > speedIntensity + offset;\r\n}\r\n\r\nfunction flag(player: Player, old: ILocationLog) {\r\n const violationCount = (violations.get(player) ?? 0) + 1;\r\n violations.set(player, violationCount);\r\n onPlayerMove.delete(player); // Reset Players old location\r\n if (violationCount < 3) return;\r\n player.teleport(\r\n old.location,\r\n old.dimension,\r\n player.rotation.x,\r\n player.rotation.y\r\n );\r\n}\r\n\r\nfunction flagPhase(player: Player): boolean {\r\n const blockIn = player.dimension.getBlock(\r\n vector3ToBlockLocation(player.location)\r\n );\r\n if (blockIn.getTags().some((tag) => VALID_BLOCK_TAGS.includes(tag))) return;\r\n if (blockIn.type.id.endsWith(\"grass\")) return;\r\n if (blockIn.type.id.endsWith(\"water\")) return;\r\n if (blockIn.type.id.endsWith(\"lava\")) return;\r\n if (blockIn.type.id.endsWith(\"portal\")) return;\r\n if (blockIn.type.id.endsWith(\"gateway\")) return;\r\n\r\n if (\r\n blockIn.typeId != MinecraftBlockTypes.air.id &&\r\n !blockIn.type.canBeWaterlogged\r\n )\r\n return true;\r\n}\r\n\r\n/**\r\n * The key used to unsubscribe from this event\r\n */\r\nlet onPlayerMoveSubKey: number = null;\r\n\r\nconst protection = new Protection<{\r\n tpCheck: boolean;\r\n}>(\r\n \"movement\",\r\n \"Blocks illegal movements on players\",\r\n \"textures/ui/move.png\",\r\n false\r\n).setConfigDefault({\r\n tpCheck: {\r\n description: \"If teleports should be flagged\",\r\n defaultValue: true,\r\n },\r\n});\r\n\r\nprotection\r\n .onEnable(() => {\r\n const config = protection.getConfig();\r\n onPlayerMoveSubKey = onPlayerMove.subscribe((player, old) => {\r\n if (getRole(player) == \"admin\") return;\r\n if (player.dimension.id != old.dimension.id) return;\r\n if (player.getTags().some((tag) => TAGS.includes(tag))) return;\r\n const distance = distanceBetween(player.location, old.location);\r\n if (player.hasTag(`skip-movement-check`))\r\n return player.removeTag(`skip-movement-check`);\r\n if (old.location.y == DIMENSION_SWITCH_Y) return;\r\n if (ON_RIPTIDE_TIMEOUT.has(player)) return;\r\n if (flagPhase(player)) return flag(player, old);\r\n if (distance > ANTI_TP_DISTANCE_THRESHOLD) {\r\n if (!config.tpCheck) return;\r\n // Anti Tp.\r\n flag(player, old);\r\n } else {\r\n // Anti speed/jet pack\r\n if (!isDistanceFlag(distance, old.currentTick, player)) return;\r\n // Flagged\r\n flag(player, old);\r\n }\r\n });\r\n })\r\n .onDisable(() => {\r\n onPlayerMove.unsubscribe(onPlayerMoveSubKey);\r\n });\r\n\r\nprotection.subscribe(\"dataDrivenEntityTriggerEvent\", (data) => {\r\n if (!(data.entity instanceof Player)) return;\r\n if (data.id != \"on_death\") return;\r\n const player = data.entity;\r\n system.run(() => {\r\n onPlayerMove.delete(player);\r\n }); // Reset Players old location\r\n});\r\n\r\nprotection.subscribe(\"projectileHit\", ({ projectile, source }) => {\r\n if (projectile.typeId != MinecraftItemTypes.enderPearl.id) return;\r\n if (!(source instanceof Player)) return;\r\n onPlayerMove.delete(source); // Reset Players old location\r\n});\r\n\r\nprotection.subscribe(\"itemCompleteCharge\", ({ itemStack, source }) => {\r\n if (itemStack.typeId != MinecraftItemTypes.chorusFruit.id) return;\r\n if (!(source instanceof Player)) return;\r\n onPlayerMove.delete(source); // Reset Players old location\r\n});\r\n\r\nprotection.subscribe(\"itemReleaseCharge\", ({ itemStack, source }) => {\r\n if (itemStack.typeId != MinecraftItemTypes.trident.id) return;\r\n if (!(source instanceof Player)) return;\r\n ON_RIPTIDE_TIMEOUT.set(source, true);\r\n system.runSchedule(() => {\r\n ON_RIPTIDE_TIMEOUT.delete(source);\r\n }, RIPTIDE_TIMEOUT);\r\n});\r\n", "import { Dimension, Player, system, Vector3, world } from \"@minecraft/server\";\r\nimport { PlayerLog } from \"../../database/types/PlayerLog\";\r\n\r\ntype onPlayerMoveCallback = (player: Player, data: ILocationLog) => void;\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: onPlayerMoveCallback;\r\n };\r\n} = {};\r\n\r\nexport interface ILocationLog {\r\n /**\r\n * The Location this is\r\n */\r\n location: Vector3;\r\n /**\r\n * The dimension this location was in\r\n */\r\n dimension: Dimension;\r\n /**\r\n * The tick this was set at\r\n */\r\n currentTick: number\r\n}\r\n\r\n/**\r\n * Checks if two vectors are the same\r\n * @param from first vector\r\n * @param to second vector\r\n */\r\nfunction vector3Equals(from: Vector3, to: Vector3): boolean {\r\n if (from.x != to.x) return false;\r\n if (from.y != to.y) return false;\r\n if (from.z != to.z) return false;\r\n return true;\r\n}\r\n\r\n/**\r\n * Stores Last Previous grounded location\r\n */\r\nexport const playerLocation = new PlayerLog();\r\n\r\nsystem.runSchedule(() => {\r\n const sendCallback = (player: Player, data: ILocationLog) => {\r\n for (const callback of Object.values(CALLBACKS)) {\r\n callback.callback(player, data);\r\n }\r\n };\r\n for (const player of world.getPlayers()) {\r\n const oldLocation = playerLocation.get(player);\r\n if (oldLocation) {\r\n if (vector3Equals(player.location, oldLocation.location)) {\r\n continue;\r\n }\r\n }\r\n playerLocation.set(player, {\r\n location: player.location,\r\n dimension: player.dimension,\r\n currentTick: system.currentTick\r\n });\r\n if (!oldLocation) continue;\r\n sendCallback(player, oldLocation);\r\n }\r\n});\r\n\r\nexport class onPlayerMove {\r\n /**\r\n * Subscribes to a callback to get notified when a player moves\r\n * @param callback what to be called when one of these entity's inventory changes\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(callback: onPlayerMoveCallback): number {\r\n const key = Date.now();\r\n CALLBACKS[key] = { callback: callback };\r\n return key;\r\n \r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n /**\r\n * Clears a players location\r\n * @param player player to clear\r\n */\r\n static delete(player: Player): void {\r\n playerLocation.delete(player);\r\n }\r\n}\r\n", "/**\r\n * The leeway that the distances can be off before it flags\r\n */\r\nexport const MOVEMENT_DISTANCE_THRESHOLD = 0.60;\r\n\r\n/**\r\n * Constant of speeds when players are moving per tick\r\n */\r\nexport const MOVEMENT_CONSTANTS = {\r\n walk: {\r\n velocity: 0.17 as const,\r\n distance: 0.23 as const,\r\n },\r\n run: {\r\n velocity: 0.19 as const,\r\n distance: 0.35 as const,\r\n },\r\n};\r\n\r\n/**\r\n * The distance increase per speed effect increase\r\n */\r\nexport const SPEED_EFFECT_INCREASE = 0.056;\r\n\r\n/**\r\n * if the distance is over this amount the system will automatically flag tp\r\n */\r\nexport const ANTI_TP_DISTANCE_THRESHOLD = 10;\r\n\r\n/**\r\n * If your \r\n */\r\nexport const TAGS = [\"gliding\", \"riding\"];\r\n\r\n/**\r\n * This is a Y value that occurs when you die in another dimension and \r\n * you get teleported twice, this should be ignored\r\n */\r\nexport const DIMENSION_SWITCH_Y = 32767.001953125\r\n\r\n/**\r\n * Time in ticks that a player will be on timeout\r\n * for this check\r\n */\r\nexport const RIPTIDE_TIMEOUT = 60", "import {\r\n world,\r\n Location,\r\n Block,\r\n BlockPermutation,\r\n Dimension,\r\n Player,\r\n system,\r\n} from \"@minecraft/server\";\r\nimport { API_CONTAINERS } from \"../../config/containers.js\";\r\nimport { CONTAINER_LOCATIONS } from \"../Containers/index.js\";\r\n\r\ntype beforeBlockBreakCallback = (arg0: BeforeBlockBreakEvent) => void;\r\n\r\nconst CALLBACKS: {\r\n [key: number]: {\r\n callback: beforeBlockBreakCallback;\r\n };\r\n} = {};\r\n\r\nworld.events.blockBreak.subscribe((data) => {\r\n for (const callback of Object.values(CALLBACKS)) {\r\n callback.callback(\r\n new BeforeBlockBreakEvent(\r\n data.block,\r\n data.brokenBlockPermutation,\r\n data.dimension,\r\n data.player\r\n )\r\n );\r\n }\r\n});\r\n\r\nexport class beforeBlockBreak {\r\n /**\r\n * Subscribes to a callback to get notified when a chat is sent that is not a command\r\n * @param callback what to be called when one of these entities inventory's changes\r\n * @returns the id that is used to unsubscribe\r\n */\r\n static subscribe(callback: beforeBlockBreakCallback): number {\r\n const key = Date.now();\r\n CALLBACKS[key] = { callback: callback };\r\n return key;\r\n }\r\n static unsubscribe(key: number): void {\r\n delete CALLBACKS[key];\r\n }\r\n}\r\n\r\nclass BeforeBlockBreakEvent {\r\n /**\r\n * Contains information regarding an event before a player breaks a block.\r\n * @param block Block broken in this event. Note that because this event fires right after a block is broken, the block you will receive will likely be of type 'minecraft:air'. See the .brokenBlockPermutation property for information on this block before it was broken.\r\n * @param brokenBlockPermutation Returns permutation information about this block before it was broken.\r\n * @param dimension Dimension that contains the block that has been broken in this event.\r\n * @param player Player that broke the block for this event.\r\n */\r\n constructor(\r\n public block: Block,\r\n public brokenBlockPermutation: BlockPermutation,\r\n public dimension: Dimension,\r\n public player: Player\r\n ) {\r\n this.block = block;\r\n this.brokenBlockPermutation = brokenBlockPermutation;\r\n this.dimension = dimension;\r\n this.player = player;\r\n }\r\n\r\n set cancel(value: boolean) {\r\n // setting block back\r\n this.dimension\r\n .getBlock(this.block.location)\r\n .setPermutation(this.brokenBlockPermutation.clone());\r\n // setting chest inventory back\r\n if (API_CONTAINERS.includes(this.brokenBlockPermutation.type.id)) {\r\n const OLD_INVENTORY =\r\n CONTAINER_LOCATIONS[JSON.stringify(this.block.location)];\r\n if (OLD_INVENTORY) {\r\n OLD_INVENTORY.load(this.block.getComponent(\"inventory\").container);\r\n }\r\n }\r\n // killing dropped items\r\n system.run(() => {\r\n [\r\n ...this.dimension.getEntities({\r\n maxDistance: 2,\r\n type: \"minecraft:item\",\r\n location: new Location(\r\n this.block.location.x,\r\n this.block.location.y,\r\n this.block.location.z\r\n ),\r\n }),\r\n ].forEach((e) => e.kill());\r\n });\r\n }\r\n}\r\n", "import { getRole } from \"../../utils.js\";\nimport { Ban } from \"../models/Ban.js\";\nimport { Protection } from \"../models/Protection.js\";\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog.js\";\nimport { beforeBlockBreak } from \"../../../../rubedo/lib/Events/beforeBlockBreak.js\";\n\n/**\n * The log of the players break times\n */\nconst log = new PlayerLog();\n\n/**\n * if a block is broken faster than this time it is considered hacking\n */\nconst IMPOSSIBLE_BREAK_TIME = 15;\n\n/**\n * When breaking vegetation blocks it could cause a false trigger\n * so when a block gets broken and it has one of the block tags\n * it gets skipped and doesn't count in the nuker event\n *\n * @link https://wiki.bedrock.dev/blocks/block-tags.html\n */\nexport const VALID_BLOCK_TAGS = [\n \"snow\",\n \"lush_plants_replaceable\",\n \"azalea_log_replaceable\",\n \"minecraft:crop\",\n \"fertilize_area\",\n \"plant\"\n];\n\n/**\n * A list of all the blocks that are impossible to break unless you have hacks\n */\nconst IMPOSSIBLE_BREAKS = [\n \"minecraft:water\",\n \"minecraft:flowing_water\",\n \"minecraft:lava\",\n \"minecraft:flowing_lava\",\n \"minecraft:bedrock\",\n];\n\n/**\n * Stores per world load violation data for players\n */\nconst ViolationCount = new PlayerLog();\n\nlet beforeBlockBreakKey: number = null;\n\nconst protection = new Protection<{\n banPlayer: boolean;\n violationCount: number;\n}>(\n \"nuker\",\n \"Blocks block breaking too fast\",\n \"textures/blocks/dirt.png\",\n true\n).setConfigDefault({\n banPlayer: {\n description: \"If the player should be banned once violation count is met\",\n defaultValue: false,\n },\n violationCount: {\n description: \"Violations before ban\",\n defaultValue: 0,\n },\n});\n\nprotection\n .onEnable(() => {\n const config = protection.getConfig();\n beforeBlockBreakKey = beforeBlockBreak.subscribe((data) => {\n if ([\"moderator\", \"admin\"].includes(getRole(data.player))) return;\n if (data.block.getTags().some((tag) => VALID_BLOCK_TAGS.includes(tag)))\n return;\n const old = log.get(data.player);\n log.set(data.player, Date.now());\n if (!old) return;\n\n // If block is impossible to break skip check, reduces lag.\n if (!IMPOSSIBLE_BREAKS.includes(data.block.typeId)) {\n if (old < Date.now() - IMPOSSIBLE_BREAK_TIME) return;\n const count = (ViolationCount.get(data.player) ?? 0) + 1;\n ViolationCount.set(data.player, count);\n if (config.banPlayer && count >= config.violationCount)\n new Ban(data.player, null, \"Using Nuker\");\n }\n data.cancel = true;\n });\n })\n .onDisable(() => {\n beforeBlockBreak.unsubscribe(beforeBlockBreakKey);\n });\n", "import { PREFIX } from \"../../../../rubedo/config/commands\";\r\nimport { PlayerLog } from \"../../../../rubedo/database/types/PlayerLog\";\r\nimport { getRole } from \"../../utils\";\r\nimport { Mute } from \"../models/Mute\";\r\nimport { Protection } from \"../models/Protection\";\r\n\r\nconst previousMessage = new PlayerLog();\r\n\r\n/**\r\n * Stores per world load violation data for players\r\n */\r\nconst ViolationCount = new PlayerLog();\r\n\r\nconst protection = new Protection<{\r\n permMutePlayer: boolean;\r\n violationCount: number;\r\n repeatedMessages: boolean;\r\n zalgo: boolean;\r\n}>(\r\n \"spam\",\r\n \"Blocks spam in chat\",\r\n \"textures/ui/mute_on.png\",\r\n false\r\n).setConfigDefault({\r\n permMutePlayer: {\r\n description:\r\n \"If player should be permanently muted once violation count is met.\",\r\n defaultValue: false,\r\n },\r\n violationCount: {\r\n description: \"Violation count before permanent mute\",\r\n defaultValue: 0,\r\n },\r\n repeatedMessages: {\r\n description: \"Blocks repeated messages\",\r\n defaultValue: true,\r\n },\r\n zalgo: {\r\n description: \"Blocks zalgo\",\r\n defaultValue: true,\r\n },\r\n});\r\n\r\nprotection.subscribe(\"beforeChat\", (data) => {\r\n try {\r\n if (data.message.startsWith(PREFIX)) return;\r\n if ([\"admin\", \"moderator\"].includes(getRole(data.sender))) return;\r\n const config = protection.getConfig();\r\n const isSpam = () => {\r\n const count = (ViolationCount.get(data.sender) ?? 0) + 1;\r\n ViolationCount.set(data.sender, count);\r\n if (config.permMutePlayer && count >= config.violationCount)\r\n new Mute(data.sender, null, \"Spamming\");\r\n };\r\n if (\r\n config.repeatedMessages &&\r\n previousMessage.get(data.sender) == data.message\r\n ) {\r\n data.cancel = true;\r\n isSpam();\r\n return data.sender.tell(`\u00A7cRepeated message detected!`);\r\n }\r\n if (config.zalgo && /%CC%/g.test(encodeURIComponent(data.message))) {\r\n data.cancel = true;\r\n isSpam();\r\n return data.sender.tell(\r\n `\u00A7cYou message contains some type of zalgo and cannot be sent!`\r\n );\r\n }\r\n previousMessage.set(data.sender, data.message);\r\n } catch (error) {\r\n console.warn(error + error.stack);\r\n }\r\n});\r\n", "import { MinecraftEffectTypes, Player, world } from \"@minecraft/server\";\r\nimport { getServerOwnerName, setRole, setServerOwner } from \"../../utils\";\r\n\r\nlet e = world.events.beforeDataDrivenEntityTriggerEvent.subscribe((data) => {\r\n if (!(data.entity instanceof Player)) return;\r\n if (data.id != \"rubedo:becomeAdmin\") return;\r\n // Rubedo is now verified to be at the top\r\n data.entity.removeTag(\"CHECK_PACK\");\r\n const serverOwnerName = getServerOwnerName();\r\n if (serverOwnerName) {\r\n data.entity.playSound(\"note.bass\");\r\n data.entity.tell(\r\n `\u00A7cFailed to give server owner: \"${serverOwnerName}\" is already owner!`\r\n );\r\n return world.events.beforeDataDrivenEntityTriggerEvent.unsubscribe(e);\r\n }\r\n setRole(data.entity, \"admin\");\r\n setServerOwner(data.entity);\r\n data.entity.addEffect(MinecraftEffectTypes.blindness, 3, 255, true);\r\n data.entity.tell(\r\n `\u00A7aYou have now been set as the \"owner\" of this server. The command \"/function start\" will not do anything anymore, type \"-help\" for more information!`\r\n );\r\n});\r\n", "import {\r\n DynamicPropertiesDefinition,\r\n MinecraftEntityTypes,\r\n world,\r\n} from \"@minecraft/server\";\r\nimport { OBJECTIVES } from \"../../../../rubedo/config/objectives\";\r\n\r\nworld.events.worldInitialize.subscribe(({ propertyRegistry }) => {\r\n let def2 = new DynamicPropertiesDefinition();\r\n def2.defineString(\"role\", 30);\r\n propertyRegistry.registerEntityTypeDynamicProperties(\r\n def2,\r\n MinecraftEntityTypes.player\r\n );\r\n\r\n let def3 = new DynamicPropertiesDefinition();\r\n def3.defineString(\"worldsOwner\", 100);\r\n def3.defineBoolean(\"isLockDown\");\r\n propertyRegistry.registerWorldDynamicProperties(def3);\r\n\r\n for (const obj of OBJECTIVES) {\r\n world.scoreboard.addObjective(obj.objective, obj.displayName ?? \"\");\r\n }\r\n});\r\n", "/*\n|--------------------------------------------------------------------------\n| Objectives\n|--------------------------------------------------------------------------\n|\n| This is a list of all objectives this pack uses\n| please add any objective to this list so it can be added at world creation\n| make sure to add them before sending pack to others and new worlds.\n|\n*/\ninterface IObjective {\n objective: string;\n displayName?: string;\n}\n\nexport const OBJECTIVES: Array = [];\n", "import { Location } from \"@minecraft/server\";\r\nimport \"./tables\";\r\nimport \"./protections\";\r\nimport \"./modules/commands/import\";\r\nimport \"./modules/managers/import\";\r\nimport \"./modules/pages/import\";\r\nimport \"./modules/protections/import\";\r\nimport \"./modules/events/import\";\r\n\r\n/**\r\n * Stores npc locations that are verified to allow NPC's to spawn in\r\n */\r\nexport let NPC_LOCATIONS: Array = [];\r\n\r\nexport function clearNpcLocations() {\r\n NPC_LOCATIONS = [];\r\n}\r\n", "console.warn(`----- Importing Plugins -----`);\r\n\r\nimport \"./Anti-Cheat/index\";\r\n//import \"./ChatRanks/index\";\r\n//import \"./GlobalBans/index\";\r\n"], + "mappings": ";AAAA,SAAS,UAAAA,gBAAc;;;ACAvB,SAA0B,SAAAC,cAAa;;;ACUhC,IAAM,SAAS;;;ACVtB,SAAiB,SAAAC,cAAa;;;ACA9B,SAAiB,WAAW,0BAA0B;;;ACAtD,SAAS,qBAAqB;AAYvB,IAAM,2BAA2B;AAYjC,IAAM,sBAAsB;AAW5B,IAAM,oBAAoB;AAW1B,IAAM,kBAAkB,IAAI,cAAc,GAAG,KAAK,CAAC;AAUnD,IAAM,iBAAiB;;;ACxD9B;AAAA,EACE,iBAAAC;AAAA,EAGA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAKA,IAAM,aAAa;AAAA,EACxB,WAAW,MAAM,aAAa,wBAAwB,SAAS;AAAA,EAC/D,QAAQ,MAAM,aA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AAIC,6BAA4B;AAC3C,OAAK,aAAa,QAAQ,EAAE;AAC5B,mBAAiB;AAAA,IACf;AAAA,IACA,qBAAqB;AAAA,EACvB;AAEA,MAAI,OAAO,IAAIA,6BAA4B;AAC3C,OAAK,aAAa,eAAe,GAAG;AACpC,OAAK,cAAc,YAAY;AAC/B,mBAAiB,+BAA+B,IAAI;AAEpD,aAAW,OAAO,YAAY;AAC5B,IAAAD,QAAM,WAAW,aAAa,IAAI,WAAW,IAAI,eAAe,EAAE;AAAA,EACpE;AACF,CAAC;;;AEXM,IAAI,gBAAiC,CAAC;AAEtC,SAAS,oBAAoB;AAClC,kBAAgB,CAAC;AACnB;;;AChBA,QAAQ,KAAK,+BAA+B;;;AxFO5CE,SAAO,OAAO,wBAAwB,UAAU,CAAC,SAAS;AACxD,OAAK,SAAS;AACd,UAAQ,KAAK,6BAA6B,KAAK,iBAAiB;AAClE,CAAC;", + "names": ["system", "world", "world", "BlockLocation", "BlockLocation", "system", "world", "system", "e", "world", "e", "i", "world", "text", "e", "command", "world", "command", "v", "ItemStack", "MinecraftItemTypes", "system", "world", "system", "system", "CALLBACKS", "system", "Location", "e", "text", "system", "ItemStack", "MinecraftItemTypes", "world", "Player", "BlockLocation", "MinecraftBlockTypes", "BlockLocation", "BlockLocation", "MinecraftBlockTypes", "MinecraftItemTypes", "Player", "world", "BlockLocation", "MinecraftBlockTypes", "ItemStack", "MinecraftItemTypes", "system", "world", "world", "world", "system", "world", "MinecraftBlockTypes", "system", "world", "protection", "Player", "Player", "text", "ban", "root", "root", "freeze", "root", "command", "world", "world", "root", "mute", "Location", "Location", "system", "system", "BlockLocation", "BlockLocation", "ROLES", "root", "text", "i", "protection", "keys", "world", "world", "root", "protection", "root", "system", "world", "CALLBACKS", "system", "world", "Location", "Location", "world", "CALLBACKS", "world", "BlockLocation", "system", "world", "system", "world", "BlockLocation", "world", "world", "MinecraftItemTypes", "world", "world", "MinecraftItemTypes", "e", "ctx", "GameMode", "world", "system", "world", "world", "system", "world", "GameMode", "world", "MinecraftBlockTypes", "MinecraftItemTypes", "Player", "system", "system", "world", "CALLBACKS", "system", "sendCallback", "world", "world", "Location", "system", "CALLBACKS", "world", "system", "Location", "e", "ViolationCount", "protection", "system", "MinecraftBlockTypes", "protection", "Player", "MinecraftItemTypes", "ViolationCount", "protection", "MinecraftEffectTypes", "Player", "world", "world", "Player", "MinecraftEffectTypes", "DynamicPropertiesDefinition", "world", "world", "DynamicPropertiesDefinition", "system"] } diff --git a/src/rubedo/config/database.ts b/src/rubedo/config/database.ts index c5a8e7e..34f0bad 100644 --- a/src/rubedo/config/database.ts +++ b/src/rubedo/config/database.ts @@ -12,6 +12,18 @@ import { BlockLocation } from "@minecraft/server"; */ export const MAX_DATABASE_STRING_SIZE = 32000; +/* +|-------------------------------------------------------------------------- +| Max Lore Array Size +|-------------------------------------------------------------------------- +| +| Here is the max database lore size meaning when a save gets made +| it tests the size of that lore array is bigger than this then splits up +| the length. It's related to int32 NBT storage of lists. +| +*/ +export const MAX_LORE_ARRAY_SIZE = 2000000; + /* |-------------------------------------------------------------------------- | Entity Id @@ -21,7 +33,7 @@ export const MAX_DATABASE_STRING_SIZE = 32000; | of the database on its nameTag | */ -export const ENTITY_IDENTIFIER = "rubedo:database"; +export const ENTITY_IDENTIFIER = "database:database"; /* |-------------------------------------------------------------------------- @@ -43,3 +55,13 @@ export const ENTITY_LOCATION = new BlockLocation(0, -64, 0); | */ export const INVENTORY_SIZE = 128; + +/* +|-------------------------------------------------------------------------- +| Back Up Name +|-------------------------------------------------------------------------- +| +| The structure file name for the backed up data in this database +| +*/ +export const BACKUP_NAME = "database:entities"; diff --git a/src/rubedo/database/Database.ts b/src/rubedo/database/Database.ts index 0def9c0..5ae3d41 100644 --- a/src/rubedo/database/Database.ts +++ b/src/rubedo/database/Database.ts @@ -4,9 +4,10 @@ import { ENTITY_LOCATION, INVENTORY_SIZE, MAX_DATABASE_STRING_SIZE, + MAX_LORE_ARRAY_SIZE, } from "../config/database"; +import { DIMENSIONS, splitString } from "../../utils"; import { EntitiesLoad } from "../lib/Events/EntitiesLoad"; -import { DIMENSIONS, chunkString } from "../../utils"; export class Database { /** @@ -41,22 +42,39 @@ export class Database { ); } + /** + * Despawn's all database entities + */ + static despawnTableEntities() { + return DIMENSIONS.overworld + .getEntitiesAtBlockLocation(ENTITY_LOCATION) + .map((e) => e.triggerEvent("despawn")); + } + /** * Data saved in memory */ - private MEMORY: { [key in Key]: Value } | null; + private MEMORY: { [key in Key]: Value }; /** * List of queued tasks on this table */ private QUEUE: Array<() => void>; + private onLoadCallback: (data: Database["MEMORY"]) => void; + + /** + * Creates a new instance of the Database + * @param tableName - The name of the table + */ constructor(public tableName: string) { this.tableName = tableName; this.MEMORY = null; this.QUEUE = []; + this.onLoadCallback = null; EntitiesLoad.subscribe(async () => { - await this.initData(); + const data = await this.initData(); + this.onLoadCallback(data); this.QUEUE.forEach((v) => v()); }); } @@ -73,24 +91,16 @@ export class Database { /** * Saves data into this database - * @param data - * @returns once data is saved + * @returns once data is saved to the database entities */ private async saveData(): Promise { if (!this.MEMORY) await this.addQueueTask(); - let entities = Database.getTableEntities(this.tableName); - /** - * The split chunks of the stringified data, This is done because we can - * only store {@link MAX_DATABASE_STRING_SIZE} chars in a single nameTag - */ - let chunks = chunkString( + let chunks = splitString( JSON.stringify(this.MEMORY), - MAX_DATABASE_STRING_SIZE + MAX_DATABASE_STRING_SIZE, + MAX_LORE_ARRAY_SIZE ); - /** - * The amount of entities that is needed to store {@link chunks} data - */ const entitiesNeeded = Math.ceil(chunks.length / INVENTORY_SIZE) - entities.length; if (entitiesNeeded > 0) { @@ -98,31 +108,29 @@ export class Database { entities.push(Database.createTableEntity(this.tableName)); } } - - let chunkIndex = 0; - for (const [i, entity] of entities.entries()) { + let savedChunks = 0; + let i = 0; + while (savedChunks < chunks.length) { + const entity = entities[i]; + if (!entity) continue; const inventory = entity.getComponent("inventory").container; - while (chunkIndex < chunks.length && inventory.size > 0) { + inventory.clearAll(); + for (let j = 0; j < inventory.size && savedChunks < chunks.length; j++) { + const chunk = chunks[savedChunks]; let item = new ItemStack(MinecraftItemTypes.acaciaBoat); - item.nameTag = chunks[chunkIndex]; - inventory.setItem(i, item); - chunkIndex++; - } - // Set all unUsed slots to air - for (let i = inventory.size; i < INVENTORY_SIZE; i++) { - inventory.setItem(i, new ItemStack(MinecraftItemTypes.stick, 0)); + item.setLore(chunk); + inventory.setItem(j, item); + savedChunks++; } entity.setDynamicProperty("index", i); + i++; } - // Check for unUsed entities and despawn them - for (let i = entities.length - 1; i >= chunkIndex / INVENTORY_SIZE; i--) { - entities[i].triggerEvent("despawn"); - } + entities.slice(i).forEach((e) => e?.triggerEvent("despawn")); } /** * Grabs Data and should only be used on worldLoad - * @returns + * @returns {Promise<{ [key in Key]: Value }>} The parsed data. */ private async initData(): Promise<{ [key in Key]: Value }> { let entities = Database.getTableEntities(this.tableName).sort( @@ -130,24 +138,37 @@ export class Database { (a.getDynamicProperty("index") as number) - (b.getDynamicProperty("index") as number) ); - let stringifiedData: string = ""; + if (entities.length == 0) { + console.warn( + `[Database-Warning]: No data found for table ${this.tableName}!` + ); + } + const stringifiedData: string[] = []; for (const entity of entities) { const inventory = entity.getComponent("inventory").container; for (let i = 0; i < inventory.size; i++) { const item = inventory.getItem(i); - if (!item) continue; - stringifiedData = stringifiedData + item.nameTag; + if (item) stringifiedData.push(...item.getLore()); } } - const data = stringifiedData == "" ? {} : JSON.parse(stringifiedData); - this.MEMORY = data; - return data; + this.MEMORY = JSON.parse(stringifiedData.join("") || "{}"); + console.warn(`table ${this.tableName} memor ${this.MEMORY}`); + return this.MEMORY; + } + + /** + * Sends a callback once this database has initiated data + * @param callback + */ + async onLoad(callback: Database["onLoadCallback"]) { + this.onLoadCallback = callback; } /** - * Sets a key to a value in this table - * @param key - * @param value + * Sets the specified `key` to the given `value` in the database table. + * @param key - Key to store the value in. + * @param value - The value to store for the specified key. + * @returns A promise that resolves once the value has been saved in the database table. */ async set(key: Key, value: Value): Promise { this.MEMORY[key] = value; @@ -156,8 +177,8 @@ export class Database { /** * Gets a value from this table - * @param key - * @returns the keys corresponding key + * @param {Key} key - The key to retrieve the value for. + * @returns the value associated with the given key in the database table. */ get(key: Key): Value { if (!this.MEMORY) @@ -168,10 +189,9 @@ export class Database { } /** - * Gets a value async from this table, this should be used on calls from like - * entityCreate, system.runSchedule or things that could be before database entities spawn - * @param key - * @returns + * Gets a value asynchronously from the database table. + * @param {Key} key - The key to retrieve the value for. + * @returns {Promise} A Promise that resolves to the value associated with the given key in the database table. */ async getSync(key: Key): Promise { if (this.MEMORY) return this.get(key); @@ -181,7 +201,7 @@ export class Database { /** * Get all the keys in the table - * @returns + * @returns {Key[]} the keys on this table */ keys(): Key[] { if (!this.MEMORY) @@ -193,7 +213,7 @@ export class Database { /** * Get all the keys in the table async, this should be used on world load - * @returns + * @returns {Promise} the keys on this table */ async keysSync(): Promise { if (this.MEMORY) return this.keys(); @@ -203,7 +223,7 @@ export class Database { /** * Get all the values in the table - * @returns + * @returns {Value[]} values in this table */ values(): Value[] { if (!this.MEMORY) @@ -215,7 +235,7 @@ export class Database { /** * Get all the values in the table async, this should be used on world load - * @returns + * @returns {Promise} the values on this table */ async valuesSync(): Promise { if (this.MEMORY) return this.values(); @@ -225,8 +245,8 @@ export class Database { /** * Check if the key exists in the table - * @param key the key to test - * @returns + * @param {Key} key the key to test + * @returns {boolean} if this key exists on this table */ has(key: Key): boolean { if (!this.MEMORY) @@ -235,9 +255,9 @@ export class Database { } /** - * Check if the key exists in the table async, this should be used on worldLoad - * @param key the key to test - * @returns + * Check if the key exists in the table async + * @param {Key} key the key to test + * @returns {Promise} if this table contains this key. */ async hasSync(key: Key): Promise { if (this.MEMORY) return this.has(key); @@ -247,7 +267,7 @@ export class Database { /** * Gets all the keys and values - * @returns + * @returns { [key in Key]: Value } The collection data. */ collection(): { [key in Key]: Value } { if (!this.MEMORY) @@ -259,7 +279,7 @@ export class Database { /** * Gets all the keys and values async, this should be used for grabbingCollection on world load - * @returns + * @returns {Promise<{ [key in Key]: Value }>} The collection data. */ async collectionSync(): Promise<{ [key in Key]: Value }> { if (this.MEMORY) return this.collection(); @@ -268,9 +288,9 @@ export class Database { } /** - * Delete the key from the table + * Delete a key from this table * @param key the key to delete - * @returns + * @returns if the deletion was successful */ async delete(key: Key): Promise { const status = delete this.MEMORY[key]; @@ -280,9 +300,10 @@ export class Database { /** * Clear everything in the table + * @returns once this table has been cleared */ async clear(): Promise { this.MEMORY = {} as { [key in Key]: Value }; - return this.saveData(); + return await this.saveData(); } } diff --git a/src/rubedo/lib/Command/ArgumentTypes.ts b/src/rubedo/lib/Command/ArgumentTypes.ts index 32bf4bf..67fa7d4 100644 --- a/src/rubedo/lib/Command/ArgumentTypes.ts +++ b/src/rubedo/lib/Command/ArgumentTypes.ts @@ -1,5 +1,5 @@ import { Player, world } from "@minecraft/server"; -import { Database } from "../../database/Database"; +import { TABLES } from "../../../vendor/Anti-Cheat/tables"; /** * Fetch an online players data @@ -232,8 +232,7 @@ export class PlayerNameArgumentType implements IArgumentType { type: string; typeName = "playerName"; matches(value: string): IArgumentReturnData { - const db = new Database("ids"); - const player = db.get(value); + const player = TABLES.ids.get(value); return { success: player ? true : false, value: value, diff --git a/src/rubedo/lib/Command/utils.ts b/src/rubedo/lib/Command/utils.ts index c7d02fe..c252636 100644 --- a/src/rubedo/lib/Command/utils.ts +++ b/src/rubedo/lib/Command/utils.ts @@ -1,4 +1,4 @@ -import { BeforeChatEvent, Player, Vector, Vector3 } from "@minecraft/server"; +import { BeforeChatEvent, Player, Vector3 } from "@minecraft/server"; import { PREFIX } from "../../config/commands"; import { LiteralArgumentType, LocationArgumentType } from "./ArgumentTypes"; import { CommandCallback } from "./Callback"; @@ -108,11 +108,11 @@ export function commandSyntaxFail( */ export function parseLocationArgs( [x, y, z]: [x: string, y: string, z: string], - { location, viewVector }: { location: Vector3; viewVector: Vector } + { location, viewDirection }: { location: Vector3; viewDirection: Vector3 } ): Vector3 { if (!x || !y || !x) return null; const locations = [location.x, location.y, location.z]; - const viewVectors = [viewVector.x, viewVector.y, viewVector.z]; + const viewVectors = [viewDirection.x, viewDirection.y, viewDirection.z]; const a = [x, y, z].map((arg) => { const r = parseFloat(arg); return isNaN(r) ? 0 : r; diff --git a/src/rubedo/lib/Events/EntitiesLoad.ts b/src/rubedo/lib/Events/EntitiesLoad.ts index 90afd50..e8b9cee 100644 --- a/src/rubedo/lib/Events/EntitiesLoad.ts +++ b/src/rubedo/lib/Events/EntitiesLoad.ts @@ -1,6 +1,9 @@ import { system, world } from "@minecraft/server"; import { DIMENSIONS } from "../../../utils"; +/** + * Callbacks that are called when the entities are loaded + */ const CALLBACKS: { [key: number]: () => void; } = {}; @@ -10,45 +13,62 @@ const CALLBACKS: { */ export let ENTITIES_LOADED = false; +/** + * Sets the world as loaded in, meaning entities are now able to be grabbed + */ +function setEntitiesLoaded() { + ENTITIES_LOADED = true; + for (const [i, callback] of Object.entries(CALLBACKS)) { + callback(); + delete CALLBACKS[i as unknown as number]; + } +} + system.run(async () => { try { await DIMENSIONS.overworld.runCommandAsync(`testfor @a`); - ENTITIES_LOADED = true; - for (const [i, callback] of Object.entries(CALLBACKS)) { - callback(); - delete CALLBACKS[i as unknown as number]; - } + setEntitiesLoaded(); } catch (error) { - let e = world.events.entityCreate.subscribe((data) => { - system.run(() => { - ENTITIES_LOADED = true; - for (const [i, callback] of Object.entries(CALLBACKS)) { - callback(); - delete CALLBACKS[i as unknown as number]; - } - world.events.entityCreate.unsubscribe(e); - }); + let e = world.events.playerSpawn.subscribe(() => { + setEntitiesLoaded(); + world.events.playerSpawn.unsubscribe(e); }); } }); +/** + * Class that exposes methods to subscribe to or wait for entities to be loaded. + */ export class EntitiesLoad { + /** + * Returns a Promise that resolves when the entities are loaded. + * @returns {Promise} A Promise that resolves when the entities are loaded. + */ static async awaitLoad(): Promise { if (ENTITIES_LOADED) return; return new Promise((resolve) => { EntitiesLoad.subscribe(resolve); }); } + /** + * Subscribe a callback to be called when the entities are loaded. + * @param {() => void} callback The function to be called when the entities are loaded. + * @returns {number} The key associated with this subscription. + */ static subscribe(callback: () => void): number { + const key = Object.keys(CALLBACKS).length; if (ENTITIES_LOADED) { callback(); - return; + return key; } - const key = Object.keys(CALLBACKS).length; CALLBACKS[key] = callback; return key; } + /** + * Unsubscribe a callback from being called when the entities are loaded. + * @param {number} key The key associated with the subscription to be unsubscribed. + */ static unsubscribe(key: number): void { delete CALLBACKS[key]; } diff --git a/src/utils.ts b/src/utils.ts index 6a9f89e..8e6da42 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -188,3 +188,34 @@ export function betweenVector3( export function chunkString(str: string, length: number): string[] { return str.match(new RegExp(".{1," + length + "}", "g")); } + +/** + * Splits a string into an array of arrays of strings with a maximum length of 32767 characters per string in the innermost array. + * @param str The input string to split. + * @param maxLength Max Length of the 1st array + * @param subArraysMaxLength Max Length of the strings in the 2d array + * @returns A two-dimensional array of strings, where each inner array has a maximum length of 2147483647. + */ +export function splitString( + str: string, + maxLength: number, + subArraysMaxLength: number +): string[][] { + const subStrings: string[] = []; + for (let i = 0; i < str.length; i += maxLength) { + subStrings.push(str.slice(i, i + maxLength)); + } + + const subArrays: string[][] = []; + for (const subString of subStrings) { + subArrays.push( + Array.from( + { length: Math.ceil(subString.length / subArraysMaxLength) }, + (_, i) => + subString.slice(i * subArraysMaxLength, (i + 1) * subArraysMaxLength) + ) + ); + } + + return subArrays; +} \ No newline at end of file diff --git a/src/vendor/Anti-Cheat/config/movement.ts b/src/vendor/Anti-Cheat/config/movement.ts index de0c38b..909a587 100644 --- a/src/vendor/Anti-Cheat/config/movement.ts +++ b/src/vendor/Anti-Cheat/config/movement.ts @@ -1,7 +1,7 @@ /** * The leeway that the distances can be off before it flags */ -export const MOVEMENT_DISTANCE_THRESHOLD = 0.80; +export const MOVEMENT_DISTANCE_THRESHOLD = 0.60; /** * Constant of speeds when players are moving per tick diff --git a/src/vendor/Anti-Cheat/modules/commands/ban.ts b/src/vendor/Anti-Cheat/modules/commands/ban.ts index fdce003..d8d0a8f 100644 --- a/src/vendor/Anti-Cheat/modules/commands/ban.ts +++ b/src/vendor/Anti-Cheat/modules/commands/ban.ts @@ -9,8 +9,6 @@ import { } from "../../../../rubedo/lib/Command/Command.js"; import { text } from "../../../../rubedo/lang/text.js"; import type { CommandCallback } from "../../../../rubedo/lib/Command/Callback.js"; -import { ActionForm } from "../../../../rubedo/lib/Form/Models/ActionForm.js"; -import { ModalForm } from "../../../../rubedo/lib/Form/Models/ModelForm.js"; function ban( ctx: CommandCallback, @@ -92,29 +90,4 @@ root ) ); } - }); - -root - .literal({ - name: "test", - description: "sdhsd", - }) - .executes((ctx) => { - new ActionForm("Manage Bans") - .addButton("Ban a Player", "textures/ui/hammer_r", () => { - new ModalForm("Ban a Player") - .addDropdown("Player Name:", TABLES.ids.keys()) - .addTextField("Duration", "10d, 5h, 2s", "null") - .addTextField("Ban Reason", "", "No Reason Provided") - .show(ctx.sender, (ctx, playerName, duration, reason) => { - console.warn(playerName, duration, reason); - }); - }) - .addButton("Revoke a Ban", "textures/ui/hammer_r_disabled", () => { - console.warn(`Revoke a player`); - }) - .addButton("View Current Bans", "textures/ui/store_sort_icon", () => { - console.warn(`Revoke a player`); - }) - .show(ctx.sender); - }); + }); \ No newline at end of file diff --git a/src/vendor/Anti-Cheat/modules/events/import.ts b/src/vendor/Anti-Cheat/modules/events/import.ts index 065eb31..463eccb 100644 --- a/src/vendor/Anti-Cheat/modules/events/import.ts +++ b/src/vendor/Anti-Cheat/modules/events/import.ts @@ -8,4 +8,4 @@ */ import "./beforeDataDrivenEntityTriggerEvent"; import "./worldInitialize"; -import "./playerJoin"; +import "./playerSpawn"; diff --git a/src/vendor/Anti-Cheat/modules/events/playerJoin.ts b/src/vendor/Anti-Cheat/modules/events/playerJoin.ts deleted file mode 100644 index 8a5bc6c..0000000 --- a/src/vendor/Anti-Cheat/modules/events/playerJoin.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { world } from "@minecraft/server"; -import { TABLES } from "../../tables.js"; -import { getRole, isLockedDown, kick, setRole } from "../../utils"; -import { Mute } from "../models/Mute"; -import { ChangePlayerRoleTask } from "../models/Task"; -import { text } from "../../../../rubedo/lang/text.js"; -import { EntitiesLoad } from "../../../../rubedo/lib/Events/EntitiesLoad.js"; - -world.events.playerJoin.subscribe(async ({ player }) => { - await EntitiesLoad.awaitLoad(); - if (isLockedDown() && getRole(player) != "admin") - return kick(player, text["lockdown.kick.message"]()); - // -- - if (Mute.getMuteData(player)) player.runCommandAsync(`ability @s mute true`); - if (!TABLES.ids.has(player.name)) { - // Player is new! - TABLES.ids.set(player.name, player.id); - } - /** - * This is a role that was tried to push when the player was offline - * so were setting it now because the player just joined - */ - const roleToSet = ChangePlayerRoleTask.getPlayersRoleToSet(player.name); - if (roleToSet) setRole(player, roleToSet); -}); diff --git a/src/vendor/Anti-Cheat/modules/events/playerSpawn.ts b/src/vendor/Anti-Cheat/modules/events/playerSpawn.ts new file mode 100644 index 0000000..05e0adc --- /dev/null +++ b/src/vendor/Anti-Cheat/modules/events/playerSpawn.ts @@ -0,0 +1,26 @@ +import { world } from "@minecraft/server"; +import { TABLES } from "../../tables.js"; +import { getRole, isLockedDown, kick, setRole } from "../../utils"; +import { Mute } from "../models/Mute"; +import { ChangePlayerRoleTask } from "../models/Task"; +import { text } from "../../../../rubedo/lang/text.js"; + +world.events.playerSpawn.subscribe(({ player }) => { + TABLES.ids.onLoad(() => { + if (isLockedDown() && getRole(player) != "admin") + return kick(player, text["lockdown.kick.message"]()); + // -- + if (Mute.getMuteData(player)) + player.runCommandAsync(`ability @s mute true`); + if (!TABLES.ids.has(player.name)) { + // Player is new! + TABLES.ids.set(player.name, player.id); + } + /** + * This is a role that was tried to push when the player was offline + * so were setting it now because the player just joined + */ + const roleToSet = ChangePlayerRoleTask.getPlayersRoleToSet(player.name); + if (roleToSet) setRole(player, roleToSet); + }); +}); diff --git a/src/vendor/Anti-Cheat/modules/managers/ban.ts b/src/vendor/Anti-Cheat/modules/managers/ban.ts index 91eaf14..aad5e7c 100644 --- a/src/vendor/Anti-Cheat/modules/managers/ban.ts +++ b/src/vendor/Anti-Cheat/modules/managers/ban.ts @@ -3,28 +3,30 @@ import { msToTime } from "../../../../utils.js"; import { kick, getConfigId } from "../../utils.js"; import { forEachPlayer } from "../../../../rubedo/lib/Events/forEachPlayer.js"; -forEachPlayer.subscribe((player) => { - try { - const banData = TABLES.bans.get(player.id); - if (!banData) return; - if (banData.expire && banData.expire < Date.now()) - return TABLES.bans.delete(player.id); - kick( - player, - [ - `§cYou have been banned!`, - `§aReason: §f${banData.reason}`, - `§fExpiry: §b${ - banData.expire ? msToTime(banData.expire - Date.now()) : "Forever" - }`, - `§fAppeal at: §b${getConfigId("appealLink")}`, - ], - () => { - console.warn(new Error("Failed to kick player")); - TABLES.bans.delete(player.id); - } - ); - } catch (error) { - console.warn(error + error.stack); - } -}, 20); +TABLES.bans.onLoad(() => { + forEachPlayer.subscribe((player) => { + try { + const banData = TABLES.bans.get(player.id); + if (!banData) return; + if (banData.expire && banData.expire < Date.now()) + return TABLES.bans.delete(player.id); + kick( + player, + [ + `§cYou have been banned!`, + `§aReason: §f${banData.reason}`, + `§fExpiry: §b${ + banData.expire ? msToTime(banData.expire - Date.now()) : "Forever" + }`, + `§fAppeal at: §b${getConfigId("appealLink")}`, + ], + () => { + console.warn(new Error("Failed to kick player")); + TABLES.bans.delete(player.id); + } + ); + } catch (error) { + console.warn(error + error.stack); + } + }, 100); +}); diff --git a/src/vendor/Anti-Cheat/modules/managers/import.ts b/src/vendor/Anti-Cheat/modules/managers/import.ts index 8380ab9..a65b2fc 100644 --- a/src/vendor/Anti-Cheat/modules/managers/import.ts +++ b/src/vendor/Anti-Cheat/modules/managers/import.ts @@ -12,4 +12,4 @@ import "./ban"; import "./freeze"; import "./mute"; import "./region"; -import "../events/playerJoin"; +import "../events/playerSpawn"; diff --git a/src/vendor/Anti-Cheat/modules/managers/region.ts b/src/vendor/Anti-Cheat/modules/managers/region.ts index 39b1b85..68d1f13 100644 --- a/src/vendor/Anti-Cheat/modules/managers/region.ts +++ b/src/vendor/Anti-Cheat/modules/managers/region.ts @@ -5,6 +5,7 @@ import { BLOCK_CONTAINERS, DOORS_SWITCHES } from "../../config/region.js"; import { DIMENSIONS } from "../../../../utils.js"; import { EntitiesLoad } from "../../../../rubedo/lib/Events/EntitiesLoad.js"; import { forEachPlayer } from "../../../../rubedo/lib/Events/forEachPlayer.js"; +import { TABLES } from "../../tables.js"; /** * Sets Deny blocks at bottom of region every 5 mins @@ -45,7 +46,7 @@ world.events.beforeExplosion.subscribe((data) => { } }); -world.events.entityCreate.subscribe(async ({ entity }) => { +world.events.entitySpawn.subscribe(async ({ entity }) => { const region = await Region.blockLocationInRegionSync( new BlockLocation(entity.location.x, entity.location.y, entity.location.z), entity.dimension.id @@ -73,14 +74,16 @@ EntitiesLoad.subscribe(() => { /** * Gives player a tag if they are in a region */ -forEachPlayer.subscribe((player) => { - for (const region of Region.getAllRegions()) { - if (region.entityInRegion(player)) { - player.addTag(`inRegion`); - if (!region.permissions.pvp) player.addTag(`region-protected`); - } else { - player.removeTag(`inRegion`); - player.removeTag(`region-protected`); +TABLES.regions.onLoad(() => { + forEachPlayer.subscribe((player) => { + for (const region of Region.getAllRegions()) { + if (region.entityInRegion(player)) { + player.addTag(`inRegion`); + if (!region.permissions.pvp) player.addTag(`region-protected`); + } else { + player.removeTag(`inRegion`); + player.removeTag(`region-protected`); + } } - } -}, 5); + }, 5); +}); diff --git a/src/vendor/Anti-Cheat/modules/protections/cbe.ts b/src/vendor/Anti-Cheat/modules/protections/cbe.ts deleted file mode 100644 index e79426a..0000000 --- a/src/vendor/Anti-Cheat/modules/protections/cbe.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { Player, MinecraftBlockTypes } from "@minecraft/server"; -import { FORBIDDEN_BLOCKS } from "../../config/moderation"; -import { Npc } from "../models/Npc"; -import { getConfigId, getRole } from "../../utils"; -import { Ban } from "../models/Ban"; -import { Protection } from "../models/Protection"; - -/** - * Entities that are not allowed to spawn because they can be used by CBE - */ -const CBE_ENTITIES = ["minecraft:command_block_minecart"]; - -const protection = new Protection<{ - entityCreate: boolean; - banSpawnEggs: boolean; -}>( - "cbe", - "Stops CBE", - "textures/blocks/command_block.png", - true -).setConfigDefault({ - entityCreate: { - description: "Adds NPC protection", - defaultValue: true, - }, - banSpawnEggs: { - description: "If spawn eggs should be banned", - defaultValue: true, - }, -}); - -protection.subscribe("entityCreate", ({ entity }) => { - const config = protection.getConfig(); - if (!config.entityCreate) return; - const kill = () => { - try { - entity.triggerEvent("despawn"); - entity.kill(); - } catch (error) { - entity.kill(); - } - }; - if (CBE_ENTITIES.includes(entity.typeId)) return kill(); - if (entity.typeId == "minecraft:npc" && !Npc.isValid(entity)) return kill(); -}); - -protection.subscribe("beforeItemUseOn", (data) => { - if (!(data.source instanceof Player)) return; - if (["admin", "moderator"].includes(getRole(data.source))) return; - const config = protection.getConfig(); - - if (data.item.typeId.endsWith("spawn_egg")) { - if (!config.banSpawnEggs) return; - const block = data.source.dimension.getBlock(data.blockLocation); - if (block.typeId == MinecraftBlockTypes.mobSpawner.id) return; - // Cancel use so players cant use spawnEggs on floor - data.cancel = true; - data.source.tell(`§c[Rubedo]: You cannot place spawnEggs on the floor!`); - data.source.playSound(`note.bass`); - } else { - if (FORBIDDEN_BLOCKS.includes(data.item.typeId)) { - data.cancel = true; - return; - } - const BANNED_BLOCKS = getConfigId("banned_blocks"); - if (!BANNED_BLOCKS.includes(data.item.typeId)) return; - data.cancel = true; - new Ban(data.source, null, "Placing Banned Blocks"); - } -}); diff --git a/src/vendor/Anti-Cheat/modules/protections/crasher.ts b/src/vendor/Anti-Cheat/modules/protections/crasher.ts deleted file mode 100644 index c039898..0000000 --- a/src/vendor/Anti-Cheat/modules/protections/crasher.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { getRole } from "../../utils.js"; -import { Ban } from "../models/Ban.js"; -import { Protection } from "../models/Protection.js"; - -/** - * Minecraft Bedrock Anti Crasher - * @license MIT - * @author Smell of curry - * @version 1.0.0 - * -------------------------------------------------------------------------- - * This anti crasher works by testing if a player has reached a location - * Horion's crasher teleports the player to 30 Million so we just test for - * That location and if they are there we kick the player (USES: player.json) - * -------------------------------------------------------------------------- - */ - -/** - * This is the distance where if you go past it will ban you - */ -const DISTANCE = 320000; - -new Protection( - "crasher", - "Protection against type 1 crasher", - "textures/ui/servers.png", - true -).forEachPlayer((player) => { - if (getRole(player) == "admin") return; - if ( - Math.abs(player.location.x) > DISTANCE || - Math.abs(player.location.y) > DISTANCE || - Math.abs(player.location.z) > DISTANCE - ) { - new Ban(player, null, "Crasher detected"); - } -}); diff --git a/src/vendor/Anti-Cheat/modules/protections/import.ts b/src/vendor/Anti-Cheat/modules/protections/import.ts index 9d653b6..bd2e429 100644 --- a/src/vendor/Anti-Cheat/modules/protections/import.ts +++ b/src/vendor/Anti-Cheat/modules/protections/import.ts @@ -8,11 +8,7 @@ | please make sure this is the files name | */ -import "./cbe"; -import "./crasher"; import "./gamemode"; +import "./movement"; import "./nuker"; import "./spam"; -import "./unobtainable"; -import "./nbt"; -import "./movement"; diff --git a/src/vendor/Anti-Cheat/modules/protections/movement.ts b/src/vendor/Anti-Cheat/modules/protections/movement.ts index 2d0abad..16b6f75 100644 --- a/src/vendor/Anti-Cheat/modules/protections/movement.ts +++ b/src/vendor/Anti-Cheat/modules/protections/movement.ts @@ -66,9 +66,8 @@ function isDistanceFlag( * This is the amount of ticks that have passed */ const ticks = system.currentTick - tick; - const offset = - MOVEMENT_CONSTANTS.run.distance * ticks + MOVEMENT_DISTANCE_THRESHOLD; - return distance > speedIntensity + offset; + const offset = MOVEMENT_CONSTANTS.run.distance + MOVEMENT_DISTANCE_THRESHOLD; + return distance / ticks > speedIntensity + offset; } function flag(player: Player, old: ILocationLog) { @@ -113,7 +112,7 @@ const protection = new Protection<{ "movement", "Blocks illegal movements on players", "textures/ui/move.png", - true + false ).setConfigDefault({ tpCheck: { description: "If teleports should be flagged", diff --git a/src/vendor/Anti-Cheat/modules/protections/nbt.ts b/src/vendor/Anti-Cheat/modules/protections/nbt.ts deleted file mode 100644 index 3b72754..0000000 --- a/src/vendor/Anti-Cheat/modules/protections/nbt.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { - ItemStack, - MinecraftBlockTypes, - MinecraftEntityTypes, - MinecraftItemTypes, - Player, -} from "@minecraft/server"; -import { AIR } from "../../../../rubedo/lib/Chest GUI/index.js"; -import { getGamemode } from "../../utils.js"; -import { Protection } from "../models/Protection.js"; - -/** - * List of blocks to test - */ -const BLOCKS = [ - MinecraftBlockTypes.chest.id, - MinecraftBlockTypes.trappedChest.id, - MinecraftBlockTypes.barrel.id, - MinecraftBlockTypes.dispenser.id, - MinecraftBlockTypes.dropper.id, - MinecraftBlockTypes.furnace.id, - MinecraftBlockTypes.litFurnace.id, - MinecraftBlockTypes.blastFurnace.id, - MinecraftBlockTypes.litBlastFurnace.id, - MinecraftBlockTypes.smoker.id, - MinecraftBlockTypes.litSmoker.id, - MinecraftBlockTypes.hopper.id, - MinecraftBlockTypes.beehive.id, - MinecraftBlockTypes.beeNest.id, - MinecraftBlockTypes.mobSpawner.id, -]; - -/** - * List of items to test - */ -const CHEST_BOATS = [ - MinecraftItemTypes.chestBoat.id, - MinecraftItemTypes.oakChestBoat.id, - MinecraftItemTypes.birchChestBoat.id, - MinecraftItemTypes.acaciaChestBoat.id, - MinecraftItemTypes.jungleChestBoat.id, - MinecraftItemTypes.spruceChestBoat.id, - MinecraftItemTypes.darkOakChestBoat.id, - MinecraftItemTypes.mangroveChestBoat.id, -]; - -new Protection( - "nbt", - "Blocks illegal nbt on items", - "textures/ui/icon_random.png", - true -) - .subscribe("blockPlace", async ({ block }) => { - if (!BLOCKS.includes(block.typeId)) return; - if ( - [ - MinecraftBlockTypes.chest.id, - MinecraftBlockTypes.trappedChest.id, - ].includes(block.typeId) - ) { - const container = block.getComponent("inventory").container; - for (let i = 0; i < container.size; i++) { - container.setItem(i, new ItemStack(MinecraftItemTypes.acaciaBoat, 0)); - } - } else { - const permutation = block.permutation; - await block.dimension.runCommandAsync( - `setblock ${block.x} ${block.y} ${block.z} ${block.typeId}` - ); - block.setPermutation(permutation); - } - }) - .subscribe("beforeItemUseOn", (data) => { - if (!(data.source instanceof Player)) return; - if (!CHEST_BOATS.includes(data.item.typeId)) return; - data.cancel = true; - data.source.dimension.spawnEntity( - MinecraftEntityTypes.chestBoat.id, - data.blockLocation.above() - ); - if (getGamemode(data.source) == "creative") return; - data.source - .getComponent("inventory") - .container.setItem(data.source.selectedSlot, AIR); - }); diff --git a/src/vendor/Anti-Cheat/modules/protections/spam.ts b/src/vendor/Anti-Cheat/modules/protections/spam.ts index 18adcc0..2897488 100644 --- a/src/vendor/Anti-Cheat/modules/protections/spam.ts +++ b/src/vendor/Anti-Cheat/modules/protections/spam.ts @@ -20,7 +20,7 @@ const protection = new Protection<{ "spam", "Blocks spam in chat", "textures/ui/mute_on.png", - true + false ).setConfigDefault({ permMutePlayer: { description: diff --git a/src/vendor/Anti-Cheat/modules/protections/unobtainable.ts b/src/vendor/Anti-Cheat/modules/protections/unobtainable.ts deleted file mode 100644 index 1283d4f..0000000 --- a/src/vendor/Anti-Cheat/modules/protections/unobtainable.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { Player } from "@minecraft/server"; -import { PlayerLog } from "../../../../rubedo/database/types/PlayerLog.js"; -import { AIR } from "../../../../rubedo/lib/Chest GUI/index.js"; -import { FORBIDDEN_ITEMS } from "../../config/moderation.js"; -import { getConfigId, getMaxEnchantmentLevel, getRole } from "../../utils"; -import { Ban } from "../models/Ban.js"; -import { Log } from "../models/Log.js"; -import { Protection } from "../models/Protection.js"; - -/** - * Stores violation count for player - */ -const ViolationCount = new PlayerLog(); - -const protection = new Protection<{ - clearItem: boolean; - banPlayer: boolean; - violationCount: number; -}>( - "unobtainable", - "Blocks unobtainable items", - "textures/blocks/end_portal.png", - true -) - .setConfigDefault({ - clearItem: { - description: - "If the possessed item should be cleared from there inventory", - defaultValue: true, - }, - banPlayer: { - description: "If the player should be banned once hit violation count.", - defaultValue: true, - }, - violationCount: { - description: - "The amount of times this player can posses a banned item before ban.", - defaultValue: 3, - }, - }) - .forEachPlayer((player) => { - if (getRole(player) == "admin") return; - const BANNED_ITEMS = new Set(getConfigId("banned_items")); - - const inventory = player.getComponent("inventory").container; - for (let i = 0; i < inventory.size; i++) { - const item = inventory.getItem(i); - if (!item) continue; - if (BANNED_ITEMS.has(item.typeId)) return flag(player, i); - if (FORBIDDEN_ITEMS.includes(item.typeId)) { - // Log action - new Log({ - playerName: player.name, - message: `${player.name} Has obtained a Forbidden item: ${item.typeId}`, - protection: "unobtainable", - }); - return inventory.setItem(i, AIR); - } - // Player is allowed to have this itemType - /** - * List of all enchantments that are valid on this item - */ - let enchantments = new Set(); - for (const enchantment of item.getComponent("enchantments") - .enchantments) { - const MAX_LEVEL = getMaxEnchantmentLevel(enchantment); - if (enchantment.level > MAX_LEVEL) return flag(player, i); - if (enchantment.level < 1) return flag(player, i); - if (enchantments.has(enchantment.type.id)) return flag(player, i); - // Enchantment Is valid - enchantments.add(enchantment.type.id); - } - } - }); - -/** - * Flags a player for a item they should not have - * @param player player to flag - * @param index the index of this item in the players inventory - */ -function flag(player: Player, index: number) { - const inventory = player.getComponent("inventory").container; - const item = inventory.getItem(index); - const data = protection.getConfig(); - // Clear Item - if (data.clearItem) inventory.setItem(index, AIR); - // Log action - new Log({ - playerName: player.name, - message: `${player.name} Has obtained a unobtainable item: ${item.typeId}`, - protection: "unobtainable", - }); - // Violation - if (!data.banPlayer) return; - const violations = (ViolationCount.get(player) ?? 0) + 1; - ViolationCount.set(player, violations); - if (violations < data.violationCount) return; - new Ban(player, null, "Possession of Unobtainable item"); -} diff --git a/src/vendor/Anti-Cheat/protections.ts b/src/vendor/Anti-Cheat/protections.ts index 6028a95..304e9e9 100644 --- a/src/vendor/Anti-Cheat/protections.ts +++ b/src/vendor/Anti-Cheat/protections.ts @@ -1,18 +1,15 @@ -import { system } from "@minecraft/server"; -import { EntitiesLoad } from "../../rubedo/lib/Events/EntitiesLoad"; import type { Protection } from "./modules/models/Protection"; +import { TABLES } from "./tables"; /** * All protections in this anti-cheat */ export const PROTECTIONS: { [key: string]: Protection } = {}; -EntitiesLoad.subscribe(() => { - system.run(() => { - for (const protection of Object.values(PROTECTIONS)) { - if (!protection.getConfig().enabled ?? protection.isEnabledByDefault) - continue; - protection.enable(); - } - }); +TABLES.protections.onLoad(() => { + for (const protection of Object.values(PROTECTIONS)) { + if (!protection.getConfig().enabled ?? protection.isEnabledByDefault) + continue; + protection.enable(); + } }); diff --git a/src/vendor/GlobalBans/index.ts b/src/vendor/GlobalBans/index.ts index 4dbb5d6..d7f5256 100644 --- a/src/vendor/GlobalBans/index.ts +++ b/src/vendor/GlobalBans/index.ts @@ -2,7 +2,7 @@ import { world } from "@minecraft/server"; import { Ban } from "../Anti-Cheat/modules/models/Ban"; import { GLOBAL_BAN_LIST } from "./list"; -world.events.playerJoin.subscribe(({ player }) => { - if (!GLOBAL_BAN_LIST.includes(player.name)) return; - new Ban(player, null, "Global Ban List"); +world.events.playerJoin.subscribe(({playerName}) => { + if (!GLOBAL_BAN_LIST.includes(playerName)) return; + new Ban(playerName, null, "Global Ban List"); });