refactor: fix mess in essentials selfcare

This commit is contained in:
ChomeNS
2025-03-18 17:00:52 +07:00
parent c6adc4cc0f
commit 670c678ced
2 changed files with 13 additions and 11 deletions

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);