2024-07-07 15:44:16 -04:00
function selfcare ( bot , options , config ) {
let entityId ;
let permissionLevel = 2 ;
2024-07-20 20:27:17 -04:00
let unmuted = false ;
2024-07-07 15:44:16 -04:00
let gameMode ;
let commandSpy = false ;
let vanished = false ;
let prefix = false ;
2024-07-20 20:27:17 -04:00
let god = false ;
2024-08-21 12:20:11 -04:00
let teleportToggle = false ;
let username = false ;
let nickname = false ;
2024-10-07 09:58:32 -04:00
let login = false ;
let register = false ;
2024-07-07 15:44:16 -04:00
// You now have the tag: &8[&bPrefix&8: &3~&8]
// You no longer have a tag
bot . on ( 'message' , ( message ) => {
2024-07-20 20:27:17 -04:00
const stringMessage = bot . getMessageAsPrismarine ( message ) ? . toString ( ) ;
2024-10-07 09:58:32 -04:00
if ( options . isSavage ) {
if ( stringMessage === "Please, login with the command: /login <password>" ) login = true ;
else if ( stringMessage === "Successful login!" ) login = false ;
else if ( stringMessage === "You're already logged in!" ) login = false ;
else if ( stringMessage === "Please, register to the server with the command: /register <password> <ConfirmPassword>" ) register = true ;
2024-10-17 20:38:21 -04:00
else if ( stringMessage === "This user isn't registered!" ) register = true ;
2024-10-07 09:58:32 -04:00
else if ( stringMessage === "Successfully registered!" ) register = false ;
// else if (stringMessage === "You already have registered this username!") register = false;
else if ( stringMessage === "You're already logged in!" ) register = false ;
else if ( stringMessage === "Successful login!" ) register = false ;
/ *
You ' re already logged in !
Please , register to the server with the command : / r e g i s t e r < p a s s w o r d > < C o n f i r m P a s s w o r d >
Please , login with the command : / l o g i n < p a s s w o r d >
Successfully registered !
Successful login !
You already have registered this username !
* /
} else if ( options . isKaboom ) {
// const stringMessage = bot.getMessageAsPrismarine(message)?.toString();
if ( stringMessage === "Successfully enabled CommandSpy" ) commandSpy = true ;
else if ( stringMessage === "Successfully enabled CommandSpy." ) commandSpy = true ;
else if ( stringMessage === "Successfully disabled CommandSpy" ) commandSpy = false ;
else if ( stringMessage === "Successfully disabled CommandSpy." ) commandSpy = false ;
else if ( stringMessage === ` Vanish for ${ bot . options . username } : enabled ` ) vanished = true ;
else if ( stringMessage === ` Vanish for ${ bot . options . username } : disabled ` ) vanished = false ;
else if ( stringMessage === ` You now have the tag: &8[&bPrefix&8: &3 ${ config . prefixes [ 0 ] } &8] ` || stringMessage === "Something went wrong while saving the prefix. Please check console." ) prefix = true ;
else if ( stringMessage ? . startsWith ( "You now have the tag: " ) || stringMessage === "You no longer have a tag" ) prefix = false
else if ( stringMessage ? . startsWith ( "You have been muted" ) ) unmuted = true ;
else if ( stringMessage ? . startsWith ( "You have been unmuted" ) ) unmuted = false ;
else if ( stringMessage ? . startsWith ( "Your voice has been silenced" ) ) unmuted = true ;
else if ( stringMessage === "God mode disabled." ) god = false ;
else if ( stringMessage === "God mode enabled." ) god = true ;
else if ( stringMessage === "Teleportation disabled." ) teleportToggle = true ;
else if ( stringMessage === "Teleportation enabled." ) teleportToggle = false ;
else if ( stringMessage === ` Successfully set your username to " ${ bot . username } " ` ) {
username = false
return
}
else if ( stringMessage ? . startsWith ( "Successfully set your username to " ) ) username = true
else if ( stringMessage === ` You already have the username " ${ bot . username } " ` ) username = false
else if ( stringMessage === ` You no longer have a nickname. ` ) nickname = false ;
else if ( stringMessage . startsWith ( 'Your nickname is now ' ) ) nickname = true ;
2024-08-21 12:20:11 -04:00
}
2024-07-07 15:44:16 -04:00
} )
bot . on ( 'packet.entity_status' , packet => {
if ( packet . entityId !== entityId || packet . entityStatus < 24 || packet . entityStatus > 28 ) return
permissionLevel = packet . entityStatus - 24
} )
bot . on ( 'packet.game_state_change' , packet => {
if ( packet . reason !== 3 ) return // Reason 3 = Change Game Mode
gameMode = packet . gameMode ;
} ) ;
bot . on ( "packet.game_state.change" , packet => {
2024-08-30 11:56:58 -04:00
if ( packet . reason !== 4 ) return // checks if the bot is seeing the endcredits or died
2024-07-20 20:27:17 -04:00
clientLock = packet . gameMode ;
2024-07-07 15:44:16 -04:00
} )
let timer ;
bot . on ( 'packet.login' , ( packet ) => {
2024-08-30 11:56:58 -04:00
entityId = packet . entityId ;
gameMode = packet . gameMode ;
clientLock = packet . gameMode ;
timer = setInterval ( ( ) => {
2024-09-19 11:30:06 -04:00
if ( bot . options . isSavage && ! bot . options . isKaboom && ! bot . options . isCreayun ) {
2024-10-07 09:58:32 -04:00
if ( login ) bot . chat . command ( 'login amogusissus' ) ;
else if ( register ) bot . chat . command ( 'register amogusissus amogusissus' ) ;
// else if (permissionLevel < 2) bot.chat.command(`minecraft:op ${bot.options.username}`);
else if ( gameMode !== 1 ) bot . chat . command ( 'minecraft:gamemode creative' ) ;
else if ( clientLock !== 4 ) bot . _client . write ( "client_command" , { actionId : 0 } ) ;
2024-09-19 11:30:06 -04:00
} else if ( bot . options . isCreayun && ! bot . options . isKaboom && ! bot . options . isSavage ) {
2024-08-30 11:56:58 -04:00
} else if ( bot . options . isKaboom && ! bot . options . isSavage ) {
if ( permissionLevel < 2 ) bot . chat . command ( 'op @s[type=player]' ) ;
2024-09-07 21:13:24 -04:00
else if ( gameMode !== 1 ) bot . chat . command ( 'minecraft:gamemode creative' ) ;
2024-08-30 11:56:58 -04:00
else if ( ! commandSpy ) bot . chat . command ( 'commandspy on' ) ;
else if ( username ) bot . chat . command ( ` username ${ bot . options . username } ` )
else if ( nickname ) bot . chat . command ( ` nick off ` )
else if ( ! prefix ) bot . chat . command ( ` prefix &8[&bPrefix&8: &3 ${ config . prefixes [ 0 ] } &8] ` ) ;
2024-10-09 12:12:54 -04:00
else if ( ! vanished ) bot . chat . command ( ` essentials:vanish on ` ) ;
2024-08-30 11:56:58 -04:00
else if ( unmuted ) bot . core . run ( ` essentials:mute ${ bot . uuid } ` ) ;
else if ( ! god ) bot . core . run ( ` god ${ bot . options . username } enable ` ) ;
else if ( ! teleportToggle ) bot . core . run ( ` tptoggle ${ bot . options . username } disable ` ) ;
else if ( clientLock !== 4 ) bot . _client . write ( "client_command" , { actionId : 0 } ) ;
}
} , 1000 ) ;
2024-07-07 15:44:16 -04:00
} ) ;
bot . on ( 'end' , ( ) => {
if ( timer ) clearInterval ( timer )
prefix = false ;
commandSpy = false ;
vanished = false ;
prefix = false ;
2024-07-20 20:27:17 -04:00
god = false ;
unmuted = false ;
2024-08-21 12:20:11 -04:00
username = false ;
2024-07-07 15:44:16 -04:00
} ) ;
}
module . exports = selfcare ;