last load time must be for each player

This commit is contained in:
Tiago Freitas 2014-06-28 14:02:14 +01:00
parent b480922b15
commit 5a900a16c8

View file

@ -106,7 +106,7 @@ function revokeScripting ( player ) {
var playerDir = new File( playersDir + playerName ); var playerDir = new File( playersDir + playerName );
unwatchDir( playerDir ); unwatchDir( playerDir );
} }
exports.classroomAutoloadTime = 0; exports.classroomAutoloadTime = {};
function grantScripting( player ) { function grantScripting( player ) {
console.log('Enabling scripting for player ' + player.name); console.log('Enabling scripting for player ' + player.name);
var playerName = '' + player.name; var playerName = '' + player.name;
@ -122,10 +122,10 @@ function grantScripting( player ) {
//this check is here because this callback might get called multiple times for the watch interval //this check is here because this callback might get called multiple times for the watch interval
//one call for the file change and another for directory change //one call for the file change and another for directory change
//(this happens only in Linux because in Windows the folder lastModifiedTime is not changed) //(this happens only in Linux because in Windows the folder lastModifiedTime is not changed)
if(currentTime-exports.classroomAutoloadTime>1000) { if(currentTime-exports.classroomAutoloadTime[playerName]>1000) {
autoload(playerContext, playerDir, logger, { cache: false }); autoload(playerContext, playerDir, logger, { cache: false });
} }
exports.classroomAutoloadTime = currentTime; exports.classroomAutoloadTime[playerName] = currentTime;
}); });
/* /*