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
let gameMode = 1
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
}
} )
target . on ( 'game_state_change' , ( data ) => {
if ( data . reason !== 3 ) return
gameMode = data . gameMode
} )
target . on ( 'login' , ( data ) => {
gameMode = data . gameMode
} )
const interval = setInterval ( ( ) => {
if ( bot . options . kaboom ) {
if ( ! op && config . self _care . op ) target . chat ( '/minecraft:op @s[type=player]' )
if ( ! cspy && config . self _care . cspy ) target . chat ( '/commandspy:commandspy on' )
}
if ( gameMode !== 1 && config . self _care . gamemode ) target . chat ( '/minecraft:gamemode creative @s[type=player]' )
} , config . self _care _check _interval )
bot . on ( 'end' , ( ) => {
clearInterval ( interval )
} )
} ;
module . exports = { inject }