omegga 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/README.md +20 -1
  2. package/dist/brickadia/config.js +26 -90
  3. package/dist/brickadia/config.js.map +1 -1
  4. package/dist/brickadia/server.js +294 -293
  5. package/dist/brickadia/server.js.map +1 -1
  6. package/dist/cli/auth.js +149 -177
  7. package/dist/cli/auth.js.map +1 -1
  8. package/dist/cli/config.js +64 -66
  9. package/dist/cli/config.js.map +1 -1
  10. package/dist/cli/index.js +14 -14
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/cli/installer.js +37 -43
  13. package/dist/cli/installer.js.map +1 -1
  14. package/dist/cli/plugin.js +651 -682
  15. package/dist/cli/plugin.js.map +1 -1
  16. package/dist/cli/terminal.js +811 -733
  17. package/dist/cli/terminal.js.map +1 -1
  18. package/dist/config/formats/format_js.js +6 -6
  19. package/dist/config/formats/format_js.js.map +1 -1
  20. package/dist/config/formats/format_yml.js +7 -10
  21. package/dist/config/formats/format_yml.js.map +1 -1
  22. package/dist/config/index.js +46 -68
  23. package/dist/config/index.js.map +1 -1
  24. package/dist/config/reader.js +16 -27
  25. package/dist/config/reader.js.map +1 -1
  26. package/dist/config/validator.js +23 -25
  27. package/dist/config/validator.js.map +1 -1
  28. package/dist/config/writer.js +11 -21
  29. package/dist/config/writer.js.map +1 -1
  30. package/dist/index.js +18 -64
  31. package/dist/index.js.map +1 -1
  32. package/dist/info/default_commands.json.js +39 -0
  33. package/dist/info/default_commands.json.js.map +1 -0
  34. package/dist/logger.js +61 -60
  35. package/dist/logger.js.map +1 -1
  36. package/dist/main.js +424 -471
  37. package/dist/main.js.map +1 -1
  38. package/dist/omegga/auth.js +101 -148
  39. package/dist/omegga/auth.js.map +1 -1
  40. package/dist/omegga/commandInjector.js +261 -251
  41. package/dist/omegga/commandInjector.js.map +1 -1
  42. package/dist/omegga/index.js +14 -52
  43. package/dist/omegga/index.js.map +1 -1
  44. package/dist/omegga/logWrangler.js +224 -275
  45. package/dist/omegga/logWrangler.js.map +1 -1
  46. package/dist/omegga/matchers/auth.js +36 -50
  47. package/dist/omegga/matchers/auth.js.map +1 -1
  48. package/dist/omegga/matchers/chat.js +49 -71
  49. package/dist/omegga/matchers/chat.js.map +1 -1
  50. package/dist/omegga/matchers/command.js +25 -36
  51. package/dist/omegga/matchers/command.js.map +1 -1
  52. package/dist/omegga/matchers/exit.js +15 -18
  53. package/dist/omegga/matchers/exit.js.map +1 -1
  54. package/dist/omegga/matchers/index.js +26 -40
  55. package/dist/omegga/matchers/index.js.map +1 -1
  56. package/dist/omegga/matchers/init.js +20 -23
  57. package/dist/omegga/matchers/init.js.map +1 -1
  58. package/dist/omegga/matchers/interact.js +58 -64
  59. package/dist/omegga/matchers/interact.js.map +1 -1
  60. package/dist/omegga/matchers/join.js +74 -95
  61. package/dist/omegga/matchers/join.js.map +1 -1
  62. package/dist/omegga/matchers/leave.js +43 -56
  63. package/dist/omegga/matchers/leave.js.map +1 -1
  64. package/dist/omegga/matchers/mapChange.js +26 -35
  65. package/dist/omegga/matchers/mapChange.js.map +1 -1
  66. package/dist/omegga/matchers/minigameJoin.js +24 -31
  67. package/dist/omegga/matchers/minigameJoin.js.map +1 -1
  68. package/dist/omegga/matchers/version.js +42 -49
  69. package/dist/omegga/matchers/version.js.map +1 -1
  70. package/dist/omegga/player.js +527 -527
  71. package/dist/omegga/player.js.map +1 -1
  72. package/dist/omegga/plugin/interface.js +91 -98
  73. package/dist/omegga/plugin/interface.js.map +1 -1
  74. package/dist/omegga/plugin/plugin_jsonrpc_stdio.js +524 -429
  75. package/dist/omegga/plugin/plugin_jsonrpc_stdio.js.map +1 -1
  76. package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js +282 -294
  77. package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js.map +1 -1
  78. package/dist/omegga/plugin/plugin_node_safe.js +365 -393
  79. package/dist/omegga/plugin/plugin_node_safe.js.map +1 -1
  80. package/dist/omegga/plugin/plugin_node_unsafe.js +119 -179
  81. package/dist/omegga/plugin/plugin_node_unsafe.js.map +1 -1
  82. package/dist/omegga/plugin.js +402 -347
  83. package/dist/omegga/plugin.js.map +1 -1
  84. package/dist/omegga/server.js +742 -774
  85. package/dist/omegga/server.js.map +1 -1
  86. package/dist/omegga/wrapper.js +64 -91
  87. package/dist/omegga/wrapper.js.map +1 -1
  88. package/dist/plugin.js +11 -31
  89. package/dist/plugin.js.map +1 -1
  90. package/dist/softconfig.js +121 -100
  91. package/dist/softconfig.js.map +1 -1
  92. package/dist/updater/steam.js +97 -112
  93. package/dist/updater/steam.js.map +1 -1
  94. package/dist/util/brdb.js +496 -528
  95. package/dist/util/brdb.js.map +1 -1
  96. package/dist/util/brick/checkBounds.js +11 -15
  97. package/dist/util/brick/checkBounds.js.map +1 -1
  98. package/dist/util/brick/constants.js +723 -174
  99. package/dist/util/brick/constants.js.map +1 -1
  100. package/dist/util/brick/displayName.js +204 -211
  101. package/dist/util/brick/displayName.js.map +1 -1
  102. package/dist/util/brick/getBounds.js +29 -41
  103. package/dist/util/brick/getBounds.js.map +1 -1
  104. package/dist/util/brick/getBrickSize.js +6 -7
  105. package/dist/util/brick/getBrickSize.js.map +1 -1
  106. package/dist/util/brick/getScaleAxis.js +24 -30
  107. package/dist/util/brick/getScaleAxis.js.map +1 -1
  108. package/dist/util/brick/index.js +8 -29
  109. package/dist/util/brick/index.js.map +1 -1
  110. package/dist/util/brick/rotate.js +29 -34
  111. package/dist/util/brick/rotate.js.map +1 -1
  112. package/dist/util/brick/setOwnership.js +13 -19
  113. package/dist/util/brick/setOwnership.js.map +1 -1
  114. package/dist/util/chat.js +53 -44
  115. package/dist/util/chat.js.map +1 -1
  116. package/dist/util/color.js +112 -124
  117. package/dist/util/color.js.map +1 -1
  118. package/dist/util/file.js +54 -98
  119. package/dist/util/file.js.map +1 -1
  120. package/dist/util/index.js +84 -106
  121. package/dist/util/index.js.map +1 -1
  122. package/dist/util/map.js +18 -20
  123. package/dist/util/map.js.map +1 -1
  124. package/dist/util/pattern.js +6 -9
  125. package/dist/util/pattern.js.map +1 -1
  126. package/dist/util/time.js +31 -34
  127. package/dist/util/time.js.map +1 -1
  128. package/dist/util/uuid.js +10 -8
  129. package/dist/util/uuid.js.map +1 -1
  130. package/dist/util/wsl.js +19 -25
  131. package/dist/util/wsl.js.map +1 -1
  132. package/dist/version.js +7 -9
  133. package/dist/version.js.map +1 -1
  134. package/dist/webserver/backend/api.js +784 -874
  135. package/dist/webserver/backend/api.js.map +1 -1
  136. package/dist/webserver/backend/calendar.js +14 -17
  137. package/dist/webserver/backend/calendar.js.map +1 -1
  138. package/dist/webserver/backend/database.js +563 -613
  139. package/dist/webserver/backend/database.js.map +1 -1
  140. package/dist/webserver/backend/index.js +153 -191
  141. package/dist/webserver/backend/index.js.map +1 -1
  142. package/dist/webserver/backend/metrics.js +219 -248
  143. package/dist/webserver/backend/metrics.js.map +1 -1
  144. package/dist/webserver/backend/util.js +47 -68
  145. package/dist/webserver/backend/util.js.map +1 -1
  146. package/dist/worker.js +322 -0
  147. package/dist/worker.js.map +1 -0
  148. package/package.json +14 -10
  149. package/templates/safe-ts/omegga.d.ts +2 -2
  150. package/vite.backend.config.mts +46 -0
  151. package/vite.frontend.config.mts +58 -0
  152. package/vitest.backend.config.mts +7 -0
  153. package/dist/brickadia/config.d.ts +0 -3
  154. package/dist/brickadia/presets.d.ts +0 -65
  155. package/dist/brickadia/presets.js +0 -3
  156. package/dist/brickadia/presets.js.map +0 -1
  157. package/dist/brickadia/server.d.ts +0 -36
  158. package/dist/brickadia/types.d.ts +0 -45
  159. package/dist/brickadia/types.js +0 -3
  160. package/dist/brickadia/types.js.map +0 -1
  161. package/dist/cli/auth.d.ts +0 -26
  162. package/dist/cli/config.d.ts +0 -10
  163. package/dist/cli/index.d.ts +0 -30
  164. package/dist/cli/installer.d.ts +0 -1
  165. package/dist/cli/plugin.d.ts +0 -22
  166. package/dist/cli/terminal.d.ts +0 -25
  167. package/dist/config/authorizer.d.ts +0 -2
  168. package/dist/config/authorizer.js +0 -38
  169. package/dist/config/authorizer.js.map +0 -1
  170. package/dist/config/formats/format_js.d.ts +0 -3
  171. package/dist/config/formats/format_yml.d.ts +0 -3
  172. package/dist/config/index.d.ts +0 -18
  173. package/dist/config/reader.d.ts +0 -3
  174. package/dist/config/types.d.ts +0 -50
  175. package/dist/config/types.js +0 -3
  176. package/dist/config/types.js.map +0 -1
  177. package/dist/config/validator.d.ts +0 -6
  178. package/dist/config/writer.d.ts +0 -3
  179. package/dist/index.d.ts +0 -22
  180. package/dist/info/default_commands.json +0 -29
  181. package/dist/logger.d.ts +0 -41
  182. package/dist/main.d.ts +0 -1
  183. package/dist/omegga/auth.d.ts +0 -9
  184. package/dist/omegga/commandInjector.d.ts +0 -35
  185. package/dist/omegga/index.d.ts +0 -7
  186. package/dist/omegga/logWrangler.d.ts +0 -32
  187. package/dist/omegga/matchers/auth.d.ts +0 -10
  188. package/dist/omegga/matchers/chat.d.ts +0 -10
  189. package/dist/omegga/matchers/command.d.ts +0 -7
  190. package/dist/omegga/matchers/exit.d.ts +0 -3
  191. package/dist/omegga/matchers/index.d.ts +0 -3
  192. package/dist/omegga/matchers/init.d.ts +0 -3
  193. package/dist/omegga/matchers/interact.d.ts +0 -4
  194. package/dist/omegga/matchers/join.d.ts +0 -4
  195. package/dist/omegga/matchers/leave.d.ts +0 -4
  196. package/dist/omegga/matchers/mapChange.d.ts +0 -3
  197. package/dist/omegga/matchers/minigameJoin.d.ts +0 -9
  198. package/dist/omegga/matchers/types.d.ts +0 -5
  199. package/dist/omegga/matchers/types.js +0 -3
  200. package/dist/omegga/matchers/types.js.map +0 -1
  201. package/dist/omegga/matchers/version.d.ts +0 -3
  202. package/dist/omegga/player.d.ts +0 -81
  203. package/dist/omegga/plugin/interface.d.ts +0 -30
  204. package/dist/omegga/plugin/plugin_jsonrpc_stdio.d.ts +0 -23
  205. package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.d.ts +0 -145
  206. package/dist/omegga/plugin/plugin_node_safe/worker.d.ts +0 -1
  207. package/dist/omegga/plugin/plugin_node_safe/worker.js +0 -367
  208. package/dist/omegga/plugin/plugin_node_safe/worker.js.map +0 -1
  209. package/dist/omegga/plugin/plugin_node_safe.d.ts +0 -23
  210. package/dist/omegga/plugin/plugin_node_unsafe.d.ts +0 -13
  211. package/dist/omegga/plugin.d.ts +0 -63
  212. package/dist/omegga/server.d.ts +0 -166
  213. package/dist/omegga/types.d.ts +0 -49
  214. package/dist/omegga/types.js +0 -3
  215. package/dist/omegga/types.js.map +0 -1
  216. package/dist/omegga/wrapper.d.ts +0 -32
  217. package/dist/plugin.d.ts +0 -916
  218. package/dist/softconfig.d.ts +0 -67
  219. package/dist/tsconfig.tsbuildinfo +0 -1
  220. package/dist/updater/index.d.ts +0 -1
  221. package/dist/updater/index.js +0 -10
  222. package/dist/updater/index.js.map +0 -1
  223. package/dist/updater/steam.d.ts +0 -52
  224. package/dist/util/brdb.d.ts +0 -31
  225. package/dist/util/brick/checkBounds.d.ts +0 -8
  226. package/dist/util/brick/constants.d.ts +0 -18
  227. package/dist/util/brick/displayName.d.ts +0 -7
  228. package/dist/util/brick/getBounds.d.ts +0 -5
  229. package/dist/util/brick/getBrickSize.d.ts +0 -3
  230. package/dist/util/brick/getScaleAxis.d.ts +0 -3
  231. package/dist/util/brick/index.d.ts +0 -14
  232. package/dist/util/brick/rotate.d.ts +0 -16
  233. package/dist/util/brick/setOwnership.d.ts +0 -12
  234. package/dist/util/chat.d.ts +0 -23
  235. package/dist/util/color.d.ts +0 -13
  236. package/dist/util/file.d.ts +0 -5
  237. package/dist/util/index.d.ts +0 -183
  238. package/dist/util/map.d.ts +0 -6
  239. package/dist/util/pattern.d.ts +0 -1
  240. package/dist/util/time.d.ts +0 -39
  241. package/dist/util/uuid.d.ts +0 -3
  242. package/dist/util/wsl.d.ts +0 -2
  243. package/dist/version.d.ts +0 -2
  244. package/dist/webserver/backend/api.d.ts +0 -115
  245. package/dist/webserver/backend/calendar.d.ts +0 -5
  246. package/dist/webserver/backend/database.d.ts +0 -150
  247. package/dist/webserver/backend/index.d.ts +0 -30
  248. package/dist/webserver/backend/metrics.d.ts +0 -3
  249. package/dist/webserver/backend/types.d.ts +0 -114
  250. package/dist/webserver/backend/types.js +0 -3
  251. package/dist/webserver/backend/types.js.map +0 -1
  252. package/dist/webserver/backend/util.d.ts +0 -2
  253. package/dist/webserver/index.d.ts +0 -2
  254. package/dist/webserver/index.js +0 -9
  255. package/dist/webserver/index.js.map +0 -1
