From cb2be348d74ad9d1d1cadb309949d04e8dda09b8 Mon Sep 17 00:00:00 2001 From: Casper Warden <216465704+casperwardensl@users.noreply.github.com> Date: Sat, 6 Oct 2018 17:16:51 +0100 Subject: [PATCH] The rest of the refactor --- dist/classes/ClientCommands.d.ts | 2 + dist/classes/ClientCommands.js | 2 + dist/classes/ClientCommands.js.map | 2 +- lib/classes/ClientEvents.ts | 23 +++++---- lib/classes/Comms.ts | 21 ++++---- lib/classes/commands/GridCommands.ts | 43 ++++++++--------- lib/classes/commands/TeleportCommands.ts | 8 +--- lib/events/ChatEvent.ts | 4 +- lib/events/FriendRequestEvent.ts | 2 +- lib/events/GroupChatEvent.ts | 2 +- lib/events/GroupChatSessionAgentListEvent.ts | 2 +- lib/events/GroupChatSessionJoinEvent.ts | 2 +- lib/events/GroupInviteEvent.ts | 2 +- lib/events/InstantMessageEvent.ts | 4 +- lib/events/InventoryOfferedEvent.ts | 4 +- lib/events/LureEvent.ts | 3 +- lib/index.ts | 50 +++++++++++++++++--- 17 files changed, 101 insertions(+), 75 deletions(-) diff --git a/dist/classes/ClientCommands.d.ts b/dist/classes/ClientCommands.d.ts index 42910fe..e9a9e37 100644 --- a/dist/classes/ClientCommands.d.ts +++ b/dist/classes/ClientCommands.d.ts @@ -10,11 +10,13 @@ import { CommunicationsCommands } from './commands/CommunicationsCommands'; import { AgentCommands } from './commands/AgentCommands'; import { GroupCommands } from './commands/GroupCommands'; import { InventoryCommands } from './commands/InventoryCommands'; +import { ParcelCommands } from './commands/ParcelCommands'; export declare class ClientCommands { network: NetworkCommands; asset: AssetCommands; teleport: TeleportCommands; region: RegionCommands; + parcel: ParcelCommands; grid: GridCommands; comms: CommunicationsCommands; agent: AgentCommands; diff --git a/dist/classes/ClientCommands.js b/dist/classes/ClientCommands.js index b7803de..fbaa31d 100644 --- a/dist/classes/ClientCommands.js +++ b/dist/classes/ClientCommands.js @@ -9,12 +9,14 @@ const CommunicationsCommands_1 = require("./commands/CommunicationsCommands"); const AgentCommands_1 = require("./commands/AgentCommands"); const GroupCommands_1 = require("./commands/GroupCommands"); const InventoryCommands_1 = require("./commands/InventoryCommands"); +const ParcelCommands_1 = require("./commands/ParcelCommands"); class ClientCommands { constructor(region, agent, bot) { this.network = new NetworkCommands_1.NetworkCommands(region, agent, bot); this.asset = new AssetCommands_1.AssetCommands(region, agent, bot); this.teleport = new TeleportCommands_1.TeleportCommands(region, agent, bot); this.region = new RegionCommands_1.RegionCommands(region, agent, bot); + this.parcel = new ParcelCommands_1.ParcelCommands(region, agent, bot); this.grid = new GridCommands_1.GridCommands(region, agent, bot); this.comms = new CommunicationsCommands_1.CommunicationsCommands(region, agent, bot); this.agent = new AgentCommands_1.AgentCommands(region, agent, bot); diff --git a/dist/classes/ClientCommands.js.map b/dist/classes/ClientCommands.js.map index 8fc9733..55dda37 100644 --- a/dist/classes/ClientCommands.js.map +++ b/dist/classes/ClientCommands.js.map @@ -1 +1 @@ -{"version":3,"file":"ClientCommands.js","sourceRoot":"","sources":["../../lib/classes/ClientCommands.ts"],"names":[],"mappings":";;AAGA,gEAA2D;AAC3D,4DAAuD;AACvD,kEAA6D;AAC7D,8DAAyD;AACzD,0DAAqD;AACrD,8EAAyE;AACzE,4DAAuD;AACvD,4DAAuD;AACvD,oEAA+D;AAE/D;IAYI,YAAY,MAAc,EAAE,KAAY,EAAE,GAAQ;QAE9C,IAAI,CAAC,OAAO,GAAG,IAAI,iCAAe,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,mCAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,IAAI,+BAAc,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,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CAAC,IAAI,GAAG,IAAI,2BAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAI,+CAAsB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,GAAG,IAAI,6BAAa,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,IAAI,qCAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/D,CAAC;CACJ;AA1BD,wCA0BC"} \ No newline at end of file diff --git a/lib/classes/ClientEvents.ts b/lib/classes/ClientEvents.ts index 70df908..bb754fc 100644 --- a/lib/classes/ClientEvents.ts +++ b/lib/classes/ClientEvents.ts @@ -1,16 +1,15 @@ -import {LureEvent} from '../events/LureEvent'; -import {ChatEvent} from '../events/ChatEvent'; -import {TeleportEvent} from '../events/TeleportEvent'; import {Subject} from 'rxjs/Subject'; -import {InstantMessageEvent} from '../events/InstantMessageEvent'; -import {GroupInviteEvent} from '../events/GroupInviteEvent'; -import {FriendRequestEvent} from '../events/FriendRequestEvent'; -import {DisconnectEvent} from '../events/DisconnectEvent'; -import {GroupChatEvent} from '../events/GroupChatEvent'; -import {GroupChatSessionJoinEvent} from '../events/GroupChatSessionJoinEvent'; -import {GroupChatSessionAgentListEvent} from '../events/GroupChatSessionAgentListEvent'; -import {InventoryOfferedEvent} from '../events/InventoryOfferedEvent'; -import {FriendResponseEvent} from '../events/FriendshipResponseEvent'; +import { + ChatEvent, + DisconnectEvent, + FriendRequestEvent, FriendResponseEvent, GroupChatEvent, GroupChatSessionAgentListEvent, GroupChatSessionJoinEvent, + GroupInviteEvent, + InstantMessageEvent, + InventoryOfferedEvent, + LureEvent, + TeleportEvent +} from '..'; + export class ClientEvents { diff --git a/lib/classes/Comms.ts b/lib/classes/Comms.ts index 8573795..1adab6e 100644 --- a/lib/classes/Comms.ts +++ b/lib/classes/Comms.ts @@ -5,19 +5,20 @@ import {Message} from '../enums/Message'; import {ChatFromSimulatorMessage} from './messages/ChatFromSimulator'; import {ImprovedInstantMessageMessage} from './messages/ImprovedInstantMessage'; import {Utils} from './Utils'; -import {ChatEvent} from '../events/ChatEvent'; import {InstantMessageDialog} from '../enums/InstantMessageDialog'; -import {LureEvent} from '../events/LureEvent'; import {AlertMessageMessage} from './messages/AlertMessage'; import {ClientEvents} from './ClientEvents'; -import {InstantMessageEvent} from '../events/InstantMessageEvent'; -import {ChatSourceType} from '../enums/ChatSourceType'; -import {InstantMessageEventFlags} from '../enums/InstantMessageEventFlags'; -import {GroupInviteEvent} from '../events/GroupInviteEvent'; -import {GroupChatEvent} from '../events/GroupChatEvent'; -import {FriendRequestEvent} from '../events/FriendRequestEvent'; -import {InventoryOfferedEvent} from '../events/InventoryOfferedEvent'; -import {FriendResponseEvent} from '../events/FriendshipResponseEvent'; +import { + ChatEvent, + ChatSourceType, + FriendRequestEvent, + FriendResponseEvent, + GroupChatEvent, + GroupInviteEvent, + InstantMessageEvent, + InstantMessageEventFlags, + InventoryOfferedEvent, LureEvent +} from '..'; export class Comms { diff --git a/lib/classes/commands/GridCommands.ts b/lib/classes/commands/GridCommands.ts index 1eecd41..64d870f 100644 --- a/lib/classes/commands/GridCommands.ts +++ b/lib/classes/commands/GridCommands.ts @@ -1,4 +1,3 @@ -import {MapInfoReply} from '../../events/MapInfoReply'; import {Packet} from '../Packet'; import * as Long from 'long'; import {MapItemReplyMessage} from '../messages/MapItemReply'; @@ -8,7 +7,6 @@ import {MapBlockRequestMessage} from '../messages/MapBlockRequest'; import {UUID} from '../UUID'; import {MapItemRequestMessage} from '../messages/MapItemRequest'; import {Utils} from '../Utils'; -import {PacketFlags} from '../../enums/PacketFlags'; import {GridItemType} from '../../enums/GridItemType'; import {CommandsBase} from './CommandsBase'; import {AvatarPickerRequestMessage} from '../messages/AvatarPickerRequest'; @@ -16,17 +14,15 @@ import {AvatarPickerReplyMessage} from '../messages/AvatarPickerReply'; import {FilterResponse} from '../../enums/FilterResponse'; import {MapNameRequestMessage} from '../messages/MapNameRequest'; import {GridLayerType} from '../../enums/GridLayerType'; -import {RegionInfoReply} from '../../events/RegionInfoReply'; -import {MapInfoRangeReply} from '../../events/MapInfoRangeReply'; import {MapBlock} from '../MapBlock'; +import {MapInfoRangeReplyEvent, MapInfoReplyEvent, PacketFlags, RegionInfoReplyEvent} from '../..'; export class GridCommands extends CommandsBase { getRegionByName(regionName: string) { - return new Promise((resolve, reject) => + return new Promise((resolve, reject) => { const circuit = this.currentRegion.circuit; - const response = new MapInfoReply(); const msg: MapNameRequestMessage = new MapNameRequestMessage(); msg.AgentData = { AgentID: this.agent.agentID, @@ -64,17 +60,18 @@ export class GridCommands extends CommandsBase const name = Utils.BufferToStringSimple(region.Name); if (name.trim().toLowerCase() === regionName.trim().toLowerCase() && !(region.X === 0 && region.Y === 0)) { - const reply = new RegionInfoReply(); - reply.access = region.Access; - reply.X = region.X; - reply.Y = region.Y; - reply.name = name; - reply.regionFlags = region.RegionFlags; - reply.waterHeight = region.WaterHeight; - reply.agents = region.Agents; - reply.mapImageID = region.MapImageID; - - reply.handle = Utils.RegionCoordinatesToHandle(region.X * 256, region.Y * 256); + const reply = new class implements RegionInfoReplyEvent + { + X = region.X; + Y = region.Y; + name = name; + access = region.Access; + regionFlags = region.RegionFlags; + waterHeight = region.WaterHeight; + agents = region.Agents; + mapImageID = region.MapImageID; + handle = Utils.RegionCoordinatesToHandle(region.X * 256, region.Y * 256) + }; resolve(reply); } }); @@ -84,12 +81,12 @@ export class GridCommands extends CommandsBase }); }); } - getRegionMapInfo(gridX: number, gridY: number): Promise + getRegionMapInfo(gridX: number, gridY: number): Promise { - return new Promise((resolve, reject) => + return new Promise((resolve, reject) => { const circuit = this.currentRegion.circuit; - const response = new MapInfoReply(); + const response = new MapInfoReplyEvent(); const msg: MapBlockRequestMessage = new MapBlockRequestMessage(); msg.AgentData = { AgentID: this.agent.agentID, @@ -198,12 +195,12 @@ export class GridCommands extends CommandsBase }); } - getRegionMapInfoRange(minX: number, minY: number, maxX: number, maxY: number): Promise + getRegionMapInfoRange(minX: number, minY: number, maxX: number, maxY: number): Promise { - return new Promise((resolve, reject) => + return new Promise((resolve, reject) => { const circuit = this.currentRegion.circuit; - const response = new MapInfoRangeReply(); + const response = new MapInfoRangeReplyEvent(); const msg: MapBlockRequestMessage = new MapBlockRequestMessage(); msg.AgentData = { AgentID: this.agent.agentID, diff --git a/lib/classes/commands/TeleportCommands.ts b/lib/classes/commands/TeleportCommands.ts index a2a101c..16d50bc 100644 --- a/lib/classes/commands/TeleportCommands.ts +++ b/lib/classes/commands/TeleportCommands.ts @@ -1,15 +1,11 @@ import {CommandsBase} from './CommandsBase'; import {Region} from '../Region'; -import {LureEvent} from '../../events/LureEvent'; import {TeleportEventType} from '../../enums/TeleportEventType'; -import {TeleportEvent} from '../../events/TeleportEvent'; -import {PacketFlags} from '../../enums/PacketFlags'; import {TeleportLureRequestMessage} from '../messages/TeleportLureRequest'; -import {TeleportFlags} from '../../enums/TeleportFlags'; import {Vector3} from '../Vector3'; -import {RegionInfoReply} from '../../events/RegionInfoReply'; import {TeleportLocationRequestMessage} from '../messages/TeleportLocationRequest'; import * as Long from 'long'; +import {LureEvent, PacketFlags, RegionInfoReplyEvent, TeleportEvent, TeleportFlags} from '../..'; export class TeleportCommands extends CommandsBase { @@ -131,7 +127,7 @@ export class TeleportCommands extends CommandsBase { return new Promise((resolve, reject) => { - this.bot.clientCommands.grid.getRegionByName(regionName).then((region: RegionInfoReply) => + this.bot.clientCommands.grid.getRegionByName(regionName).then((region: RegionInfoReplyEvent) => { this.teleportToHandle(region.handle, position, lookAt).then((event: TeleportEvent) => { diff --git a/lib/events/ChatEvent.ts b/lib/events/ChatEvent.ts index ade8e9a..44b3720 100644 --- a/lib/events/ChatEvent.ts +++ b/lib/events/ChatEvent.ts @@ -1,8 +1,6 @@ -import {UUID} from '../classes/UUID'; import {ChatAudibleLevel} from '../enums/ChatAudible'; import {ChatType} from '../enums/ChatType'; -import {ChatSourceType} from '../enums/ChatSourceType'; -import {Vector3} from '../classes/Vector3'; +import {ChatSourceType, UUID, Vector3} from '..'; export class ChatEvent { diff --git a/lib/events/FriendRequestEvent.ts b/lib/events/FriendRequestEvent.ts index 04957b4..0c0249f 100644 --- a/lib/events/FriendRequestEvent.ts +++ b/lib/events/FriendRequestEvent.ts @@ -1,4 +1,4 @@ -import {UUID} from '../classes/UUID'; +import {UUID} from '..'; export class FriendRequestEvent { diff --git a/lib/events/GroupChatEvent.ts b/lib/events/GroupChatEvent.ts index 74eedba..e19df71 100644 --- a/lib/events/GroupChatEvent.ts +++ b/lib/events/GroupChatEvent.ts @@ -1,4 +1,4 @@ -import {UUID} from '../classes/UUID'; +import {UUID} from '..'; export class GroupChatEvent { diff --git a/lib/events/GroupChatSessionAgentListEvent.ts b/lib/events/GroupChatSessionAgentListEvent.ts index ba53520..2ee436a 100644 --- a/lib/events/GroupChatSessionAgentListEvent.ts +++ b/lib/events/GroupChatSessionAgentListEvent.ts @@ -1,4 +1,4 @@ -import {UUID} from '../classes/UUID'; +import {UUID} from '..'; export class GroupChatSessionAgentListEvent { diff --git a/lib/events/GroupChatSessionJoinEvent.ts b/lib/events/GroupChatSessionJoinEvent.ts index bef69dd..f75bf5d 100644 --- a/lib/events/GroupChatSessionJoinEvent.ts +++ b/lib/events/GroupChatSessionJoinEvent.ts @@ -1,4 +1,4 @@ -import {UUID} from '../classes/UUID'; +import {UUID} from '..'; export class GroupChatSessionJoinEvent { diff --git a/lib/events/GroupInviteEvent.ts b/lib/events/GroupInviteEvent.ts index f9810b5..b99689e 100644 --- a/lib/events/GroupInviteEvent.ts +++ b/lib/events/GroupInviteEvent.ts @@ -1,4 +1,4 @@ -import {UUID} from '../classes/UUID'; +import {UUID} from '..'; export class GroupInviteEvent { diff --git a/lib/events/InstantMessageEvent.ts b/lib/events/InstantMessageEvent.ts index 8de4e51..48571d0 100644 --- a/lib/events/InstantMessageEvent.ts +++ b/lib/events/InstantMessageEvent.ts @@ -1,6 +1,4 @@ -import {ChatSourceType} from '../enums/ChatSourceType'; -import {UUID} from '../classes/UUID'; -import {InstantMessageEventFlags} from '../enums/InstantMessageEventFlags'; +import {ChatSourceType, InstantMessageEventFlags, UUID} from '..'; export class InstantMessageEvent { diff --git a/lib/events/InventoryOfferedEvent.ts b/lib/events/InventoryOfferedEvent.ts index b5f9133..df1feb6 100644 --- a/lib/events/InventoryOfferedEvent.ts +++ b/lib/events/InventoryOfferedEvent.ts @@ -1,6 +1,4 @@ -import {UUID} from '../classes/UUID'; -import {ChatSourceType} from '../enums/ChatSourceType'; -import {AssetType} from '../enums/AssetType'; +import {AssetType, ChatSourceType, UUID} from '..'; export class InventoryOfferedEvent { diff --git a/lib/events/LureEvent.ts b/lib/events/LureEvent.ts index c46b035..98ffe95 100644 --- a/lib/events/LureEvent.ts +++ b/lib/events/LureEvent.ts @@ -1,5 +1,4 @@ -import {UUID} from '../classes/UUID'; -import {Vector3} from '../classes/Vector3'; +import {UUID, Vector3} from '..'; export class LureEvent { diff --git a/lib/index.ts b/lib/index.ts index c0e7aa4..1871c4a 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -17,12 +17,28 @@ import {Vector3} from './classes/Vector3'; import {ChatEvent} from './events/ChatEvent'; import {GroupInviteEvent} from './events/GroupInviteEvent'; import {FriendRequestEvent} from './events/FriendRequestEvent'; +import {FriendResponseEvent} from './events/FriendResponseEvent'; import {LureEvent} from './events/LureEvent'; import {TeleportEvent} from './events/TeleportEvent'; import {DisconnectEvent} from './events/DisconnectEvent'; import {GroupChatEvent} from './events/GroupChatEvent'; import {GroupChatSessionJoinEvent} from './events/GroupChatSessionJoinEvent'; import {GroupChatSessionAgentListEvent} from './events/GroupChatSessionAgentListEvent'; +import {RegionInfoReplyEvent} from './events/RegionInfoReplyEvent'; +import {MapInfoReplyEvent} from './events/MapInfoReplyEvent'; +import {MapInfoRangeReplyEvent} from './events/MapInfoRangeReplyEvent'; +import {InventoryOfferedEvent} from './events/InventoryOfferedEvent'; +import {AgentFlags} from './enums/AgentFlags'; +import {ControlFlags} from './enums/ControlFlags'; +import {InventoryItemFlags} from './enums/InventoryItemFlags'; +import {LoginFlags} from './enums/LoginFlags'; +import {MessageFlags} from './enums/MessageFlags'; +import {PacketFlags} from './enums/PacketFlags'; +import {RegionProtocolFlags} from './enums/RegionProtocolFlags'; +import {SoundFlags} from './enums/SoundFlags'; +import {TeleportFlags} from './enums/TeleportFlags'; +import {CompressedFlags} from './enums/CompressedFlags'; +import {DecodeFlags} from './enums/DecodeFlags'; export { Bot, @@ -31,19 +47,39 @@ export { HTTPAssets, ClientEvents, BVH, - InstantMessageEvent, - InstantMessageEventFlags, ChatSourceType, BotOptionFlags, UUID, Vector3, + + // Flags + AgentFlags, + CompressedFlags, + ControlFlags, + DecodeFlags, + InstantMessageEventFlags, + InventoryItemFlags, + LoginFlags, + MessageFlags, + PacketFlags, + RegionProtocolFlags, + SoundFlags, + TeleportFlags, + + // Events ChatEvent, - GroupInviteEvent, - FriendRequestEvent, - LureEvent, - TeleportEvent, DisconnectEvent, + FriendRequestEvent, + FriendResponseEvent, GroupChatEvent, + GroupChatSessionAgentListEvent, GroupChatSessionJoinEvent, - GroupChatSessionAgentListEvent + GroupInviteEvent, + InstantMessageEvent, + InventoryOfferedEvent, + LureEvent, + MapInfoRangeReplyEvent, + MapInfoReplyEvent, + RegionInfoReplyEvent, + TeleportEvent };