diff --git a/module/chat-utility.js b/module/chat-utility.js index 224b2d2b..65e0c557 100644 --- a/module/chat-utility.js +++ b/module/chat-utility.js @@ -138,7 +138,7 @@ export class ChatUtility { /* -------------------------------------------- */ static getUsers(filter) { - return game.users.filter(filter).map(user => user.data._id); + return Misc.getUsers().filter(filter).map(user => user.data._id); } /* -------------------------------------------- */ diff --git a/module/misc.js b/module/misc.js index f7c62a42..3f8fa2a9 100644 --- a/module/misc.js +++ b/module/misc.js @@ -134,16 +134,17 @@ export class Misc { return Misc.firstConnectedGM()?.id ?? game.user.id; } - static getActiveUser(id) { - return game.users.entities.find(u => u.id == id && u.active); + static getUsers() { + return game.version ? game.users : game.users.entities; } + static getActiveUser(id) { + return Misc.getUsers().find(u => u.id == id && u.active); + } + static firstConnectedGM() { - if (game.version){ - return game.users.filter(u => u.isGM && u.active)[0]; - } else { - return game.users.entities.sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active); - } + return Misc.getUsers().filter(u => u.isGM && u.active).sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active); + } /** @@ -155,7 +156,7 @@ export class Misc { /* -------------------------------------------- */ static findPlayer(name) { - return Misc.findFirstLike(name, game.users, { description: 'joueur' }); + return Misc.findFirstLike(name, Misc.getUsers(), { description: 'joueur' }); } /* -------------------------------------------- */