@@ -1,543 +1,543 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _Player_omegga;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const util_1 = require("../util/");
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const index = require("../util/index.js");
16
4
  const DEFAULT_PERMS = {
17
- moderator: [
18
- 'Bricks.ClearAll',
19
- 'Minigame.AlwaysLeave',
20
- 'Players.Kick',
21
- 'Players.TPInMinigame',
22
- 'Players.TPOthers',
23
- 'Self.Ghost',
24
- ],
25
- admin: [
26
- 'Bricks.ClearAll',
27
- 'Bricks.ClearOwn',
28
- 'Bricks.IgnoreTrust',
29
- 'Bricks.Load',
30
- 'Map.Environment',
31
- 'Minigame.AlwaysEdit',
32
- 'Minigame.AlwaysLeave',
33
- 'Minigame.AlwaysSwitchTeam',
34
- 'Minigame.MakeDefault',
35
- 'Minigame.MakePersistent',
36
- 'Minigame.UseAllBricks',
37
- 'Players.Ban',
38
- 'Players.Kick',
39
- 'Players.TPInMinigame',
40
- 'Players.TPOthers',
41
- 'Roles.Grant',
42
- 'Self.Ghost',
43
- 'Server.ChangeRoles',
44
- 'Server.ChangeSettings',
45
- 'Server.FreezeCamera',
46
- 'Tools.Selector.BypassLimits',
47
- 'Tools.Selector.BypassTimeouts',
48
- ],
5
+ moderator: [
6
+ "Bricks.ClearAll",
7
+ "Minigame.AlwaysLeave",
8
+ "Players.Kick",
9
+ "Players.TPInMinigame",
10
+ "Players.TPOthers",
11
+ "Self.Ghost"
12
+ ],
13
+ admin: [
14
+ "Bricks.ClearAll",
15
+ "Bricks.ClearOwn",
16
+ "Bricks.IgnoreTrust",
17
+ "Bricks.Load",
18
+ "Map.Environment",
19
+ "Minigame.AlwaysEdit",
20
+ "Minigame.AlwaysLeave",
21
+ "Minigame.AlwaysSwitchTeam",
22
+ "Minigame.MakeDefault",
23
+ "Minigame.MakePersistent",
24
+ "Minigame.UseAllBricks",
25
+ "Players.Ban",
26
+ "Players.Kick",
27
+ "Players.TPInMinigame",
28
+ "Players.TPOthers",
29
+ "Roles.Grant",
30
+ "Self.Ghost",
31
+ "Server.ChangeRoles",
32
+ "Server.ChangeSettings",
33
+ "Server.FreezeCamera",
34
+ "Tools.Selector.BypassLimits",
35
+ "Tools.Selector.BypassTimeouts"
36
+ ]
49
37
  };
