omegga 1.2.9 → 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.
- package/README.md +20 -1
- package/dist/brickadia/config.js +26 -90
- package/dist/brickadia/config.js.map +1 -1
- package/dist/brickadia/server.js +294 -293
- package/dist/brickadia/server.js.map +1 -1
- package/dist/cli/auth.js +149 -177
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.js +64 -66
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.js +14 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/installer.js +37 -43
- package/dist/cli/installer.js.map +1 -1
- package/dist/cli/plugin.js +651 -682
- package/dist/cli/plugin.js.map +1 -1
- package/dist/cli/terminal.js +811 -733
- package/dist/cli/terminal.js.map +1 -1
- package/dist/config/formats/format_js.js +6 -6
- package/dist/config/formats/format_js.js.map +1 -1
- package/dist/config/formats/format_yml.js +7 -10
- package/dist/config/formats/format_yml.js.map +1 -1
- package/dist/config/index.js +46 -68
- package/dist/config/index.js.map +1 -1
- package/dist/config/reader.js +16 -27
- package/dist/config/reader.js.map +1 -1
- package/dist/config/validator.js +23 -25
- package/dist/config/validator.js.map +1 -1
- package/dist/config/writer.js +11 -21
- package/dist/config/writer.js.map +1 -1
- package/dist/index.js +18 -64
- package/dist/index.js.map +1 -1
- package/dist/info/default_commands.json.js +39 -0
- package/dist/info/default_commands.json.js.map +1 -0
- package/dist/logger.js +61 -60
- package/dist/logger.js.map +1 -1
- package/dist/main.js +424 -471
- package/dist/main.js.map +1 -1
- package/dist/omegga/auth.js +101 -148
- package/dist/omegga/auth.js.map +1 -1
- package/dist/omegga/commandInjector.js +261 -251
- package/dist/omegga/commandInjector.js.map +1 -1
- package/dist/omegga/index.js +14 -52
- package/dist/omegga/index.js.map +1 -1
- package/dist/omegga/logWrangler.js +224 -275
- package/dist/omegga/logWrangler.js.map +1 -1
- package/dist/omegga/matchers/auth.js +36 -50
- package/dist/omegga/matchers/auth.js.map +1 -1
- package/dist/omegga/matchers/chat.js +49 -71
- package/dist/omegga/matchers/chat.js.map +1 -1
- package/dist/omegga/matchers/command.js +25 -36
- package/dist/omegga/matchers/command.js.map +1 -1
- package/dist/omegga/matchers/exit.js +15 -18
- package/dist/omegga/matchers/exit.js.map +1 -1
- package/dist/omegga/matchers/index.js +26 -40
- package/dist/omegga/matchers/index.js.map +1 -1
- package/dist/omegga/matchers/init.js +20 -23
- package/dist/omegga/matchers/init.js.map +1 -1
- package/dist/omegga/matchers/interact.js +58 -64
- package/dist/omegga/matchers/interact.js.map +1 -1
- package/dist/omegga/matchers/join.js +74 -95
- package/dist/omegga/matchers/join.js.map +1 -1
- package/dist/omegga/matchers/leave.js +43 -56
- package/dist/omegga/matchers/leave.js.map +1 -1
- package/dist/omegga/matchers/mapChange.js +26 -35
- package/dist/omegga/matchers/mapChange.js.map +1 -1
- package/dist/omegga/matchers/minigameJoin.js +24 -31
- package/dist/omegga/matchers/minigameJoin.js.map +1 -1
- package/dist/omegga/matchers/version.js +42 -49
- package/dist/omegga/matchers/version.js.map +1 -1
- package/dist/omegga/player.js +527 -527
- package/dist/omegga/player.js.map +1 -1
- package/dist/omegga/plugin/interface.js +91 -98
- package/dist/omegga/plugin/interface.js.map +1 -1
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.js +524 -429
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.js.map +1 -1
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js +282 -294
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js.map +1 -1
- package/dist/omegga/plugin/plugin_node_safe.js +365 -393
- package/dist/omegga/plugin/plugin_node_safe.js.map +1 -1
- package/dist/omegga/plugin/plugin_node_unsafe.js +119 -179
- package/dist/omegga/plugin/plugin_node_unsafe.js.map +1 -1
- package/dist/omegga/plugin.js +402 -347
- package/dist/omegga/plugin.js.map +1 -1
- package/dist/omegga/server.js +742 -774
- package/dist/omegga/server.js.map +1 -1
- package/dist/omegga/wrapper.js +64 -91
- package/dist/omegga/wrapper.js.map +1 -1
- package/dist/plugin.js +11 -31
- package/dist/plugin.js.map +1 -1
- package/dist/softconfig.js +121 -100
- package/dist/softconfig.js.map +1 -1
- package/dist/updater/steam.js +97 -112
- package/dist/updater/steam.js.map +1 -1
- package/dist/util/brdb.js +496 -528
- package/dist/util/brdb.js.map +1 -1
- package/dist/util/brick/checkBounds.js +11 -15
- package/dist/util/brick/checkBounds.js.map +1 -1
- package/dist/util/brick/constants.js +723 -174
- package/dist/util/brick/constants.js.map +1 -1
- package/dist/util/brick/displayName.js +204 -211
- package/dist/util/brick/displayName.js.map +1 -1
- package/dist/util/brick/getBounds.js +29 -41
- package/dist/util/brick/getBounds.js.map +1 -1
- package/dist/util/brick/getBrickSize.js +6 -7
- package/dist/util/brick/getBrickSize.js.map +1 -1
- package/dist/util/brick/getScaleAxis.js +24 -30
- package/dist/util/brick/getScaleAxis.js.map +1 -1
- package/dist/util/brick/index.js +8 -29
- package/dist/util/brick/index.js.map +1 -1
- package/dist/util/brick/rotate.js +29 -34
- package/dist/util/brick/rotate.js.map +1 -1
- package/dist/util/brick/setOwnership.js +13 -19
- package/dist/util/brick/setOwnership.js.map +1 -1
- package/dist/util/chat.js +53 -44
- package/dist/util/chat.js.map +1 -1
- package/dist/util/color.js +112 -124
- package/dist/util/color.js.map +1 -1
- package/dist/util/file.js +54 -98
- package/dist/util/file.js.map +1 -1
- package/dist/util/index.js +84 -106
- package/dist/util/index.js.map +1 -1
- package/dist/util/map.js +18 -20
- package/dist/util/map.js.map +1 -1
- package/dist/util/pattern.js +6 -9
- package/dist/util/pattern.js.map +1 -1
- package/dist/util/time.js +31 -34
- package/dist/util/time.js.map +1 -1
- package/dist/util/uuid.js +10 -8
- package/dist/util/uuid.js.map +1 -1
- package/dist/util/wsl.js +19 -25
- package/dist/util/wsl.js.map +1 -1
- package/dist/version.js +7 -9
- package/dist/version.js.map +1 -1
- package/dist/webserver/backend/api.js +784 -874
- package/dist/webserver/backend/api.js.map +1 -1
- package/dist/webserver/backend/calendar.js +14 -17
- package/dist/webserver/backend/calendar.js.map +1 -1
- package/dist/webserver/backend/database.js +563 -613
- package/dist/webserver/backend/database.js.map +1 -1
- package/dist/webserver/backend/index.js +153 -191
- package/dist/webserver/backend/index.js.map +1 -1
- package/dist/webserver/backend/metrics.js +219 -248
- package/dist/webserver/backend/metrics.js.map +1 -1
- package/dist/webserver/backend/util.js +47 -68
- package/dist/webserver/backend/util.js.map +1 -1
- package/dist/worker.js +322 -0
- package/dist/worker.js.map +1 -0
- package/package.json +14 -10
- package/templates/safe-ts/omegga.d.ts +1 -1
- package/vite.backend.config.mts +46 -0
- package/vite.frontend.config.mts +58 -0
- package/vitest.backend.config.mts +7 -0
- package/dist/brickadia/config.d.ts +0 -3
- package/dist/brickadia/presets.d.ts +0 -65
- package/dist/brickadia/presets.js +0 -3
- package/dist/brickadia/presets.js.map +0 -1
- package/dist/brickadia/server.d.ts +0 -36
- package/dist/brickadia/types.d.ts +0 -45
- package/dist/brickadia/types.js +0 -3
- package/dist/brickadia/types.js.map +0 -1
- package/dist/cli/auth.d.ts +0 -26
- package/dist/cli/config.d.ts +0 -10
- package/dist/cli/index.d.ts +0 -30
- package/dist/cli/installer.d.ts +0 -1
- package/dist/cli/plugin.d.ts +0 -22
- package/dist/cli/terminal.d.ts +0 -25
- package/dist/config/authorizer.d.ts +0 -2
- package/dist/config/authorizer.js +0 -38
- package/dist/config/authorizer.js.map +0 -1
- package/dist/config/formats/format_js.d.ts +0 -3
- package/dist/config/formats/format_yml.d.ts +0 -3
- package/dist/config/index.d.ts +0 -18
- package/dist/config/reader.d.ts +0 -3
- package/dist/config/types.d.ts +0 -50
- package/dist/config/types.js +0 -3
- package/dist/config/types.js.map +0 -1
- package/dist/config/validator.d.ts +0 -6
- package/dist/config/writer.d.ts +0 -3
- package/dist/index.d.ts +0 -22
- package/dist/info/default_commands.json +0 -29
- package/dist/logger.d.ts +0 -41
- package/dist/main.d.ts +0 -1
- package/dist/omegga/auth.d.ts +0 -9
- package/dist/omegga/commandInjector.d.ts +0 -35
- package/dist/omegga/index.d.ts +0 -7
- package/dist/omegga/logWrangler.d.ts +0 -32
- package/dist/omegga/matchers/auth.d.ts +0 -10
- package/dist/omegga/matchers/chat.d.ts +0 -10
- package/dist/omegga/matchers/command.d.ts +0 -7
- package/dist/omegga/matchers/exit.d.ts +0 -3
- package/dist/omegga/matchers/index.d.ts +0 -3
- package/dist/omegga/matchers/init.d.ts +0 -3
- package/dist/omegga/matchers/interact.d.ts +0 -4
- package/dist/omegga/matchers/join.d.ts +0 -4
- package/dist/omegga/matchers/leave.d.ts +0 -4
- package/dist/omegga/matchers/mapChange.d.ts +0 -3
- package/dist/omegga/matchers/minigameJoin.d.ts +0 -9
- package/dist/omegga/matchers/types.d.ts +0 -5
- package/dist/omegga/matchers/types.js +0 -3
- package/dist/omegga/matchers/types.js.map +0 -1
- package/dist/omegga/matchers/version.d.ts +0 -3
- package/dist/omegga/player.d.ts +0 -81
- package/dist/omegga/plugin/interface.d.ts +0 -30
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.d.ts +0 -23
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.d.ts +0 -145
- package/dist/omegga/plugin/plugin_node_safe/worker.d.ts +0 -1
- package/dist/omegga/plugin/plugin_node_safe/worker.js +0 -367
- package/dist/omegga/plugin/plugin_node_safe/worker.js.map +0 -1
- package/dist/omegga/plugin/plugin_node_safe.d.ts +0 -23
- package/dist/omegga/plugin/plugin_node_unsafe.d.ts +0 -13
- package/dist/omegga/plugin.d.ts +0 -63
- package/dist/omegga/server.d.ts +0 -166
- package/dist/omegga/types.d.ts +0 -49
- package/dist/omegga/types.js +0 -3
- package/dist/omegga/types.js.map +0 -1
- package/dist/omegga/wrapper.d.ts +0 -32
- package/dist/plugin.d.ts +0 -916
- package/dist/softconfig.d.ts +0 -67
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/updater/index.d.ts +0 -1
- package/dist/updater/index.js +0 -10
- package/dist/updater/index.js.map +0 -1
- package/dist/updater/steam.d.ts +0 -52
- package/dist/util/brdb.d.ts +0 -31
- package/dist/util/brick/checkBounds.d.ts +0 -8
- package/dist/util/brick/constants.d.ts +0 -18
- package/dist/util/brick/displayName.d.ts +0 -7
- package/dist/util/brick/getBounds.d.ts +0 -5
- package/dist/util/brick/getBrickSize.d.ts +0 -3
- package/dist/util/brick/getScaleAxis.d.ts +0 -3
- package/dist/util/brick/index.d.ts +0 -14
- package/dist/util/brick/rotate.d.ts +0 -16
- package/dist/util/brick/setOwnership.d.ts +0 -12
- package/dist/util/chat.d.ts +0 -23
- package/dist/util/color.d.ts +0 -13
- package/dist/util/file.d.ts +0 -5
- package/dist/util/index.d.ts +0 -183
- package/dist/util/map.d.ts +0 -6
- package/dist/util/pattern.d.ts +0 -1
- package/dist/util/time.d.ts +0 -39
- package/dist/util/uuid.d.ts +0 -3
- package/dist/util/wsl.d.ts +0 -2
- package/dist/version.d.ts +0 -2
- package/dist/webserver/backend/api.d.ts +0 -115
- package/dist/webserver/backend/calendar.d.ts +0 -5
- package/dist/webserver/backend/database.d.ts +0 -150
- package/dist/webserver/backend/index.d.ts +0 -30
- package/dist/webserver/backend/metrics.d.ts +0 -3
- package/dist/webserver/backend/types.d.ts +0 -114
- package/dist/webserver/backend/types.js +0 -3
- package/dist/webserver/backend/types.js.map +0 -1
- package/dist/webserver/backend/util.d.ts +0 -2
- package/dist/webserver/index.d.ts +0 -2
- package/dist/webserver/index.js +0 -9
- package/dist/webserver/index.js.map +0 -1
package/dist/cli/terminal.js
CHANGED
|
@@ -1,754 +1,832 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const wsl_1 = require("../util/wsl");
|
|
9
|
-
const readline_1 = __importDefault(require("readline"));
|
|
10
|
-
const plugin_1 = require("./plugin");
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const steam = require("../updater/steam.js");
|
|
4
|
+
const chat = require("../util/chat.js");
|
|
5
|
+
const wsl = require("../util/wsl.js");
|
|
6
|
+
const readline = require("readline");
|
|
7
|
+
const plugin = require("./plugin.js");
|
|
11
8
|
let log, err, warn, info;
|
|
12
9
|
function gameCommand(aliases, desc, usage, command, quoteArgs) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
return {
|
|
11
|
+
aliases,
|
|
12
|
+
desc,
|
|
13
|
+
fn(...args) {
|
|
14
|
+
if (!this.omegga.started) {
|
|
15
|
+
err("The server is not running");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!args.length) {
|
|
19
|
+
err("usage:", ("/" + aliases[0] + " " + usage).yellow);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
this.omegga.writeln(
|
|
23
|
+
`${command} ${quoteArgs ? '"' : ""}${args.join(" ")}${quoteArgs ? '"' : ""}`
|
|
24
|
+
);
|
|
25
|
+
this.rl.prompt(true);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
29
28
|
}
|
|
30
29
|
const COMMANDS = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
30
|
+
// Brickadia commands
|
|
31
|
+
gameCommand(
|
|
32
|
+
["kick"],
|
|
33
|
+
"kick a player",
|
|
34
|
+
"<name|id> [reason]",
|
|
35
|
+
"Chat.Command /Kick"
|
|
36
|
+
),
|
|
37
|
+
gameCommand(
|
|
38
|
+
["ban", "banish"],
|
|
39
|
+
"ban a player",
|
|
40
|
+
"<name|id> [time] [reason]",
|
|
41
|
+
"Ban"
|
|
42
|
+
),
|
|
43
|
+
gameCommand(
|
|
44
|
+
["unban", "pardon"],
|
|
45
|
+
"unban a player",
|
|
46
|
+
"<name|id>",
|
|
47
|
+
"Chat.Command /Unban"
|
|
48
|
+
),
|
|
49
|
+
gameCommand(
|
|
50
|
+
["grantrole", "giverole"],
|
|
51
|
+
"grant a role to a player",
|
|
52
|
+
"<role> <name|id>",
|
|
53
|
+
"Chat.Command /GrantRole"
|
|
54
|
+
),
|
|
55
|
+
gameCommand(
|
|
56
|
+
["revokerole", "takerole"],
|
|
57
|
+
"revoke a role from a player",
|
|
58
|
+
"<role> <name|id>",
|
|
59
|
+
"Chat.Command /RevokeRole"
|
|
60
|
+
),
|
|
61
|
+
gameCommand(
|
|
62
|
+
["clearbricks"],
|
|
63
|
+
"clear a player's bricks",
|
|
64
|
+
"<name|id>",
|
|
65
|
+
"Bricks.Clear",
|
|
66
|
+
true
|
|
67
|
+
),
|
|
68
|
+
gameCommand(["clearallbricks"], "clear all bricks", "", "Bricks.ClearAll"),
|
|
69
|
+
// Help command
|
|
70
|
+
{
|
|
71
|
+
aliases: ["help", "cmds", "commands"],
|
|
72
|
+
desc: "list supported commands and their descriptions",
|
|
73
|
+
fn() {
|
|
74
|
+
const maxLen = Math.max(...COMMANDS.map((c) => c.aliases[0].length));
|
|
75
|
+
log("Omegga Help Text:\n");
|
|
76
|
+
log(
|
|
77
|
+
' Console input not starting with / will be sent in chat from a "SERVER" user'
|
|
78
|
+
);
|
|
79
|
+
log(
|
|
80
|
+
" Console input starting with / will be treated as one of the following commands\n"
|
|
81
|
+
);
|
|
82
|
+
log(
|
|
83
|
+
"-- Available Omegga commands (type",
|
|
84
|
+
"/command".yellow.underline,
|
|
85
|
+
"to run)"
|
|
86
|
+
);
|
|
87
|
+
for (const command of COMMANDS.sort(
|
|
88
|
+
(a, b) => a.aliases[0].localeCompare(b.aliases[0])
|
|
89
|
+
)) {
|
|
90
|
+
const name = command.aliases[0];
|
|
91
|
+
this.log(
|
|
92
|
+
" ",
|
|
93
|
+
("/" + name).yellow.underline,
|
|
94
|
+
"-".padStart(maxLen - name.length + 1),
|
|
95
|
+
command.desc
|
|
96
|
+
);
|
|
97
|
+
if (command.descLines)
|
|
98
|
+
for (const descLine of command.descLines())
|
|
99
|
+
this.log(" ", " ".repeat(maxLen + 1), descLine);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
// Server controls
|
|
104
|
+
{
|
|
105
|
+
aliases: ["stop"],
|
|
106
|
+
desc: "stop the server and close Omegga",
|
|
107
|
+
async fn() {
|
|
108
|
+
log("Stopping server...");
|
|
109
|
+
await this.omegga.stop();
|
|
110
|
+
process.exit();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
aliases: ["restart"],
|
|
115
|
+
desc: "trigger a server restart (without announcement or saving)",
|
|
116
|
+
async fn() {
|
|
117
|
+
log("Restarting server...");
|
|
118
|
+
await this.omegga.restartServer();
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
aliases: ["update"],
|
|
123
|
+
desc: "try to update the server and restart if started (without announcement or saving",
|
|
124
|
+
async fn() {
|
|
125
|
+
if (!this.omegga.config.__STEAM) {
|
|
126
|
+
err(
|
|
127
|
+
"This command is only available when the server is installed via SteamCMD"
|
|
128
|
+
);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (this.omegga.stopping || this.omegga.starting) {
|
|
132
|
+
err(
|
|
133
|
+
"The server is currently starting or stopping. Please wait a moment"
|
|
134
|
+
);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const wasStarted = this.omegga.started;
|
|
138
|
+
if (wasStarted) {
|
|
139
|
+
log("Stopping server to update...");
|
|
140
|
+
await this.omegga.stop();
|
|
141
|
+
}
|
|
142
|
+
log("Updating server...");
|
|
143
|
+
try {
|
|
144
|
+
steam.steamcmdDownloadGame({
|
|
145
|
+
steambeta: this.omegga.config.server?.steambeta,
|
|
146
|
+
steambetaPassword: this.omegga.config.server?.steambetaPassword
|
|
147
|
+
});
|
|
148
|
+
log("Server updated successfully.");
|
|
149
|
+
} catch (e) {
|
|
150
|
+
err("Error updating server:", e);
|
|
151
|
+
}
|
|
152
|
+
if (wasStarted) {
|
|
153
|
+
log("Starting server...");
|
|
154
|
+
await this.omegga.start();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
aliases: ["kill"],
|
|
160
|
+
desc: "forcefully kill brickadia server process without closing omegga",
|
|
161
|
+
async fn() {
|
|
162
|
+
log("Stopping server...");
|
|
163
|
+
await this.omegga.stop();
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
aliases: ["start"],
|
|
168
|
+
desc: "start the server if it is stopped",
|
|
169
|
+
fn() {
|
|
170
|
+
if (!this.omegga || this.omegga && (this.omegga.starting || this.omegga.started)) {
|
|
171
|
+
err("The server is already running");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
log("Starting server...");
|
|
175
|
+
this.omegga.start();
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
aliases: ["cmd"],
|
|
180
|
+
desc: "run a console command on the Brickadia server. requires /debug for log to show",
|
|
181
|
+
fn(...args) {
|
|
182
|
+
if (!this.omegga.started) {
|
|
183
|
+
err("The server is not running");
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.omegga.writeln(args.join(" "));
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
aliases: ["debug"],
|
|
191
|
+
desc: "toggle visibility of brickadia console logs",
|
|
192
|
+
fn() {
|
|
193
|
+
this.options.debug = !this.options.debug;
|
|
194
|
+
log(
|
|
195
|
+
"Brickadia logs now",
|
|
196
|
+
this.options.debug ? "visible".green : "hidden".red
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
aliases: ["status"],
|
|
202
|
+
desc: "display server status information. brick count, online players, etc",
|
|
203
|
+
async fn() {
|
|
204
|
+
if (!this.omegga.started) {
|
|
205
|
+
err("Omegga is not running");
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const msToTime = (ms) => new Date(ms).toISOString().slice(11, 19);
|
|
209
|
+
try {
|
|
210
|
+
const status = await this.omegga.getServerStatus();
|
|
211
|
+
log("Server Status");
|
|
212
|
+
this.log(`
|
|
164
213
|
${status.serverName.yellow}
|
|
165
|
-
Bricks: ${(status.bricks +
|
|
166
|
-
Components: ${(status.components +
|
|
214
|
+
Bricks: ${(status.bricks + "").yellow}
|
|
215
|
+
Components: ${(status.components + "").yellow}
|
|
167
216
|
Uptime: ${msToTime(status.time).yellow}
|
|
168
|
-
Players: ${status.players.length === 0 ?
|
|
169
|
-
${status.players
|
|
170
|
-
.map(p => `[${msToTime(p.time).grey}] ${p.name.brightYellow}`)
|
|
171
|
-
.join('\n ')}
|
|
217
|
+
Players: ${status.players.length === 0 ? "none".grey : ""}
|
|
218
|
+
${status.players.map((p) => `[${msToTime(p.time).grey}] ${p.name.brightYellow}`).join("\n ")}
|
|
172
219
|
`);
|
|
220
|
+
} catch (e) {
|
|
221
|
+
err("An error occurred while getting server status");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
// plugin stuff
|
|
226
|
+
{
|
|
227
|
+
aliases: ["reload"],
|
|
228
|
+
desc: "shorthand for /plugins reload",
|
|
229
|
+
async fn() {
|
|
230
|
+
await COMMANDS.find((c) => c.aliases.includes("plugins")).fn.bind(this)(
|
|
231
|
+
"reload"
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
aliases: ["plugins", "plugin", "p"],
|
|
237
|
+
desc: "manage Omegga plugins",
|
|
238
|
+
descLines: () => [
|
|
239
|
+
"/plugins install <...plugin names>".yellow + " installs plugins",
|
|
240
|
+
"/plugins load <...plugin names>".yellow + " loads plugins, and enables if they were disabled",
|
|
241
|
+
"/plugins unload <...plugin names>".yellow + " unloads plugins",
|
|
242
|
+
"/plugins reload [...plugin names]".yellow + " reloads all plugins, or those specified",
|
|
243
|
+
"/plugins enable <...plugin names>".yellow + " enables plugins",
|
|
244
|
+
"/plugins disable <...plugin names>".yellow + " disables plugins, and unloads if they were loaded"
|
|
245
|
+
],
|
|
246
|
+
async fn(subcommand, ...args) {
|
|
247
|
+
if (!this.omegga.pluginLoader) {
|
|
248
|
+
err("Omegga is not using plugins");
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (!subcommand) {
|
|
252
|
+
const plugins = this.omegga.pluginLoader.plugins;
|
|
253
|
+
if (plugins.length === 0) {
|
|
254
|
+
log("No plugins are installed");
|
|
255
|
+
log(" Install some with", "/plugins install".yellow.underline);
|
|
256
|
+
} else {
|
|
257
|
+
log("Installed plugins".yellow.underline);
|
|
258
|
+
for (const plugin2 of plugins) {
|
|
259
|
+
const name = plugin2.getName();
|
|
260
|
+
const docs = plugin2.getDocumentation();
|
|
261
|
+
if (plugin2.isLoaded()) log(name.cyan.underline + " (loaded)");
|
|
262
|
+
else if (plugin2.isEnabled())
|
|
263
|
+
log(name.green.underline + " (enabled, not loaded)");
|
|
264
|
+
else log(name.red.underline + " (disabled)");
|
|
265
|
+
log(" " + docs.description);
|
|
266
|
+
log((" Author: " + docs.author).gray);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
} else if (subcommand === "install") {
|
|
270
|
+
await plugin.install(args);
|
|
271
|
+
log();
|
|
272
|
+
log(
|
|
273
|
+
"Use",
|
|
274
|
+
"/plugins reload".yellow,
|
|
275
|
+
"to reload all plugins and use the installed ones"
|
|
276
|
+
);
|
|
277
|
+
} else if (subcommand === "load") {
|
|
278
|
+
if (args.length === 0) {
|
|
279
|
+
log("Please specify at least one plugin to load");
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
for (const pluginName of args) {
|
|
283
|
+
const plugin2 = this.omegga.pluginLoader.plugins.find(
|
|
284
|
+
(p) => p.getName().toLowerCase() === pluginName.toLowerCase()
|
|
285
|
+
);
|
|
286
|
+
if (!plugin2) {
|
|
287
|
+
warn("No plugin by the name", pluginName.cyan);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const name = plugin2.getName();
|
|
291
|
+
if (plugin2.isLoaded()) {
|
|
292
|
+
warn(
|
|
293
|
+
name.cyan,
|
|
294
|
+
"is already loaded, reload with",
|
|
295
|
+
("/plugins reload " + name).yellow
|
|
296
|
+
);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (!plugin2.isEnabled()) {
|
|
300
|
+
log("Enabling and loading", name.cyan.underline);
|
|
301
|
+
plugin2.setEnabled(true);
|
|
302
|
+
await plugin2.load();
|
|
303
|
+
} else {
|
|
304
|
+
log("Loading", name.cyan.underline);
|
|
305
|
+
await plugin2.load();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
} else if (subcommand === "unload") {
|
|
309
|
+
if (args.length === 0) {
|
|
310
|
+
log("Please specify at least one plugin to unload");
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
for (const pluginName of args) {
|
|
314
|
+
const plugin2 = this.omegga.pluginLoader.plugins.find(
|
|
315
|
+
(p) => p.getName().toLowerCase() === pluginName.toLowerCase()
|
|
316
|
+
);
|
|
317
|
+
if (!plugin2) {
|
|
318
|
+
warn("No plugin by the name", pluginName.cyan);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const name = plugin2.getName();
|
|
322
|
+
if (!plugin2.isLoaded()) {
|
|
323
|
+
warn(
|
|
324
|
+
name.cyan,
|
|
325
|
+
"is already unloaded, load with",
|
|
326
|
+
("/plugins load " + name).yellow
|
|
327
|
+
);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
log("Unloading", name.cyan.underline);
|
|
331
|
+
await plugin2.unload();
|
|
332
|
+
}
|
|
333
|
+
} else if (subcommand === "reload") {
|
|
334
|
+
let plugins = (args.length === 0 ? this.omegga.pluginLoader.plugins : this.omegga.pluginLoader.plugins.filter(
|
|
335
|
+
(p) => args.map((a) => a.toLowerCase()).includes(p.getName().toLowerCase())
|
|
336
|
+
)).filter((p) => p.isEnabled());
|
|
337
|
+
const loaded = plugins.filter((p) => p.isLoaded());
|
|
338
|
+
log("Unloading", loaded.length, "plugins");
|
|
339
|
+
for (const plugin2 of loaded) await plugin2.unload();
|
|
340
|
+
if (args.length === 0) {
|
|
341
|
+
log("Scanning for new plugins");
|
|
342
|
+
if (!await this.omegga.pluginLoader.scan()) {
|
|
343
|
+
err("Could not scan for plugins. All plugins are unloaded");
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
plugins = (args.length === 0 ? this.omegga.pluginLoader.plugins : this.omegga.pluginLoader.plugins.filter(
|
|
348
|
+
(p) => args.map((a) => a.toLowerCase()).includes(p.getName().toLowerCase())
|
|
349
|
+
)).filter((p) => p.isEnabled());
|
|
350
|
+
log("Loading", plugins.length, "plugins");
|
|
351
|
+
for (const plugin2 of plugins) await plugin2.load();
|
|
352
|
+
log("Reloaded", plugins.length, "plugins");
|
|
353
|
+
} else if (subcommand === "enable") {
|
|
354
|
+
if (args.length === 0) {
|
|
355
|
+
log("Please specify at least one plugin to enable");
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
for (const pluginName of args) {
|
|
359
|
+
const plugin2 = this.omegga.pluginLoader.plugins.find(
|
|
360
|
+
(p) => p.getName().toLowerCase() === pluginName.toLowerCase()
|
|
361
|
+
);
|
|
362
|
+
if (!plugin2) {
|
|
363
|
+
warn("No plugin by the name", pluginName.cyan);
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
const name = plugin2.getName();
|
|
367
|
+
if (plugin2.isEnabled()) {
|
|
368
|
+
warn(
|
|
369
|
+
name.cyan,
|
|
370
|
+
"is already enabled, disable with",
|
|
371
|
+
("/plugins disable " + name).yellow
|
|
372
|
+
);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
log(
|
|
376
|
+
"Enabling",
|
|
377
|
+
name.cyan.underline,
|
|
378
|
+
"(load with",
|
|
379
|
+
("/plugins load " + name).yellow + ")"
|
|
380
|
+
);
|
|
381
|
+
plugin2.setEnabled(true);
|
|
382
|
+
}
|
|
383
|
+
} else if (subcommand === "disable") {
|
|
384
|
+
if (args.length === 0) {
|
|
385
|
+
log("Please specify at least one plugin to disable");
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
for (const pluginName of args) {
|
|
389
|
+
const plugin2 = this.omegga.pluginLoader.plugins.find(
|
|
390
|
+
(p) => p.getName().toLowerCase() === pluginName.toLowerCase()
|
|
391
|
+
);
|
|
392
|
+
if (!plugin2) {
|
|
393
|
+
warn("No plugin by the name", pluginName.cyan);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const name = plugin2.getName();
|
|
397
|
+
if (!plugin2.isEnabled()) {
|
|
398
|
+
warn(
|
|
399
|
+
name.cyan,
|
|
400
|
+
"is already disabled, enable with",
|
|
401
|
+
("/plugins enable " + name).yellow
|
|
402
|
+
);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (plugin2.isLoaded()) {
|
|
406
|
+
log("Unloading and disabling", name.cyan.underline);
|
|
407
|
+
await plugin2.unload();
|
|
408
|
+
plugin2.setEnabled(false);
|
|
409
|
+
} else {
|
|
410
|
+
log("Disabling", name.cyan.underline);
|
|
411
|
+
plugin2.setEnabled(false);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
aliases: ["world", "worlds", "w"],
|
|
419
|
+
desc: "Manage worlds on the server",
|
|
420
|
+
descLines: () => ["Type /worlds load a world"],
|
|
421
|
+
async fn(subcommand, ...args) {
|
|
422
|
+
switch (subcommand) {
|
|
423
|
+
default:
|
|
424
|
+
const commands = [
|
|
425
|
+
{
|
|
426
|
+
command: "/worlds use [world]",
|
|
427
|
+
desc: "set or remove a world as the default world for startup",
|
|
428
|
+
short: "/w u [world]"
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
command: "/worlds load <world> [rev]",
|
|
432
|
+
desc: "load a world",
|
|
433
|
+
short: "/w load <world> [rev]"
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
command: "/worlds saveas <world>",
|
|
437
|
+
desc: "save the current world as a new world",
|
|
438
|
+
short: "/w sa <world>"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
command: "/worlds save",
|
|
442
|
+
desc: "save the current world",
|
|
443
|
+
short: "/w s"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
command: "/worlds revisions <world>",
|
|
447
|
+
desc: "list revisions of a world",
|
|
448
|
+
short: "/w r <world>"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
command: "/worlds new",
|
|
452
|
+
desc: "create a new world",
|
|
453
|
+
short: "/w new <name> [Plate|Space|Studio|Peaks]"
|
|
173
454
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
],
|
|
201
|
-
async fn(subcommand, ...args) {
|
|
202
|
-
if (!this.omegga.pluginLoader) {
|
|
203
|
-
err('Omegga is not using plugins');
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (!subcommand) {
|
|
207
|
-
const plugins = this.omegga.pluginLoader.plugins;
|
|
208
|
-
if (plugins.length === 0) {
|
|
209
|
-
log('No plugins are installed');
|
|
210
|
-
log(' Install some with', '/plugins install'.yellow.underline);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
log('Installed plugins'.yellow.underline);
|
|
214
|
-
for (const plugin of plugins) {
|
|
215
|
-
const name = plugin.getName();
|
|
216
|
-
const docs = plugin.getDocumentation();
|
|
217
|
-
if (plugin.isLoaded())
|
|
218
|
-
log(name.cyan.underline + ' (loaded)');
|
|
219
|
-
else if (plugin.isEnabled())
|
|
220
|
-
log(name.green.underline + ' (enabled, not loaded)');
|
|
221
|
-
else
|
|
222
|
-
log(name.red.underline + ' (disabled)');
|
|
223
|
-
log(' ' + docs.description);
|
|
224
|
-
log((' Author: ' + docs.author).gray);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
else if (subcommand === 'install') {
|
|
229
|
-
// install plugins
|
|
230
|
-
await (0, plugin_1.install)(args, { verbose: true });
|
|
231
|
-
log();
|
|
232
|
-
log('Use', '/plugins reload'.yellow, 'to reload all plugins and use the installed ones');
|
|
233
|
-
}
|
|
234
|
-
else if (subcommand === 'load') {
|
|
235
|
-
if (args.length === 0) {
|
|
236
|
-
log('Please specify at least one plugin to load');
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
for (const pluginName of args) {
|
|
240
|
-
const plugin = this.omegga.pluginLoader.plugins.find(p => p.getName().toLowerCase() === pluginName.toLowerCase());
|
|
241
|
-
if (!plugin) {
|
|
242
|
-
warn('No plugin by the name', pluginName.cyan);
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
const name = plugin.getName();
|
|
246
|
-
if (plugin.isLoaded()) {
|
|
247
|
-
warn(name.cyan, 'is already loaded, reload with', ('/plugins reload ' + name).yellow);
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
if (!plugin.isEnabled()) {
|
|
251
|
-
log('Enabling and loading', name.cyan.underline);
|
|
252
|
-
plugin.setEnabled(true);
|
|
253
|
-
await plugin.load();
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
log('Loading', name.cyan.underline);
|
|
257
|
-
await plugin.load();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
else if (subcommand === 'unload') {
|
|
262
|
-
if (args.length === 0) {
|
|
263
|
-
log('Please specify at least one plugin to unload');
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
for (const pluginName of args) {
|
|
267
|
-
const plugin = this.omegga.pluginLoader.plugins.find(p => p.getName().toLowerCase() === pluginName.toLowerCase());
|
|
268
|
-
if (!plugin) {
|
|
269
|
-
warn('No plugin by the name', pluginName.cyan);
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
const name = plugin.getName();
|
|
273
|
-
if (!plugin.isLoaded()) {
|
|
274
|
-
warn(name.cyan, 'is already unloaded, load with', ('/plugins load ' + name).yellow);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
log('Unloading', name.cyan.underline);
|
|
278
|
-
await plugin.unload();
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
else if (subcommand === 'reload') {
|
|
282
|
-
let plugins = (args.length === 0
|
|
283
|
-
? this.omegga.pluginLoader.plugins
|
|
284
|
-
: this.omegga.pluginLoader.plugins.filter(p => args
|
|
285
|
-
.map(a => a.toLowerCase())
|
|
286
|
-
.includes(p.getName().toLowerCase()))).filter(p => p.isEnabled());
|
|
287
|
-
const loaded = plugins.filter(p => p.isLoaded());
|
|
288
|
-
log('Unloading', loaded.length, 'plugins');
|
|
289
|
-
for (const plugin of loaded)
|
|
290
|
-
await plugin.unload();
|
|
291
|
-
if (args.length === 0) {
|
|
292
|
-
log('Scanning for new plugins');
|
|
293
|
-
if (!(await this.omegga.pluginLoader.scan())) {
|
|
294
|
-
err('Could not scan for plugins. All plugins are unloaded');
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
plugins = (args.length === 0
|
|
299
|
-
? this.omegga.pluginLoader.plugins
|
|
300
|
-
: this.omegga.pluginLoader.plugins.filter(p => args
|
|
301
|
-
.map(a => a.toLowerCase())
|
|
302
|
-
.includes(p.getName().toLowerCase()))).filter(p => p.isEnabled());
|
|
303
|
-
log('Loading', plugins.length, 'plugins');
|
|
304
|
-
for (const plugin of plugins)
|
|
305
|
-
await plugin.load();
|
|
306
|
-
log('Reloaded', plugins.length, 'plugins');
|
|
455
|
+
];
|
|
456
|
+
log(
|
|
457
|
+
"Default world is",
|
|
458
|
+
this.omegga.getNextWorld()?.file?.yellow || "none".grey
|
|
459
|
+
);
|
|
460
|
+
log("Available world commands:");
|
|
461
|
+
for (const { command, desc, short } of commands) {
|
|
462
|
+
this.log(" ", command.yellow, "-", desc, `(${short.yellow})`);
|
|
463
|
+
}
|
|
464
|
+
return;
|
|
465
|
+
case "use":
|
|
466
|
+
case "u":
|
|
467
|
+
const world = args[0]?.replace(/\.brdb$/, "");
|
|
468
|
+
if (world && !this.omegga.worldExists(world)) {
|
|
469
|
+
err(`World "${world}" does not exist`);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (this.omegga.setActiveWorld(world || null)) {
|
|
473
|
+
if (world) {
|
|
474
|
+
log(
|
|
475
|
+
`Default world set to ${world.yellow}. It will be loaded next startup.`
|
|
476
|
+
);
|
|
477
|
+
} else {
|
|
478
|
+
log(
|
|
479
|
+
"Default world cleared. No world will be loaded on next startup."
|
|
480
|
+
);
|
|
307
481
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
482
|
+
} else {
|
|
483
|
+
err(`Failed to set default world to ${world.yellow}.`);
|
|
484
|
+
}
|
|
485
|
+
return;
|
|
486
|
+
case "list":
|
|
487
|
+
case "ls":
|
|
488
|
+
const worlds = this.omegga.getWorlds();
|
|
489
|
+
if (worlds.length === 0) {
|
|
490
|
+
log(
|
|
491
|
+
"No worlds found. Create one with",
|
|
492
|
+
"/worlds saveas <world>".yellow
|
|
493
|
+
);
|
|
494
|
+
} else {
|
|
495
|
+
log("Available worlds:");
|
|
496
|
+
const prefix = this.omegga.worldPath + "/";
|
|
497
|
+
for (const world2 of worlds) {
|
|
498
|
+
this.log(
|
|
499
|
+
" ",
|
|
500
|
+
world2.replace(prefix, "").replace(/\.brdb$/, "").yellow
|
|
501
|
+
);
|
|
327
502
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
plugin.setEnabled(false);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
503
|
+
}
|
|
504
|
+
return;
|
|
505
|
+
case "load":
|
|
506
|
+
case "l":
|
|
507
|
+
if (!this.omegga.started) {
|
|
508
|
+
err("The server is not running");
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (args.length === 0) {
|
|
512
|
+
err("Please specify a world to load");
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const worldName = args[0].replace(/\.brdb$/, "");
|
|
516
|
+
if (!this.omegga.getWorldPath(worldName)) {
|
|
517
|
+
err(`World "${worldName}" does not exist`);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
let revision;
|
|
521
|
+
if (args.length > 1) {
|
|
522
|
+
revision = parseInt(args[1], 10);
|
|
523
|
+
if (isNaN(revision) || revision < 1) {
|
|
524
|
+
err(`Invalid revision number: ${args[1]}`);
|
|
525
|
+
return;
|
|
354
526
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
return;
|
|
437
|
-
case 'load':
|
|
438
|
-
case 'l':
|
|
439
|
-
if (!this.omegga.started) {
|
|
440
|
-
err('The server is not running');
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
// load a world
|
|
444
|
-
if (args.length === 0) {
|
|
445
|
-
err('Please specify a world to load');
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
const worldName = args[0].replace(/\.brdb$/, '');
|
|
449
|
-
if (!this.omegga.getWorldPath(worldName)) {
|
|
450
|
-
err(`World "${worldName}" does not exist`);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
let revision;
|
|
454
|
-
if (args.length > 1) {
|
|
455
|
-
revision = parseInt(args[1], 10);
|
|
456
|
-
if (isNaN(revision) || revision < 1) {
|
|
457
|
-
err(`Invalid revision number: ${args[1]}`);
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
let loadRes = false;
|
|
462
|
-
if (revision) {
|
|
463
|
-
log(`Loading world ${worldName.yellow} at revision ${revision}...`);
|
|
464
|
-
loadRes = await this.omegga.loadWorldRevision(worldName, revision);
|
|
465
|
-
}
|
|
466
|
-
else {
|
|
467
|
-
log(`Loading world ${worldName.yellow}...`);
|
|
468
|
-
loadRes = await this.omegga.loadWorld(worldName);
|
|
469
|
-
}
|
|
470
|
-
if (loadRes) {
|
|
471
|
-
log(`World ${worldName.yellow} loaded successfully.`);
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
err(`Failed to load world ${worldName.yellow}`);
|
|
475
|
-
}
|
|
476
|
-
return;
|
|
477
|
-
case 'saveas':
|
|
478
|
-
case 'sa':
|
|
479
|
-
if (!this.omegga.started) {
|
|
480
|
-
err('The server is not running');
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
// save the current world as a new world
|
|
484
|
-
if (args.length === 0) {
|
|
485
|
-
err('Please specify a world to save as');
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
const saveWorldName = args[0].replace(/\.brdb$/, '');
|
|
489
|
-
if (this.omegga.getWorldPath(saveWorldName)) {
|
|
490
|
-
err(`World "${saveWorldName}" already exists`);
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
log(`Saving current world as ${saveWorldName.yellow}...`);
|
|
494
|
-
const saveAsRes = await this.omegga.saveWorldAs(saveWorldName);
|
|
495
|
-
if (saveAsRes) {
|
|
496
|
-
log(`Current world saved as ${saveWorldName.yellow} successfully.`);
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
err(`Failed to save current world as ${saveWorldName.yellow}`);
|
|
500
|
-
}
|
|
501
|
-
return;
|
|
502
|
-
case 'save':
|
|
503
|
-
case 's':
|
|
504
|
-
if (!this.omegga.started) {
|
|
505
|
-
err('The server is not running');
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
// save the current world
|
|
509
|
-
log('Saving current world...');
|
|
510
|
-
const res = await this.omegga.saveWorld();
|
|
511
|
-
if (res) {
|
|
512
|
-
log('Current world saved successfully.');
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
err('Failed to save the current world');
|
|
516
|
-
}
|
|
517
|
-
return;
|
|
518
|
-
case 'revisions':
|
|
519
|
-
case 'r':
|
|
520
|
-
if (!this.omegga.started) {
|
|
521
|
-
err('The server is not running');
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
// list revisions of a world
|
|
525
|
-
if (args.length === 0) {
|
|
526
|
-
err('Please specify a world to list revisions for');
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
const revisionsWorldName = args[0].replace(/\.brdb$/, '');
|
|
530
|
-
if (!this.omegga.getWorldPath(revisionsWorldName)) {
|
|
531
|
-
err(`World "${revisionsWorldName}" does not exist`);
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
log(`Listing revisions for world ${revisionsWorldName.yellow}...`);
|
|
535
|
-
try {
|
|
536
|
-
const revisions = await this.omegga.getWorldRevisions(revisionsWorldName);
|
|
537
|
-
if (revisions.length === 0) {
|
|
538
|
-
log('No revisions found for world', revisionsWorldName.yellow);
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
log('Revisions for world', revisionsWorldName.yellow + ':');
|
|
542
|
-
for (const rev of revisions) {
|
|
543
|
-
this.log(' ', `Revision ${rev.index.toString().yellow} - ${rev.date
|
|
544
|
-
.toISOString()
|
|
545
|
-
.replace('T', ' ')
|
|
546
|
-
.replace('.000Z', '').blue}`, `(${rev.note})`.grey);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
catch (e) {
|
|
551
|
-
err('An error occurred while getting world revisions:', e.toString());
|
|
552
|
-
}
|
|
553
|
-
return;
|
|
554
|
-
case 'new':
|
|
555
|
-
case 'n':
|
|
556
|
-
if (!this.omegga.started) {
|
|
557
|
-
err('The server is not running');
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
// create a new world
|
|
561
|
-
if (args.length === 0) {
|
|
562
|
-
err('Please specify a name for the new world');
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
const newWorldName = args[0].replace(/\.brdb$/, '');
|
|
566
|
-
if (this.omegga.getWorldPath(newWorldName)) {
|
|
567
|
-
err(`World "${newWorldName}" already exists`);
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
const map = (args[1] ? args[1] : 'Plate');
|
|
571
|
-
if (!['Plate', 'Space', 'Studio', 'Peaks'].includes(map)) {
|
|
572
|
-
err(`Invalid preset "${map}". Valid map are: Plate, Space, Studio`);
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
log(`Creating new world ${newWorldName.yellow}...`);
|
|
576
|
-
this.omegga.createEmptyWorld(newWorldName, map);
|
|
527
|
+
}
|
|
528
|
+
let loadRes = false;
|
|
529
|
+
if (revision) {
|
|
530
|
+
log(`Loading world ${worldName.yellow} at revision ${revision}...`);
|
|
531
|
+
loadRes = await this.omegga.loadWorldRevision(worldName, revision);
|
|
532
|
+
} else {
|
|
533
|
+
log(`Loading world ${worldName.yellow}...`);
|
|
534
|
+
loadRes = await this.omegga.loadWorld(worldName);
|
|
535
|
+
}
|
|
536
|
+
if (loadRes) {
|
|
537
|
+
log(`World ${worldName.yellow} loaded successfully.`);
|
|
538
|
+
} else {
|
|
539
|
+
err(`Failed to load world ${worldName.yellow}`);
|
|
540
|
+
}
|
|
541
|
+
return;
|
|
542
|
+
case "saveas":
|
|
543
|
+
case "sa":
|
|
544
|
+
if (!this.omegga.started) {
|
|
545
|
+
err("The server is not running");
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (args.length === 0) {
|
|
549
|
+
err("Please specify a world to save as");
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
const saveWorldName = args[0].replace(/\.brdb$/, "");
|
|
553
|
+
if (this.omegga.getWorldPath(saveWorldName)) {
|
|
554
|
+
err(`World "${saveWorldName}" already exists`);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
log(`Saving current world as ${saveWorldName.yellow}...`);
|
|
558
|
+
const saveAsRes = await this.omegga.saveWorldAs(saveWorldName);
|
|
559
|
+
if (saveAsRes) {
|
|
560
|
+
log(`Current world saved as ${saveWorldName.yellow} successfully.`);
|
|
561
|
+
} else {
|
|
562
|
+
err(`Failed to save current world as ${saveWorldName.yellow}`);
|
|
563
|
+
}
|
|
564
|
+
return;
|
|
565
|
+
case "save":
|
|
566
|
+
case "s":
|
|
567
|
+
if (!this.omegga.started) {
|
|
568
|
+
err("The server is not running");
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
log("Saving current world...");
|
|
572
|
+
const res = await this.omegga.saveWorld();
|
|
573
|
+
if (res) {
|
|
574
|
+
log("Current world saved successfully.");
|
|
575
|
+
} else {
|
|
576
|
+
err("Failed to save the current world");
|
|
577
|
+
}
|
|
578
|
+
return;
|
|
579
|
+
case "revisions":
|
|
580
|
+
case "r":
|
|
581
|
+
if (!this.omegga.started) {
|
|
582
|
+
err("The server is not running");
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
if (args.length === 0) {
|
|
586
|
+
err("Please specify a world to list revisions for");
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
const revisionsWorldName = args[0].replace(/\.brdb$/, "");
|
|
590
|
+
if (!this.omegga.getWorldPath(revisionsWorldName)) {
|
|
591
|
+
err(`World "${revisionsWorldName}" does not exist`);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
log(`Listing revisions for world ${revisionsWorldName.yellow}...`);
|
|
595
|
+
try {
|
|
596
|
+
const revisions = await this.omegga.getWorldRevisions(revisionsWorldName);
|
|
597
|
+
if (revisions.length === 0) {
|
|
598
|
+
log("No revisions found for world", revisionsWorldName.yellow);
|
|
599
|
+
} else {
|
|
600
|
+
log("Revisions for world", revisionsWorldName.yellow + ":");
|
|
601
|
+
for (const rev of revisions) {
|
|
602
|
+
this.log(
|
|
603
|
+
" ",
|
|
604
|
+
`Revision ${rev.index.toString().yellow} - ${rev.date.toISOString().replace("T", " ").replace(".000Z", "").blue}`,
|
|
605
|
+
`(${rev.note})`.grey
|
|
606
|
+
);
|
|
607
|
+
}
|
|
577
608
|
}
|
|
578
|
-
|
|
579
|
-
|
|
609
|
+
} catch (e) {
|
|
610
|
+
err(
|
|
611
|
+
"An error occurred while getting world revisions:",
|
|
612
|
+
e.toString()
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
return;
|
|
616
|
+
case "new":
|
|
617
|
+
case "n":
|
|
618
|
+
if (!this.omegga.started) {
|
|
619
|
+
err("The server is not running");
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
if (args.length === 0) {
|
|
623
|
+
err("Please specify a name for the new world");
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const newWorldName = args[0].replace(/\.brdb$/, "");
|
|
627
|
+
if (this.omegga.getWorldPath(newWorldName)) {
|
|
628
|
+
err(`World "${newWorldName}" already exists`);
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
const map = args[1] ? args[1] : "Plate";
|
|
632
|
+
if (!["Plate", "Space", "Studio", "Peaks"].includes(map)) {
|
|
633
|
+
err(`Invalid preset "${map}". Valid map are: Plate, Space, Studio`);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
log(`Creating new world ${newWorldName.yellow}...`);
|
|
637
|
+
this.omegga.createEmptyWorld(newWorldName, map);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
580
641
|
];
|
|
581
|
-
// the terminal wraps omegga and displays console output and handles console input
|
|
582
642
|
class Terminal {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
info('This might be resolved by deleting brickadia and reinstalling:');
|
|
608
|
-
info(' rm -rf ~/.local/share/brickadia-launcher'.grey);
|
|
609
|
-
}
|
|
610
|
-
if (l.startsWith('DOWNLOADING')) {
|
|
611
|
-
// TODO: if someone is proactive enough in the future, you could turn these steps into a legitimate progress bar
|
|
612
|
-
/* Here's some launcher log lines that might be helpful
|
|
613
|
-
Grabbing manifest and checking game files...
|
|
614
|
-
DOWNLOADING MANIFEST | Hold on...
|
|
615
|
-
DOWNLOADING MANIFEST (100%) | Hold on...
|
|
616
|
-
DOWNLOADING MANIFEST (100%) | 0 B/s - 13 KiB / 13 KiB (Unknown time remaining...)
|
|
617
|
-
DOWNLOADING MANIFEST (100%) | Done!
|
|
618
|
-
Checking launcher and downloading version info...
|
|
619
|
-
Installing patches and booting...
|
|
620
|
-
DOWNLOADING BRICKADIA (0%) | Done!
|
|
621
|
-
DOWNLOADING BRICKADIA (100%) | 110 MiB/s - 584 MiB / 584 MiB (1 second remaining...)
|
|
622
|
-
DOWNLOADING BRICKADIA (100%) | Nearly done...
|
|
623
|
-
DOWNLOADING BRICKADIA (100%), INSTALLING BRICKADIA (86%) | Nearly done...
|
|
624
|
-
*/
|
|
625
|
-
process.stdout.clearLine(0);
|
|
626
|
-
process.stdout.cursorTo(0);
|
|
627
|
-
process.stdout.write(l);
|
|
628
|
-
// add a newline on "Done!" but prevent newlines on repeat done messages
|
|
629
|
-
if (l.match(/Done!/) && l !== lastDoneMessage) {
|
|
630
|
-
lastDoneMessage = l;
|
|
631
|
-
process.stdout.write('\n');
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
else if (l.match(/Disabling core dumps./)) {
|
|
635
|
-
launcherDone = true;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
// [2025.07.07-20.45.40:310][845]LogBRWorldManager: World successfully loaded.
|
|
639
|
-
if (l.match(/^\[[^\]]+\]\[[^\]]+\]LogBRWorldManager: World successfully loaded\.$/)) {
|
|
640
|
-
info('World successfully loaded.');
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
// print debug events regardless of debug status
|
|
644
|
-
omegga.on('debug', l => this.log('?>'.magenta, l));
|
|
645
|
-
// print chat events as players join/leave the server
|
|
646
|
-
omegga.on('join', (p) => this.log(`${p.displayName.underline} (${p.name.underline}) joined.`.brightBlue));
|
|
647
|
-
omegga.on('leave', (p) => this.log(`${p.displayName.underline} (${p.name.underline}) left.`.brightBlue));
|
|
648
|
-
omegga.on('chat', (name, message) => {
|
|
649
|
-
var _a, _b;
|
|
650
|
-
const player = omegga.getPlayer(name);
|
|
651
|
-
this.log(`${((_b = (_a = player.displayName) !== null && _a !== void 0 ? _a : player.name) !== null && _b !== void 0 ? _b : name).brightYellow.underline}: ${message}`);
|
|
652
|
-
});
|
|
653
|
-
omegga.on('start', () => {
|
|
654
|
-
const wsl = (0, wsl_1.checkWsl)();
|
|
655
|
-
log(`Server has started${wsl === 1 ? ' in single thread mode due to WSL1' : ''}. Type ${'/help'.yellow} for more commands`);
|
|
656
|
-
if (!this.omegga.getNextWorld()) {
|
|
657
|
-
info('No', 'default world'.yellow, 'is configured. Run', '/worlds use <world>'.yellow, 'to load one on startup.');
|
|
658
|
-
}
|
|
659
|
-
// check if this is WSL2 and wsl2binds is installed
|
|
660
|
-
if (wsl === 2 &&
|
|
661
|
-
this.omegga.pluginLoader &&
|
|
662
|
-
!this.omegga.pluginLoader.plugins.some(p => p.getName() === 'wsl2binds')) {
|
|
663
|
-
warn('####'.yellow, `You are running ${'WSL2'.yellow} and you don't have the ${'wsl2binds'.yellow} plugin.`);
|
|
664
|
-
warn('####'.yellow, `The wsl2binds plugin works as a ${'UDP proxy'.underline} between Windows and the WSL2 VM.`);
|
|
665
|
-
warn('####'.yellow, 'Install it by:');
|
|
666
|
-
warn('####'.yellow, ' 1. Closing omegga with', '/stop'.green);
|
|
667
|
-
warn('####'.yellow, ' 2. Installing wsl2binds with', 'omegga install gh:Meshiest/wsl2binds'.green);
|
|
668
|
-
warn('####'.yellow, ' 3. Restarting', 'omegga'.green);
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
omegga.on('mapchange', ({ map }) => log('Map changed to', (map.charAt(0).toUpperCase() + map.slice(1)).green));
|
|
672
|
-
omegga.on('unauthorized', () => {
|
|
673
|
-
err('Server failed authentication check');
|
|
674
|
-
info('You can clear auth tokens with', 'omegga auth -gl'.green);
|
|
675
|
-
info('This will require you to paste a new hosting token or sign-in again');
|
|
676
|
-
process.exit();
|
|
677
|
-
});
|
|
678
|
-
omegga.on('error', e => err('Server caught unhandled exception:\n' + e));
|
|
679
|
-
omegga.on('server:stopped', () => log('Server has closed. Type', '/stop'.yellow, 'to close omegga'));
|
|
680
|
-
this.rl.on('line', this.handleLine.bind(this));
|
|
681
|
-
// Gracefully shut down server on Ctrl+C and SIGTERM
|
|
682
|
-
process.on('SIGINT', () => this.handleLine('/stop'));
|
|
683
|
-
process.on('SIGTERM', () => this.handleLine('/stop'));
|
|
684
|
-
}
|
|
685
|
-
async handleLine(line) {
|
|
686
|
-
if (line.startsWith('/')) {
|
|
687
|
-
const [cmd, ...args] = line.slice(1).split(' ');
|
|
688
|
-
const c = COMMANDS.find(c => c.aliases.includes(cmd));
|
|
689
|
-
if (!c) {
|
|
690
|
-
err(`unrecognized command /${cmd.underline}. Type /help for more info`
|
|
691
|
-
.red);
|
|
692
|
-
}
|
|
693
|
-
else {
|
|
694
|
-
try {
|
|
695
|
-
const res = c.fn.bind(this)(...args);
|
|
696
|
-
if (res instanceof Promise)
|
|
697
|
-
await res;
|
|
698
|
-
}
|
|
699
|
-
catch (e) {
|
|
700
|
-
err('unhandled terminal error', e);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
643
|
+
constructor(omegga, options = {}) {
|
|
644
|
+
this.options = options;
|
|
645
|
+
this.omegga = omegga;
|
|
646
|
+
this.rl = readline.createInterface({
|
|
647
|
+
input: process.stdin,
|
|
648
|
+
output: process.stdout,
|
|
649
|
+
terminal: true
|
|
650
|
+
});
|
|
651
|
+
this.rl.setPrompt("> ".brightGreen);
|
|
652
|
+
log = (...args) => this.log(">>".green, ...args);
|
|
653
|
+
err = (...args) => this.error("!>".red, ...args);
|
|
654
|
+
info = (...args) => this.log("?>".blue, ...args);
|
|
655
|
+
warn = (...args) => this.warn("W>".yellow, ...args);
|
|
656
|
+
let launcherDone = false;
|
|
657
|
+
let lastDoneMessage = "";
|
|
658
|
+
omegga.on("line", (l) => {
|
|
659
|
+
if (options.debug) this.log("::".blue, l);
|
|
660
|
+
else if (!launcherDone) {
|
|
661
|
+
if (l.match(/Update Failed/)) {
|
|
662
|
+
err(l);
|
|
663
|
+
info(
|
|
664
|
+
"This might be resolved by deleting brickadia and reinstalling:"
|
|
665
|
+
);
|
|
666
|
+
info(" rm -rf ~/.local/share/brickadia-launcher".grey);
|
|
703
667
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
this.omegga.webserver.io
|
|
715
|
-
.to('chat')
|
|
716
|
-
.emit('chat', await this.omegga.webserver.database.addChatLog('msg', user, line));
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
else {
|
|
720
|
-
err('Server is not started yet. type'.red, '/help'.yellow, 'for more info'.red);
|
|
721
|
-
}
|
|
668
|
+
if (l.startsWith("DOWNLOADING")) {
|
|
669
|
+
process.stdout.clearLine(0);
|
|
670
|
+
process.stdout.cursorTo(0);
|
|
671
|
+
process.stdout.write(l);
|
|
672
|
+
if (l.match(/Done!/) && l !== lastDoneMessage) {
|
|
673
|
+
lastDoneMessage = l;
|
|
674
|
+
process.stdout.write("\n");
|
|
675
|
+
}
|
|
676
|
+
} else if (l.match(/Disabling core dumps./)) {
|
|
677
|
+
launcherDone = true;
|
|
722
678
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
679
|
+
}
|
|
680
|
+
if (l.match(
|
|
681
|
+
/^\[[^\]]+\]\[[^\]]+\]LogBRWorldManager: World successfully loaded\.$/
|
|
682
|
+
)) {
|
|
683
|
+
info("World successfully loaded.");
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
omegga.on("debug", (l) => this.log("?>".magenta, l));
|
|
687
|
+
omegga.on(
|
|
688
|
+
"join",
|
|
689
|
+
(p) => this.log(
|
|
690
|
+
`${p.displayName.underline} (${p.name.underline}) joined.`.brightBlue
|
|
691
|
+
)
|
|
692
|
+
);
|
|
693
|
+
omegga.on(
|
|
694
|
+
"leave",
|
|
695
|
+
(p) => this.log(
|
|
696
|
+
`${p.displayName.underline} (${p.name.underline}) left.`.brightBlue
|
|
697
|
+
)
|
|
698
|
+
);
|
|
699
|
+
omegga.on("chat", (name, message) => {
|
|
700
|
+
const player = omegga.getPlayer(name);
|
|
701
|
+
this.log(
|
|
702
|
+
`${(player.displayName ?? player.name ?? name).brightYellow.underline}: ${message}`
|
|
703
|
+
);
|
|
704
|
+
});
|
|
705
|
+
omegga.on("start", () => {
|
|
706
|
+
const wsl$1 = wsl.checkWsl();
|
|
707
|
+
log(
|
|
708
|
+
`Server has started${wsl$1 === 1 ? " in single thread mode due to WSL1" : ""}. Type ${"/help".yellow} for more commands`
|
|
709
|
+
);
|
|
710
|
+
if (!this.omegga.getNextWorld()) {
|
|
711
|
+
info(
|
|
712
|
+
"No",
|
|
713
|
+
"default world".yellow,
|
|
714
|
+
"is configured. Run",
|
|
715
|
+
"/worlds use <world>".yellow,
|
|
716
|
+
"to load one on startup."
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
if (wsl$1 === 2 && this.omegga.pluginLoader && !this.omegga.pluginLoader.plugins.some((p) => p.getName() === "wsl2binds")) {
|
|
720
|
+
warn(
|
|
721
|
+
"####".yellow,
|
|
722
|
+
`You are running ${"WSL2".yellow} and you don't have the ${"wsl2binds".yellow} plugin.`
|
|
723
|
+
);
|
|
724
|
+
warn(
|
|
725
|
+
"####".yellow,
|
|
726
|
+
`The wsl2binds plugin works as a ${"UDP proxy".underline} between Windows and the WSL2 VM.`
|
|
727
|
+
);
|
|
728
|
+
warn("####".yellow, "Install it by:");
|
|
729
|
+
warn("####".yellow, " 1. Closing omegga with", "/stop".green);
|
|
730
|
+
warn(
|
|
731
|
+
"####".yellow,
|
|
732
|
+
" 2. Installing wsl2binds with",
|
|
733
|
+
"omegga install gh:Meshiest/wsl2binds".green
|
|
734
|
+
);
|
|
735
|
+
warn("####".yellow, " 3. Restarting", "omegga".green);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
omegga.on(
|
|
739
|
+
"mapchange",
|
|
740
|
+
({ map }) => log("Map changed to", (map.charAt(0).toUpperCase() + map.slice(1)).green)
|
|
741
|
+
);
|
|
742
|
+
omegga.on("unauthorized", () => {
|
|
743
|
+
err("Server failed authentication check");
|
|
744
|
+
info("You can clear auth tokens with", "omegga auth -gl".green);
|
|
745
|
+
info(
|
|
746
|
+
"This will require you to paste a new hosting token or sign-in again"
|
|
747
|
+
);
|
|
748
|
+
process.exit();
|
|
749
|
+
});
|
|
750
|
+
omegga.on("error", (e) => err("Server caught unhandled exception:\n" + e));
|
|
751
|
+
omegga.on(
|
|
752
|
+
"server:stopped",
|
|
753
|
+
() => log("Server has closed. Type", "/stop".yellow, "to close omegga")
|
|
754
|
+
);
|
|
755
|
+
this.rl.on("line", this.handleLine.bind(this));
|
|
756
|
+
process.on("SIGINT", () => this.handleLine("/stop"));
|
|
757
|
+
process.on("SIGTERM", () => this.handleLine("/stop"));
|
|
758
|
+
}
|
|
759
|
+
async handleLine(line) {
|
|
760
|
+
if (line.startsWith("/")) {
|
|
761
|
+
const [cmd, ...args] = line.slice(1).split(" ");
|
|
762
|
+
const c = COMMANDS.find((c2) => c2.aliases.includes(cmd));
|
|
763
|
+
if (!c) {
|
|
764
|
+
err(
|
|
765
|
+
`unrecognized command /${cmd.underline}. Type /help for more info`.red
|
|
766
|
+
);
|
|
767
|
+
} else {
|
|
768
|
+
try {
|
|
769
|
+
const res = c.fn.bind(this)(...args);
|
|
770
|
+
if (res instanceof Promise) await res;
|
|
771
|
+
} catch (e) {
|
|
772
|
+
err("unhandled terminal error", e);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
} else if (line.trim().length > 0) {
|
|
776
|
+
if (this.omegga.started) {
|
|
777
|
+
this.omegga.broadcast(
|
|
778
|
+
`"[<b><color=\\"ff00ff\\">SERVER</></>]: ${chat.sanitize(line)}"`
|
|
779
|
+
);
|
|
747
780
|
process.stdout.clearLine(0);
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
781
|
+
this.log(`[${"SERVER".brightMagenta.underline}]: ${line}`);
|
|
782
|
+
if (this.omegga.webserver) {
|
|
783
|
+
const user = { name: "SERVER", id: "", web: true, color: "ff00ff" };
|
|
784
|
+
this.omegga.webserver.io.to("chat").emit(
|
|
785
|
+
"chat",
|
|
786
|
+
await this.omegga.webserver.database.addChatLog(
|
|
787
|
+
"msg",
|
|
788
|
+
user,
|
|
789
|
+
line
|
|
790
|
+
)
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
} else {
|
|
794
|
+
err(
|
|
795
|
+
"Server is not started yet. type".red,
|
|
796
|
+
"/help".yellow,
|
|
797
|
+
"for more info".red
|
|
798
|
+
);
|
|
799
|
+
}
|
|
751
800
|
}
|
|
801
|
+
}
|
|
802
|
+
// let readline render a log without interrupting user input
|
|
803
|
+
log(...args) {
|
|
804
|
+
process.stdout.clearLine(0);
|
|
805
|
+
process.stdout.cursorTo(0);
|
|
806
|
+
console.log(...args);
|
|
807
|
+
this.rl.prompt(true);
|
|
808
|
+
}
|
|
809
|
+
// let readline render a debug log without interrupting user input
|
|
810
|
+
debug(...args) {
|
|
811
|
+
process.stdout.clearLine(0);
|
|
812
|
+
process.stdout.cursorTo(0);
|
|
813
|
+
console.debug(...args);
|
|
814
|
+
this.rl.prompt(true);
|
|
815
|
+
}
|
|
816
|
+
// let readline render a warning log without interrupting user input
|
|
817
|
+
warn(...args) {
|
|
818
|
+
process.stdout.clearLine(0);
|
|
819
|
+
process.stdout.cursorTo(0);
|
|
820
|
+
console.warn(...args);
|
|
821
|
+
this.rl.prompt(true);
|
|
822
|
+
}
|
|
823
|
+
// let readline render an error log without interrupting user input
|
|
824
|
+
error(...args) {
|
|
825
|
+
process.stdout.clearLine(0);
|
|
826
|
+
process.stdout.cursorTo(0);
|
|
827
|
+
console.error(...args);
|
|
828
|
+
this.rl.prompt(true);
|
|
829
|
+
}
|
|
752
830
|
}
|
|
753
831
|
exports.default = Terminal;
|
|
754
|
-
//# sourceMappingURL=terminal.js.map
|
|
832
|
+
//# sourceMappingURL=terminal.js.map
|