Skip to content

Commit 3ed89e6

Browse files
committed
V1.0.6
- Added `/spreadplayers` command to spread all players manually. - Updated administrator validation on each commands, now required players to have operator permission.
1 parent 5ef80a4 commit 3ed89e6

17 files changed

Lines changed: 39 additions & 43 deletions

File tree

.github/workflows/auto_upload.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ name: Automation Uploader
44

55
# Controls when the workflow will run
66
on:
7-
# Triggers the workflow on push or pull request events but only for the "main" branch
8-
push:
9-
branches: [ "main" ]
10-
117
# Allows you to run this workflow manually from the Actions tab
128
workflow_dispatch:
139

BP/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"format_version": 2,
33
"header": {
4-
"name": "§l§rSpawn-Randomizer §r(§a1.0.5§r)",
4+
"name": "§l§rSpawn-Randomizer §r(§a1.0.6§r)",
55
"description": "This randomize all new player spawn location with specified threshold. You can even specify a specific locations!",
66
"uuid": "39e659c0-785d-4475-a051-b7267dcc9e3b",
77
"min_engine_version": [1, 21, 120],
8-
"version": [1, 0, 5]
8+
"version": [1, 0, 6]
99
},
1010
"modules": [
1111
{

BP/scripts/commands/handler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import "./list/clearspawns.js"
22
import "./list/deletespawn.js"
33
import "./list/addspawn.js"
4-
import "./list/spawnmode.js"
4+
import "./list/spawnmode.js"
5+
import "./list/spreadplayers.js"

BP/scripts/commands/list/addspawn.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ import {
44
} from "@minecraft/server";
55
import { registerCommand } from "../commandRegistry.js"
66
import { messages } from "../../messages.js"
7-
import * as db from "../../utilities/storage.js"
7+
import * as db from "../../utilities/DatabaseHandler.js"
88

99
const commandInformation = {
1010
name: "addspawn",
1111
description: "Add your current location to be listed as one of the specified random spawn location.",
12+
permissionLevel: 1,
1213
aliases: [],
1314
usage:[]
1415
}
1516

1617
registerCommand(commandInformation, (origin) => {
1718

1819
const player = origin.sourceEntity
19-
if(!player.isAdmin()) return player.sendMessage(messages.MUST_BE_ADMIN)
2020
let specifiedLocations = db.fetch("randomSpecifiedLocation", true)
21+
2122
specifiedLocations.push({
2223
location: {
2324
x: Math.round(player.location.x),

BP/scripts/commands/list/clearspawns.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ import {
44
} from "@minecraft/server";
55
import { registerCommand } from "../commandRegistry.js"
66
import { messages } from "../../messages.js"
7-
import * as db from "../../utilities/storage.js"
7+
import * as db from "../../utilities/DatabaseHandler.js"
88

99

1010
const commandInformation = {
1111
name: "clearspawns",
1212
description: "Clear all specified random spawn locations.",
13+
permissionLevel: 1,
1314
aliases: [],
1415
usage:[]
1516
}
1617

1718
registerCommand(commandInformation, (origin) => {
1819

1920
const player = origin.sourceEntity
20-
if(!player.isAdmin()) return player.sendMessage(messages.MUST_BE_ADMIN)
2121
db.store("randomSpecifiedLocation", [])
22+
2223
player.sendMessage(messages.SUCCESS_CLEARED_RANDOM_SPAWN_LOCATIONS)
2324
return {
2425
status: 0

BP/scripts/commands/list/deletespawn.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ import {
44
} from "@minecraft/server";
55
import { registerCommand } from "../commandRegistry.js"
66
import { messages } from "../../messages.js"
7-
import * as db from "../../utilities/storage.js"
7+
import * as db from "../../utilities/DatabaseHandler.js"
88

99

1010
const commandInformation = {
1111
name: "deletespawn",
1212
description: "Delete the current spawn location that you are standing on.",
13+
permissionLevel: 1,
1314
aliases: ["delspawn"],
1415
usage:[]
1516
}
1617

1718
registerCommand(commandInformation, (origin) => {
1819

1920
const player = origin.sourceEntity
20-
if(!player.isAdmin()) return player.sendMessage(messages.MUST_BE_ADMIN)
2121
let specifiedLocations = db.fetch("randomSpecifiedLocation", true)
22+
2223
if(!specifiedLocations.some(d => d.location.x === Math.round(player.location.x) && d.location.z === Math.round(player.location.z) && d.dimension === player.dimension.id)) return player.sendMessage(messages.FAILED_DELETED_RANDOM_SPAWN_LOCATION)
2324
specifiedLocations = specifiedLocations.filter(d => !(d.location.x === Math.round(player.location.x) && d.location.z === Math.round(player.location.z) && d.dimension === player.dimension.id))
2425
db.store("randomSpecifiedLocation", specifiedLocations)

BP/scripts/commands/list/spawnmode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import {
44
} from "@minecraft/server";
55
import { registerCommand } from "../commandRegistry.js"
66
import { messages } from "../../messages.js"
7-
import * as db from "../../utilities/storage.js"
7+
import * as db from "../../utilities/DatabaseHandler.js"
88

99

1010
const commandInformation = {
1111
name: "spawnmode",
1212
description: "Choose which spawn mode will the spawn-randomize should use.",
13+
permissionLevel: 1,
1314
aliases: [],
1415
usage:[
1516
{
@@ -23,7 +24,6 @@ const commandInformation = {
2324
registerCommand(commandInformation, (origin, mode) => {
2425

2526
const player = origin.sourceEntity
26-
if(!player.isAdmin()) return player.sendMessage(messages.MUST_BE_ADMIN)
2727

2828
let spawnRandomizerSetting = db.fetch("spawnRandomizerSetting", true)
2929
if(!spawnRandomizerSetting[0]) {

BP/scripts/commands/list/spreadplayers.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@ import {
44
} from "@minecraft/server";
55
import { registerCommand } from "../commandRegistry.js"
66
import { messages } from "../../messages.js"
7-
import * as db from "../../utilities/storage.js"
8-
import "../../utilities/getTopBlock.js"
7+
import * as db from "../../utilities/DatabaseHandler.js"
8+
import "../../utilities/FetchTopBlock.js"
99

1010
const commandInformation = {
1111
name: "spreadplayers",
1212
description: "Spread out players around the overworld.",
13+
permissionLevel: 1,
1314
aliases: [],
1415
usage:[
1516
{
1617
name: "radius",
17-
type: 9, // change later, should be int
18+
type: "Integer",
1819
optional: false
1920
},
2021
{
2122
name: "setSpawnPoint",
22-
type: 9, // change later, should be Boolean
23-
optional true,
24-
}
23+
type: "Boolean",
24+
optional: true,
25+
},
2526
{
2627
name: "includeAdmin",
27-
type; 9, // change later, should be Boolean
28+
type: "Boolean",
2829
optional: true
2930
}
3031
]
@@ -33,15 +34,13 @@ const commandInformation = {
3334
registerCommand(commandInformation, (origin, radius, setSpawnPoint = false, includeAdmin = false) => {
3435

3536
const player = origin.sourceEntity
36-
if(!player.isAdmin()) return player.sendMessage(messages.MUST_BE_ADMIN)
37-
3837
let recentPlayerList = db.fetch("recentPlayerList", true);
3938

4039
for(const selectedPlayer of world.getPlayers()) {
41-
if(!includeAdmin && selectedPlayer.isAdmin()) continue;
40+
if(!includeAdmin && selectedPlayer.commandPermission === 1) continue;
4241
let x = Math.floor(Math.random() * radius) + 1;
4342
let z = Math.floor(Math.random() * radius) + 1;
44-
selectedPlayer.tryTeleport({x, y: 320, z})
43+
system.run(() => selectedPlayer.tryTeleport({x, y: 320, z}))
4544

4645
const runner = system.runInterval(() => {
4746
const topBlock = getTopBlock({x, z})
@@ -67,13 +66,14 @@ registerCommand(commandInformation, (origin, radius, setSpawnPoint = false, incl
6766
z: z
6867
}
6968
})
70-
selectedPlayer.runCommand(`spawnpoint @s ${x} ${topBlock.location.y + 1} ${z}`) : null
69+
system.run(() => selectedPlayer.runCommand(`spawnpoint @s ${x} ${topBlock.location.y + 1} ${z}`))
70+
db.store("recentPlayerList", recentPlayerList)
7171
}
7272
system.clearRun(runner)
7373
}
7474
}, 1*20)
7575
}
76-
player.sendMessage(messages.SUCCESS_CHANGES_SPAWN_MODE.replace("{0}", mode))
76+
player.sendMessage(messages.SUCCESS_SPREAD_PLAYERS)
7777
return {
7878
status: 0
7979
}

BP/scripts/commands/list/test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import {
44
} from "@minecraft/server";
55
import { registerCommand } from "../commandRegistry.js"
66
import { messages } from "../../messages.js"
7-
import * as db from "../../utilities/storage.js"
7+
import * as db from "../../utilities/DatabaseHandler.js"
88

99
const commandInformation = {
1010
name: "test",
1111
description: "description",
12+
permissionLevel: 1,
1213
aliases: [],
1314
usage:[]
1415
}

BP/scripts/events/list/newPlayerSpawn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { world, system } from "@minecraft/server"
22
import { config } from "../../config.js"
3-
import * as db from "../../utilities/storage.js"
4-
import "../../utilities/getTopBlock.js"
3+
import * as db from "../../utilities/DatabaseHandler.js"
4+
import "../../utilities/FetchTopBlock.js"
55

66
world.afterEvents.playerSpawn.subscribe(async (event) => {
77
const player = event.player;

0 commit comments

Comments
 (0)