mbler 0.1.3-alpha → 0.1.3-alpha-r2
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/LICENSE +21 -21
- package/README.md +15 -6
- package/bin/mbler.js +12 -12
- package/bin/minify.js +58 -44
- package/lib/build/base.js +1 -297
- package/lib/build/build-g-config.json +12 -12
- package/lib/build/getModule.js +1 -182
- package/lib/build/index.js +1 -370
- package/lib/build/manifest.build.js +1 -103
- package/lib/build/mcVersion.js +1 -86
- package/lib/build/utils.js +1 -6
- package/lib/code-processor/c-handler-export.js +1 -12
- package/lib/code-processor/index.js +1 -141
- package/lib/code-processor/mtreehandler.js +1 -164
- package/lib/commander/index.js +1 -154
- package/lib/data/includes.json +13 -13
- package/lib/data/version.json +88 -88
- package/lib/git/clone.js +1 -28
- package/lib/git/index.js +1 -12
- package/lib/git/pull.js +1 -100
- package/lib/lang/__translate.js +1 -93
- package/lib/lang/en.js +1 -128
- package/lib/lang/index.js +1 -78
- package/lib/lang/zh.js +1 -146
- package/lib/loger/colors.js +1 -13
- package/lib/loger/index.js +1 -136
- package/lib/mcx/ast/index.js +1 -11
- package/lib/mcx/ast/prop.js +1 -78
- package/lib/mcx/ast/tag.js +1 -246
- package/lib/mcx/compile-component/lib.js +1 -106
- package/lib/mcx/compile-component/types.js +1 -2
- package/lib/mcx/compile-component/utils.js +1 -26
- package/lib/mcx/compile-mcx/compile.js +1 -34
- package/lib/mcx/compile-mcx/compiler/bundler.js +1 -0
- package/lib/mcx/compile-mcx/compiler/compileData.js +1 -0
- package/lib/mcx/compile-mcx/compiler/compileMain.js +1 -0
- package/lib/mcx/compile-mcx/compiler/index.js +1 -0
- package/lib/mcx/compile-mcx/compiler/utils.js +1 -0
- package/lib/mcx/compile-mcx/context.js +1 -19
- package/lib/mcx/compile-mcx/index.js +1 -10
- package/lib/mcx/compile-mcx/mcx/index.js +1 -2
- package/lib/mcx/compile-mcx/mcx/types.js +1 -2
- package/lib/mcx/compile-mcx/template/module.js +1 -42
- package/lib/mcx/compile-mcx/types.js +1 -2
- package/lib/mcx/compile-mcx/utils.node.js +1 -207
- package/lib/mcx/index.js +1 -13
- package/lib/mcx/test/index.js +1 -7
- package/lib/mcx/test.js +1 -21
- package/lib/mcx/types.js +1 -2
- package/lib/mcx/utils.js +1 -86
- package/lib/module-handler/index.js +1 -482
- package/lib/modules/create-game/mbler.config.json +13 -13
- package/lib/modules/create-game/src/Runner/RunnerManager.js +1 -113
- package/lib/modules/create-game/src/Runner/scriptRunner.js +1 -70
- package/lib/modules/create-game/src/config.js +1 -27
- package/lib/modules/create-game/src/constants.js +1 -19
- package/lib/modules/create-game/src/createGameModule.js +1 -24
- package/lib/modules/create-game/src/gameComponent/common/autoStop.js +1 -38
- package/lib/modules/create-game/src/gameComponent/common/lazyLoader.js +1 -76
- package/lib/modules/create-game/src/gameComponent/common/stopWatch/onTimeEvent.js +1 -36
- package/lib/modules/create-game/src/gameComponent/common/stopWatch/stopWatch.js +1 -90
- package/lib/modules/create-game/src/gameComponent/common/stopWatch/tickEvent.js +1 -29
- package/lib/modules/create-game/src/gameComponent/common/timer/onTimeEvent.js +1 -36
- package/lib/modules/create-game/src/gameComponent/common/timer/tickEvent.js +1 -29
- package/lib/modules/create-game/src/gameComponent/common/timer/timer.js +1 -87
- package/lib/modules/create-game/src/gameComponent/gameComponent.js +1 -53
- package/lib/modules/create-game/src/gameComponent/index.js +1 -31
- package/lib/modules/create-game/src/gameComponent/player/blockInteractionBlocker.js +1 -40
- package/lib/modules/create-game/src/gameComponent/player/entityInteractionBlocker.js +1 -48
- package/lib/modules/create-game/src/gameComponent/player/healthIndicator.js +1 -48
- package/lib/modules/create-game/src/gameComponent/player/regionMonitor.js +1 -22
- package/lib/modules/create-game/src/gameComponent/player/respawn.js +1 -59
- package/lib/modules/create-game/src/gameComponent/player/spawnProtector.js +1 -69
- package/lib/modules/create-game/src/gameComponent/region/regionProtecter.js +1 -53
- package/lib/modules/create-game/src/gameComponent/region/regionTeamChooser.js +1 -71
- package/lib/modules/create-game/src/gameComponent/region/regionTeamCleaner.js +1 -20
- package/lib/modules/create-game/src/gameComponent/view/infoScoreboard.js +1 -77
- package/lib/modules/create-game/src/gameComponent/view/teamScoreboard.js +1 -83
- package/lib/modules/create-game/src/gameContext.js +1 -6
- package/lib/modules/create-game/src/gameEngine.js +1 -139
- package/lib/modules/create-game/src/gameEvent/eventManager.js +1 -108
- package/lib/modules/create-game/src/gameEvent/eventSignal.js +1 -28
- package/lib/modules/create-game/src/gameEvent/events/buttonPush.js +1 -41
- package/lib/modules/create-game/src/gameEvent/events/inSlot.js +1 -77
- package/lib/modules/create-game/src/gameEvent/events/interval.js +1 -51
- package/lib/modules/create-game/src/gameEvent/events/itemUse.js +1 -36
- package/lib/modules/create-game/src/gameEvent/events/onBlock.js +1 -106
- package/lib/modules/create-game/src/gameEvent/events/regionEvents.js +1 -105
- package/lib/modules/create-game/src/gameEvent/events/signClick.js +1 -45
- package/lib/modules/create-game/src/gameEvent/gameEvent.js +1 -54
- package/lib/modules/create-game/src/gameEvent/index.js +1 -20
- package/lib/modules/create-game/src/gameEvent/mapEventSignal.js +1 -101
- package/lib/modules/create-game/src/gameEvent/subscription.js +1 -17
- package/lib/modules/create-game/src/gamePlayer/gamePlayer.js +1 -102
- package/lib/modules/create-game/src/gamePlayer/groupBuilder.js +1 -38
- package/lib/modules/create-game/src/gamePlayer/groupSet.js +1 -96
- package/lib/modules/create-game/src/gamePlayer/index.js +1 -25
- package/lib/modules/create-game/src/gamePlayer/playerGroup.js +1 -145
- package/lib/modules/create-game/src/gamePlayer/playerManager.js +1 -57
- package/lib/modules/create-game/src/gameRegion/gameRegion.js +1 -229
- package/lib/modules/create-game/src/gameRegion/index.js +1 -43
- package/lib/modules/create-game/src/gameRegion/regionHelper.js +1 -79
- package/lib/modules/create-game/src/gameState/common/autoStop.js +1 -39
- package/lib/modules/create-game/src/gameState/gameState.js +1 -169
- package/lib/modules/create-game/src/gameState/index.js +1 -7
- package/lib/modules/create-game/src/gameState/types.js +1 -35
- package/lib/modules/create-game/src/gameStructure/gameStructure.js +1 -36
- package/lib/modules/create-game/src/main.js +1 -86
- package/lib/modules/create-game/src/system/gameCommand.js +1 -107
- package/lib/modules/create-game/src/system/gameManager.js +1 -124
- package/lib/modules/create-game/src/system/globalPlayerManager.js +1 -119
- package/lib/modules/create-game/src/utils/GameError.js +1 -31
- package/lib/modules/create-game/src/utils/algorithm.js +1 -95
- package/lib/modules/create-game/src/utils/chunk.js +1 -63
- package/lib/modules/create-game/src/utils/deferredObject.js +1 -27
- package/lib/modules/create-game/src/utils/duration.js +1 -25
- package/lib/modules/create-game/src/utils/func.js +1 -20
- package/lib/modules/create-game/src/utils/index.js +1 -52
- package/lib/modules/create-game/src/utils/interfaces.js +1 -2
- package/lib/modules/create-game/src/utils/logger.js +1 -47
- package/lib/modules/create-game/src/utils/random.js +1 -76
- package/lib/modules/create-game/src/utils/vanila-data.js +1 -123
- package/lib/modules/create-game/src/utils/vector.js +1 -96
- package/lib/modules/gameLib/mbler.config.json +15 -15
- package/lib/modules/gameLib/src/config.js +1 -134
- package/lib/modules/gameLib/src/data.js +1 -77
- package/lib/modules/gameLib/src/entity.js +1 -256
- package/lib/modules/gameLib/src/event.js +1 -285
- package/lib/modules/gameLib/src/index.js +1 -20
- package/lib/modules/gameLib/src/loger.js +1 -21
- package/lib/modules/gameLib/src/ui.js +1 -209
- package/lib/modules/gameLib/src/utils.js +1 -122
- package/lib/modules/gutils/mbler.config.json +11 -11
- package/lib/modules/gutils/src/index.js +1 -22
- package/lib/modules/innerDef.json +4 -4
- package/lib/runTemp/File.js +1 -54
- package/lib/runTemp/config.json +3 -3
- package/lib/runTemp/index.js +1 -137
- package/lib/runTemp/securityFile.js +1 -93
- package/lib/start/addPack.js +1 -3
- package/lib/start/clean.js +1 -84
- package/lib/start/create.js +1 -146
- package/lib/start/dev.js +1 -99
- package/lib/start/getResConfig.js +1 -3
- package/lib/start/incg.js +1 -3
- package/lib/start/index.js +1 -207
- package/lib/start/init.js +1 -125
- package/lib/start/rechce.js +1 -57
- package/lib/start/unaddPack.js +1 -3
- package/lib/start/unincg.js +1 -67
- package/lib/start/version.js +1 -73
- package/lib/utils/index.js +1 -298
- package/lib/uuid/index.js +1 -27
- package/package.json +49 -1
- package/test/2x sword/behavior/scripts/index.js +24 -24
- package/test/2x sword/mbler.config.json +11 -11
- package/test/2x sword/package.json +13 -13
- package/test/README.md +7 -7
- package/test/des/index.js +19 -19
- package/test/des/mbler.config.json +4 -4
- package/test/des/package.json +6 -6
- package/test/initializer/index.js +5 -5
- package/test/initializer/mbler.config.json +4 -4
- package/test/initializer/package.json +6 -6
- package/test/mbler-int/behavior/res/items/mang_one_int.json +21 -21
- package/test/mbler-int/behavior/scripts/index.js +7 -7
- package/test/mbler-int/behavior/scripts/lib/event/index.js +19 -19
- package/test/mbler-int/behavior/scripts/lib/ui/Lore.js +18 -18
- package/test/mbler-int/behavior/scripts/lib/ui/baseUi.js +6 -6
- package/test/mbler-int/behavior/scripts/lib/ui/index.js +206 -206
- package/test/mbler-int/behavior/scripts/lib/utils/index.js +51 -51
- package/test/mbler-int/mbler.config.json +18 -18
- package/test/mbler-int/package.json +12 -12
- package/test/script-mbler/behavior/scripts/index.js +5 -0
- package/test/script-mbler/behavior/scripts/index.ts +5 -5
- package/test/script-mbler/mbler.config.json +14 -14
- package/test/script-mbler/package.json +15 -15
- package/lib/mcx/compile-mcx/_compile.js +0 -602
|
@@ -1,31 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.GameComponent = void 0;
|
|
18
|
-
__exportStar(require("./view/infoScoreboard.js"), exports);
|
|
19
|
-
__exportStar(require("./common/lazyLoader.js"), exports);
|
|
20
|
-
__exportStar(require("./common/timer/timer.js"), exports);
|
|
21
|
-
__exportStar(require("./common/stopWatch/stopWatch.js"), exports);
|
|
22
|
-
var gameComponent_js_1 = require("./gameComponent.js");
|
|
23
|
-
Object.defineProperty(exports, "GameComponent", { enumerable: true, get: function () { return gameComponent_js_1.GameComponent; } });
|
|
24
|
-
__exportStar(require("./player/blockInteractionBlocker.js"), exports);
|
|
25
|
-
__exportStar(require("./player/entityInteractionBlocker.js"), exports);
|
|
26
|
-
__exportStar(require("./region/regionProtecter.js"), exports);
|
|
27
|
-
__exportStar(require("./region/regionTeamChooser.js"), exports);
|
|
28
|
-
__exportStar(require("./region/regionTeamCleaner.js"), exports);
|
|
29
|
-
__exportStar(require("./view/teamScoreboard.js"), exports);
|
|
30
|
-
__exportStar(require("./player/healthIndicator.js"), exports);
|
|
31
|
-
__exportStar(require("./player/regionMonitor.js"), exports);
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var n=Object.getOwnPropertyDescriptor(r,t);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,n)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameComponent=void 0,__exportStar(require("./view/infoScoreboard.js"),exports),__exportStar(require("./common/lazyLoader.js"),exports),__exportStar(require("./common/timer/timer.js"),exports),__exportStar(require("./common/stopWatch/stopWatch.js"),exports);var gameComponent_js_1=require("./gameComponent.js");Object.defineProperty(exports,"GameComponent",{enumerable:!0,get:function(){return gameComponent_js_1.GameComponent}}),__exportStar(require("./player/blockInteractionBlocker.js"),exports),__exportStar(require("./player/entityInteractionBlocker.js"),exports),__exportStar(require("./region/regionProtecter.js"),exports),__exportStar(require("./region/regionTeamChooser.js"),exports),__exportStar(require("./region/regionTeamCleaner.js"),exports),__exportStar(require("./view/teamScoreboard.js"),exports),__exportStar(require("./player/healthIndicator.js"),exports),__exportStar(require("./player/regionMonitor.js"),exports);
|
|
@@ -1,40 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlockInteractionBlocker = void 0;
|
|
4
|
-
const server_1 = require("@minecraft/server");
|
|
5
|
-
const main_js_1 = require("../../main.js");
|
|
6
|
-
/**
|
|
7
|
-
* 通用方块交互阻止组件
|
|
8
|
-
*/
|
|
9
|
-
class BlockInteractionBlocker extends main_js_1.GameComponent {
|
|
10
|
-
onAttach() {
|
|
11
|
-
if (!this.options)
|
|
12
|
-
return;
|
|
13
|
-
const { groupSet, blockIds, blockComponentType, showMessage = true, message, } = this.options;
|
|
14
|
-
this.subscribe(server_1.world.beforeEvents.playerInteractWithBlock, (t) => {
|
|
15
|
-
const { player, block } = t;
|
|
16
|
-
// 1️⃣ 不在限制组内 -> 放行
|
|
17
|
-
if (!groupSet.findById(player.id))
|
|
18
|
-
return;
|
|
19
|
-
// 2️⃣ 若设置 blockIds,则仅匹配这些方块
|
|
20
|
-
if (blockIds &&
|
|
21
|
-
blockIds.length > 0 &&
|
|
22
|
-
!blockIds.includes(block.typeId)) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
// 3️⃣ 若设置 blockComponentType,则仅匹配拥有该组件的方块
|
|
26
|
-
if (blockComponentType) {
|
|
27
|
-
const comp = block.getComponent(blockComponentType);
|
|
28
|
-
if (!comp)
|
|
29
|
-
return; // 若该方块没有该组件 -> 放行
|
|
30
|
-
}
|
|
31
|
-
// 4️⃣ 阻止交互
|
|
32
|
-
t.cancel = true;
|
|
33
|
-
// 5️⃣ 提示
|
|
34
|
-
if (showMessage) {
|
|
35
|
-
server_1.system.run(() => player.onScreenDisplay.setActionBar(message ?? "§c你无法与该方块交互!"));
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.BlockInteractionBlocker = BlockInteractionBlocker;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlockInteractionBlocker=void 0;const server_1=require("@minecraft/server"),main_js_1=require("../../main.js");class BlockInteractionBlocker extends main_js_1.GameComponent{onAttach(){if(!this.options)return;const{groupSet:e,blockIds:t,blockComponentType:o,showMessage:r=!0,message:n}=this.options;this.subscribe(server_1.world.beforeEvents.playerInteractWithBlock,s=>{const{player:c,block:i}=s;if(e.findById(c.id)&&(!(t&&t.length>0)||t.includes(i.typeId))){if(o){if(!i.getComponent(o))return}s.cancel=!0,r&&server_1.system.run(()=>c.onScreenDisplay.setActionBar(n??"§c你无法与该方块交互!"))}})}}exports.BlockInteractionBlocker=BlockInteractionBlocker;
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityInteractionBlocker = void 0;
|
|
4
|
-
const server_1 = require("@minecraft/server");
|
|
5
|
-
const main_js_1 = require("../../main.js");
|
|
6
|
-
/**
|
|
7
|
-
* 通用实体交互阻止组件
|
|
8
|
-
*/
|
|
9
|
-
class EntityInteractionBlocker extends main_js_1.GameComponent {
|
|
10
|
-
onAttach() {
|
|
11
|
-
if (!this.options)
|
|
12
|
-
return;
|
|
13
|
-
const { groupSet, entityIds, entityComponentTypes, showMessage = true, message, } = this.options;
|
|
14
|
-
this.subscribe(server_1.world.beforeEvents.playerInteractWithEntity, (t) => {
|
|
15
|
-
const { player, target } = t;
|
|
16
|
-
console.log(target.typeId);
|
|
17
|
-
// 1️⃣ 不在限制组内 -> 放行
|
|
18
|
-
if (!groupSet.findById(player.id))
|
|
19
|
-
return;
|
|
20
|
-
// 2️⃣ 若有实体类型限制,且当前实体不在其中 -> 放行
|
|
21
|
-
if (entityIds &&
|
|
22
|
-
entityIds.length > 0 &&
|
|
23
|
-
!entityIds.includes(target.typeId)) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// 3️⃣ 若指定组件类型数组,且实体不含任意一个组件 -> 放行
|
|
27
|
-
if (entityComponentTypes && entityComponentTypes.length > 0) {
|
|
28
|
-
const hasComponent = entityComponentTypes.some((type) => {
|
|
29
|
-
try {
|
|
30
|
-
return !!target.getComponent(type);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
if (!hasComponent)
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
// 4️⃣ 阻止交互
|
|
40
|
-
t.cancel = true;
|
|
41
|
-
// 5️⃣ 提示
|
|
42
|
-
if (showMessage) {
|
|
43
|
-
server_1.system.run(() => player.onScreenDisplay.setActionBar(message ?? "§c你无法与该实体交互!"));
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.EntityInteractionBlocker = EntityInteractionBlocker;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EntityInteractionBlocker=void 0;const server_1=require("@minecraft/server"),main_js_1=require("../../main.js");class EntityInteractionBlocker extends main_js_1.GameComponent{onAttach(){if(!this.options)return;const{groupSet:e,entityIds:t,entityComponentTypes:n,showMessage:r=!0,message:s}=this.options;this.subscribe(server_1.world.beforeEvents.playerInteractWithEntity,o=>{const{player:i,target:c}=o;if(console.log(c.typeId),e.findById(i.id)&&(!(t&&t.length>0)||t.includes(c.typeId))){if(n&&n.length>0){if(!n.some(e=>{try{return!!c.getComponent(e)}catch{return!1}}))return}o.cancel=!0,r&&server_1.system.run(()=>i.onScreenDisplay.setActionBar(s??"§c你无法与该实体交互!"))}})}}exports.EntityInteractionBlocker=EntityInteractionBlocker;
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlayerHealthIndicator = void 0;
|
|
4
|
-
const server_1 = require("@minecraft/server");
|
|
5
|
-
const main_js_1 = require("../../main.js");
|
|
6
|
-
const index_js_1 = require("../index.js");
|
|
7
|
-
class PlayerHealthIndicator extends index_js_1.GameComponent {
|
|
8
|
-
obj;
|
|
9
|
-
onAttach() {
|
|
10
|
-
if (!this.options)
|
|
11
|
-
return;
|
|
12
|
-
this.subscribe(main_js_1.Game.events.interval, () => this.refresh(), this.options.refreshInterval);
|
|
13
|
-
}
|
|
14
|
-
onDetach() {
|
|
15
|
-
if (this.obj?.isValid) {
|
|
16
|
-
server_1.world.scoreboard.removeObjective(this.obj);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
getObj() {
|
|
20
|
-
if (this.obj && this.obj.isValid)
|
|
21
|
-
return this.obj;
|
|
22
|
-
this.obj =
|
|
23
|
-
server_1.world.scoreboard.getObjective(this.options.scoreBoardName) ??
|
|
24
|
-
server_1.world.scoreboard.addObjective(this.options.scoreBoardName, this.options.displayName);
|
|
25
|
-
return this.obj;
|
|
26
|
-
}
|
|
27
|
-
/**展示 */
|
|
28
|
-
show() {
|
|
29
|
-
const obj = this.getObj();
|
|
30
|
-
server_1.world.scoreboard.setObjectiveAtDisplaySlot(server_1.DisplaySlotId.BelowName, {
|
|
31
|
-
objective: obj,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**刷新计分板 */
|
|
35
|
-
refresh() {
|
|
36
|
-
const obj = this.getObj();
|
|
37
|
-
server_1.world.getAllPlayers().forEach((p) => {
|
|
38
|
-
if (!p)
|
|
39
|
-
return;
|
|
40
|
-
const comp = p.getComponent(server_1.EntityComponentTypes.Health);
|
|
41
|
-
if (!comp)
|
|
42
|
-
return;
|
|
43
|
-
const cur = comp.currentValue;
|
|
44
|
-
obj.setScore(p, cur);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.PlayerHealthIndicator = PlayerHealthIndicator;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PlayerHealthIndicator=void 0;const server_1=require("@minecraft/server"),main_js_1=require("../../main.js"),index_js_1=require("../index.js");class PlayerHealthIndicator extends index_js_1.GameComponent{obj;onAttach(){this.options&&this.subscribe(main_js_1.Game.events.interval,()=>this.refresh(),this.options.refreshInterval)}onDetach(){this.obj?.isValid&&server_1.world.scoreboard.removeObjective(this.obj)}getObj(){return this.obj&&this.obj.isValid||(this.obj=server_1.world.scoreboard.getObjective(this.options.scoreBoardName)??server_1.world.scoreboard.addObjective(this.options.scoreBoardName,this.options.displayName)),this.obj}show(){const e=this.getObj();server_1.world.scoreboard.setObjectiveAtDisplaySlot(server_1.DisplaySlotId.BelowName,{objective:e})}refresh(){const e=this.getObj();server_1.world.getAllPlayers().forEach(r=>{if(!r)return;const t=r.getComponent(server_1.EntityComponentTypes.Health);if(!t)return;const s=t.currentValue;e.setScore(r,s)})}}exports.PlayerHealthIndicator=PlayerHealthIndicator;
|
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlayerRegionMonitor = void 0;
|
|
4
|
-
const main_js_1 = require("../../main.js");
|
|
5
|
-
const gameComponent_js_1 = require("../gameComponent.js");
|
|
6
|
-
/**玩家区域监测 */
|
|
7
|
-
class PlayerRegionMonitor extends gameComponent_js_1.GameComponent {
|
|
8
|
-
onAttach() {
|
|
9
|
-
if (!this.options)
|
|
10
|
-
return;
|
|
11
|
-
this.subscribe(main_js_1.Game.events.interval, () => this.detectOutOfRegionPlayers(), this.options.interval);
|
|
12
|
-
}
|
|
13
|
-
detectOutOfRegionPlayers() {
|
|
14
|
-
const region = this.options.region;
|
|
15
|
-
this.options.groups.forEach((p) => {
|
|
16
|
-
if (!region.isInside(p.player.location)) {
|
|
17
|
-
this.options.onLeave(p);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.PlayerRegionMonitor = PlayerRegionMonitor;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PlayerRegionMonitor=void 0;const main_js_1=require("../../main.js"),gameComponent_js_1=require("../gameComponent.js");class PlayerRegionMonitor extends gameComponent_js_1.GameComponent{onAttach(){this.options&&this.subscribe(main_js_1.Game.events.interval,()=>this.detectOutOfRegionPlayers(),this.options.interval)}detectOutOfRegionPlayers(){const e=this.options.region;this.options.groups.forEach(o=>{e.isInside(o.player.location)||this.options.onLeave(o)})}}exports.PlayerRegionMonitor=PlayerRegionMonitor;
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RespawnComponent = void 0;
|
|
4
|
-
const server_1 = require("@minecraft/server");
|
|
5
|
-
const vanila_data_js_1 = require("../../utils/vanila-data.js");
|
|
6
|
-
const index_js_1 = require("../index.js");
|
|
7
|
-
class RespawnComponent extends index_js_1.GameComponent {
|
|
8
|
-
onAttach() {
|
|
9
|
-
if (!this.options)
|
|
10
|
-
return;
|
|
11
|
-
const { onDie, autoBroadcast, buildNameFunc, groupSet, onSpawn, buildMsg, } = this.options;
|
|
12
|
-
this.subscribe(server_1.world.afterEvents.entityDie, (event) => {
|
|
13
|
-
const deadEntity = event.deadEntity;
|
|
14
|
-
if (deadEntity.typeId !== vanila_data_js_1.EntityTypeIds.Player)
|
|
15
|
-
return;
|
|
16
|
-
const result = groupSet.findById(deadEntity.id);
|
|
17
|
-
if (!result)
|
|
18
|
-
return;
|
|
19
|
-
const { player, group } = result;
|
|
20
|
-
// 执行自定义逻辑
|
|
21
|
-
onDie?.(player, group, event.damageSource.damagingEntity);
|
|
22
|
-
// 自动广播消息
|
|
23
|
-
if (autoBroadcast && buildNameFunc) {
|
|
24
|
-
const playerName = buildNameFunc(player, group);
|
|
25
|
-
const killerName = this.getKillerName(event.damageSource.damagingEntity);
|
|
26
|
-
let message;
|
|
27
|
-
if (buildMsg) {
|
|
28
|
-
message = buildMsg(playerName, killerName, player);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
message = killerName
|
|
32
|
-
? `${playerName} §r 被 ${killerName} §r 杀死了`
|
|
33
|
-
: `${playerName} §r 死了`;
|
|
34
|
-
}
|
|
35
|
-
groupSet.sendMessage(message);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
if (onSpawn) {
|
|
39
|
-
this.subscribe(server_1.world.afterEvents.playerSpawn, (t) => {
|
|
40
|
-
const ans = groupSet.findById(t.player.id);
|
|
41
|
-
if (ans?.player) {
|
|
42
|
-
onSpawn(ans.player, ans.group);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
getKillerName(source) {
|
|
48
|
-
if (!source || source.typeId !== vanila_data_js_1.EntityTypeIds.Player)
|
|
49
|
-
return undefined;
|
|
50
|
-
const result = this.options.groupSet.findById(source.id);
|
|
51
|
-
if (!result)
|
|
52
|
-
return undefined;
|
|
53
|
-
if (this.options.buildNameFunc) {
|
|
54
|
-
return this.options.buildNameFunc(result.player, result.group);
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.RespawnComponent = RespawnComponent;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RespawnComponent=void 0;const server_1=require("@minecraft/server"),vanila_data_js_1=require("../../utils/vanila-data.js"),index_js_1=require("../index.js");class RespawnComponent extends index_js_1.GameComponent{onAttach(){if(!this.options)return;const{onDie:e,autoBroadcast:t,buildNameFunc:n,groupSet:s,onSpawn:i,buildMsg:r}=this.options;this.subscribe(server_1.world.afterEvents.entityDie,i=>{const a=i.deadEntity;if(a.typeId!==vanila_data_js_1.EntityTypeIds.Player)return;const o=s.findById(a.id);if(!o)return;const{player:d,group:p}=o;if(e?.(d,p,i.damageSource.damagingEntity),t&&n){const e=n(d,p),t=this.getKillerName(i.damageSource.damagingEntity);let a;a=r?r(e,t,d):t?`${e} §r 被 ${t} §r 杀死了`:`${e} §r 死了`,s.sendMessage(a)}}),i&&this.subscribe(server_1.world.afterEvents.playerSpawn,e=>{const t=s.findById(e.player.id);t?.player&&i(t.player,t.group)})}getKillerName(e){if(!e||e.typeId!==vanila_data_js_1.EntityTypeIds.Player)return;const t=this.options.groupSet.findById(e.id);return t&&this.options.buildNameFunc?this.options.buildNameFunc(t.player,t.group):void 0}}exports.RespawnComponent=RespawnComponent;
|
|
@@ -1,69 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SpawnPointProtector = void 0;
|
|
4
|
-
const server_1 = require("@minecraft/server");
|
|
5
|
-
const main_js_1 = require("../../main.js");
|
|
6
|
-
const index_js_1 = require("../../utils/index.js");
|
|
7
|
-
const gameComponent_js_1 = require("../gameComponent.js");
|
|
8
|
-
class SpawnPointProtector extends gameComponent_js_1.GameComponent {
|
|
9
|
-
onAttach() {
|
|
10
|
-
const options = this.options;
|
|
11
|
-
if (!options)
|
|
12
|
-
return;
|
|
13
|
-
// 初始设置玩家重生点
|
|
14
|
-
if (options.autoSetSpawnPoint ?? true) {
|
|
15
|
-
this.setPlayerSpawnPoints();
|
|
16
|
-
}
|
|
17
|
-
// 循环设置重生点 & 保护区域
|
|
18
|
-
const interval = options.protectInterval ?? new index_js_1.Duration(10);
|
|
19
|
-
this.subscribe(main_js_1.Game.events.interval, () => {
|
|
20
|
-
if (options.autoSetSpawnPoint) {
|
|
21
|
-
this.setPlayerSpawnPoints();
|
|
22
|
-
}
|
|
23
|
-
this.protectSpawnAreas();
|
|
24
|
-
}, interval);
|
|
25
|
-
// 出生点保护:拦截方块交互
|
|
26
|
-
const protectedBlock = index_js_1.Vector3Utils.below(options.spawnPoint);
|
|
27
|
-
this.subscribe(server_1.world.beforeEvents.playerInteractWithBlock, (t) => {
|
|
28
|
-
if (index_js_1.Vector3Utils.isEqual(t.block.location, protectedBlock)) {
|
|
29
|
-
t.cancel = true;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/** 设置玩家重生点 */
|
|
34
|
-
setPlayerSpawnPoints() {
|
|
35
|
-
const { playerGroup, spawnPoint, dimension } = this.options;
|
|
36
|
-
playerGroup.forEach((p) => {
|
|
37
|
-
p.player.setSpawnPoint({
|
|
38
|
-
dimension,
|
|
39
|
-
...spawnPoint,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/** 传送所有玩家到出生点 */
|
|
44
|
-
teleportAllToSpawn() {
|
|
45
|
-
const { playerGroup, spawnPoint, dimension } = this.options;
|
|
46
|
-
playerGroup.forEach((p) => {
|
|
47
|
-
p.player.teleport(spawnPoint, { dimension });
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/** 循环保护出生点区域 */
|
|
51
|
-
protectSpawnAreas() {
|
|
52
|
-
const { spawnPoint, dimension, protectRadius } = this.options;
|
|
53
|
-
if (!spawnPoint || !dimension)
|
|
54
|
-
return;
|
|
55
|
-
try {
|
|
56
|
-
const radius = protectRadius ?? { x: 1, y: 1, z: 1 };
|
|
57
|
-
const max = index_js_1.Vector3Utils.add(spawnPoint, radius);
|
|
58
|
-
const min = index_js_1.Vector3Utils.subtract(spawnPoint, {
|
|
59
|
-
x: radius.x,
|
|
60
|
-
y: 0,
|
|
61
|
-
z: radius.z,
|
|
62
|
-
});
|
|
63
|
-
dimension.fillBlocks(new server_1.BlockVolume(max, min), "air");
|
|
64
|
-
dimension.setBlockType(index_js_1.Vector3Utils.below(spawnPoint), "bedrock");
|
|
65
|
-
}
|
|
66
|
-
catch (err) { }
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.SpawnPointProtector = SpawnPointProtector;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SpawnPointProtector=void 0;const server_1=require("@minecraft/server"),main_js_1=require("../../main.js"),index_js_1=require("../../utils/index.js"),gameComponent_js_1=require("../gameComponent.js");class SpawnPointProtector extends gameComponent_js_1.GameComponent{onAttach(){const e=this.options;if(!e)return;(e.autoSetSpawnPoint??1)&&this.setPlayerSpawnPoints();const t=e.protectInterval??new index_js_1.Duration(10);this.subscribe(main_js_1.Game.events.interval,()=>{e.autoSetSpawnPoint&&this.setPlayerSpawnPoints(),this.protectSpawnAreas()},t);const o=index_js_1.Vector3Utils.below(e.spawnPoint);this.subscribe(server_1.world.beforeEvents.playerInteractWithBlock,e=>{index_js_1.Vector3Utils.isEqual(e.block.location,o)&&(e.cancel=!0)})}setPlayerSpawnPoints(){const{playerGroup:e,spawnPoint:t,dimension:o}=this.options;e.forEach(e=>{e.player.setSpawnPoint({dimension:o,...t})})}teleportAllToSpawn(){const{playerGroup:e,spawnPoint:t,dimension:o}=this.options;e.forEach(e=>{e.player.teleport(t,{dimension:o})})}protectSpawnAreas(){const{spawnPoint:e,dimension:t,protectRadius:o}=this.options;if(e&&t)try{const n=o??{x:1,y:1,z:1},s=index_js_1.Vector3Utils.add(e,n),i=index_js_1.Vector3Utils.subtract(e,{x:n.x,y:0,z:n.z});t.fillBlocks(new server_1.BlockVolume(s,i),"air"),t.setBlockType(index_js_1.Vector3Utils.below(e),"bedrock")}catch(e){}}}exports.SpawnPointProtector=SpawnPointProtector;
|
|
@@ -1,53 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RegionProtector = void 0;
|
|
4
|
-
const server_1 = require("@minecraft/server");
|
|
5
|
-
const gameComponent_js_1 = require("../gameComponent.js");
|
|
6
|
-
class RegionProtector extends gameComponent_js_1.GameComponent {
|
|
7
|
-
onAttach() {
|
|
8
|
-
if (!this.options)
|
|
9
|
-
return;
|
|
10
|
-
// 处理破坏方块
|
|
11
|
-
if (this.options.blockBreakInside || this.options.blockBreakOutside) {
|
|
12
|
-
this.subscribe(server_1.world.beforeEvents.playerBreakBlock, (t) => {
|
|
13
|
-
if (this.options?.groupSet &&
|
|
14
|
-
!this.options.groupSet.has(t.player.id)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
this.handleBreak(t);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
// 处理方块交互
|
|
21
|
-
if (this.options.blockInteractOutside ||
|
|
22
|
-
this.options.blockInteractInside) {
|
|
23
|
-
this.subscribe(server_1.world.beforeEvents.playerInteractWithBlock, (t) => {
|
|
24
|
-
if (this.options?.groupSet &&
|
|
25
|
-
!this.options.groupSet.has(t.player.id)) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
this.handleInteract(t);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
handleBreak(t) {
|
|
33
|
-
if (this.options.blockBreakInside &&
|
|
34
|
-
this.options.region.isBlockInside(t.block.location)) {
|
|
35
|
-
t.cancel = true;
|
|
36
|
-
}
|
|
37
|
-
else if (this.options.blockBreakOutside &&
|
|
38
|
-
!this.options.region.isBlockInside(t.block.location)) {
|
|
39
|
-
t.cancel = true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
handleInteract(t) {
|
|
43
|
-
if (this.options.blockInteractInside &&
|
|
44
|
-
this.options.region.isBlockInside(t.block.location)) {
|
|
45
|
-
t.cancel = true;
|
|
46
|
-
}
|
|
47
|
-
else if (this.options.blockInteractOutside &&
|
|
48
|
-
!this.options.region.isBlockInside(t.block.location)) {
|
|
49
|
-
t.cancel = true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.RegionProtector = RegionProtector;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RegionProtector=void 0;const server_1=require("@minecraft/server"),gameComponent_js_1=require("../gameComponent.js");class RegionProtector extends gameComponent_js_1.GameComponent{onAttach(){this.options&&((this.options.blockBreakInside||this.options.blockBreakOutside)&&this.subscribe(server_1.world.beforeEvents.playerBreakBlock,o=>{this.options?.groupSet&&!this.options.groupSet.has(o.player.id)||this.handleBreak(o)}),(this.options.blockInteractOutside||this.options.blockInteractInside)&&this.subscribe(server_1.world.beforeEvents.playerInteractWithBlock,o=>{this.options?.groupSet&&!this.options.groupSet.has(o.player.id)||this.handleInteract(o)}))}handleBreak(o){(this.options.blockBreakInside&&this.options.region.isBlockInside(o.block.location)||this.options.blockBreakOutside&&!this.options.region.isBlockInside(o.block.location))&&(o.cancel=!0)}handleInteract(o){(this.options.blockInteractInside&&this.options.region.isBlockInside(o.block.location)||this.options.blockInteractOutside&&!this.options.region.isBlockInside(o.block.location))&&(o.cancel=!0)}}exports.RegionProtector=RegionProtector;
|
|
@@ -1,71 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RegionTeamChooser = void 0;
|
|
4
|
-
const regionEvents_js_1 = require("../../gameEvent/events/regionEvents.js");
|
|
5
|
-
const main_js_1 = require("../../main.js");
|
|
6
|
-
const gameComponent_js_1 = require("../gameComponent.js");
|
|
7
|
-
const server_1 = require("@minecraft/server");
|
|
8
|
-
/**区域队伍选择器 */
|
|
9
|
-
class RegionTeamChooser extends gameComponent_js_1.GameComponent {
|
|
10
|
-
onAttach() {
|
|
11
|
-
if (!this.options)
|
|
12
|
-
return;
|
|
13
|
-
this.options.config.forEach((data) => {
|
|
14
|
-
this.subscribe(main_js_1.Game.events.region, (event) => this.handleRegionEvent(event, data), data.region);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
handleRegionEvent(event, data) {
|
|
18
|
-
const gamePlayer = this.state.playerManager.get(event.player);
|
|
19
|
-
if (!gamePlayer.isValid) {
|
|
20
|
-
if (event.player.isValid) {
|
|
21
|
-
event.player.sendMessage("暂时无法进入队伍");
|
|
22
|
-
}
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
switch (event.type) {
|
|
26
|
-
case regionEvents_js_1.RegionEventType.Enter:
|
|
27
|
-
this.handlePlayerEnter(gamePlayer, data);
|
|
28
|
-
break;
|
|
29
|
-
case regionEvents_js_1.RegionEventType.Leave:
|
|
30
|
-
this.handlePlayerLeave(gamePlayer, data);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
handlePlayerEnter(gamePlayer, configData) {
|
|
35
|
-
//不允许旁观者直接返回
|
|
36
|
-
if ((this.options.allowSpectator ?? true) &&
|
|
37
|
-
gamePlayer.player?.getGameMode() == server_1.GameMode.Spectator) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const newTeam = configData.team;
|
|
41
|
-
const alreadyInTeam = newTeam.has(gamePlayer);
|
|
42
|
-
if (configData.onEnter) {
|
|
43
|
-
configData.onEnter(gamePlayer);
|
|
44
|
-
}
|
|
45
|
-
//从所有队伍清除目标玩家
|
|
46
|
-
this.options?.config.forEach((d) => {
|
|
47
|
-
if (d.team !== newTeam) {
|
|
48
|
-
d.team.delete(gamePlayer);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
//添加到新队伍
|
|
52
|
-
newTeam.add(gamePlayer);
|
|
53
|
-
//执行回调
|
|
54
|
-
if (configData.onJoin && !alreadyInTeam) {
|
|
55
|
-
configData.onJoin(gamePlayer);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
handlePlayerLeave(gamePlayer, configData) {
|
|
59
|
-
const shouldRemoveOnLeave = this.options?.removeOnLeave ?? false;
|
|
60
|
-
if (shouldRemoveOnLeave) {
|
|
61
|
-
configData.team.delete(gamePlayer);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
onDetach() {
|
|
65
|
-
super.onDetach();
|
|
66
|
-
if (this.options) {
|
|
67
|
-
this.options.config.forEach((t) => t.team.clearInvalid());
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.RegionTeamChooser = RegionTeamChooser;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RegionTeamChooser=void 0;const regionEvents_js_1=require("../../gameEvent/events/regionEvents.js"),main_js_1=require("../../main.js"),gameComponent_js_1=require("../gameComponent.js"),server_1=require("@minecraft/server");class RegionTeamChooser extends gameComponent_js_1.GameComponent{onAttach(){this.options&&this.options.config.forEach(e=>{this.subscribe(main_js_1.Game.events.region,n=>this.handleRegionEvent(n,e),e.region)})}handleRegionEvent(e,n){const o=this.state.playerManager.get(e.player);if(o.isValid)switch(e.type){case regionEvents_js_1.RegionEventType.Enter:this.handlePlayerEnter(o,n);break;case regionEvents_js_1.RegionEventType.Leave:this.handlePlayerLeave(o,n)}else e.player.isValid&&e.player.sendMessage("暂时无法进入队伍")}handlePlayerEnter(e,n){if((this.options.allowSpectator??1)&&e.player?.getGameMode()==server_1.GameMode.Spectator)return;const o=n.team,t=o.has(e);n.onEnter&&n.onEnter(e),this.options?.config.forEach(n=>{n.team!==o&&n.team.delete(e)}),o.add(e),n.onJoin&&!t&&n.onJoin(e)}handlePlayerLeave(e,n){(this.options?.removeOnLeave??!1)&&n.team.delete(e)}onDetach(){super.onDetach(),this.options&&this.options.config.forEach(e=>e.team.clearInvalid())}}exports.RegionTeamChooser=RegionTeamChooser;
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RegionTeamCleaner = void 0;
|
|
4
|
-
const regionEvents_js_1 = require("../../gameEvent/events/regionEvents.js");
|
|
5
|
-
const main_js_1 = require("../../main.js");
|
|
6
|
-
const gameComponent_js_1 = require("../gameComponent.js");
|
|
7
|
-
/**玩家离开指定区域时将他从team移除 */
|
|
8
|
-
class RegionTeamCleaner extends gameComponent_js_1.GameComponent {
|
|
9
|
-
onAttach() {
|
|
10
|
-
if (!this.options)
|
|
11
|
-
return;
|
|
12
|
-
this.subscribe(main_js_1.Game.events.region, (t) => {
|
|
13
|
-
if (t.type == regionEvents_js_1.RegionEventType.Leave) {
|
|
14
|
-
this.options?.teams.forEach((team) => team.delete(t.player));
|
|
15
|
-
this.options?.onClean?.(t.player);
|
|
16
|
-
}
|
|
17
|
-
}, this.options.region);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.RegionTeamCleaner = RegionTeamCleaner;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RegionTeamCleaner=void 0;const regionEvents_js_1=require("../../gameEvent/events/regionEvents.js"),main_js_1=require("../../main.js"),gameComponent_js_1=require("../gameComponent.js");class RegionTeamCleaner extends gameComponent_js_1.GameComponent{onAttach(){this.options&&this.subscribe(main_js_1.Game.events.region,e=>{e.type==regionEvents_js_1.RegionEventType.Leave&&(this.options?.teams.forEach(n=>n.delete(e.player)),this.options?.onClean?.(e.player))},this.options.region)}}exports.RegionTeamCleaner=RegionTeamCleaner;
|
|
@@ -1,77 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InfoScoreboard = void 0;
|
|
4
|
-
const server_1 = require("@minecraft/server");
|
|
5
|
-
const gameComponent_js_1 = require("../gameComponent.js");
|
|
6
|
-
/**信息侧边栏 */
|
|
7
|
-
class InfoScoreboard extends gameComponent_js_1.GameComponent {
|
|
8
|
-
objective;
|
|
9
|
-
initCode = 48;
|
|
10
|
-
getObj() {
|
|
11
|
-
if (this.objective && this.objective.isValid)
|
|
12
|
-
return this.objective;
|
|
13
|
-
const name = this.options.scoreBoardName;
|
|
14
|
-
this.objective =
|
|
15
|
-
server_1.world.scoreboard.getObjective(name) ??
|
|
16
|
-
server_1.world.scoreboard.addObjective(name, this.options.displayName);
|
|
17
|
-
return this.objective;
|
|
18
|
-
}
|
|
19
|
-
onAttach() {
|
|
20
|
-
if (!this.options) {
|
|
21
|
-
throw new Error("无options");
|
|
22
|
-
}
|
|
23
|
-
if (this.options.showOnAttach) {
|
|
24
|
-
this.show();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
onDetach() {
|
|
28
|
-
if (this.objective?.isValid) {
|
|
29
|
-
server_1.world.scoreboard.removeObjective(this.objective);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**手动显示计分板 */
|
|
33
|
-
show() {
|
|
34
|
-
if (!this.options)
|
|
35
|
-
return;
|
|
36
|
-
server_1.world.scoreboard.setObjectiveAtDisplaySlot(server_1.DisplaySlotId.Sidebar, {
|
|
37
|
-
objective: this.getObj(),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**更新计分板内容 */
|
|
41
|
-
updateLines(lines) {
|
|
42
|
-
if (!this.options)
|
|
43
|
-
return;
|
|
44
|
-
const sb = this.getObj();
|
|
45
|
-
const isDisplay = server_1.world.scoreboard.getObjectiveAtDisplaySlot(server_1.DisplaySlotId.Sidebar)
|
|
46
|
-
?.objective.id == sb.id;
|
|
47
|
-
server_1.world.scoreboard.removeObjective(sb);
|
|
48
|
-
//如果不在显示则直接返回
|
|
49
|
-
if (!isDisplay) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
this.show();
|
|
53
|
-
//预处理
|
|
54
|
-
let blankCode = this.initCode;
|
|
55
|
-
for (let i = 0; i < lines.length; i++) {
|
|
56
|
-
if (lines[i] === "") {
|
|
57
|
-
lines[i] = "§" + String.fromCodePoint(blankCode++);
|
|
58
|
-
}
|
|
59
|
-
lines[i] = " ".repeat(this.options.paddingLeft ?? 0) + lines[i];
|
|
60
|
-
}
|
|
61
|
-
//加上header和footer
|
|
62
|
-
const header = this.options?.header;
|
|
63
|
-
const footer = this.options?.footer;
|
|
64
|
-
if (header) {
|
|
65
|
-
lines.unshift(...header());
|
|
66
|
-
}
|
|
67
|
-
if (footer) {
|
|
68
|
-
lines.push(...footer());
|
|
69
|
-
}
|
|
70
|
-
const sb1 = this.getObj();
|
|
71
|
-
//设置
|
|
72
|
-
for (let i = 0; i < lines.length; i++) {
|
|
73
|
-
sb1.setScore(lines[i], lines.length - i - 1);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.InfoScoreboard = InfoScoreboard;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InfoScoreboard=void 0;const server_1=require("@minecraft/server"),gameComponent_js_1=require("../gameComponent.js");class InfoScoreboard extends gameComponent_js_1.GameComponent{objective;initCode=48;getObj(){if(this.objective&&this.objective.isValid)return this.objective;const e=this.options.scoreBoardName;return this.objective=server_1.world.scoreboard.getObjective(e)??server_1.world.scoreboard.addObjective(e,this.options.displayName),this.objective}onAttach(){if(!this.options)throw new Error("无options");this.options.showOnAttach&&this.show()}onDetach(){this.objective?.isValid&&server_1.world.scoreboard.removeObjective(this.objective)}show(){this.options&&server_1.world.scoreboard.setObjectiveAtDisplaySlot(server_1.DisplaySlotId.Sidebar,{objective:this.getObj()})}updateLines(e){if(!this.options)return;const o=this.getObj(),t=server_1.world.scoreboard.getObjectiveAtDisplaySlot(server_1.DisplaySlotId.Sidebar)?.objective.id==o.id;if(server_1.world.scoreboard.removeObjective(o),!t)return;this.show();let r=this.initCode;for(let o=0;o<e.length;o++)""===e[o]&&(e[o]="§"+String.fromCodePoint(r++)),e[o]=" ".repeat(this.options.paddingLeft??0)+e[o];const s=this.options?.header,i=this.options?.footer;s&&e.unshift(...s()),i&&e.push(...i());const n=this.getObj();for(let o=0;o<e.length;o++)n.setScore(e[o],e.length-o-1)}}exports.InfoScoreboard=InfoScoreboard;
|
|
@@ -1,83 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TeamScoreBoard = void 0;
|
|
4
|
-
const server_1 = require("@minecraft/server");
|
|
5
|
-
const gameComponent_js_1 = require("../gameComponent.js");
|
|
6
|
-
class TeamScoreBoard extends gameComponent_js_1.GameComponent {
|
|
7
|
-
obj;
|
|
8
|
-
lastRefresh = 0;
|
|
9
|
-
onAttach() {
|
|
10
|
-
if (!this.options)
|
|
11
|
-
return;
|
|
12
|
-
this.reset();
|
|
13
|
-
}
|
|
14
|
-
getObj() {
|
|
15
|
-
if (this.obj && this.obj.isValid)
|
|
16
|
-
return this.obj;
|
|
17
|
-
this.obj =
|
|
18
|
-
server_1.world.scoreboard.getObjective(this.options.scoreboardName) ??
|
|
19
|
-
server_1.world.scoreboard.addObjective(this.options.scoreboardName, this.options.displayName);
|
|
20
|
-
return this.obj;
|
|
21
|
-
}
|
|
22
|
-
reset() {
|
|
23
|
-
const obj = this.getObj();
|
|
24
|
-
const isDisplay = server_1.world.scoreboard.getObjectiveAtDisplaySlot(server_1.DisplaySlotId.Sidebar)
|
|
25
|
-
?.objective.id == obj.id;
|
|
26
|
-
server_1.world.scoreboard.removeObjective(obj);
|
|
27
|
-
if (isDisplay) {
|
|
28
|
-
this.show();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**显示 */
|
|
32
|
-
show() {
|
|
33
|
-
if (!this.options)
|
|
34
|
-
return;
|
|
35
|
-
server_1.world.scoreboard.setObjectiveAtDisplaySlot(server_1.DisplaySlotId.Sidebar, {
|
|
36
|
-
objective: this.getObj(),
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
/**刷新选队计分板 */
|
|
40
|
-
refreshScoreBoard() {
|
|
41
|
-
if (!this.options)
|
|
42
|
-
return;
|
|
43
|
-
if (this.lastRefresh == server_1.system.currentTick)
|
|
44
|
-
return;
|
|
45
|
-
//清空计分板
|
|
46
|
-
this.reset();
|
|
47
|
-
//构建计分项
|
|
48
|
-
const scores = [];
|
|
49
|
-
const teams = this.options.teams;
|
|
50
|
-
for (const team of teams) {
|
|
51
|
-
let sortedTeam = team.team.getAll();
|
|
52
|
-
//过滤
|
|
53
|
-
if (team.teamFilter) {
|
|
54
|
-
sortedTeam = sortedTeam.filter(team.teamFilter);
|
|
55
|
-
}
|
|
56
|
-
//排序
|
|
57
|
-
if (team.teamSort) {
|
|
58
|
-
sortedTeam.sort(team.teamSort);
|
|
59
|
-
}
|
|
60
|
-
sortedTeam.forEach((p) => {
|
|
61
|
-
if (!(team.showInvalid ?? false) && !p.isValid) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const text = team.buildName
|
|
65
|
-
? team.buildName(p)
|
|
66
|
-
: (team.prefix ?? "") + p.name;
|
|
67
|
-
scores.push(text);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
//设置积分项
|
|
71
|
-
const obj = this.getObj();
|
|
72
|
-
for (let i = 0; i < scores.length; i++) {
|
|
73
|
-
obj.setScore(scores[i], i);
|
|
74
|
-
}
|
|
75
|
-
this.lastRefresh = server_1.system.currentTick;
|
|
76
|
-
}
|
|
77
|
-
onDetach() {
|
|
78
|
-
if (this.obj?.isValid) {
|
|
79
|
-
server_1.world.scoreboard.removeObjective(this.obj);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.TeamScoreBoard = TeamScoreBoard;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TeamScoreBoard=void 0;const server_1=require("@minecraft/server"),gameComponent_js_1=require("../gameComponent.js");class TeamScoreBoard extends gameComponent_js_1.GameComponent{obj;lastRefresh=0;onAttach(){this.options&&this.reset()}getObj(){return this.obj&&this.obj.isValid||(this.obj=server_1.world.scoreboard.getObjective(this.options.scoreboardName)??server_1.world.scoreboard.addObjective(this.options.scoreboardName,this.options.displayName)),this.obj}reset(){const e=this.getObj(),r=server_1.world.scoreboard.getObjectiveAtDisplaySlot(server_1.DisplaySlotId.Sidebar)?.objective.id==e.id;server_1.world.scoreboard.removeObjective(e),r&&this.show()}show(){this.options&&server_1.world.scoreboard.setObjectiveAtDisplaySlot(server_1.DisplaySlotId.Sidebar,{objective:this.getObj()})}refreshScoreBoard(){if(!this.options)return;if(this.lastRefresh==server_1.system.currentTick)return;this.reset();const e=[],r=this.options.teams;for(const t of r){let r=t.team.getAll();t.teamFilter&&(r=r.filter(t.teamFilter)),t.teamSort&&r.sort(t.teamSort),r.forEach(r=>{if(!t.showInvalid&&!r.isValid)return;const s=t.buildName?t.buildName(r):(t.prefix??"")+r.name;e.push(s)})}const t=this.getObj();for(let r=0;r<e.length;r++)t.setScore(e[r],r);this.lastRefresh=server_1.system.currentTick}onDetach(){this.obj?.isValid&&server_1.world.scoreboard.removeObjective(this.obj)}}exports.TeamScoreBoard=TeamScoreBoard;
|