diff --git a/core/components/PlayerlistManager/index.ts b/core/components/PlayerlistManager/index.ts index 24acc146b..0bc2ebacd 100644 --- a/core/components/PlayerlistManager/index.ts +++ b/core/components/PlayerlistManager/index.ts @@ -91,6 +91,14 @@ export default class PlayerlistManager { return this.#playerlist[netid]; } + /** + * Returns a specifc ServerPlayer or undefined. + * NOTE: this returns the actual object and not a deep clone! + */ + getOnlinePlayersByLicense(searchLicense: string) { + return this.#playerlist.filter(p => p && p.license === searchLicense && p.isConnected) as ServerPlayer[]; + } + /** * Handler for all txAdminPlayerlistEvent structured trace events diff --git a/core/playerLogic/playerResolver.ts b/core/playerLogic/playerResolver.ts index 1c9931366..5ec1ae3d7 100644 --- a/core/playerLogic/playerResolver.ts +++ b/core/playerLogic/playerResolver.ts @@ -45,7 +45,12 @@ export default (mutex: any, netid: any, license: any) => { //If license provided or resolved through licenseCache, search in the database if (typeof searchLicense === 'string' && searchLicense.length) { - return new DatabasePlayer(searchLicense, playerDatabase); + const onlineMatches = playerlistManager.getOnlinePlayersByLicense(searchLicense); + if(onlineMatches.length){ + return onlineMatches.at(-1); + }else{ + return new DatabasePlayer(searchLicense, playerDatabase); + } } //Player not found