@occultus/task-api 0.21.0-beta.1 → 0.21.0-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@occultus/task-api",
3
- "version": "0.21.0-beta.1",
3
+ "version": "0.21.0-beta.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://codeberg.org/TeamOccultus/StarTenonAPI"
@@ -24,8 +24,8 @@
24
24
  "author": "CTN Studios",
25
25
  "type": "module",
26
26
  "dependencies": {
27
- "@occultus/format-api": "0.21.0-beta.1",
28
- "@occultus/entity-api": "0.20.0",
27
+ "@occultus/format-api": "0.21.0-beta.2",
28
+ "@occultus/entity-api": "0.21.0-beta.2",
29
29
  "@occultus/text-api": "0.20.0",
30
30
  "@occultus/item-api": "0.20.0"
31
31
  },
package/src/api/Task.ts CHANGED
@@ -4,7 +4,7 @@ import { TaskOptions } from "../interface/TaskOptions";
4
4
  import { TaskStatus } from "../enum/TaskStaus";
5
5
  import { TaskGroup } from "./TaskGroup";
6
6
  import { TaskCenter } from "./TaskCenter";
7
- import { MessageFormData } from "@minecraft/server-ui";
7
+ import { ActionFormData } from "@minecraft/server-ui";
8
8
  import { TaskUtils } from "../utils/TaskUtils";
9
9
  import { LockedScreen } from "../ui/LockedScreen";
10
10
  import { TaskServer } from "./TaskServer";
@@ -32,16 +32,16 @@ export class Task {
32
32
  this.lockedDisplay(player, backTo);
33
33
  return;
34
34
  }
35
- const form = new MessageFormData();
35
+ const form = new ActionFormData();
36
36
  form.title(parseText(this.name, player));
37
37
  form.body(TaskUtils.generateTaskBody(this, player));
38
- form.button1({ translate: "gui.back" });
38
+ form.button({ translate: "gui.back" });
39
39
  if (this.getStatus(player) === TaskStatus.Done) {
40
40
  // 任务已完成
41
- form.button2({ translate: "ui.task.done" });
41
+ form.button({ translate: "ui.task.done" });
42
42
  } else {
43
43
  // 提交任务
44
- form.button2({ translate: "ui.task.submit" });
44
+ form.button({ translate: "ui.task.submit" });
45
45
  }
46
46
  form.show(player).then((result) => {
47
47
  if (result.selection === 1) {
@@ -1,12 +1,9 @@
1
- import {
2
- EntityDamageCause,
3
- Player,
4
- world,
5
- } from "@minecraft/server";
1
+ import { EntityDamageCause, Player, world } from "@minecraft/server";
6
2
  import { KillEntityConditions } from "./conditions/KillEntityCondition";
7
3
  import { KillEntityFamilyConditions } from "./conditions/KillEntityFamilyCondition";
8
4
  import { TaskConditions } from "./conditions/TaskConditions";
9
5
  import { Task } from "./Task";
6
+ import { getFamilies } from "@occultus/entity-api";
10
7
 
11
8
  export class TaskServer {
12
9
  private startUp() {
@@ -21,13 +18,17 @@ export class TaskServer {
21
18
  });
22
19
  world.afterEvents.entityDie.subscribe((event) => {
23
20
  const { deadEntity, damageSource } = event;
24
- const task = this.entities.get(deadEntity.typeId);
25
- if (!task) return;
21
+ const damagingEntity = damageSource.damagingEntity;
26
22
  if (damageSource.cause !== EntityDamageCause.entityAttack) return;
27
- if (!damageSource.damagingEntity) return;
28
- if (!(damageSource.damagingEntity instanceof Player)) return;
29
- task.complete(damageSource.damagingEntity);
23
+ if (!damagingEntity) return;
24
+ if (!(damagingEntity instanceof Player)) return;
25
+ getFamilies(deadEntity)?.forEach((family) => {
26
+ const task = this.families.get(deadEntity.typeId);
27
+ if (!task) return;
28
+ task.complete(damagingEntity);
29
+ });
30
30
  });
31
+ console.log("[Occultus SDK] Task Server Started")
31
32
  }
32
33
  entities: Map<string, Task> = new Map();
33
34
  families: Map<string, Task> = new Map();