Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions scripts/jaylydb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
import { ScoreboardIdentityType, system, world } from "@minecraft/server";
const version = "1.1.3";
/** Ticks between each sync with the scoreboard (20 ticks = 1 second) */
const SYNC_INTERVAL = 20;
const str = () => ('00000000000000000' + (Math.random() * 0xffffffffffffffff).toString(16)).slice(-16);
/**
* A rough mechanism for create a random uuid. Not as secure as uuid without as much of a guarantee of uniqueness,
Expand Down Expand Up @@ -117,7 +119,8 @@ class JaylyDB {
updateParticipants() {
this.localState.clear();
for (const participant of this.objective.getParticipants()) {
if (participant.type !== ScoreboardIdentityType.FakePlayer)
// getParticipants() can contain undefined entries for removed identities (#334)
if (!participant || participant.type !== ScoreboardIdentityType.FakePlayer)
continue;
const data = DisplayName.parse(participant.displayName, this.objective, this.salt);
const key = Object.keys(data)[0];
Expand Down Expand Up @@ -157,7 +160,7 @@ class JaylyDB {
console.error(`[JaylyDB] There is a sync issue with database '${id}'.`);
this.SYNC_OK = false;
}
});
}, SYNC_INTERVAL); // #311: sync once per second instead of every tick
}
/**
* @returns the number of elements in the database.
Expand Down
7 changes: 5 additions & 2 deletions scripts/jaylydb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import { ScoreboardIdentity, ScoreboardIdentityType, ScoreboardObjective, system, world } from "@minecraft/server";

const version = "1.1.3";
/** Ticks between each sync with the scoreboard (20 ticks = 1 second) */
const SYNC_INTERVAL = 20;
const str = () => ('00000000000000000' + (Math.random() * 0xffffffffffffffff).toString(16)).slice(-16);
/**
* A rough mechanism for create a random uuid. Not as secure as uuid without as much of a guarantee of uniqueness,
Expand Down Expand Up @@ -132,7 +134,8 @@ class JaylyDB implements Map<string, string | number | boolean> {
private updateParticipants() {
this.localState.clear();
for (const participant of this.objective.getParticipants()) {
if (participant.type !== ScoreboardIdentityType.FakePlayer) continue;
// getParticipants() can contain undefined entries for removed identities (#334)
if (!participant || participant.type !== ScoreboardIdentityType.FakePlayer) continue;
const data = DisplayName.parse(participant.displayName, this.objective, this.salt);
const key = Object.keys(data)[0];
const value = data[key];
Expand Down Expand Up @@ -171,7 +174,7 @@ class JaylyDB implements Map<string, string | number | boolean> {
console.error(`[JaylyDB] There is a sync issue with database '${id}'.`);
this.SYNC_OK = false;
}
});
}, SYNC_INTERVAL); // #311: sync once per second instead of every tick
}
/**
* @returns the number of elements in the database.
Expand Down