Skip to content

Commit

Permalink
Btter wording and bump version to 1.21.50
Browse files Browse the repository at this point in the history
  • Loading branch information
yetnt committed Dec 9, 2024
1 parent 6e1deab commit 8277659
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 23 deletions.
13 changes: 7 additions & 6 deletions BP/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@
"format_version": 2,
"metadata": {
"authors": [
"yetnt"
"yetnt",
"YeTNTPlayZ"
],
"generated_with": {
"bridge": [
"2.7.22"
"2.7.42"
],
"dash": [
"github:bridge-core/dash-compiler#8fa35c73292f6382747d0f411fca26431a6d2c8e"
"0.11.7"
]
}
},
"header": {
"name": "§ldo every §o§av1.3.0",
"name": "§ldo every §o§av1.4.0",
"description": "§lRun a command every (X) amount of seconds. §4Beta Apis has to enabled in Experimental Features for this to work!",
"min_engine_version": [
1,
21,
1
50
],
"uuid": "0bff64e6-f1f5-436c-8b7f-20130c853863",
"version": [
Expand Down Expand Up @@ -53,7 +54,7 @@
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.12.0-beta"
"version": "1.17.0-beta"
}
]
}
57 changes: 45 additions & 12 deletions BP/scripts/funcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,37 @@ const r = {
}
}

function doevery(p: Player, msg: string) {

export const help = {
func: (p: Player) => {
const msg = [doevery, stopevery, listevery].map(func => {
return func(true)
})
p.sendMessage(msg.join("\n"))
}
}

export function doevery(help: boolean, p?: Player, msg?: string) {
// !doevery (Task name) (Amount of time in seconds)
const helpString = "§o§2!doevery [Task Name] [Amount in seconds]"
if (help) {
return helpString + " | Create a new task with the given name and runs every [Amount in seconds]"
}
const [, name, t] = msg.split(" ");
console.warn(t)
console.warn(msg)
if (!name) {
error(p, "Enter the task name. \n" + helpString)
return
}
if (Object.keys(ints).filter(n => n == name).length !== 0) {
error(p, `A task with the name §o${name}§r already exists!`)
return
}
console.error(name)
console.error(t)
const time = parseInt(t);

if (isNaN(time)) {
error(p, "The time must be a valid number! (In seconds)")
error(p, "The time must be a valid number! (In seconds)" + "\n" + helpString)
return;
}
let executable: string;
Expand Down Expand Up @@ -96,15 +119,20 @@ function doevery(p: Player, msg: string) {

r.c();

p.sendMessage(`Task with the name (${name}) has been added!`)
p.sendMessage(`Task with the name (${name}) has been added! (Tasks reset when the world is left)`)
}
})
}

function stopevery(p: Player, msg: string) {
export function stopevery(help: boolean, p?: Player, msg?: string) {
// !stopevery (Task name)
const helpString = "§o§2!stopevery [Task Name]"
if (help) {
return helpString + " | Stops the given task."
}
const [, name] = msg.split(" ");
if (!(name in ints)) {
error(p, `Task with the name (${name}) does not exist.`);
error(p, `Task with the name (${name}) does not exist.` + "\n" + helpString);
return;
}

Expand All @@ -113,17 +141,22 @@ function stopevery(p: Player, msg: string) {
p.sendMessage("Task has successfully been cleared!")
}

function listevery(p: Player) {
const intervalList = Object.keys(ints).map(name => `§lTask Name: §r§o${name}§r | §lExecutable: §r§o${ints[name].exec}`);
export function listevery(help: boolean, p?: Player) {
// !listevery
const helpString = "§o§2!listevery"
if (help) {
return helpString + " | Lists every task that's active."
}
const intervalList = Object.keys(ints).map(
name => `§lTask Name: §r§o${name}§r | §lExecutable: §r§o/${ints[name].exec}`
);

if (intervalList.length == 0) {
p.sendMessage("No intervals have been set. yet.")
p.sendMessage("No tasks have been set. yet.")
} else {
for (const i of intervalList) {
p.sendMessage(i)
}
}

}

export { doevery, stopevery, listevery }
14 changes: 9 additions & 5 deletions BP/scripts/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { world } from "@minecraft/server"
import { doevery, stopevery, listevery } from "./funcs"
import { world } from "@minecraft/server"
import { doevery, stopevery, listevery, help } from "./funcs"

world.afterEvents.chatSend.subscribe((arg) => {
// !doevery name time
Expand All @@ -15,21 +15,25 @@ world.afterEvents.chatSend.subscribe((arg) => {
case "doevery":
case "startevery":
case "sev":
doevery(p, message.substring(1));
doevery(false, p, message.substring(1));
break;
case "stopevery":
case "se":
case "endevery":
case "ee":
stopevery(p, message.substring(1))
stopevery(false, p, message.substring(1))
break;
case "listevery":
case "le":
case "list":
case "listtasks":
case "l":
case "lt":
listevery(p)
listevery(false, p)
break;
case "?":
case "help":
case "h":
help.func(p)
}
})

0 comments on commit 8277659

Please sign in to comment.