From 81264e36c54242195e3ec420bcb649ee225d9628 Mon Sep 17 00:00:00 2001 From: Casper Warden <216465704+casperwardensl@users.noreply.github.com> Date: Wed, 22 Nov 2023 03:48:39 +0000 Subject: [PATCH] Make sure copied inventory items have the intended perms --- examples/Inventory/Inventory.ts | 13 +++ lib/classes/commands/RegionCommands.ts | 120 +++++++++++-------------- package-lock.json | 4 +- package.json | 2 +- 4 files changed, 66 insertions(+), 73 deletions(-) diff --git a/examples/Inventory/Inventory.ts b/examples/Inventory/Inventory.ts index 06d9305..0578a96 100644 --- a/examples/Inventory/Inventory.ts +++ b/examples/Inventory/Inventory.ts @@ -73,6 +73,19 @@ class Inventory extends ExampleBot // Delete the copy await copy.delete(); + // Let's set some perms + const copyOnly = await exampleNotecard.copyTo(exampleFolder, exampleNotecard.name + ' - Copy Only ' + UUID.random().toString().substring(0, 8)); + copyOnly.permissions.nextOwnerMask = PermissionMask.Copy; + await copyOnly.update(); + + const modOnly = await exampleNotecard.copyTo(exampleFolder, exampleNotecard.name + ' - Mod Only ' + UUID.random().toString().substring(0, 8)); + modOnly.permissions.nextOwnerMask = PermissionMask.Modify; + await modOnly.update(); + + const transOnly = await exampleNotecard.copyTo(exampleFolder, exampleNotecard.name + ' - Trans Only ' + UUID.random().toString().substring(0, 8)); + transOnly.permissions.nextOwnerMask = PermissionMask.Transfer; + await transOnly.update(); + let exampleScript = exampleFolder.items.find(f => f.name === exampleScriptName); if (exampleScript === undefined) { diff --git a/lib/classes/commands/RegionCommands.ts b/lib/classes/commands/RegionCommands.ts index 3914d5c..5afb29c 100644 --- a/lib/classes/commands/RegionCommands.ts +++ b/lib/classes/commands/RegionCommands.ts @@ -846,15 +846,13 @@ export class RegionCommands extends CommandsBase if (item !== null) { await object.dropInventoryIntoContents(item); - if (invItem.name !== item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === item.name) { - if (taskItem.name === item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -869,15 +867,13 @@ export class RegionCommands extends CommandsBase if (item !== null) { await object.dropInventoryIntoContents(item); - if (invItem.name !== item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === item.name) { - if (taskItem.name === item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -893,15 +889,13 @@ export class RegionCommands extends CommandsBase if (item !== null) { await object.dropInventoryIntoContents(item); - if (invItem.name !== item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === item.name) { - if (taskItem.name === item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -916,15 +910,13 @@ export class RegionCommands extends CommandsBase if (item !== null) { await object.dropInventoryIntoContents(item); - if (invItem.name !== item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === item.name) { - if (taskItem.name === item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -939,15 +931,13 @@ export class RegionCommands extends CommandsBase if (item !== null) { await object.dropInventoryIntoContents(item); - if (invItem.name !== item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === item.name) { - if (taskItem.name === item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -962,15 +952,13 @@ export class RegionCommands extends CommandsBase if (item !== null) { await object.dropInventoryIntoContents(item); - if (invItem.name !== item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === item.name) { - if (taskItem.name === item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -986,15 +974,13 @@ export class RegionCommands extends CommandsBase if (item !== null) { await object.dropInventoryIntoContents(item); - if (invItem.name !== item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === item.name) { - if (taskItem.name === item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -1009,15 +995,13 @@ export class RegionCommands extends CommandsBase if (item !== null) { await object.dropInventoryIntoContents(item); - if (invItem.name !== item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === item.name) { - if (taskItem.name === item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -1032,15 +1016,13 @@ export class RegionCommands extends CommandsBase if (inventoryItem !== null) { await object.dropInventoryIntoContents(inventoryItem); - if (invItem.name !== inventoryItem.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === inventoryItem.name) { - if (taskItem.name === inventoryItem.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } @@ -1060,15 +1042,13 @@ export class RegionCommands extends CommandsBase if (texItem.item !== null) { await object.dropInventoryIntoContents(texItem.item); - if (invItem.name !== texItem.item.name) + await object.updateInventory(); + for (const taskItem of object.inventory) { - await object.updateInventory(); - for (const taskItem of object.inventory) + if (taskItem.name === texItem.item.name) { - if (taskItem.name === texItem.item.name) - { - await taskItem.renameInTask(object, invItem.name); - } + taskItem.permissions = invItem.permissions; + await taskItem.renameInTask(object, invItem.name); } } } diff --git a/package-lock.json b/package-lock.json index 12b5ba6..9834f36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@caspertech/node-metaverse", - "version": "0.7.11", + "version": "0.7.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@caspertech/node-metaverse", - "version": "0.7.11", + "version": "0.7.12", "license": "MIT", "dependencies": { "@caspertech/llsd": "^1.0.5", diff --git a/package.json b/package.json index 3d06dd8..5889e8a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@caspertech/node-metaverse", - "version": "0.7.11", + "version": "0.7.12", "description": "A node.js interface for Second Life.", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts",