Big WIP...

This commit is contained in:
2022-06-12 08:17:59 +02:00
parent a3fb328b7d
commit 451ee677d2
56 changed files with 990 additions and 921 deletions

View File

@ -32,7 +32,6 @@ export class ChatUtility {
}
}
/* -------------------------------------------- */
static onNotifyUser(data) {
if (game.user.id == data.userId) {
switch (data.level) {
@ -47,15 +46,28 @@ export class ChatUtility {
static onRemoveMessages(data) {
if (Misc.isUniqueConnectedGM()) {
if (data.part) {
const toDelete = game.messages.filter(it => it.content.includes(data.part))
toDelete.forEach(it => it.delete())
const toDelete = game.messages.filter(it => it.data.content.includes(data.part));
toDelete.forEach(it => it.delete());
}
if (data.messageId) {
game.messages.get(data.messageId)?.delete()
game.messages.get(data.messageId)?.delete();
}
}
}
static onRemoveMessages(data) {
if (Misc.isUniqueConnectedGM()) {
if (data.part) {
const toDelete = game.messages.filter(it => it.content.includes(data.part));
toDelete.forEach(it => it.delete());
}
if (data.messageId) {
game.messages.get(data.messageId)?.delete();
}
}
}
/* -------------------------------------------- */
static removeMessages(data) {
if (Misc.isUniqueConnectedGM()) {
ChatUtility.onRemoveMessages(data);
@ -78,7 +90,7 @@ export class ChatUtility {
/* -------------------------------------------- */
static async createChatWithRollMode(name, chatOptions) {
return await ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions)
return await ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions);
}
/* -------------------------------------------- */
@ -129,7 +141,7 @@ export class ChatUtility {
/* -------------------------------------------- */
static getUsers(filter) {
return Misc.getUsers().filter(filter).map(user => user.id)
return Misc.getUsers().filter(filter).map(user => user.data._id);
}
/* -------------------------------------------- */
@ -150,20 +162,17 @@ export class ChatUtility {
}
}
/* -------------------------------------------- */
static async setMessageData(chatMessage, key, data) {
if (data) {
await chatMessage.setFlag(SYSTEM_RDD, key, JSON.stringify(data));
}
}
/* -------------------------------------------- */
static getMessageData(chatMessage, key) {
const json = chatMessage.getFlag(SYSTEM_RDD, key);
return json ? JSON.parse(json) : undefined;
}
/* -------------------------------------------- */
static getChatMessage(event) {
const chatMessageId = $(event.currentTarget).closest('.chat-message').attr('data-message-id');
return game.messages.get(chatMessageId);