@starktma/minecraft-utils 1.3.20 → 1.3.22
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/dist/constants.d.ts +23 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +30 -5
- package/dist/constants.js.map +1 -1
- package/dist/database/database.d.ts +1 -1
- package/dist/database/database.d.ts.map +1 -1
- package/dist/database/database.js +6 -14
- package/dist/database/database.js.map +1 -1
- package/dist/database/index.d.ts +1 -2
- package/dist/database/index.d.ts.map +1 -1
- package/dist/database/index.js +1 -2
- package/dist/database/index.js.map +1 -1
- package/dist/game-state-machine/branch.js +2 -2
- package/dist/game-state-machine/branch.js.map +1 -1
- package/dist/game-state-machine/database.d.ts +1 -1
- package/dist/game-state-machine/database.d.ts.map +1 -1
- package/dist/game-state-machine/database.js +1 -1
- package/dist/game-state-machine/database.js.map +1 -1
- package/dist/game-state-machine/index.d.ts +1 -51
- package/dist/game-state-machine/index.d.ts.map +1 -1
- package/dist/game-state-machine/index.js +1 -328
- package/dist/game-state-machine/index.js.map +1 -1
- package/dist/game-state-machine/stateMachine.d.ts +52 -0
- package/dist/game-state-machine/stateMachine.d.ts.map +1 -0
- package/dist/game-state-machine/stateMachine.js +324 -0
- package/dist/game-state-machine/stateMachine.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -6
- package/dist/config.d.ts +0 -26
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -34
- package/dist/config.js.map +0 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This
|
|
2
|
+
* Configuration for minecraft-utils package.
|
|
3
|
+
* This allows consumers to set a custom namespace for their project.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Sets the namespace for this package instance.
|
|
7
|
+
* This should be called once at the beginning of your application.
|
|
8
|
+
*
|
|
9
|
+
* @param namespace - The namespace to use for this package
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { setNamespace } from "@starktma/minecraft-utils/config";
|
|
14
|
+
*
|
|
15
|
+
* // Set your custom namespace
|
|
16
|
+
* setNamespace("myproject");
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function setNamespace(namespace: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the current namespace.
|
|
22
|
+
*
|
|
23
|
+
* @returns The current namespace
|
|
24
|
+
*/
|
|
25
|
+
export declare function getNamespace(): string;
|
|
6
26
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAKpD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
import { getNamespace } from "./config";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
* This
|
|
2
|
+
* Configuration for minecraft-utils package.
|
|
3
|
+
* This allows consumers to set a custom namespace for their project.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
let _namespace = "starktma"; // Default namespace
|
|
6
|
+
/**
|
|
7
|
+
* Sets the namespace for this package instance.
|
|
8
|
+
* This should be called once at the beginning of your application.
|
|
9
|
+
*
|
|
10
|
+
* @param namespace - The namespace to use for this package
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { setNamespace } from "@starktma/minecraft-utils/config";
|
|
15
|
+
*
|
|
16
|
+
* // Set your custom namespace
|
|
17
|
+
* setNamespace("myproject");
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function setNamespace(namespace) {
|
|
21
|
+
if (!namespace || typeof namespace !== "string") {
|
|
22
|
+
throw new Error("Namespace must be a non-empty string");
|
|
23
|
+
}
|
|
24
|
+
_namespace = namespace;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gets the current namespace.
|
|
28
|
+
*
|
|
29
|
+
* @returns The current namespace
|
|
30
|
+
*/
|
|
31
|
+
export function getNamespace() {
|
|
32
|
+
return _namespace;
|
|
8
33
|
}
|
|
9
34
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,IAAI,UAAU,GAAW,UAAU,CAAC,CAAC,oBAAoB;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC7C,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACzD,CAAC;IACD,UAAU,GAAG,SAAS,CAAC;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC3B,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -28,7 +28,7 @@ declare class SimpleDatabase<T extends SimpleObject> {
|
|
|
28
28
|
* @param databaseName The name of the database.
|
|
29
29
|
* @param target The target entity to store the database in. If undefined, the database is stored in the world.
|
|
30
30
|
*/
|
|
31
|
-
protected constructor(databaseName: string, target?: Entity | undefined
|
|
31
|
+
protected constructor(databaseName: string, target?: Entity | undefined);
|
|
32
32
|
/**
|
|
33
33
|
* Updates the main database with the local database.
|
|
34
34
|
* This method is called automatically when an object is added, updated or removed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/database/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/database/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAwI5C;;;;;;;;;;;;;;;;;;GAkBG;AACH,cAAM,cAAc,CAAC,CAAC,SAAS,YAAY;IAC1C,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAAM;IAErB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAE/B;;;;OAIG;IACH,SAAS,aAAa,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS;IAYvE;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAIjB;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI;IAK1B;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI;IAO7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIpC;;;OAGG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAK9B;;;OAGG;IACH,aAAa,IAAI,CAAC,EAAE;IAIpB;;OAEG;IACH,eAAe,IAAI,IAAI;IAKvB;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;CAGtE;AAED,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Entity, world } from "@minecraft/server";
|
|
2
|
-
import {
|
|
2
|
+
import { getNamespace } from "../constants";
|
|
3
3
|
/**
|
|
4
4
|
* DatabaseManager is a class that manages databases stored in Minecraft's world properties.
|
|
5
5
|
* Currently only supports JSON databases.
|
|
@@ -8,9 +8,7 @@ class DatabaseManager {
|
|
|
8
8
|
static DYNAMIC_PROP_MAX_LENGTH = 32767;
|
|
9
9
|
static CHUNK_KEY = "__SPLIT__";
|
|
10
10
|
target;
|
|
11
|
-
namespace;
|
|
12
11
|
constructor(target) {
|
|
13
|
-
this.namespace = getPackageNamespace();
|
|
14
12
|
if (target instanceof Entity) {
|
|
15
13
|
this.target = target;
|
|
16
14
|
}
|
|
@@ -24,9 +22,7 @@ class DatabaseManager {
|
|
|
24
22
|
* @returns True if the database exists, false otherwise.
|
|
25
23
|
*/
|
|
26
24
|
hasJSONDatabase(databaseName) {
|
|
27
|
-
|
|
28
|
-
return false;
|
|
29
|
-
return this.target.getDynamicProperty(this.namespace + ":" + databaseName) !== undefined;
|
|
25
|
+
return this.target.getDynamicProperty(`${getNamespace()}:${databaseName}`) !== undefined;
|
|
30
26
|
}
|
|
31
27
|
/**
|
|
32
28
|
* Adds a new JSON database with the given name and data.
|
|
@@ -34,7 +30,7 @@ class DatabaseManager {
|
|
|
34
30
|
* @param database The data to be stored in the database.
|
|
35
31
|
*/
|
|
36
32
|
addJSONDatabase(databaseName, database) {
|
|
37
|
-
const propertyName = `${
|
|
33
|
+
const propertyName = `${getNamespace()}:${databaseName}`;
|
|
38
34
|
const jsonString = JSON.stringify(database);
|
|
39
35
|
const existingProp = this.target.getDynamicProperty(propertyName);
|
|
40
36
|
let existingChunks = 0;
|
|
@@ -81,9 +77,7 @@ class DatabaseManager {
|
|
|
81
77
|
* @param databaseName The name of the database.
|
|
82
78
|
*/
|
|
83
79
|
removeJSONDatabase(databaseName) {
|
|
84
|
-
|
|
85
|
-
return;
|
|
86
|
-
const propertyName = `${this.namespace}:${databaseName}`;
|
|
80
|
+
const propertyName = `${getNamespace()}:${databaseName}`;
|
|
87
81
|
const propString = this.target.getDynamicProperty(propertyName);
|
|
88
82
|
if (propString !== undefined) {
|
|
89
83
|
try {
|
|
@@ -107,9 +101,7 @@ class DatabaseManager {
|
|
|
107
101
|
* @throws An error if the database does not exist.
|
|
108
102
|
*/
|
|
109
103
|
getJSONDatabase(databaseName) {
|
|
110
|
-
|
|
111
|
-
return;
|
|
112
|
-
const propertyName = `${this.namespace}:${databaseName}`;
|
|
104
|
+
const propertyName = `${getNamespace()}:${databaseName}`;
|
|
113
105
|
const propString = this.target.getDynamicProperty(propertyName);
|
|
114
106
|
if (propString === undefined) {
|
|
115
107
|
throw new Error("Database does not exist");
|
|
@@ -168,7 +160,7 @@ class SimpleDatabase {
|
|
|
168
160
|
* @param databaseName The name of the database.
|
|
169
161
|
* @param target The target entity to store the database in. If undefined, the database is stored in the world.
|
|
170
162
|
*/
|
|
171
|
-
constructor(databaseName, target
|
|
163
|
+
constructor(databaseName, target) {
|
|
172
164
|
this.mainDB = new DatabaseManager(target);
|
|
173
165
|
this.databaseName = databaseName;
|
|
174
166
|
if (this.mainDB.hasJSONDatabase(this.databaseName)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/database/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"database.js","source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OAIG;IACH,SAAS,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,EAAU;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,EAAE,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,aAAa;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,eAAe;QACd,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,YAAY,EAAE,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,QAAuD;QAC9D,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAClE,CAAC;CACD;AAED,OAAO,EAAE,cAAc,EAAgB,CAAC"}
|
package/dist/database/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/database/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BranchDatabase } from "./database";
|
|
2
2
|
import { Level } from "./level";
|
|
3
3
|
import { levelState } from "./interfaces";
|
|
4
|
-
import {
|
|
4
|
+
import { getNamespace } from "../constants";
|
|
5
5
|
class BranchManager {
|
|
6
6
|
branchDatabase = BranchDatabase.getInstance();
|
|
7
7
|
levels = new Map();
|
|
@@ -40,7 +40,7 @@ class BranchManager {
|
|
|
40
40
|
this.updateBranchState();
|
|
41
41
|
}
|
|
42
42
|
constructor(name) {
|
|
43
|
-
this.identifier = `${
|
|
43
|
+
this.identifier = `${getNamespace()}:${name}`;
|
|
44
44
|
this.getBranchState();
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/game-state-machine/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/game-state-machine/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C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ChD,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;gBACrE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;gBAE/C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;gBACzD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;gBAC3E,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;gBACnB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACpB,CAAC;YACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC;CACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlayerObject, BranchObject } from "./interfaces";
|
|
2
|
-
import { SimpleDatabase } from "
|
|
2
|
+
import { SimpleDatabase } from "@starktma/minecraft-utils/database";
|
|
3
3
|
export declare class BranchDatabase extends SimpleDatabase<BranchObject> {
|
|
4
4
|
protected static instance: BranchDatabase;
|
|
5
5
|
private constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/game-state-machine/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/game-state-machine/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,qBAAa,cAAe,SAAQ,cAAc,CAAC,YAAY,CAAC;IAC/D,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC;IAC1C,OAAO;IAIP,MAAM,CAAC,WAAW,IAAI,cAAc;CAMpC;AAED,qBAAa,cAAe,SAAQ,cAAc,CAAC,YAAY,CAAC;IAC/D,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC;IAC1C,OAAO;IAIP,MAAM,CAAC,WAAW,IAAI,cAAc;CAMpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/game-state-machine/database.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/game-state-machine/database.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,MAAM,OAAO,cAAe,SAAQ,cAA4B;IACrD,MAAM,CAAC,QAAQ,CAAiB;IAC1C;QACC,KAAK,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,WAAW;QACjB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC9B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QAChD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IAChC,CAAC;CACD;AAED,MAAM,OAAO,cAAe,SAAQ,cAA4B;IACrD,MAAM,CAAC,QAAQ,CAAiB;IAC1C;QACC,KAAK,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,WAAW;QACjB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC9B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QAChD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IAChC,CAAC;CACD"}
|
|
@@ -1,52 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Branch } from "./branch";
|
|
3
|
-
declare class StateMachineEvents {
|
|
4
|
-
resetFunctions: (() => void)[];
|
|
5
|
-
tickFunctions: (() => void)[];
|
|
6
|
-
constructor();
|
|
7
|
-
triggerReset(): void;
|
|
8
|
-
triggerTick(): void;
|
|
9
|
-
}
|
|
10
|
-
declare class StateMachineEventRegister {
|
|
11
|
-
private events;
|
|
12
|
-
constructor(events: StateMachineEvents);
|
|
13
|
-
onReset(callback: () => void): void;
|
|
14
|
-
onTick(callback: () => void): void;
|
|
15
|
-
}
|
|
16
|
-
declare class StateMachine {
|
|
17
|
-
private static instance;
|
|
18
|
-
private eventTrigger;
|
|
19
|
-
events: StateMachineEventRegister;
|
|
20
|
-
private playersManager;
|
|
21
|
-
private branches;
|
|
22
|
-
private activeBranches;
|
|
23
|
-
private defaultActiveBranches;
|
|
24
|
-
/**
|
|
25
|
-
* Debug function to display the branches' state in the action bar.
|
|
26
|
-
*/
|
|
27
|
-
private debugBranches;
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new branch.
|
|
30
|
-
* @param name The branch name to create.
|
|
31
|
-
* @param activate Whether to activate the branch or not.
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
createBranch(name: string, activate?: boolean): Branch;
|
|
35
|
-
/**
|
|
36
|
-
* Activates a branch.
|
|
37
|
-
* @param branch The branch to activate.
|
|
38
|
-
*/
|
|
39
|
-
activateBranch(branch: Branch): void;
|
|
40
|
-
/**
|
|
41
|
-
* Deactivates a branch.
|
|
42
|
-
* @param branch The branch to deactivate.
|
|
43
|
-
*/
|
|
44
|
-
deactivateBranch(branch: Branch): void;
|
|
45
|
-
static getInstance(): StateMachine;
|
|
46
|
-
private constructor();
|
|
47
|
-
}
|
|
48
|
-
export declare let stateMachine: StateMachine;
|
|
49
|
-
export declare let mainBranch: Branch;
|
|
50
|
-
export declare let mainLevel0: Level;
|
|
51
|
-
export {};
|
|
1
|
+
export { mainBranch, mainLevel0, stateMachine } from "./stateMachine";
|
|
52
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/game-state-machine/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/game-state-machine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,329 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { PlayerDatabase } from "./database";
|
|
3
|
-
import { playerState } from "./interfaces";
|
|
4
|
-
import { Branch } from "./branch";
|
|
5
|
-
import { getPackageNamespace } from "../constants";
|
|
6
|
-
const RESET_EVENT = `${getPackageNamespace()}:reset`;
|
|
7
|
-
const JUMP_EVENT = `${getPackageNamespace()}:jump`;
|
|
8
|
-
class StateMachineEvents {
|
|
9
|
-
resetFunctions; // Functions to call when the state machine is reset
|
|
10
|
-
tickFunctions; // Functions to call when the state machine ticks
|
|
11
|
-
constructor() {
|
|
12
|
-
this.resetFunctions = [];
|
|
13
|
-
this.tickFunctions = [];
|
|
14
|
-
}
|
|
15
|
-
triggerReset() {
|
|
16
|
-
this.resetFunctions.forEach((callback) => {
|
|
17
|
-
callback();
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
triggerTick() {
|
|
21
|
-
this.tickFunctions.forEach((callback) => {
|
|
22
|
-
callback();
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
class StateMachineEventRegister {
|
|
27
|
-
events;
|
|
28
|
-
constructor(events) {
|
|
29
|
-
this.events = events;
|
|
30
|
-
}
|
|
31
|
-
onReset(callback) {
|
|
32
|
-
this.events.resetFunctions.push(callback);
|
|
33
|
-
}
|
|
34
|
-
onTick(callback) {
|
|
35
|
-
this.events.tickFunctions.push(callback);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
class PlayerManager {
|
|
39
|
-
playerDatabase = PlayerDatabase.getInstance();
|
|
40
|
-
players = new Map();
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* Debug function to display the players' state in the action bar.
|
|
44
|
-
*/
|
|
45
|
-
debugPlayers() {
|
|
46
|
-
let data = [];
|
|
47
|
-
let longestPlayerName = 0;
|
|
48
|
-
let longestBranchName = 0;
|
|
49
|
-
let longestLevelName = 0;
|
|
50
|
-
const players = mc.world.getAllPlayers();
|
|
51
|
-
for (const player of players) {
|
|
52
|
-
const playerObject = this.playerDatabase.getObject(player.id);
|
|
53
|
-
data.push({
|
|
54
|
-
playerName: player.nameTag,
|
|
55
|
-
branch: playerObject.branch,
|
|
56
|
-
level: playerObject.playerLevel,
|
|
57
|
-
state: playerObject.playerState,
|
|
58
|
-
});
|
|
59
|
-
longestPlayerName = Math.max(longestPlayerName, player.nameTag.length);
|
|
60
|
-
longestBranchName = Math.max(longestBranchName, playerObject.branch.length);
|
|
61
|
-
longestLevelName = Math.max(longestLevelName, playerObject.playerLevel.length);
|
|
62
|
-
}
|
|
63
|
-
let formattedData = data.map((player) => {
|
|
64
|
-
return `${player.playerName.padEnd(longestPlayerName)} | §a${player.branch.padEnd(longestBranchName)}§r | §6${player.level.padEnd(longestLevelName)}§r | §3${player.state}§r`;
|
|
65
|
-
});
|
|
66
|
-
return formattedData;
|
|
67
|
-
}
|
|
68
|
-
registerNewPlayer(player) {
|
|
69
|
-
if (!this.playerDatabase.hasObject(player.id)) {
|
|
70
|
-
this.playerDatabase.addObject({
|
|
71
|
-
id: player.id,
|
|
72
|
-
branch: mainBranch.identifier,
|
|
73
|
-
playerLevel: mainLevel0.identifier,
|
|
74
|
-
playerState: playerState.SETUP_PLAYER,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
updatePlayerState(currentLevel, player, playerObject, branch) {
|
|
79
|
-
if (playerObject.playerLevel === currentLevel.identifier && playerObject.playerState === playerState.SETUP_PLAYER) {
|
|
80
|
-
currentLevel.eventTrigger.triggerPlayerJoinLevel(player);
|
|
81
|
-
playerObject.playerState = playerState.EXIT_PLAYER;
|
|
82
|
-
}
|
|
83
|
-
else if (playerObject.playerLevel !== currentLevel.identifier) {
|
|
84
|
-
const levels = Array.from(branch.getLevels());
|
|
85
|
-
const currentIndex = currentLevel.levelIndex;
|
|
86
|
-
const playerIndex = levels.findIndex((level) => level[0] === playerObject.playerLevel);
|
|
87
|
-
if (currentIndex > playerIndex) {
|
|
88
|
-
for (let i = playerIndex; i < currentIndex; i++) {
|
|
89
|
-
const levelToExit = branch.getLevel(levels[i][0]);
|
|
90
|
-
const levelToEnter = branch.getLevel(levels[i + 1][0]);
|
|
91
|
-
levelToExit?.eventTrigger.triggerPlayerLeaveLevel(player);
|
|
92
|
-
levelToEnter?.eventTrigger.triggerPlayerJoinLevel(player);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else if (currentIndex < playerIndex) {
|
|
96
|
-
const levelToExit = branch.getLevel(levels[playerIndex][0]);
|
|
97
|
-
const levelToEnter = branch.getLevel(levels[currentIndex][0]);
|
|
98
|
-
levelToExit?.eventTrigger.triggerPlayerLeaveLevel(player);
|
|
99
|
-
levelToEnter?.eventTrigger.triggerPlayerJoinLevel(player);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
currentLevel.eventTrigger.triggerPlayerLeaveLevel(player);
|
|
103
|
-
}
|
|
104
|
-
playerObject.playerState = playerState.SETUP_PLAYER;
|
|
105
|
-
playerObject.playerLevel = currentLevel.identifier;
|
|
106
|
-
}
|
|
107
|
-
this.playerDatabase.updateObject(playerObject);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Resets the player database.
|
|
111
|
-
*/
|
|
112
|
-
reset() {
|
|
113
|
-
this.playerDatabase.eraseAllObjects();
|
|
114
|
-
mc.world.getAllPlayers().forEach((player) => {
|
|
115
|
-
this.players.set(player.id, player);
|
|
116
|
-
this.registerNewPlayer(player);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Called when a player joins the server.
|
|
121
|
-
* If a player does not exist on the database, it will be added to the main branch.
|
|
122
|
-
* @param player The player that joined the server.
|
|
123
|
-
*/
|
|
124
|
-
onPlayerJoinServer(player, branches) {
|
|
125
|
-
this.registerNewPlayer(player);
|
|
126
|
-
this.players.set(player.id, player);
|
|
127
|
-
const playerObject = this.playerDatabase.getObject(player.id);
|
|
128
|
-
const branch = branches.branches.get(playerObject.branch);
|
|
129
|
-
const currentLevel = branch.getActiveLevel();
|
|
130
|
-
if (!currentLevel || !branches.activeBranches.has(branch)) {
|
|
131
|
-
playerObject.branch = mainBranch.identifier;
|
|
132
|
-
playerObject.playerLevel = mainLevel0.identifier;
|
|
133
|
-
playerObject.playerState = playerState.SETUP_PLAYER;
|
|
134
|
-
mainLevel0.eventTrigger.triggerPlayerJoinServer(player);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
currentLevel.eventTrigger.triggerPlayerJoinServer(player);
|
|
138
|
-
this.updatePlayerState(currentLevel, player, playerObject, branch);
|
|
139
|
-
}
|
|
140
|
-
this.playerDatabase.updateObject(playerObject);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Called when a player respawns.
|
|
144
|
-
* @param player The player that respawned.
|
|
145
|
-
*/
|
|
146
|
-
onPlayerRespawn(player, branches) {
|
|
147
|
-
const playerObject = this.playerDatabase.getObject(player.id);
|
|
148
|
-
const branch = branches.branches.get(playerObject.branch);
|
|
149
|
-
const level = branch.getActiveLevel();
|
|
150
|
-
if (level) {
|
|
151
|
-
level.eventTrigger.triggerPlayerRespawn(player);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Called when a player leaves the server.
|
|
156
|
-
* @param player The player that left the server.
|
|
157
|
-
*/
|
|
158
|
-
onPlayerLeaveServer(player, branches) {
|
|
159
|
-
this.players.delete(player.id);
|
|
160
|
-
const playerObject = this.playerDatabase.getObject(player.id);
|
|
161
|
-
const branch = branches.branches.get(playerObject.branch);
|
|
162
|
-
const level = branch.getActiveLevel();
|
|
163
|
-
if (level) {
|
|
164
|
-
level.eventTrigger.triggerPlayerLeaveServer(player);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Called when a player dies.
|
|
169
|
-
* @param player The player that died.
|
|
170
|
-
*/
|
|
171
|
-
onPlayerDeath(player, branches) {
|
|
172
|
-
const playerObject = this.playerDatabase.getObject(player.id);
|
|
173
|
-
const branch = branches.branches.get(playerObject.branch);
|
|
174
|
-
const level = branch.getActiveLevel();
|
|
175
|
-
if (level) {
|
|
176
|
-
level.eventTrigger.triggerPlayerDeath(player);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
tick(activeBranches) {
|
|
180
|
-
activeBranches.forEach((branch) => {
|
|
181
|
-
this.playerDatabase
|
|
182
|
-
.getAllObjects()
|
|
183
|
-
.filter((player) => player.branch === branch.identifier)
|
|
184
|
-
.forEach((player) => {
|
|
185
|
-
const p = this.players.get(player.id);
|
|
186
|
-
if (p) {
|
|
187
|
-
this.updatePlayerState(branch.getActiveLevel(), p, player, branch);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
class StateMachine {
|
|
194
|
-
static instance;
|
|
195
|
-
eventTrigger = new StateMachineEvents();
|
|
196
|
-
events = new StateMachineEventRegister(this.eventTrigger);
|
|
197
|
-
playersManager = new PlayerManager();
|
|
198
|
-
branches = new Map();
|
|
199
|
-
activeBranches = new Set();
|
|
200
|
-
defaultActiveBranches = new Set();
|
|
201
|
-
/**
|
|
202
|
-
* Debug function to display the branches' state in the action bar.
|
|
203
|
-
*/
|
|
204
|
-
debugBranches() {
|
|
205
|
-
let data = [];
|
|
206
|
-
let longestBranchName = 0;
|
|
207
|
-
let longestLevelName = 0;
|
|
208
|
-
this.branches.forEach((branch) => {
|
|
209
|
-
const level = branch.getActiveLevel();
|
|
210
|
-
data.push({
|
|
211
|
-
branch: branch.identifier,
|
|
212
|
-
level: level?.identifier ?? "No active levels",
|
|
213
|
-
state: branch.levelState,
|
|
214
|
-
isActive: this.activeBranches.has(branch),
|
|
215
|
-
});
|
|
216
|
-
longestBranchName = Math.max(longestBranchName, branch.identifier.length);
|
|
217
|
-
longestLevelName = Math.max(longestLevelName, level?.identifier.length ?? 0);
|
|
218
|
-
});
|
|
219
|
-
let formattedData = data.map((branch) => {
|
|
220
|
-
return `§a${branch.branch.padEnd(longestBranchName)}§r | §6${branch.level.padEnd(longestLevelName)}§r | §3${branch.state}§r | ${branch.isActive}§r`;
|
|
221
|
-
});
|
|
222
|
-
return formattedData;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Creates a new branch.
|
|
226
|
-
* @param name The branch name to create.
|
|
227
|
-
* @param activate Whether to activate the branch or not.
|
|
228
|
-
* @returns
|
|
229
|
-
*/
|
|
230
|
-
createBranch(name, activate = false) {
|
|
231
|
-
const branchIdentifier = `${getPackageNamespace()}:${name}`;
|
|
232
|
-
if (this.branches.has(branchIdentifier)) {
|
|
233
|
-
throw new Error(`Branch with name ${branchIdentifier} already exists. Error at StateMachine.createBranch`);
|
|
234
|
-
}
|
|
235
|
-
const branch = new Branch(name);
|
|
236
|
-
this.branches.set(branchIdentifier, branch);
|
|
237
|
-
if (activate) {
|
|
238
|
-
this.activateBranch(branch);
|
|
239
|
-
this.defaultActiveBranches.add(branch);
|
|
240
|
-
}
|
|
241
|
-
return branch;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Activates a branch.
|
|
245
|
-
* @param branch The branch to activate.
|
|
246
|
-
*/
|
|
247
|
-
activateBranch(branch) {
|
|
248
|
-
this.activeBranches.add(branch);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Deactivates a branch.
|
|
252
|
-
* @param branch The branch to deactivate.
|
|
253
|
-
*/
|
|
254
|
-
deactivateBranch(branch) {
|
|
255
|
-
this.activeBranches.delete(branch);
|
|
256
|
-
}
|
|
257
|
-
static getInstance() {
|
|
258
|
-
if (!StateMachine.instance) {
|
|
259
|
-
StateMachine.instance = new StateMachine();
|
|
260
|
-
}
|
|
261
|
-
return StateMachine.instance;
|
|
262
|
-
}
|
|
263
|
-
constructor() {
|
|
264
|
-
mc.world.afterEvents.worldLoad.subscribe(() => {
|
|
265
|
-
mc.world.afterEvents.playerSpawn.subscribe((event) => {
|
|
266
|
-
if (event.initialSpawn) {
|
|
267
|
-
this.playersManager.onPlayerJoinServer(event.player, { branches: this.branches, activeBranches: this.activeBranches });
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
this.playersManager.onPlayerRespawn(event.player, { branches: this.branches, activeBranches: this.activeBranches });
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
mc.world.beforeEvents.playerLeave.subscribe((event) => {
|
|
274
|
-
this.playersManager.onPlayerLeaveServer(event.player, { branches: this.branches, activeBranches: this.activeBranches });
|
|
275
|
-
});
|
|
276
|
-
mc.world.afterEvents.entityDie.subscribe((event) => {
|
|
277
|
-
this.playersManager.onPlayerDeath(event.deadEntity, {
|
|
278
|
-
branches: this.branches,
|
|
279
|
-
activeBranches: this.activeBranches,
|
|
280
|
-
});
|
|
281
|
-
}, { entityTypes: ["minecraft:player"] });
|
|
282
|
-
mc.system.afterEvents.scriptEventReceive.subscribe((event) => {
|
|
283
|
-
if (event.id === RESET_EVENT) {
|
|
284
|
-
this.eventTrigger.triggerReset();
|
|
285
|
-
}
|
|
286
|
-
else if (event.id === JUMP_EVENT) {
|
|
287
|
-
this.activeBranches.forEach((branch) => {
|
|
288
|
-
branch.jumpToLevel(event.message);
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
mc.system.runInterval(() => this.eventTrigger.triggerTick());
|
|
293
|
-
});
|
|
294
|
-
this.events.onReset(() => {
|
|
295
|
-
this.activeBranches.clear();
|
|
296
|
-
this.branches.forEach((branch) => {
|
|
297
|
-
branch.resetBranch();
|
|
298
|
-
});
|
|
299
|
-
this.defaultActiveBranches.forEach((branch) => {
|
|
300
|
-
this.activateBranch(branch);
|
|
301
|
-
});
|
|
302
|
-
this.playersManager.reset();
|
|
303
|
-
});
|
|
304
|
-
this.events.onTick(() => {
|
|
305
|
-
this.activeBranches.forEach((branch) => {
|
|
306
|
-
if (!branch.getActiveLevel()) {
|
|
307
|
-
this.deactivateBranch(branch);
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
branch.tick();
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
this.playersManager.tick(this.activeBranches);
|
|
314
|
-
//let playerData = this.playersManager.debugPlayers();
|
|
315
|
-
//let levelData = this.debugBranches();
|
|
316
|
-
//let combinedData = [...playerData, ...levelData];
|
|
317
|
-
//mc.world.getDimension(mc.MinecraftDimensionTypes.overworld).runCommand(`title @a actionbar ${combinedData.join("\n")}`);
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
mc.world.afterEvents.worldLoad.subscribe((eventData) => {
|
|
322
|
-
stateMachine = StateMachine.getInstance();
|
|
323
|
-
mainBranch = stateMachine.createBranch("mainBranch", true);
|
|
324
|
-
mainLevel0 = mainBranch.addLevel("mainLevel0", true);
|
|
325
|
-
});
|
|
326
|
-
export let stateMachine;
|
|
327
|
-
export let mainBranch;
|
|
328
|
-
export let mainLevel0;
|
|
1
|
+
export { mainBranch, mainLevel0, stateMachine } from "./stateMachine";
|
|
329
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/game-state-machine/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EA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A,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Level } from "./level";
|
|
2
|
+
import { Branch } from "./branch";
|
|
3
|
+
declare class StateMachineEvents {
|
|
4
|
+
resetFunctions: (() => void)[];
|
|
5
|
+
tickFunctions: (() => void)[];
|
|
6
|
+
constructor();
|
|
7
|
+
triggerReset(): void;
|
|
8
|
+
triggerTick(): void;
|
|
9
|
+
}
|
|
10
|
+
declare class StateMachineEventRegister {
|
|
11
|
+
private events;
|
|
12
|
+
constructor(events: StateMachineEvents);
|
|
13
|
+
onReset(callback: () => void): void;
|
|
14
|
+
onTick(callback: () => void): void;
|
|
15
|
+
}
|
|
16
|
+
declare class StateMachine {
|
|
17
|
+
private static instance;
|
|
18
|
+
private eventTrigger;
|
|
19
|
+
events: StateMachineEventRegister;
|
|
20
|
+
private playersManager;
|
|
21
|
+
private branches;
|
|
22
|
+
private activeBranches;
|
|
23
|
+
private defaultActiveBranches;
|
|
24
|
+
/**
|
|
25
|
+
* Debug function to display the branches' state in the action bar.
|
|
26
|
+
*/
|
|
27
|
+
private debugBranches;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new branch.
|
|
30
|
+
* @param name The branch name to create.
|
|
31
|
+
* @param activate Whether to activate the branch or not.
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
createBranch(name: string, activate?: boolean): Branch;
|
|
35
|
+
/**
|
|
36
|
+
* Activates a branch.
|
|
37
|
+
* @param branch The branch to activate.
|
|
38
|
+
*/
|
|
39
|
+
activateBranch(branch: Branch): void;
|
|
40
|
+
/**
|
|
41
|
+
* Deactivates a branch.
|
|
42
|
+
* @param branch The branch to deactivate.
|
|
43
|
+
*/
|
|
44
|
+
deactivateBranch(branch: Branch): void;
|
|
45
|
+
static getInstance(): StateMachine;
|
|
46
|
+
private constructor();
|
|
47
|
+
}
|
|
48
|
+
export declare let stateMachine: StateMachine;
|
|
49
|
+
export declare let mainBranch: Branch;
|
|
50
|
+
export declare let mainLevel0: Level;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=stateMachine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateMachine.d.ts","sourceRoot":"","sources":["../../src/game-state-machine/stateMachine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,cAAM,kBAAkB;IAChB,cAAc,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAC/B,aAAa,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;;IAOrC,YAAY;IAMZ,WAAW;CAKX;AAED,cAAM,yBAAyB;IAC9B,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,EAAE,kBAAkB;IAItC,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI;IAI5B,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI;CAG3B;AAsLD,cAAM,YAAY;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IAEtC,OAAO,CAAC,YAAY,CAAgD;IAC7D,MAAM,EAAE,yBAAyB,CAAoD;IAE5F,OAAO,CAAC,cAAc,CAAsC;IAE5D,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,qBAAqB,CAA0B;IAEvD;;OAEG;IACH,OAAO,CAAC,aAAa;IA2BrB;;;;;OAKG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAe,GAAG,MAAM;IAepE;;;OAGG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM;IAIpC;;;OAGG;IACI,gBAAgB,CAAC,MAAM,EAAE,MAAM;WAIxB,WAAW,IAAI,YAAY;IAOzC,OAAO;CA6DP;AAQD,eAAO,IAAI,YAAY,EAAE,YAAY,CAAC;AACtC,eAAO,IAAI,UAAU,EAAE,MAAM,CAAC;AAC9B,eAAO,IAAI,UAAU,EAAE,KAAK,CAAC"}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import * as mc from "@minecraft/server";
|
|
2
|
+
import { PlayerDatabase } from "./database";
|
|
3
|
+
import { playerState } from "./interfaces";
|
|
4
|
+
import { Branch } from "./branch";
|
|
5
|
+
import { getNamespace } from "../constants";
|
|
6
|
+
class StateMachineEvents {
|
|
7
|
+
resetFunctions; // Functions to call when the state machine is reset
|
|
8
|
+
tickFunctions; // Functions to call when the state machine ticks
|
|
9
|
+
constructor() {
|
|
10
|
+
this.resetFunctions = [];
|
|
11
|
+
this.tickFunctions = [];
|
|
12
|
+
}
|
|
13
|
+
triggerReset() {
|
|
14
|
+
this.resetFunctions.forEach((callback) => {
|
|
15
|
+
callback();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
triggerTick() {
|
|
19
|
+
this.tickFunctions.forEach((callback) => {
|
|
20
|
+
callback();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class StateMachineEventRegister {
|
|
25
|
+
events;
|
|
26
|
+
constructor(events) {
|
|
27
|
+
this.events = events;
|
|
28
|
+
}
|
|
29
|
+
onReset(callback) {
|
|
30
|
+
this.events.resetFunctions.push(callback);
|
|
31
|
+
}
|
|
32
|
+
onTick(callback) {
|
|
33
|
+
this.events.tickFunctions.push(callback);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class PlayerManager {
|
|
37
|
+
playerDatabase = PlayerDatabase.getInstance();
|
|
38
|
+
players = new Map();
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* Debug function to display the players' state in the action bar.
|
|
42
|
+
*/
|
|
43
|
+
debugPlayers() {
|
|
44
|
+
let data = [];
|
|
45
|
+
let longestPlayerName = 0;
|
|
46
|
+
let longestBranchName = 0;
|
|
47
|
+
let longestLevelName = 0;
|
|
48
|
+
const players = mc.world.getAllPlayers();
|
|
49
|
+
for (const player of players) {
|
|
50
|
+
const playerObject = this.playerDatabase.getObject(player.id);
|
|
51
|
+
data.push({
|
|
52
|
+
playerName: player.nameTag,
|
|
53
|
+
branch: playerObject.branch,
|
|
54
|
+
level: playerObject.playerLevel,
|
|
55
|
+
state: playerObject.playerState,
|
|
56
|
+
});
|
|
57
|
+
longestPlayerName = Math.max(longestPlayerName, player.nameTag.length);
|
|
58
|
+
longestBranchName = Math.max(longestBranchName, playerObject.branch.length);
|
|
59
|
+
longestLevelName = Math.max(longestLevelName, playerObject.playerLevel.length);
|
|
60
|
+
}
|
|
61
|
+
let formattedData = data.map((player) => {
|
|
62
|
+
return `${player.playerName.padEnd(longestPlayerName)} | §a${player.branch.padEnd(longestBranchName)}§r | §6${player.level.padEnd(longestLevelName)}§r | §3${player.state}§r`;
|
|
63
|
+
});
|
|
64
|
+
return formattedData;
|
|
65
|
+
}
|
|
66
|
+
registerNewPlayer(player) {
|
|
67
|
+
if (!this.playerDatabase.hasObject(player.id)) {
|
|
68
|
+
this.playerDatabase.addObject({
|
|
69
|
+
id: player.id,
|
|
70
|
+
branch: mainBranch.identifier,
|
|
71
|
+
playerLevel: mainLevel0.identifier,
|
|
72
|
+
playerState: playerState.SETUP_PLAYER,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
updatePlayerState(currentLevel, player, playerObject, branch) {
|
|
77
|
+
if (playerObject.playerLevel === currentLevel.identifier && playerObject.playerState === playerState.SETUP_PLAYER) {
|
|
78
|
+
currentLevel.eventTrigger.triggerPlayerJoinLevel(player);
|
|
79
|
+
playerObject.playerState = playerState.EXIT_PLAYER;
|
|
80
|
+
}
|
|
81
|
+
else if (playerObject.playerLevel !== currentLevel.identifier) {
|
|
82
|
+
const levels = Array.from(branch.getLevels());
|
|
83
|
+
const currentIndex = currentLevel.levelIndex;
|
|
84
|
+
const playerIndex = levels.findIndex((level) => level[0] === playerObject.playerLevel);
|
|
85
|
+
if (currentIndex > playerIndex) {
|
|
86
|
+
for (let i = playerIndex; i < currentIndex; i++) {
|
|
87
|
+
const levelToExit = branch.getLevel(levels[i][0]);
|
|
88
|
+
const levelToEnter = branch.getLevel(levels[i + 1][0]);
|
|
89
|
+
levelToExit?.eventTrigger.triggerPlayerLeaveLevel(player);
|
|
90
|
+
levelToEnter?.eventTrigger.triggerPlayerJoinLevel(player);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else if (currentIndex < playerIndex) {
|
|
94
|
+
const levelToExit = branch.getLevel(levels[playerIndex][0]);
|
|
95
|
+
const levelToEnter = branch.getLevel(levels[currentIndex][0]);
|
|
96
|
+
levelToExit?.eventTrigger.triggerPlayerLeaveLevel(player);
|
|
97
|
+
levelToEnter?.eventTrigger.triggerPlayerJoinLevel(player);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
currentLevel.eventTrigger.triggerPlayerLeaveLevel(player);
|
|
101
|
+
}
|
|
102
|
+
playerObject.playerState = playerState.SETUP_PLAYER;
|
|
103
|
+
playerObject.playerLevel = currentLevel.identifier;
|
|
104
|
+
}
|
|
105
|
+
this.playerDatabase.updateObject(playerObject);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Resets the player database.
|
|
109
|
+
*/
|
|
110
|
+
reset() {
|
|
111
|
+
this.playerDatabase.eraseAllObjects();
|
|
112
|
+
mc.world.getAllPlayers().forEach((player) => {
|
|
113
|
+
this.players.set(player.id, player);
|
|
114
|
+
this.registerNewPlayer(player);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Called when a player joins the server.
|
|
119
|
+
* If a player does not exist on the database, it will be added to the main branch.
|
|
120
|
+
* @param player The player that joined the server.
|
|
121
|
+
*/
|
|
122
|
+
onPlayerJoinServer(player, branches) {
|
|
123
|
+
this.registerNewPlayer(player);
|
|
124
|
+
this.players.set(player.id, player);
|
|
125
|
+
const playerObject = this.playerDatabase.getObject(player.id);
|
|
126
|
+
const branch = branches.branches.get(playerObject.branch);
|
|
127
|
+
const currentLevel = branch.getActiveLevel();
|
|
128
|
+
if (!currentLevel || !branches.activeBranches.has(branch)) {
|
|
129
|
+
playerObject.branch = mainBranch.identifier;
|
|
130
|
+
playerObject.playerLevel = mainLevel0.identifier;
|
|
131
|
+
playerObject.playerState = playerState.SETUP_PLAYER;
|
|
132
|
+
mainLevel0.eventTrigger.triggerPlayerJoinServer(player);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
currentLevel.eventTrigger.triggerPlayerJoinServer(player);
|
|
136
|
+
this.updatePlayerState(currentLevel, player, playerObject, branch);
|
|
137
|
+
}
|
|
138
|
+
this.playerDatabase.updateObject(playerObject);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Called when a player respawns.
|
|
142
|
+
* @param player The player that respawned.
|
|
143
|
+
*/
|
|
144
|
+
onPlayerRespawn(player, branches) {
|
|
145
|
+
const playerObject = this.playerDatabase.getObject(player.id);
|
|
146
|
+
const branch = branches.branches.get(playerObject.branch);
|
|
147
|
+
const level = branch.getActiveLevel();
|
|
148
|
+
if (level) {
|
|
149
|
+
level.eventTrigger.triggerPlayerRespawn(player);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Called when a player leaves the server.
|
|
154
|
+
* @param player The player that left the server.
|
|
155
|
+
*/
|
|
156
|
+
onPlayerLeaveServer(player, branches) {
|
|
157
|
+
this.players.delete(player.id);
|
|
158
|
+
const playerObject = this.playerDatabase.getObject(player.id);
|
|
159
|
+
const branch = branches.branches.get(playerObject.branch);
|
|
160
|
+
const level = branch.getActiveLevel();
|
|
161
|
+
if (level) {
|
|
162
|
+
level.eventTrigger.triggerPlayerLeaveServer(player);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Called when a player dies.
|
|
167
|
+
* @param player The player that died.
|
|
168
|
+
*/
|
|
169
|
+
onPlayerDeath(player, branches) {
|
|
170
|
+
const playerObject = this.playerDatabase.getObject(player.id);
|
|
171
|
+
const branch = branches.branches.get(playerObject.branch);
|
|
172
|
+
const level = branch.getActiveLevel();
|
|
173
|
+
if (level) {
|
|
174
|
+
level.eventTrigger.triggerPlayerDeath(player);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
tick(activeBranches) {
|
|
178
|
+
activeBranches.forEach((branch) => {
|
|
179
|
+
this.playerDatabase
|
|
180
|
+
.getAllObjects()
|
|
181
|
+
.filter((player) => player.branch === branch.identifier)
|
|
182
|
+
.forEach((player) => {
|
|
183
|
+
const p = this.players.get(player.id);
|
|
184
|
+
if (p) {
|
|
185
|
+
this.updatePlayerState(branch.getActiveLevel(), p, player, branch);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
class StateMachine {
|
|
192
|
+
static instance;
|
|
193
|
+
eventTrigger = new StateMachineEvents();
|
|
194
|
+
events = new StateMachineEventRegister(this.eventTrigger);
|
|
195
|
+
playersManager = new PlayerManager();
|
|
196
|
+
branches = new Map();
|
|
197
|
+
activeBranches = new Set();
|
|
198
|
+
defaultActiveBranches = new Set();
|
|
199
|
+
/**
|
|
200
|
+
* Debug function to display the branches' state in the action bar.
|
|
201
|
+
*/
|
|
202
|
+
debugBranches() {
|
|
203
|
+
let data = [];
|
|
204
|
+
let longestBranchName = 0;
|
|
205
|
+
let longestLevelName = 0;
|
|
206
|
+
this.branches.forEach((branch) => {
|
|
207
|
+
const level = branch.getActiveLevel();
|
|
208
|
+
data.push({
|
|
209
|
+
branch: branch.identifier,
|
|
210
|
+
level: level?.identifier ?? "No active levels",
|
|
211
|
+
state: branch.levelState,
|
|
212
|
+
isActive: this.activeBranches.has(branch),
|
|
213
|
+
});
|
|
214
|
+
longestBranchName = Math.max(longestBranchName, branch.identifier.length);
|
|
215
|
+
longestLevelName = Math.max(longestLevelName, level?.identifier.length ?? 0);
|
|
216
|
+
});
|
|
217
|
+
let formattedData = data.map((branch) => {
|
|
218
|
+
return `§a${branch.branch.padEnd(longestBranchName)}§r | §6${branch.level.padEnd(longestLevelName)}§r | §3${branch.state}§r | ${branch.isActive}§r`;
|
|
219
|
+
});
|
|
220
|
+
return formattedData;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Creates a new branch.
|
|
224
|
+
* @param name The branch name to create.
|
|
225
|
+
* @param activate Whether to activate the branch or not.
|
|
226
|
+
* @returns
|
|
227
|
+
*/
|
|
228
|
+
createBranch(name, activate = false) {
|
|
229
|
+
const branchIdentifier = `${getNamespace()}:${name}`;
|
|
230
|
+
if (this.branches.has(branchIdentifier)) {
|
|
231
|
+
throw new Error(`Branch with name ${branchIdentifier} already exists. Error at StateMachine.createBranch`);
|
|
232
|
+
}
|
|
233
|
+
const branch = new Branch(name);
|
|
234
|
+
this.branches.set(branchIdentifier, branch);
|
|
235
|
+
if (activate) {
|
|
236
|
+
this.activateBranch(branch);
|
|
237
|
+
this.defaultActiveBranches.add(branch);
|
|
238
|
+
}
|
|
239
|
+
return branch;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Activates a branch.
|
|
243
|
+
* @param branch The branch to activate.
|
|
244
|
+
*/
|
|
245
|
+
activateBranch(branch) {
|
|
246
|
+
this.activeBranches.add(branch);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Deactivates a branch.
|
|
250
|
+
* @param branch The branch to deactivate.
|
|
251
|
+
*/
|
|
252
|
+
deactivateBranch(branch) {
|
|
253
|
+
this.activeBranches.delete(branch);
|
|
254
|
+
}
|
|
255
|
+
static getInstance() {
|
|
256
|
+
if (!StateMachine.instance) {
|
|
257
|
+
StateMachine.instance = new StateMachine();
|
|
258
|
+
}
|
|
259
|
+
return StateMachine.instance;
|
|
260
|
+
}
|
|
261
|
+
constructor() {
|
|
262
|
+
mc.world.afterEvents.playerSpawn.subscribe((event) => {
|
|
263
|
+
if (event.initialSpawn) {
|
|
264
|
+
this.playersManager.onPlayerJoinServer(event.player, { branches: this.branches, activeBranches: this.activeBranches });
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
this.playersManager.onPlayerRespawn(event.player, { branches: this.branches, activeBranches: this.activeBranches });
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
mc.world.beforeEvents.playerLeave.subscribe((event) => {
|
|
271
|
+
this.playersManager.onPlayerLeaveServer(event.player, { branches: this.branches, activeBranches: this.activeBranches });
|
|
272
|
+
});
|
|
273
|
+
mc.world.afterEvents.entityDie.subscribe((event) => {
|
|
274
|
+
this.playersManager.onPlayerDeath(event.deadEntity, { branches: this.branches, activeBranches: this.activeBranches });
|
|
275
|
+
}, { entityTypes: ["minecraft:player"] });
|
|
276
|
+
mc.system.afterEvents.scriptEventReceive.subscribe((event) => {
|
|
277
|
+
const RESET_EVENT = `${getNamespace()}:reset`;
|
|
278
|
+
const JUMP_EVENT = `${getNamespace()}:jump`;
|
|
279
|
+
if (event.id === RESET_EVENT) {
|
|
280
|
+
this.eventTrigger.triggerReset();
|
|
281
|
+
}
|
|
282
|
+
else if (event.id === JUMP_EVENT) {
|
|
283
|
+
this.activeBranches.forEach((branch) => {
|
|
284
|
+
branch.jumpToLevel(event.message);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
mc.system.runInterval(() => this.eventTrigger.triggerTick());
|
|
289
|
+
this.events.onReset(() => {
|
|
290
|
+
this.activeBranches.clear();
|
|
291
|
+
this.branches.forEach((branch) => {
|
|
292
|
+
branch.resetBranch();
|
|
293
|
+
});
|
|
294
|
+
this.defaultActiveBranches.forEach((branch) => {
|
|
295
|
+
this.activateBranch(branch);
|
|
296
|
+
});
|
|
297
|
+
this.playersManager.reset();
|
|
298
|
+
});
|
|
299
|
+
this.events.onTick(() => {
|
|
300
|
+
this.activeBranches.forEach((branch) => {
|
|
301
|
+
if (!branch.getActiveLevel()) {
|
|
302
|
+
this.deactivateBranch(branch);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
branch.tick();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
this.playersManager.tick(this.activeBranches);
|
|
309
|
+
//let playerData = this.playersManager.debugPlayers();
|
|
310
|
+
//let levelData = this.debugBranches();
|
|
311
|
+
//let combinedData = [...playerData, ...levelData];
|
|
312
|
+
//mc.world.getDimension(mc.MinecraftDimensionTypes.overworld).runCommand(`title @a actionbar ${combinedData.join("\n")}`);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
mc.world.afterEvents.worldLoad.subscribe((eventData) => {
|
|
317
|
+
stateMachine = StateMachine.getInstance();
|
|
318
|
+
mainBranch = stateMachine.createBranch("mainBranch", true);
|
|
319
|
+
mainLevel0 = mainBranch.addLevel("mainLevel0", true);
|
|
320
|
+
});
|
|
321
|
+
export let stateMachine;
|
|
322
|
+
export let mainBranch;
|
|
323
|
+
export let mainLevel0;
|
|
324
|
+
//# sourceMappingURL=stateMachine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateMachine.js","sourceRoot":"","sources":["../../src/game-state-machine/stateMachine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAgB,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,kBAAkB;IAChB,cAAc,CAAiB,CAAC,oDAAoD;IACpF,aAAa,CAAiB,CAAC,iDAAiD;IAEvF;QACC,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,YAAY;QACX,IAAI,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ACf,CAAC;YACF,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAE9C,sDAAsD;YACtD,uCAAuC;YACvC,mDAAmD;YACnD,0HAA0H;QAC3H,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE;IACtD,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;IAC1C,UAAU,GAAG,YAAY,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC3D,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,IAAI,YAA0B,CAAC;AACtC,MAAM,CAAC,IAAI,UAAkB,CAAC;AAC9B,MAAM,CAAC,IAAI,UAAiB,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Re-export configuration functions for convenience
|
|
2
|
-
export { setNamespace, getNamespace } from "./config";
|
|
3
1
|
// Re-export constants with the new dynamic namespace
|
|
4
|
-
export {
|
|
2
|
+
export { getNamespace, setNamespace } from "./constants";
|
|
5
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starktma/minecraft-utils",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "npx -
|
|
12
|
+
"build": "npx tsc -b --pretty --verbose",
|
|
13
13
|
"prepare": "npm run build"
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"import": "./dist/index.js",
|
|
18
18
|
"types": "./dist/index.d.ts"
|
|
19
19
|
},
|
|
20
|
-
"./config": {
|
|
21
|
-
"import": "./dist/config.js",
|
|
22
|
-
"types": "./dist/config.d.ts"
|
|
23
|
-
},
|
|
24
20
|
"./math": {
|
|
25
21
|
"import": "./dist/math/index.js",
|
|
26
22
|
"types": "./dist/math/index.d.ts"
|
package/dist/config.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for minecraft-utils package.
|
|
3
|
-
* This allows consumers to set a custom namespace for their project.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Sets the namespace for this package instance.
|
|
7
|
-
* This should be called once at the beginning of your application.
|
|
8
|
-
*
|
|
9
|
-
* @param namespace - The namespace to use for this package
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { setNamespace } from "@starktma/minecraft-utils/config";
|
|
14
|
-
*
|
|
15
|
-
* // Set your custom namespace
|
|
16
|
-
* setNamespace("myproject");
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare function setNamespace(namespace: string): void;
|
|
20
|
-
/**
|
|
21
|
-
* Gets the current namespace.
|
|
22
|
-
*
|
|
23
|
-
* @returns The current namespace
|
|
24
|
-
*/
|
|
25
|
-
export declare function getNamespace(): string;
|
|
26
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAKpD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|
package/dist/config.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for minecraft-utils package.
|
|
3
|
-
* This allows consumers to set a custom namespace for their project.
|
|
4
|
-
*/
|
|
5
|
-
let _namespace = "starktma"; // Default namespace
|
|
6
|
-
/**
|
|
7
|
-
* Sets the namespace for this package instance.
|
|
8
|
-
* This should be called once at the beginning of your application.
|
|
9
|
-
*
|
|
10
|
-
* @param namespace - The namespace to use for this package
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { setNamespace } from "@starktma/minecraft-utils/config";
|
|
15
|
-
*
|
|
16
|
-
* // Set your custom namespace
|
|
17
|
-
* setNamespace("myproject");
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export function setNamespace(namespace) {
|
|
21
|
-
if (!namespace || typeof namespace !== "string") {
|
|
22
|
-
throw new Error("Namespace must be a non-empty string");
|
|
23
|
-
}
|
|
24
|
-
_namespace = namespace;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Gets the current namespace.
|
|
28
|
-
*
|
|
29
|
-
* @returns The current namespace
|
|
30
|
-
*/
|
|
31
|
-
export function getNamespace() {
|
|
32
|
-
return _namespace;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,IAAI,UAAU,GAAW,UAAU,CAAC,CAAC,oBAAoB;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC7C,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IACzD,CAAC;IACD,UAAU,GAAG,SAAS,CAAC;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC3B,OAAO,UAAU,CAAC;AACnB,CAAC"}
|