2022-12-05 03:16:48 -05:00
2022-11-30 06:01:46 -05:00
function inject ( bot , client , target , config ) {
let cspy = false
let op = true
2022-12-27 19:57:07 -05:00
// let gameMode = 1
2022-11-30 06:01:46 -05:00
2022-12-12 03:06:50 -05:00
target . on ( 'message' , ( data ) => {
2022-11-30 06:01:46 -05:00
if ( data . toString ( ) === 'Successfully enabled CommandSpy' || data . toString ( ) === ' Enabled your command spy.' || data . toString ( ) === ' Your command spy is already enabled.' ) cspy = true
if ( data . toString ( ) === 'Successfully disabled CommandSpy' || data . toString ( ) === ' Disabled your command spy.' ) cspy = false
} )
target . on ( 'entity_status' , ( data ) => {
if ( data . entityId !== target . entityId ) return
switch ( data . entityStatus ) {
case 24 :
op = false
break
case 28 :
op = true
break
}
} )
2022-12-27 19:57:07 -05:00
// target.on('game_state_change', (data) => {
// if (data.reason !== 3) return
//
// gameMode = data.gameMode
// })
//
// target.on('login', (data) => {
// gameMode = data.gameMode
// })
2022-11-30 06:01:46 -05:00
const interval = setInterval ( ( ) => {
if ( bot . options . kaboom ) {
2023-01-16 07:20:39 -05:00
if ( ! op && config . self _care . op ) target . sendMessage ( '/minecraft:op @s[type=player]' )
if ( ! cspy && config . self _care . cspy ) target . sendMessage ( '/commandspy:commandspy on' )
2022-11-30 06:01:46 -05:00
}
2023-01-16 07:20:39 -05:00
// if (gameMode !== 1 && config.self_care.gamemode) target.sendMessage('/minecraft:gamemode creative @s[type=player]')
2022-11-30 06:01:46 -05:00
} , config . self _care _check _interval )
bot . on ( 'end' , ( ) => {
clearInterval ( interval )
} )
} ;
module . exports = { inject }