Skip to content

Commit

Permalink
stuck reconnect setting
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Jul 26, 2023
1 parent 5eb831f commit 465e00e
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 89 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/zenith/Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public void start() {
if (isOnlineOn2b2tForAtLeastDuration(Duration.ofSeconds(3))
&& CONFIG.client.extra.antiafk.enabled
&& CONFIG.client.extra.antiafk.actions.stuckWarning // ensures we don't get into a weird state
&& CONFIG.client.extra.antiafk.actions.stuckReconnect
&& MODULE_MANAGER.getModule(AntiAFK.class).map(AntiAFK::isStuck).orElse(false)
&& isNull(getCurrentPlayer().get())) {
long onlineSeconds = Instant.now().getEpochSecond() - connectTime.getEpochSecond();
Expand Down
195 changes: 106 additions & 89 deletions src/main/java/com/zenith/command/impl/AntiAFKCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,101 +18,115 @@ public class AntiAFKCommand extends Command {
@Override
public CommandUsage commandUsage() {
return CommandUsage.full(
"antiAFK",
"Configure the AntiAFK feature",
asList("on/off", "safeWalk on/off", "gravity on/off", "safeGravity on/off",
"stuckWarning on/off", "stuckWarning mention on/off", "walkDistance <int>",
"antiStuck on/off"),
aliases()
"antiAFK",
"Configure the AntiAFK feature",
asList("on/off", "safeWalk on/off", "gravity on/off", "safeGravity on/off",
"stuckWarning on/off", "stuckWarning mention on/off",
"stuckWarning reconnect on/off",
"walkDistance <int>",
"antiStuck on/off"),
aliases()
);
}

@Override
public LiteralArgumentBuilder<CommandContext> register() {
return command("antiAFK")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.enabled = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("AntiAFK On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.enabled = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("AntiAFK Off!");
}))
.then(literal("safewalk")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.safeWalk = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("SafeWalk On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.safeWalk = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("SafeWalk Off!");
})))
.then(literal("gravity")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.gravity = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Gravity On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.gravity = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Gravity Off!");
})))
.then(literal("safegravity")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.safeGravity = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("SafeGravity On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.safeGravity = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("SafeGravity Off!");
})))
.then(literal("stuckwarning")
.then(literal("mention")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.enabled = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("AntiAFK On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.enabled = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("AntiAFK Off!");
}))
.then(literal("safewalk")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.safeWalk = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("SafeWalk On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.safeWalk = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("SafeWalk Off!");
})))
.then(literal("gravity")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.gravity = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Gravity On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.gravity = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Gravity Off!");
})))
.then(literal("safegravity")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.safeGravity = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("SafeGravity On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.safeGravity = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("SafeGravity Off!");
})))
.then(literal("stuckwarning")
.then(literal("mention")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.stuckWarningMention = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Stuck Warning Mention On!");
.title("Stuck Warning Mention On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.stuckWarningMention = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Stuck Warning Mention Off!");
.title("Stuck Warning Mention Off!");
})))
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.stuckWarning = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Stuck Warning On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.stuckWarning = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Stuck Warning Off!");
})))
.then(literal("walkdistance")
.then(argument("walkdist", integer(1)).executes(c -> {
CONFIG.client.extra.antiafk.actions.walkDistance = IntegerArgumentType.getInteger(c, "walkdist");
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Walk Distance Set!");
return 1;
})))
.then(literal("antistuck")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.antiStuck = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("AntiStuck Suicide On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.antiStuck = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("AntiStuck Suicide Off!");
})));
.then(literal("reconnect")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.stuckReconnect = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Stuck Warning Reconnect On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.stuckReconnect = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Stuck Warning Reconnect Off!");
})))
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.stuckWarning = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Stuck Warning On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.stuckWarning = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Stuck Warning Off!");
})))
.then(literal("walkdistance")
.then(argument("walkdist", integer(1)).executes(c -> {
CONFIG.client.extra.antiafk.actions.walkDistance = IntegerArgumentType.getInteger(c,
"walkdist");
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("Walk Distance Set!");
return 1;
})))
.then(literal("antistuck")
.then(literal("on").executes(c -> {
CONFIG.client.extra.antiafk.actions.antiStuck = true;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("AntiStuck Suicide On!");
}))
.then(literal("off").executes(c -> {
CONFIG.client.extra.antiafk.actions.antiStuck = false;
defaultEmbedPopulate(c.getSource().getEmbedBuilder())
.title("AntiStuck Suicide Off!");
})));
}

@Override
Expand All @@ -122,13 +136,16 @@ public List<String> aliases() {

private EmbedCreateSpec.Builder defaultEmbedPopulate(final EmbedCreateSpec.Builder embedBuilder) {
return embedBuilder
.addField("AntiAFK", CONFIG.client.extra.antiafk.enabled ? "on" : "off", false)
.addField("Walk Distance", "" + CONFIG.client.extra.antiafk.actions.walkDistance, false)
.addField("Safe Walk", CONFIG.client.extra.antiafk.actions.safeWalk ? "on" : "off", false)
.addField("Gravity", CONFIG.client.extra.antiafk.actions.gravity ? "on" : "off", false)
.addField("Safe Gravity", CONFIG.client.extra.antiafk.actions.safeGravity ? "on" : "off", false)
.addField("Stuck Warning", (CONFIG.client.extra.antiafk.actions.stuckWarning ? "on" : "off") + " [Mention: " + (CONFIG.client.extra.antiafk.actions.stuckWarningMention ? "on" : "off") + "]", false)
.addField("AntiStuck Suicide", (CONFIG.client.extra.antiafk.actions.antiStuck ? "on" : "off"), false)
.color(Color.CYAN);
.addField("AntiAFK", CONFIG.client.extra.antiafk.enabled ? "on" : "off", false)
.addField("Walk Distance", "" + CONFIG.client.extra.antiafk.actions.walkDistance, false)
.addField("Safe Walk", CONFIG.client.extra.antiafk.actions.safeWalk ? "on" : "off", false)
.addField("Gravity", CONFIG.client.extra.antiafk.actions.gravity ? "on" : "off", false)
.addField("Safe Gravity", CONFIG.client.extra.antiafk.actions.safeGravity ? "on" : "off", false)
.addField("Stuck Warning",
(CONFIG.client.extra.antiafk.actions.stuckWarning ? "on" : "off") + " [Mention: " + (CONFIG.client.extra.antiafk.actions.stuckWarningMention ? "on" : "off") + "]",
false)
.addField("Stuck Reconnect", (CONFIG.client.extra.antiafk.actions.stuckReconnect ? "on" : "off"), false)
.addField("AntiStuck Suicide", (CONFIG.client.extra.antiafk.actions.antiStuck ? "on" : "off"), false)
.color(Color.CYAN);
}
}
1 change: 1 addition & 0 deletions src/main/java/com/zenith/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public static final class Actions {
public boolean safeGravity = true;
public boolean stuckWarning = true;
public boolean stuckWarningMention = false;
public boolean stuckReconnect = true;
public boolean antiStuck = false;
}
}
Expand Down

0 comments on commit 465e00e

Please sign in to comment.