forked from public/foundryvtt-reve-de-dragon
		
	Fix getActiveUser for v9
This commit is contained in:
		| @@ -138,7 +138,7 @@ export class ChatUtility { | |||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   static getUsers(filter) { |   static getUsers(filter) { | ||||||
|     return game.users.filter(filter).map(user => user.data._id); |     return Misc.getUsers().filter(filter).map(user => user.data._id); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   | |||||||
| @@ -134,16 +134,17 @@ export class Misc { | |||||||
|     return Misc.firstConnectedGM()?.id ?? game.user.id; |     return Misc.firstConnectedGM()?.id ?? game.user.id; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   static getUsers() { | ||||||
|  |     return game.version ? game.users : game.users.entities; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   static getActiveUser(id) { |   static getActiveUser(id) { | ||||||
|     return game.users.entities.find(u => u.id == id && u.active); |     return Misc.getUsers().find(u => u.id == id && u.active); | ||||||
|   }   |   }   | ||||||
|  |  | ||||||
|   static firstConnectedGM() { |   static firstConnectedGM() { | ||||||
|     if (game.version){ |     return Misc.getUsers().filter(u => u.isGM && u.active).sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active); | ||||||
|       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); |  | ||||||
|     } |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
| @@ -155,7 +156,7 @@ export class Misc { | |||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   static findPlayer(name) { |   static findPlayer(name) { | ||||||
|     return Misc.findFirstLike(name, game.users, { description: 'joueur' }); |     return Misc.findFirstLike(name, Misc.getUsers(), { description: 'joueur' }); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user