saviola777 / hhm-plugins

Plugins for the Haxball Headless Manager (HHM).
MIT License
3 stars 5 forks source link

Cannot reload `sav/players` #19

Closed morko closed 4 years ago

morko commented 4 years ago

When running HHM.manager.reloadPlugin('sav/players', true) the plugin will break and also break other plugins. The errors won't happen before a player joins the room but once running the function, following was printed in haxroomie-cli console:

from saviola777/hhm-plugins 
[2020-06-21T10:07:41.242Z] [debug] [priv] [INFO] [INFO HHM]:  Loading plugin sav/players and its dependencies 
[2020-06-21T10:07:41.242Z] [debug] [priv] [INFO] [INFO HHM]:  Loading the following plugins: 
[2020-06-21T10:07:41.242Z] [debug] [priv] [INFO] [INFO HHM]:  sav/players 
[2020-06-21T10:07:41.243Z] [debug] [priv] [INFO] [INFO HHM]:  Plugin loaded successfully: sav/players 
PLAYER JOINED niasd (id:2)
priv> [2020-06-21T10:08:04.644Z] [debug] [priv] [ERROR] [ERROR HHM]:  Error during execution of handler onPlayerJoin for plugin sav/roles 
[2020-06-21T10:08:04.644Z] [debug] [priv] [ERROR] [ERROR HHM]: 
[2020-06-21T10:08:04.644Z] [debug] [priv] [ERROR] TypeError: Cannot read property 'roles' of undefined
    at provideAuthenticationInfo (eval at _executePlugin (:16597:18), <anonymous>:321:35)
    at onPlayerJoinHandler (eval at _executePlugin (:16597:18), <anonymous>:472:3)
    at TrappedRoomManager._executeHandlerFunction (<anonymous>:18361:48)
    at TrappedRoomManager.executeHandler (<anonymous>:18328:12)
    at TrappedRoomManager.onExecuteEventHandlers (<anonymous>:18939:16)
    at room.<computed> (<anonymous>:516:41)
    at u.rh (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:64:266)
    at R.apply (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:109:257)
    at Fa.nf (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:45:101)
    at Fa.ec (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:46:144) 
[2020-06-21T10:08:12.728Z] [debug] [priv] [ERROR] [ERROR HHM]:  Error during execution of hook function onPlayerLeavePreEventHook({}, player) {
  if (player === null) {
    room.log(`Player object is null in onPlayerLeaveHandler, this should `
        + `not have happened`, HHM.log.level.WARN);
    return false;
  }

  const userData = getUserData(idToAuth[player.id]);
  userData.seen = new Date();

  const playerData = getPlayerData(player.id);
  playerData.online = false;
} (handler onPlayerLeave) for plugin sav/players 
[2020-06-21T10:08:12.729Z] [debug] [priv] [ERROR] [ERROR HHM]: 
[2020-06-21T10:08:12.729Z] [debug] [priv] [ERROR] TypeError: Cannot set property 'seen' of undefined
    at onPlayerLeavePreEventHook (eval at _executePlugin (:16597:18), <anonymous>:473:17)
    at TrappedRoomManager._executeHooks (<anonymous>:18389:25)
    at TrappedRoomManager.onExecuteEventHandlers (<anonymous>:18907:12)
    at room.<computed> (<anonymous>:516:41)
    at u.sh (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:66:137)
    at Function.Da.va (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:53:228)
    at I.apply (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:113:254)
    at Fa.nf (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:45:101)
    at Fa.ec (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:46:144)
    at A.mh (https://www.haxball.com/Unzgnb3B/__cache_static__/g/headless-min.js:63:497) 

I was using the version 1.0.1 of HHM and commit c8ee22cd46d38f4fa8ec29f201755a08ed5dc4a2 of hhm-plugins.

saviola777 commented 4 years ago

Should be fixed now with most recent plugin versions. Re-open if not, haven't actually been able to test this yet.