feat: Add `getNametagPosition` & `getNametagAtPosition` method to `MessageNametagBuffer`

This commit is contained in:
Emil Ivanichkov 2024-01-26 17:40:16 +02:00 committed by richΛrd
parent 1a0b044451
commit 4d6d4ca5bd
1 changed files with 9 additions and 0 deletions

View File

@ -84,6 +84,11 @@ export class MessageNametagBuffer {
return true; return true;
} }
getNametagPosition(messageNametag: MessageNametag): number {
const index = this.buffer.findIndex((x) => uint8ArrayEquals(x, messageNametag));
return index;
}
private rotateLeft(k: number): void { private rotateLeft(k: number): void {
if (k < 0 || this.buffer.length == 0) { if (k < 0 || this.buffer.length == 0) {
return; return;
@ -124,6 +129,10 @@ export class MessageNametagBuffer {
console.debug("The message nametags buffer has no secret set"); console.debug("The message nametags buffer has no secret set");
} }
} }
getNametagAtPosition(position: number): MessageNametag {
return this.buffer[position];
}
} }
/** /**