Skip to content

Commit

Permalink
Fixed session removal ingame;
Browse files Browse the repository at this point in the history
Disabled tools system for non-worldedit users;
Bumped version
  • Loading branch information
SIsilicon committed Mar 12, 2024
1 parent e04cbb8 commit f62d889
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 57 deletions.
44 changes: 32 additions & 12 deletions mc_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,62 @@
"header": {
"bp_name": "WorldEdit Bedrock Edition",
"rp_name": "WorldEdit Bedrock Edition [RES]",

"description": "pack.description",

"bp_uuid": "3cdb2ddf-662e-4f8f-a0a1-1293b91ccb2f",
"description": "pack.description",
"bp_uuid": "3cdb2ddf-662e-4f8f-a0a1-1293b91ccb2f",
"rp_uuid": "e304a4eb-f0a0-4979-ac17-7b0f46a555c8",
"version": [0, 8, 5],
"min_engine_version": [ 1, 20, 60 ]
"version": [
0,
8,
6
],
"min_engine_version": [
1,
20,
70
]
},
"bp_modules": [
{
"description": "item and entity definitions",
"type": "data",
"uuid": "f0bc63f7-f2b2-4de2-a27c-6a3d5ac7cee4",
"version": [ 1, 0, 0 ]
"version": [
1,
0,
0
]
},
{
"description": "scripts",
"type": "script",
"language": "javascript",
"uuid": "7f97c5a5-a9ec-4773-b29f-a26e0f653ee2",
"version": [ 1, 0, 0 ],
"version": [
1,
0,
0
],
"entry": "scripts/server/index.js"
}
],
"bp_capabilities": [ "script_eval" ],
"rp_modules": [
"bp_capabilities": [
"script_eval"
],
"rp_modules": [
{
"type": "resources",
"uuid": "f58139e1-2378-434d-91e8-9861d5579c7c",
"version": [ 1, 0, 0 ]
"version": [
1,
0,
0
]
}
],
"bp_dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.9.0-beta"
"version": "1.10.0-beta"
},
{
"module_name": "@minecraft/server-ui",
Expand Down
76 changes: 41 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"typescript": "^4.7.4"
},
"dependencies": {
"@minecraft/server": "^1.8.0-beta.1.20.50-preview.23",
"@minecraft/server": "^1.10.0-beta.1.20.70-preview.25",
"@minecraft/server-admin": "^1.0.0-beta.1.19.80-stable",
"@minecraft/server-ui": "^1.2.0-beta.1.20.50-preview.23"
"@minecraft/server-ui": "^1.2.0-beta.1.20.70-preview.25"
}
}
2 changes: 1 addition & 1 deletion src/server/commands/utilities/drain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ registerCommand(registerInformation, function* (session, builder, args) {
for (const loc of blocks) {
const block = dimension.getBlock(loc);
if (drainWaterLogged && !block.typeId.match(fluidMatch)) {
block.isWaterlogged = false;
block.setWaterlogged(false);
} else {
block.setPermutation(air);
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Server.on("tick", () => {
if (hasWorldEdit(builder)) {
getSession(builder);
} else {
removeBuilder(builder.name);
removeBuilder(builder.id);
contentLog.log(`${builder.name} has been revoked of their worldedit permissions.`);
print("worldedit.permission.revoked", builder);
continue;
Expand All @@ -104,7 +104,7 @@ function removeBuilder(player: string) {
do {
i = activeBuilders.findIndex(p => {
try {
return p.name == player;
return p.id === player;
} catch (e) {
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/server/tools/tool_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ class ToolBuilder {

constructor() {
Server.on("itemUseBefore", ev => {
if (ev.source.typeId != "minecraft:player" || !ev.itemStack) return;
if (!ev.itemStack || !hasSession(ev.source.id)) return;
this.onItemUse(ev.itemStack, ev.source as Player, ev);
});

Server.on("itemUseOnBefore", ev => {
if (ev.source.typeId != "minecraft:player" || !ev.itemStack) return;
if (!ev.itemStack || !hasSession(ev.source.id)) return;
this.onItemUse(ev.itemStack, ev.source as Player, ev, Vector.from(ev.block));
});

Server.on("blockBreak", ev => {
if (!ev.itemStack) return;
if (!ev.itemStack || !hasSession(ev.player.id)) return;
this.onBlockBreak(ev.itemStack, ev.player, ev, Vector.from(ev.block));
});

Server.on("blockHit", ev => {
if (ev.damagingEntity.typeId != "minecraft:player") return;
if (ev.damagingEntity.typeId != "minecraft:player" || !hasSession(ev.damagingEntity.id)) return;
const item = Server.player.getHeldItem(ev.damagingEntity as Player);
if (!item) return;
this.onBlockHit(item, ev.damagingEntity as Player, ev, Vector.from(ev.hitBlock));
Expand All @@ -51,7 +51,7 @@ class ToolBuilder {
for (const player of world.getPlayers()) {
try {
const item = Server.player.getHeldItem(player);
if (!item) continue;
if (!item || !hasSession(player.id)) continue;
yield* self.onItemTick(item, player, self.currentTick);
} catch (err) {
contentLog.error(err);
Expand Down

0 comments on commit f62d889

Please sign in to comment.