50
38
  class Player {
51
- static getRoles(omegga, id) {
52
- const data = omegga.getRoleAssignments().savedPlayerRoles[id];
53
- return Object.freeze(data && data.roles ? data.roles : []);
54
- }
55
- static getPermissions(omegga, id) {
56
- const { roles, defaultRole } = omegga.getRoleSetup();
57
- // if the player is the host, the player has every permission
58
- if (omegga.host.id === id) {
59
- return Object.freeze(Object.fromEntries([].concat(defaultRole.permissions.map(p => [p.name, true]),
60
- // sometimes the default role does not have every permission listed
61
- ...roles.map(r => r.permissions.map(p => [p.name, true])))));
62
- }
63
- // get the player's roles
64
- const playerRoles = Player.getRoles(omegga, id).map(r => r.toLowerCase());
65
- // default player permissions
66
- const permissions = {
67
- 'Bricks.ClearAll': false,
68
- 'Bricks.ClearOwn': true,
69
- 'Bricks.Delete': true,
70
- 'Bricks.Edit': true,
71
- 'Bricks.IgnoreTrust': false,
72
- 'Bricks.Paint': true,
73
- 'Bricks.Place': true,
74
- 'BricksItems.Spawn': true,
75
- 'Map.Change': false,
76
- 'Map.Environment': false,
77
- 'Map.SetSpawn': false,
78
- 'Minigame.AlwaysEdit': false,
79
- 'Minigame.AlwaysLeave': false,
80
- 'Minigame.AlwaysSwitchTeam': false,
81
- 'Minigame.Create': true,
82
- 'Minigame.MakePersistent': false,
83
- 'Minigame.UseAllBricks': false,
84
- 'Players.Ban': false,
85
- 'Players.TPInMinigame': false,
86
- 'Players.TPOthers': false,
87
- 'Players.TPSelf': true,
88
- 'Roles.Grant': false,
89
- 'Self.Flashlight': true,
90
- 'Self.Fly': true,
91
- 'Self.FreezeCamera': false,
92
- 'Self.Ghost': false,
93
- 'Self.Sprint': true,
94
- 'Self.Suicide': true,
95
- 'Tools.Selector.Use': true,
96
- };
97
- // apply all permissions from default role
98
- for (const p of defaultRole.permissions) {
99
- // technically this can never be Unchanged so it's always on enabled or allowed
100
- permissions[p.name] =
101
- p.state === 'Unchanged' ? permissions[p.name] : p.state === 'Allowed';
102
- }
103
- // loop through all the roles
104
- for (const role of roles) {
105
- // ignore ones the player does not have
106
- if (!playerRoles.includes(role.name.toLowerCase()))
107
- continue;
108
- const defaultPerms = DEFAULT_PERMS[role.name.toLowerCase()] || [];
109
- // iterate through default permissions
110
- for (const perm of defaultPerms) {
111
- // if they are not overriden, set it to true
112
- if (!role.permissions.find(r => r.name === perm))
113
- permissions[perm] = true;
114
- }
115
- // add all the new permissions the player now has
116
- for (const p of role.permissions) {
117
- // permission is disabled on forbidden, persisted on unchanged, and enabled on bEnabled or Allowed
118
- permissions[p.name] =
119
- p.state !== 'Forbidden' &&
120
- (p.state === 'Unchanged'
121
- ? permissions[p.name]
122
- : permissions[p.name] || p.state === 'Allowed');
123
- permissions[p.name] = permissions[p.name];
124
- }
39
+ #omegga;
40
+ static getRoles(omegga, id) {
41
+ const data = omegga.getRoleAssignments().savedPlayerRoles[id];
42
+ return Object.freeze(data && data.roles ? data.roles : []);
43
+ }
44
+ static getPermissions(omegga, id) {
45
+ const { roles, defaultRole } = omegga.getRoleSetup();
46
+ if (omegga.host.id === id) {
47
+ return Object.freeze(
48
+ Object.fromEntries(
49
+ [].concat(
50
+ defaultRole.permissions.map((p) => [p.name, true]),
51
+ ...roles.map((r) => r.permissions.map((p) => [p.name, true]))
52
+ )
53
+ )
54
+ );
55
+ }
56
+ const playerRoles = Player.getRoles(omegga, id).map((r) => r.toLowerCase());
57
+ const permissions = {
58
+ "Bricks.ClearAll": false,
59
+ "Bricks.ClearOwn": true,
60
+ "Bricks.Delete": true,
61
+ "Bricks.Edit": true,
62
+ "Bricks.IgnoreTrust": false,
63
+ "Bricks.Paint": true,
64
+ "Bricks.Place": true,
65
+ "BricksItems.Spawn": true,
66
+ "Map.Change": false,
67
+ "Map.Environment": false,
68
+ "Map.SetSpawn": false,
69
+ "Minigame.AlwaysEdit": false,
70
+ "Minigame.AlwaysLeave": false,
71
+ "Minigame.AlwaysSwitchTeam": false,
72
+ "Minigame.Create": true,
73
+ "Minigame.MakePersistent": false,
74
+ "Minigame.UseAllBricks": false,
75
+ "Players.Ban": false,
76
+ "Players.TPInMinigame": false,
77
+ "Players.TPOthers": false,
78
+ "Players.TPSelf": true,
79
+ "Roles.Grant": false,
80
+ "Self.Flashlight": true,
81
+ "Self.Fly": true,
82
+ "Self.FreezeCamera": false,
83
+ "Self.Ghost": false,
84
+ "Self.Sprint": true,
85
+ "Self.Suicide": true,
86
+ "Tools.Selector.Use": true
87
+ };
88
+ for (const p of defaultRole.permissions) {
89
+ permissions[p.name] = p.state === "Unchanged" ? permissions[p.name] : p.state === "Allowed";
90
+ }
91
+ for (const role of roles) {
92
+ if (!playerRoles.includes(role.name.toLowerCase())) continue;
93
+ const defaultPerms = DEFAULT_PERMS[role.name.toLowerCase()] || [];
94
+ for (const perm of defaultPerms) {
95
+ if (!role.permissions.find((r) => r.name === perm))
96
+ permissions[perm] = true;
97
+ }
98
+ for (const p of role.permissions) {
99
+ permissions[p.name] = p.state !== "Forbidden" && (p.state === "Unchanged" ? permissions[p.name] : permissions[p.name] || p.state === "Allowed");
100
+ permissions[p.name] = permissions[p.name];
101
+ }
102
+ }
103
+ return Object.freeze(permissions);
104
+ }
105
+ static kill(omegga, target) {
106
+ if (typeof target === "string") target = omegga.getPlayer(target);
107
+ if (target?.name) omegga.writeln(`Server.Players.Kill "${target?.name}"`);
108
+ }
109
+ static damage(omegga, target, amount) {
110
+ if (typeof target === "string") target = omegga.getPlayer(target);
111
+ if (amount === 0) return;
112
+ if (target?.name)
113
+ omegga.writeln(`Server.Players.Damage "${target?.name}" ${amount}`);
114
+ }
115
+ static heal(omegga, target, amount) {
116
+ if (amount === 0) return;
117
+ Player.damage(omegga, target, -amount);
118
+ }
119
+ static giveItem(omegga, target, item) {
120
+ if (typeof target === "string") target = omegga.getPlayer(target);
121
+ if (!item) return;
122
+ if (target?.name)
123
+ omegga.writeln(`Server.Players.GiveItem "${target?.name}" ${item}`);
124
+ }
125
+ static takeItem(omegga, target, item) {
126
+ if (typeof target === "string") target = omegga.getPlayer(target);
127
+ if (!item) return;
128
+ if (target?.name)
129
+ omegga.writeln(`Server.Players.RemoveItem "${target?.name}" ${item}`);
130
+ }
131
+ static setTeam(omegga, target, teamIndex) {
132
+ if (typeof target === "string") target = omegga.getPlayer(target);
133
+ if (target?.name)
134
+ omegga.writeln(`Server.Players.SetTeam "${target?.name}" ${teamIndex}`);
135
+ }
136
+ static setMinigame(omegga, target, index2) {
137
+ if (typeof target === "string") target = omegga.getPlayer(target);
138
+ if (target?.name)
139
+ omegga.writeln(`Server.Players.SetMinigame "${target?.name}" ${index2}`);
140
+ }
141
+ static setScore(omegga, target, minigameIndex, score) {
142
+ if (typeof target === "string") target = omegga.getPlayer(target);
143
+ if (target?.name)
144
+ omegga.writeln(
145
+ `Server.Players.SetLeaderboardValue "${target?.name}" ${minigameIndex} ${score}`
146
+ );
147
+ }
148
+ static async getScore(omegga, target, minigameIndex) {
149
+ if (typeof target === "string") target = omegga.getPlayer(target);
150
+ if (target?.name) {
151
+ const name = target?.name;
152
+ const id = target?.id;
153
+ const match = await omegga.addWatcher(
154
+ (line, match2) => {
155
+ if (match2 && match2.groups.generator === "LogConsoleCommands") {
156
+ const test = match2.groups.data.match(
157
+ /^(?<uuid>.+) leaderboard value (?<minigame>\d+) = (?<score>-?\d+)$/
158
+ );
159
+ if (!test) return;
160
+ if (test.groups.uuid !== id) return;
161
+ if (Number(test.groups.minigame) !== minigameIndex) return;
162
+ return test;
163
+ }
164
+ },
165
+ {
166
+ timeoutDelay: 1e3,
167
+ exec: () => omegga.writeln(
168
+ `Server.Players.PrintLeaderboardValue "${name}" ${minigameIndex}`
169
+ )
125
170
  }
126
- return Object.freeze(permissions);
127
- }
128
- static kill(omegga, target) {
129
- if (typeof target === 'string')
130
- target = omegga.getPlayer(target);
131
- if (target === null || target === void 0 ? void 0 : target.name)
132
- omegga.writeln(`Server.Players.Kill "${target === null || target === void 0 ? void 0 : target.name}"`);
133
- }
134
- static damage(omegga, target, amount) {
135
- if (typeof target === 'string')
136
- target = omegga.getPlayer(target);
137
- if (amount === 0)
138
- return;
139
- if (target === null || target === void 0 ? void 0 : target.name)
140
- omegga.writeln(`Server.Players.Damage "${target === null || target === void 0 ? void 0 : target.name}" ${amount}`);
141
- }
142
- static heal(omegga, target, amount) {
143
- if (amount === 0)
144
- return;
145
- Player.damage(omegga, target, -amount);
146
- }
147
- static giveItem(omegga, target, item) {
148
- if (typeof target === 'string')
149
- target = omegga.getPlayer(target);
150
- if (!item)
151
- return;
152
- if (target === null || target === void 0 ? void 0 : target.name)
153
- omegga.writeln(`Server.Players.GiveItem "${target === null || target === void 0 ? void 0 : target.name}" ${item}`);
154
- }
155
- static takeItem(omegga, target, item) {
156
- if (typeof target === 'string')
157
- target = omegga.getPlayer(target);
158
- if (!item)
159
- return;
160
- if (target === null || target === void 0 ? void 0 : target.name)
161
- omegga.writeln(`Server.Players.RemoveItem "${target === null || target === void 0 ? void 0 : target.name}" ${item}`);
162
- }
163
- static setTeam(omegga, target, teamIndex) {
164
- if (typeof target === 'string')
165
- target = omegga.getPlayer(target);
166
- if (target === null || target === void 0 ? void 0 : target.name)
167
- omegga.writeln(`Server.Players.SetTeam "${target === null || target === void 0 ? void 0 : target.name}" ${teamIndex}`);
168
- }
169
- static setMinigame(omegga, target, index) {
170
- if (typeof target === 'string')
171
- target = omegga.getPlayer(target);
172
- if (target === null || target === void 0 ? void 0 : target.name)
173
- omegga.writeln(`Server.Players.SetMinigame "${target === null || target === void 0 ? void 0 : target.name}" ${index}`);
174
- }
175
- static setScore(omegga, target, minigameIndex, score) {
176
- if (typeof target === 'string')
177
- target = omegga.getPlayer(target);
178
- if (target === null || target === void 0 ? void 0 : target.name)
179
- omegga.writeln(`Server.Players.SetLeaderboardValue "${target === null || target === void 0 ? void 0 : target.name}" ${minigameIndex} ${score}`);
180
- }
181
- static async getScore(omegga, target, minigameIndex) {
182
- if (typeof target === 'string')
183
- target = omegga.getPlayer(target);
184
- if (target === null || target === void 0 ? void 0 : target.name) {
185
- const name = target === null || target === void 0 ? void 0 : target.name;
186
- const id = target === null || target === void 0 ? void 0 : target.id;
187
- const match = await omegga.addWatcher((line, match) => {
188
- if (match && match.groups.generator === 'LogConsoleCommands') {
189
- const test = match.groups.data.match(/^(?<uuid>.+) leaderboard value (?<minigame>\d+) = (?<score>-?\d+)$/);
190
- if (!test)
191
- return;
192
- if (test.groups.uuid !== id)
193
- return;
194
- if (Number(test.groups.minigame) !== minigameIndex)
195
- return;
196
- return test;
197
- }
198
- }, {
199
- timeoutDelay: 1000,
200
- exec: () => omegga.writeln(`Server.Players.PrintLeaderboardValue "${name}" ${minigameIndex}`),
201
- });
202
- if (match)
203
- return Number(match[0].groups.score);
171
+ );
172
+ if (match) return Number(match[0].groups.score);
173
+ }
174
+ return 0;
175
+ }
176
+ /**
177
+ * players are not to be constructed
178
+ * @constructor
179
+ * @param omegga Omegga Instance
180
+ * @param name Player Name
181
+ * @param displayName Player Display Name
182
+ * @param id Player Id
183
+ * @param controller Player Controller
184
+ * @param state Player State
185
+ */
186
+ constructor(omegga, username, displayName, id, controller, state) {
187
+ this.#omegga = omegga;
188
+ this.name = username;
189
+ this.displayName = displayName;
190
+ this.id = id;
191
+ this.controller = controller;
192
+ this.state = state;
193
+ }
194
+ getOmegga() {
195
+ return this.#omegga;
196
+ }
197
+ clone() {
198
+ return new Player(
199
+ this.#omegga,
200
+ this.name,
201
+ this.displayName,
202
+ this.id,
203
+ this.controller,
204
+ this.state
205
+ );
206
+ }
207
+ raw() {
208
+ return [this.name, this.displayName, this.id, this.controller, this.state];
209
+ }
210
+ isHost() {
211
+ return this.#omegga.host.id === this.id;
212
+ }
213
+ clearBricks(quiet = false) {
214
+ this.#omegga.clearBricks(this.id, quiet);
215
+ }
216
+ getRoles() {
217
+ return Player.getRoles(this.#omegga, this.id);
218
+ }
219
+ getPermissions() {
220
+ return Player.getPermissions(this.#omegga, this.id);
221
+ }
222
+ getNameColor() {
223
+ const { roles, defaultRole, ownerRoleColor, bOwnerRoleHasColor } = this.#omegga.getRoleSetup();
224
+ if (this.isHost() && bOwnerRoleHasColor)
225
+ return index.color.rgbToHex(ownerRoleColor);
226
+ const playerRoles = this.getRoles().map((r) => r.toLowerCase());
227
+ if (playerRoles.length > 0) {
228
+ const found = roles.slice().reverse().find(
229
+ (role) => role.bHasColor && playerRoles.includes(role.name.toLowerCase())
230
+ );
231
+ if (found) return index.color.rgbToHex(found.color);
232
+ }
233
+ return index.color.rgbToHex(
234
+ defaultRole.bHasColor ? defaultRole.color : { r: 255, g: 255, b: 255, a: 255 }
235
+ );
236
+ }
237
+ async getPawn() {
238
+ const pawnRegExp = new RegExp(
239
+ `^(?<index>\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = .*?(?:BP_FigureV2_C'.+:PersistentLevel\\.)?(?<pawn>BP_FigureV2_C_\\d+|None)'?`
240
+ );
241
+ const [{ groups: { pawn = null } = {} } = {}] = await this.#omegga.watchLogChunk(
242
+ "GetAll BP_PlayerController_C Pawn Name=" + this.controller,
243
+ pawnRegExp,
244
+ { first: "index", timeoutDelay: 500 }
245
+ );
246
+ if (pawn === "None") return null;
247
+ return pawn;
248
+ }
249
+ async getPosition() {
250
+ const omegga = this.#omegga;
251
+ const pawnRegExp = new RegExp(
252
+ `^(?<index>\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = .*?(?:BP_FigureV2_C'.+:PersistentLevel\\.)?(?<pawn>BP_FigureV2_C_\\d+|None)'?`
253
+ );
254
+ const [
255
+ {
256
+ groups: { pawn }
257
+ }
258
+ ] = await omegga.watchLogChunk(
259
+ "GetAll BP_PlayerController_C Pawn Name=" + this.controller,
260
+ pawnRegExp,
261
+ { first: "index", timeoutDelay: 100 }
262
+ );
263
+ if (pawn === "None") return null;
264
+ const posRegExp = new RegExp(
265
+ `CapsuleComponent .+?PersistentLevel\\.${pawn}\\.CollisionCylinder\\.RelativeLocation = \\(X=(?<x>[\\d\\.-]+),Y=(?<y>[\\d\\.-]+),Z=(?<z>[\\d\\.-]+)\\)`
266
+ );
267
+ const [
268
+ {
269
+ groups: { x, y, z }
270
+ }
271
+ ] = await omegga.addWatcher(posRegExp, {
272
+ // request the position for this player's pawn
273
+ exec: () => omegga.writeln(
274
+ `GetAll SceneComponent RelativeLocation Name=CollisionCylinder Outer=${pawn}`
275
+ ),
276
+ timeoutDelay: 100
277
+ });
278
+ return [Number(x), Number(y), Number(z)];
279
+ }
280
+ async getGhostBrick() {
281
+ const { controller } = this;
282
+ const previewClass = "BP_ToolPreviewActor_C";
283
+ const ownerRegExp = new RegExp(
284
+ `^(?<index>\\d+)\\) ${previewClass} (.+):PersistentLevel\\.(?<actor>${previewClass}_\\d+).Owner = .*?BP_PlayerController_C'(.+):PersistentLevel\\.(?<controller>BP_PlayerController_C_\\d+)'$`
285
+ );
286
+ const transformParamsRegExp = new RegExp(
287
+ `^(?<index>\\d+)\\) ${previewClass} (.+):PersistentLevel\\.(?<actor>${previewClass}_\\d+)\\.TransformParameters = \\(TargetGrid=("(?<targetGrid>.+)"|None),Location=\\(X=(?<x>.+),Y=(?<y>.+),Z=(?<z>.+)\\),Orientation=(?<orientation>.+)\\)$`
288
+ );
289
+ const [owners, transformParams] = await Promise.all([
290
+ this.#omegga.watchLogChunk(
291
+ `GetAll ${previewClass} Owner`,
292
+ ownerRegExp,
293
+ {
294
+ first: "index",
295
+ timeoutDelay: 2e3,
296
+ afterMatchDelay: 100
204
297
  }
205
- return 0;
206
- }
207
- /**
208
- * players are not to be constructed
209
- * @constructor
210
- * @param omegga Omegga Instance
211
- * @param name Player Name
212
- * @param displayName Player Display Name
213
- * @param id Player Id
214
- * @param controller Player Controller
215
- * @param state Player State
216
- */
217
- constructor(omegga, username, displayName, id, controller, state) {
218
- _Player_omegga.set(this, void 0);
219
- __classPrivateFieldSet(this, _Player_omegga, omegga, "f");
220
- this.name = username;
221
- this.displayName = displayName;
222
- this.id = id;
223
- this.controller = controller;
224
- this.state = state;
225
- }
226
- getOmegga() {
227
- return __classPrivateFieldGet(this, _Player_omegga, "f");
228
- }
229
- clone() {
230
- return new Player(__classPrivateFieldGet(this, _Player_omegga, "f"), this.name, this.displayName, this.id, this.controller, this.state);
231
- }
232
- raw() {
233
- return [this.name, this.displayName, this.id, this.controller, this.state];
234
- }
235
- isHost() {
236
- return __classPrivateFieldGet(this, _Player_omegga, "f").host.id === this.id;
237
- }
238
- clearBricks(quiet = false) {
239
- __classPrivateFieldGet(this, _Player_omegga, "f").clearBricks(this.id, quiet);
240
- }
241
- getRoles() {
242
- return Player.getRoles(__classPrivateFieldGet(this, _Player_omegga, "f"), this.id);
243
- }
244
- getPermissions() {
245
- return Player.getPermissions(__classPrivateFieldGet(this, _Player_omegga, "f"), this.id);
246
- }
247
- getNameColor() {
248
- const { roles, defaultRole, ownerRoleColor, bOwnerRoleHasColor } = __classPrivateFieldGet(this, _Player_omegga, "f").getRoleSetup();
249
- // host check if host has host color
250
- if (this.isHost() && bOwnerRoleHasColor)
251
- return util_1.color.rgbToHex(ownerRoleColor);
252
- // get the player's role
253
- const playerRoles = this.getRoles().map(r => r.toLowerCase());
254
- // only if the player actually has roles...
255
- if (playerRoles.length > 0) {
256
- // check the role list in reverse for the player's role (highest tier first)
257
- const found = roles
258
- .slice()
259
- .reverse()
260
- .find(role => role.bHasColor && playerRoles.includes(role.name.toLowerCase()));
261
- if (found)
262
- return util_1.color.rgbToHex(found.color);
298
+ ),
299
+ this.#omegga.watchLogChunk(
300
+ `GetAll ${previewClass} TransformParameters`,
301
+ transformParamsRegExp,
302
+ {
303
+ first: "index",
304
+ timeoutDelay: 2e3,
305
+ afterMatchDelay: 100
263
306
  }
264
- return util_1.color.rgbToHex(defaultRole.bHasColor
265
- ? defaultRole.color
266
- : { r: 255, g: 255, b: 255, a: 255 });
267
- }
268
- async getPawn() {
269
- // given a player controller, match the player's pawn
270
- const pawnRegExp = new RegExp(`^(?<index>\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = .*?(?:BP_FigureV2_C'.+:PersistentLevel\\.)?(?<pawn>BP_FigureV2_C_\\d+|None)'?`);
271
- // wait for the pawn watcher to return a pawn
272
- const [{ groups: { pawn = null } = {} } = {}] = await __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk('GetAll BP_PlayerController_C Pawn Name=' + this.controller, pawnRegExp, { first: 'index', timeoutDelay: 500 });
273
- if (pawn === 'None')
274
- return null;
275
- return pawn;
276
- }
277
- async getPosition() {
278
- // this is here because my text editor had weird syntax highlighting glitches when the other omeggas were replaced with this.#omegga...
279
- // guess the code is "too new" :egg:
280
- const omegga = __classPrivateFieldGet(this, _Player_omegga, "f");
281
- // given a player controller, match the player's pawn
282
- const pawnRegExp = new RegExp(`^(?<index>\\d+)\\) BP_PlayerController_C .+?PersistentLevel\\.${this.controller}\\.Pawn = .*?(?:BP_FigureV2_C'.+:PersistentLevel\\.)?(?<pawn>BP_FigureV2_C_\\d+|None)'?`);
283
- // wait for the pawn watcher to return a pawn
284
- const [{ groups: { pawn }, },] = await omegga.watchLogChunk('GetAll BP_PlayerController_C Pawn Name=' + this.controller, pawnRegExp, { first: 'index', timeoutDelay: 100 });
285
- if (pawn === 'None')
286
- return null;
287
- // given a player's pawn, match the player's position
288
- const posRegExp = new RegExp(`CapsuleComponent .+?PersistentLevel\\.${pawn}\\.CollisionCylinder\\.RelativeLocation = \\(X=(?<x>[\\d\\.-]+),Y=(?<y>[\\d\\.-]+),Z=(?<z>[\\d\\.-]+)\\)`);
289
- // wait for the position promise
290
- const [{ groups: { x, y, z }, },] = await omegga.addWatcher(posRegExp, {
291
- // request the position for this player's pawn
292
- exec: () => omegga.writeln(`GetAll SceneComponent RelativeLocation Name=CollisionCylinder Outer=${pawn}`),
293
- timeoutDelay: 100,
294
- });
295
- // return the player's position as an array of numbers
296
- return [Number(x), Number(y), Number(z)];
297
- }
298
- async getGhostBrick() {
299
- const { controller } = this;
300
- const previewClass = 'BP_ToolPreviewActor_C';
301
- const ownerRegExp = new RegExp(`^(?<index>\\d+)\\) ${previewClass} (.+):PersistentLevel\\.(?<actor>${previewClass}_\\d+)\.Owner = .*?BP_PlayerController_C'(.+):PersistentLevel\\.(?<controller>BP_PlayerController_C_\\d+)'$`);
302
- const transformParamsRegExp = new RegExp(`^(?<index>\\d+)\\) ${previewClass} (.+):PersistentLevel\\.(?<actor>${previewClass}_\\d+)\\.TransformParameters = \\(TargetGrid=("(?<targetGrid>.+)"|None),Location=\\(X=(?<x>.+),Y=(?<y>.+),Z=(?<z>.+)\\),Orientation=(?<orientation>.+)\\)$`);
303
- const [owners, transformParams] = await Promise.all([
304
- __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk(`GetAll ${previewClass} Owner`, ownerRegExp, {
305
- first: 'index',
306
- timeoutDelay: 2000,
307
- afterMatchDelay: 100,
308
- }),
309
- __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk(`GetAll ${previewClass} TransformParameters`, transformParamsRegExp, {
310
- first: 'index',
311
- timeoutDelay: 2000,
312
- afterMatchDelay: 100,
313
- }),
314
- ]);
315
- // get BrickGridPreviewActor by controller
316
- const owner = owners.find(owner => owner.groups.controller === controller);
317
- if (!owner)
318
- return;
319
- const actor = owner.groups.actor;
320
- // get transform parameters for the found actor
321
- const transformParameters = transformParams.find(transformParameters => transformParameters.groups.actor === actor);
322
- if (!transformParameters)
323
- return;
307
+ )
308
+ ]);
309
+ const owner = owners.find((owner2) => owner2.groups.controller === controller);
310
+ if (!owner) return;
311
+ const actor = owner.groups.actor;
312
+ const transformParameters = transformParams.find(
313
+ (transformParameters2) => transformParameters2.groups.actor === actor
314
+ );
315
+ if (!transformParameters) return;
316
+ return {
317
+ targetGrid: transformParameters.groups.targetGrid,
318
+ location: [
319
+ +transformParameters.groups.x,
320
+ +transformParameters.groups.y,
321
+ +transformParameters.groups.z
322
+ ],
323
+ orientation: transformParameters.groups.orientation
324
+ };
325
+ }
326
+ async getPaint() {
327
+ const { controller } = this;
328
+ const match = await this.#omegga.addWatcher(
329
+ (line) => {
330
+ const match2 = line.match(
331
+ /^\[[^\]]+\]\[[^\]]+\]\d+\) BP_PlayerState_C .+?PersistentLevel\.(?<state>BP_PlayerState_C_\d+)\.ColorSelectionState = \(SelectedColor=\(B=(?<b>\d+),G=(?<g>\d+),R=(?<r>\d+),A=(?<a>\d+)\),MaterialIndex=(?<materialIndex>\d+),MaterialAlpha=(?<materialAlpha>\d+)\)$/
332
+ );
333
+ if (!match2) return;
334
+ if (match2.groups.state !== this.state) return;
335
+ const colorRaw = [+match2.groups.r, +match2.groups.g, +match2.groups.b];
324
336
  return {
325
- targetGrid: transformParameters.groups.targetGrid,
326
- location: [
327
- +transformParameters.groups.x,
328
- +transformParameters.groups.y,
329
- +transformParameters.groups.z,
330
- ],
331
- orientation: transformParameters.groups.orientation,
337
+ materialIndex: match2.groups.materialIndex,
338
+ materialAlpha: match2.groups.materialAlpha,
339
+ material: index.brick.BRICK_CONSTANTS.DEFAULT_MATERIALS[Number(match2.groups.materialIndex)],
340
+ color: colorRaw
332
341
  };
333
- }
334
- async getPaint() {
335
- const { controller } = this;
336
- const match = await __classPrivateFieldGet(this, _Player_omegga, "f")
337
- .addWatcher(line => {
338
- // [date][counter]0) BP_PlayerState_C /Game/Maps/Plate/Plate.Plate:PersistentLevel.BP_PlayerState_C_2147482378.ColorSelectionState = (SelectedColor=(B=6,G=73,R=246,A=255),MaterialIndex=3,MaterialAlpha=5)
339
- const match = line.match(/^\[[^\]]+\]\[[^\]]+\]0\) BP_PlayerState_C .+?PersistentLevel\.(?<state>BP_PlayerState_C_\d+)\.ColorSelectionState = \(SelectedColor=\(B=(?<b>\d+),G=(?<g>\d+),R=(?<r>\d+),A=(?<a>\d+)\),MaterialIndex=(?<materialIndex>\d+),MaterialAlpha=(?<materialAlpha>\d+)\)$/);
340
- if (!match)
341
- return;
342
- if (match.groups.state !== this.state)
343
- return;
344
- const colorRaw = [+match.groups.r, +match.groups.g, +match.groups.b];
345
- return {
346
- materialIndex: match.groups.materialIndex,
347
- materialAlpha: match.groups.materialAlpha,
348
- material: util_1.brick.BRICK_CONSTANTS.DEFAULT_MATERIALS[Number(match.groups.materialIndex)],
349
- color: colorRaw,
350
- };
351
- }, {
352
- timeoutDelay: 1000,
353
- exec: () => __classPrivateFieldGet(this, _Player_omegga, "f").writeln('GetAll BRPlayerState ColorSelectionState'),
354
- })
355
- .catch(() => null);
356
- if (!(match === null || match === void 0 ? void 0 : match[0]))
357
- return;
358
- return match[0];
359
- }
360
- async isCrouched(pawn) {
361
- if (!pawn)
362
- pawn = await this.getPawn();
363
- const reg = /(?<index>\d+)\) BP_FigureV2_C .+?PersistentLevel\.(?<pawn>BP_FigureV2_C_\d+)\.bIsCrouched = (?<crouched>True|False)$/;
364
- const resp = await __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk('GetAll BP_FigureV2_C bIsCrouched Name=' + pawn, reg, { first: 'index', timeoutDelay: 500 });
365
- const me = resp.find(r => r.groups.pawn === pawn);
366
- if (!me)
367
- return false;
368
- return me.groups.crouched == 'True';
369
- }
370
- async isDead(pawn) {
371
- if (!pawn)
372
- pawn = await this.getPawn();
373
- const reg = /(?<index>\d+)\) BP_FigureV2_C .+?PersistentLevel\.(?<pawn>BP_FigureV2_C_\d+)\.bIsDead = (?<dead>True|False)$/;
374
- const resp = await __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk('GetAll BP_FigureV2_C bIsDead Name=' + pawn, reg, { first: 'index', timeoutDelay: 500 });
375
- const me = resp.find(r => r.groups.pawn === pawn);
376
- if (!me)
377
- return true;
378
- return me.groups.dead == 'True';
379
- }
380
- async getTemplateBounds() {
381
- const { controller } = this;
382
- const brickTemplateRegExp = /^(?<index>\d+)\) Tool_Selector_C (.+):PersistentLevel\.(?<tool>Tool_Selector_C_\d+)\.CurrentTemplate = (.+)Brickadia.BrickBuildingTemplate'(.+)Transient.(?<templateName>BrickBuildingTemplate_\d+)'$/;
383
- const brickTemplateOwnerRegExp = /^(?<index>\d+)\) Tool_Selector_C (.+):PersistentLevel\.(?<tool>Tool_Selector_C_\d+)\.Owner = (.+)(?<controller>BP_PlayerController_C_\d+)'$/;
384
- const minBoundsRegExp = /^(?<index>\d+)\) BrickBuildingTemplate (.+)Transient\.(?<templateName>BrickBuildingTemplate_\d+)\.MinBounds = \(X=(?<x>.+),Y=(?<y>.+),Z=(?<z>.+)\)$/;
385
- const maxBoundsRegExp = /^(?<index>\d+)\) BrickBuildingTemplate (.+)Transient\.(?<templateName>BrickBuildingTemplate_\d+)\.MaxBounds = \(X=(?<x>.+),Y=(?<y>.+),Z=(?<z>.+)\)$/;
386
- const centerRegExp = /^(?<index>\d+)\) BrickBuildingTemplate (.+)Transient\.(?<templateName>BrickBuildingTemplate_\d+)\.Center = \(X=(?<x>.+),Y=(?<y>.+),Z=(?<z>.+)\)$/;
387
- const [templates, owners, minBounds, maxBounds, centers] = await Promise.all([
388
- __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk('GetAll Tool_Selector_C CurrentTemplate', brickTemplateRegExp, {
389
- first: 'index',
390
- timeoutDelay: 2000,
391
- afterMatchDelay: 100,
392
- }),
393
- __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk('GetAll Tool_Selector_C Owner', brickTemplateOwnerRegExp, {
394
- first: 'index',
395
- timeoutDelay: 2000,
396
- afterMatchDelay: 100,
397
- }),
398
- __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk('GetAll BrickBuildingTemplate MinBounds', minBoundsRegExp, {
399
- first: 'index',
400
- timeoutDelay: 2000,
401
- afterMatchDelay: 100,
402
- }),
403
- __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk('GetAll BrickBuildingTemplate MaxBounds', maxBoundsRegExp, {
404
- first: 'index',
405
- timeoutDelay: 2000,
406
- afterMatchDelay: 100,
407
- }),
408
- __classPrivateFieldGet(this, _Player_omegga, "f").watchLogChunk('GetAll BrickBuildingTemplate Center', centerRegExp, {
409
- first: 'index',
410
- timeoutDelay: 2000,
411
- afterMatchDelay: 100,
412
- }),
413
- ]);
414
- if (!templates.length ||
415
- !owners.length ||
416
- !minBounds.length ||
417
- !maxBounds.length ||
418
- !centers.length)
419
- return;
420
- // get selector for this controller, we need to handle if there are multiple selectors for the same controller
421
- const selectors = owners
422
- .filter(selectors => selectors.groups.controller === controller)
423
- .map(selectors => selectors.groups.tool)
424
- .sort();
425
- const selector = selectors[0]; // grab the most recently created
426
- if (!selector) {
427
- return;
342
+ },
343
+ {
344
+ timeoutDelay: 1e3,
345
+ exec: () => this.#omegga.writeln("GetAll BRPlayerState ColorSelectionState")
346
+ }
347
+ ).catch(() => null);
348
+ if (!match?.[0]) return;
349
+ return match[0];
350
+ }
351
+ async isCrouched(pawn) {
352
+ if (!pawn) pawn = await this.getPawn();
353
+ const reg = /(?<index>\d+)\) BP_FigureV2_C .+?PersistentLevel\.(?<pawn>BP_FigureV2_C_\d+)\.bIsCrouched = (?<crouched>True|False)$/;
354
+ const resp = await this.#omegga.watchLogChunk(
355
+ "GetAll BP_FigureV2_C bIsCrouched Name=" + pawn,
356
+ reg,
357
+ { first: "index", timeoutDelay: 500 }
358
+ );
359
+ const me = resp.find((r) => r.groups.pawn === pawn);
360
+ if (!me) return false;
361
+ return me.groups.crouched == "True";
362
+ }
363
+ async isDead(pawn) {
364
+ if (!pawn) pawn = await this.getPawn();
365
+ const reg = /(?<index>\d+)\) BP_FigureV2_C .+?PersistentLevel\.(?<pawn>BP_FigureV2_C_\d+)\.bIsDead = (?<dead>True|False)$/;
366
+ const resp = await this.#omegga.watchLogChunk(
367
+ "GetAll BP_FigureV2_C bIsDead Name=" + pawn,
368
+ reg,
369
+ { first: "index", timeoutDelay: 500 }
370
+ );
371
+ const me = resp.find((r) => r.groups.pawn === pawn);
372
+ if (!me) return true;
373
+ return me.groups.dead == "True";
374
+ }
375
+ async getTemplateBounds() {
376
+ const { controller } = this;
377
+ const brickTemplateRegExp = /^(?<index>\d+)\) Tool_Selector_C (.+):PersistentLevel\.(?<tool>Tool_Selector_C_\d+)\.CurrentTemplate = (.+)Brickadia.BrickBuildingTemplate'(.+)Transient.(?<templateName>BrickBuildingTemplate_\d+)'$/;
378
+ const brickTemplateOwnerRegExp = /^(?<index>\d+)\) Tool_Selector_C (.+):PersistentLevel\.(?<tool>Tool_Selector_C_\d+)\.Owner = (.+)(?<controller>BP_PlayerController_C_\d+)'$/;
379
+ const minBoundsRegExp = /^(?<index>\d+)\) BrickBuildingTemplate (.+)Transient\.(?<templateName>BrickBuildingTemplate_\d+)\.MinBounds = \(X=(?<x>.+),Y=(?<y>.+),Z=(?<z>.+)\)$/;
380
+ const maxBoundsRegExp = /^(?<index>\d+)\) BrickBuildingTemplate (.+)Transient\.(?<templateName>BrickBuildingTemplate_\d+)\.MaxBounds = \(X=(?<x>.+),Y=(?<y>.+),Z=(?<z>.+)\)$/;
381
+ const centerRegExp = /^(?<index>\d+)\) BrickBuildingTemplate (.+)Transient\.(?<templateName>BrickBuildingTemplate_\d+)\.Center = \(X=(?<x>.+),Y=(?<y>.+),Z=(?<z>.+)\)$/;
382
+ const [templates, owners, minBounds, maxBounds, centers] = await Promise.all([
383
+ this.#omegga.watchLogChunk(
384
+ "GetAll Tool_Selector_C CurrentTemplate",
385
+ brickTemplateRegExp,
386
+ {
387
+ first: "index",
388
+ timeoutDelay: 2e3,
389
+ afterMatchDelay: 100
428
390
  }
429
- // template for this selector, we need to handle if there are multiple templates for the same selector and grab the most recent one
430
- const brickTemplates = templates
431
- .filter(template => template.groups.tool === selector)
432
- .map(template => template.groups.templateName)
433
- .sort();
434
- const templateName = brickTemplates[0]; // grab the most recently created
435
- if (!templateName) {
436
- return;
391
+ ),
392
+ this.#omegga.watchLogChunk(
393
+ "GetAll Tool_Selector_C Owner",
394
+ brickTemplateOwnerRegExp,
395
+ {
396
+ first: "index",
397
+ timeoutDelay: 2e3,
398
+ afterMatchDelay: 100
437
399
  }
438
- // find all values with matching template name
439
- const minBound = minBounds.find(minBound => minBound.groups.templateName === templateName);
440
- const maxBound = maxBounds.find(maxBound => maxBound.groups.templateName === templateName);
441
- const center = centers.find(center => center.groups.templateName === templateName);
442
- if (!minBound || !maxBound || !center)
443
- return;
444
- return {
445
- minBound: [+minBound.groups.x, +minBound.groups.y, +minBound.groups.z],
446
- maxBound: [+maxBound.groups.x, +maxBound.groups.y, +maxBound.groups.z],
447
- center: [+center.groups.x, +center.groups.y, +center.groups.z],
448
- };
449
- }
450
- async getTemplateBoundsData() {
451
- const templateBounds = await this.getTemplateBounds();
452
- if (!templateBounds)
453
- return;
454
- const saveData = await __classPrivateFieldGet(this, _Player_omegga, "f").getSaveData({
455
- center: templateBounds.center,
456
- extent: [
457
- Math.round((templateBounds.maxBound[0] - templateBounds.minBound[0]) / 2),
458
- Math.round((templateBounds.maxBound[1] - templateBounds.minBound[1]) / 2),
459
- Math.round((templateBounds.maxBound[2] - templateBounds.minBound[2]) / 2),
460
- ],
461
- });
462
- if (!saveData)
463
- return;
464
- // filter bricks outside the bounds
465
- // no longer necessary thanks to Bricks.SaveRegion
466
- /* saveData.bricks = (saveData.bricks as Brick[]).filter(brick => {
467
- return brickUtils.checkBounds(
468
- brick,
469
- saveData.brick_assets,
470
- templateBounds
471
- );
472
- }) as typeof saveData.bricks; */
473
- if (saveData.bricks.length > 0) {
474
- return saveData;
400
+ ),
401
+ this.#omegga.watchLogChunk(
402
+ "GetAll BrickBuildingTemplate MinBounds",
403
+ minBoundsRegExp,
404
+ {
405
+ first: "index",
406
+ timeoutDelay: 2e3,
407
+ afterMatchDelay: 100
475
408
  }
476
- return undefined;
477
- }
478
- loadBricks(saveName) {
479
- __classPrivateFieldGet(this, _Player_omegga, "f").loadBricksOnPlayer(saveName, this);
480
- }
481
- async loadSaveData(saveData, { offX = 0, offY = 0, offZ = 0 } = {}) {
482
- await __classPrivateFieldGet(this, _Player_omegga, "f").loadSaveDataOnPlayer(saveData, this, {
483
- offX,
484
- offY,
485
- offZ,
486
- });
487
- }
488
- async loadDataAtGhostBrick(saveData, { rotate = true, offX = 0, offY = 0, offZ = 0, quiet = true } = {}) {
489
- const ghostBrickData = await this.getGhostBrick();
490
- if (!ghostBrickData || !saveData)
491
- return;
492
- // get bounds of the bricks
493
- const bounds = util_1.brick.getBounds(saveData);
494
- if (rotate) {
495
- const orientation = util_1.brick.BRICK_CONSTANTS.orientationMap[ghostBrickData.orientation];
496
- saveData.bricks = saveData.bricks.map(brick => util_1.brick.rotate(brick, orientation));
497
- // rotate bounds, if we dont use the original bounds they are off by 1 sometimes >:(
498
- bounds.minBound = util_1.brick.BRICK_CONSTANTS.translationTable[util_1.brick.d2o(...orientation)](bounds.minBound);
499
- bounds.maxBound = util_1.brick.BRICK_CONSTANTS.translationTable[util_1.brick.d2o(...orientation)](bounds.maxBound);
500
- bounds.center = util_1.brick.BRICK_CONSTANTS.translationTable[util_1.brick.d2o(...orientation)](bounds.center);
409
+ ),
410
+ this.#omegga.watchLogChunk(
411
+ "GetAll BrickBuildingTemplate MaxBounds",
412
+ maxBoundsRegExp,
413
+ {
414
+ first: "index",
415
+ timeoutDelay: 2e3,
416
+ afterMatchDelay: 100
501
417
  }
502
- // calculate offset from bricks center to ghost brick center
503
- const offset = bounds.center.map((center, index) => ghostBrickData.location[index] - center);
504
- // load at offset location
505
- await __classPrivateFieldGet(this, _Player_omegga, "f").loadSaveData(saveData, {
506
- offX: offX + offset[0],
507
- offY: offY + offset[1],
508
- offZ: offZ + offset[2],
509
- quiet,
510
- });
511
- }
512
- kill() {
513
- Player.kill(__classPrivateFieldGet(this, _Player_omegga, "f"), this);
514
- }
515
- damage(amount) {
516
- Player.damage(__classPrivateFieldGet(this, _Player_omegga, "f"), this, amount);
517
- }
518
- heal(amount) {
519
- Player.heal(__classPrivateFieldGet(this, _Player_omegga, "f"), this, amount);
520
- }
521
- giveItem(item) {
522
- Player.giveItem(__classPrivateFieldGet(this, _Player_omegga, "f"), this, item);
523
- }
524
- takeItem(item) {
525
- Player.takeItem(__classPrivateFieldGet(this, _Player_omegga, "f"), this, item);
526
- }
527
- setTeam(teamIndex) {
528
- Player.setTeam(__classPrivateFieldGet(this, _Player_omegga, "f"), this, teamIndex);
529
- }
530
- setMinigame(index) {
531
- Player.setMinigame(__classPrivateFieldGet(this, _Player_omegga, "f"), this, index);
532
- }
533
- setScore(minigameIndex, score) {
534
- Player.setScore(__classPrivateFieldGet(this, _Player_omegga, "f"), this, minigameIndex, score);
535
- }
536
- getScore(minigameIndex) {
537
- return Player.getScore(__classPrivateFieldGet(this, _Player_omegga, "f"), this, minigameIndex);
538
- }
418
+ ),
419
+ this.#omegga.watchLogChunk(
420
+ "GetAll BrickBuildingTemplate Center",
421
+ centerRegExp,
422
+ {
423
+ first: "index",
424
+ timeoutDelay: 2e3,
425
+ afterMatchDelay: 100
426
+ }
427
+ )
428
+ ]);
429
+ if (!templates.length || !owners.length || !minBounds.length || !maxBounds.length || !centers.length)
430
+ return;
431
+ const selectors = owners.filter((selectors2) => selectors2.groups.controller === controller).map((selectors2) => selectors2.groups.tool).sort();
432
+ const selector = selectors[0];
433
+ if (!selector) {
434
+ return;
435
+ }
436
+ const brickTemplates = templates.filter((template) => template.groups.tool === selector).map((template) => template.groups.templateName).sort();
437
+ const templateName = brickTemplates[0];
438
+ if (!templateName) {
439
+ return;
440
+ }
441
+ const minBound = minBounds.find(
442
+ (minBound2) => minBound2.groups.templateName === templateName
443
+ );
444
+ const maxBound = maxBounds.find(
445
+ (maxBound2) => maxBound2.groups.templateName === templateName
446
+ );
447
+ const center = centers.find(
448
+ (center2) => center2.groups.templateName === templateName
449
+ );
450
+ if (!minBound || !maxBound || !center) return;
451
+ return {
452
+ minBound: [+minBound.groups.x, +minBound.groups.y, +minBound.groups.z],
453
+ maxBound: [+maxBound.groups.x, +maxBound.groups.y, +maxBound.groups.z],
454
+ center: [+center.groups.x, +center.groups.y, +center.groups.z]
455
+ };
456
+ }
457
+ async getTemplateBoundsData() {
458
+ const templateBounds = await this.getTemplateBounds();
459
+ if (!templateBounds) return;
460
+ const saveData = await this.#omegga.getSaveData({
461
+ center: templateBounds.center,
462
+ extent: [
463
+ Math.round(
464
+ (templateBounds.maxBound[0] - templateBounds.minBound[0]) / 2
465
+ ),
466
+ Math.round(
467
+ (templateBounds.maxBound[1] - templateBounds.minBound[1]) / 2
468
+ ),
469
+ Math.round(
470
+ (templateBounds.maxBound[2] - templateBounds.minBound[2]) / 2
471
+ )
472
+ ]
473
+ });
474
+ if (!saveData) return;
475
+ if (saveData.bricks.length > 0) {
476
+ return saveData;
477
+ }
478
+ return void 0;
479
+ }
480
+ loadBricks(saveName) {
481
+ this.#omegga.loadBricksOnPlayer(saveName, this);
482
+ }
483
+ async loadSaveData(saveData, { offX = 0, offY = 0, offZ = 0 } = {}) {
484
+ await this.#omegga.loadSaveDataOnPlayer(saveData, this, {
485
+ offX,
486
+ offY,
487
+ offZ
488
+ });
489
+ }
490
+ async loadDataAtGhostBrick(saveData, { rotate = true, offX = 0, offY = 0, offZ = 0, quiet = true } = {}) {
491
+ const ghostBrickData = await this.getGhostBrick();
492
+ if (!ghostBrickData || !saveData) return;
493
+ const bounds = index.brick.getBounds(saveData);
494
+ if (rotate) {
495
+ const orientation = index.brick.BRICK_CONSTANTS.orientationMap[ghostBrickData.orientation];
496
+ saveData.bricks = saveData.bricks.map(
497
+ (brick) => index.brick.rotate(brick, orientation)
498
+ );
499
+ bounds.minBound = index.brick.BRICK_CONSTANTS.translationTable[index.brick.d2o(...orientation)](bounds.minBound);
500
+ bounds.maxBound = index.brick.BRICK_CONSTANTS.translationTable[index.brick.d2o(...orientation)](bounds.maxBound);
501
+ bounds.center = index.brick.BRICK_CONSTANTS.translationTable[index.brick.d2o(...orientation)](bounds.center);
502
+ }
503
+ const offset = bounds.center.map(
504
+ (center, index2) => ghostBrickData.location[index2] - center
505
+ );
506
+ await this.#omegga.loadSaveData(saveData, {
507
+ offX: offX + offset[0],
508
+ offY: offY + offset[1],
509
+ offZ: offZ + offset[2],
510
+ quiet
511
+ });
512
+ }
513
+ kill() {
514
+ Player.kill(this.#omegga, this);
515
+ }
516
+ damage(amount) {
517
+ Player.damage(this.#omegga, this, amount);
518
+ }
519
+ heal(amount) {
520
+ Player.heal(this.#omegga, this, amount);
521
+ }
522
+ giveItem(item) {
523
+ Player.giveItem(this.#omegga, this, item);
524
+ }
525
+ takeItem(item) {
526
+ Player.takeItem(this.#omegga, this, item);
527
+ }
528
+ setTeam(teamIndex) {
529
+ Player.setTeam(this.#omegga, this, teamIndex);
530
+ }
531
+ setMinigame(index2) {
532
+ Player.setMinigame(this.#omegga, this, index2);
533
+ }
534
+ setScore(minigameIndex, score) {
535
+ Player.setScore(this.#omegga, this, minigameIndex, score);
536
+ }
537
+ getScore(minigameIndex) {
538
+ return Player.getScore(this.#omegga, this, minigameIndex);
539
+ }
539
540
  }
540
- _Player_omegga = new WeakMap();
541
541
  global.Player = Player;
542
542
  exports.default = Player;
543
- //# sourceMappingURL=player.js.map
543
+ //# sourceMappingURL=player.js.map