refactor: fix mess in essentials selfcare

This commit is contained in:
Chayapak 2025-03-18 17:00:52 +07:00
parent c6adc4cc0f
commit 670c678ced
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA
2 changed files with 13 additions and 11 deletions
build-number.txt
src/main/java/me/chayapak1/chomens_bot/plugins

View file

@ -1 +1 @@
1911
1912

View file

@ -125,21 +125,18 @@ public class SelfCarePlugin extends Bot.Listener {
// core
else if (selfCares.icu.enabled && positionPacketsPerSecond > selfCares.icu.positionPacketsPerSecond) bot.core.run("essentials:sudo * icu stop");
else if (hasEssentials) {
// TODO: improve lol, this is ohio
final String usernameOrBlank = !bot.options.useChat ?
bot.username + " " :
"";
if (selfCares.vanish && !vanish && !visibility && !creayun) {
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:vanish enable");
else bot.core.run("essentials:vanish " + bot.username + " enable");
runEssentialsCommand("essentials:vanish " + usernameOrBlank + "enable");
} else if (selfCares.nickname && !nickname) {
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:nick off");
else bot.core.run("essentials:nickname " + bot.username + " off");
runEssentialsCommand("essentials:nickname " + usernameOrBlank + "off");
} else if (selfCares.socialspy && !socialspy && !creayun) {
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:socialspy enable");
else bot.core.run("essentials:socialspy " + bot.username + " enable");
runEssentialsCommand("essentials:socialspy " + usernameOrBlank + "enable");
} else if (selfCares.mute && muted && !creayun) {
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:mute " + bot.profile.getIdAsString());
else bot.core.run("essentials:mute " + bot.profile.getIdAsString());
runEssentialsCommand("essentials:mute " + bot.profile.getIdAsString());
muted = false;
}
}
@ -232,6 +229,11 @@ public class SelfCarePlugin extends Bot.Listener {
positionPacketsPerSecond++;
}
private void runEssentialsCommand (String command) {
if (bot.options.useChat) bot.chat.sendCommandInstantly(command);
else bot.core.run(command);
}
@Override
public void disconnected (DisconnectedEvent event) {
checkTask.cancel(true);