Skip to content

Commit

Permalink
BedWars support
Browse files Browse the repository at this point in the history
The bedwars voting menu doesn't have any submenu's so we have to monkey patch the start sequence
  • Loading branch information
Fesaa committed Jul 16, 2024
1 parent e7fb6b9 commit 3c72164
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class AutoVoteSubConfig extends Config {
@DropdownSetting
private final ConfigProperty<FiveOptionsMode> pofMapMode = new ConfigProperty<>(
FiveOptionsMode.LEFT);
@DropdownSetting
private final ConfigProperty<TwoOptionsMode> bedWarsModifier = new ConfigProperty<>(TwoOptionsMode.RIGHT);

@SwitchSetting
private final ConfigProperty<Boolean> experiments = new ConfigProperty<>(false);
Expand Down Expand Up @@ -129,6 +131,10 @@ public ConfigProperty<FiveOptionsMode> getPofMapMode() {
return pofMapMode;
}

public ConfigProperty<TwoOptionsMode> getBedWarsModifier() {
return bedWarsModifier;
}

public ConfigProperty<Boolean> getExperiments() {
return experiments;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public static void init(AutoVoteSubConfig config) {
() -> VotePair.of(12, config.getPofGameMode().get().slot),
() -> VotePair.of(14, config.getPofMapMode().get().slot)
));
providers.put(CubeGame.BEDWARS, AutoVoteProvider.of(0,
() -> VotePair.of(-1, config.getBedWarsModifier().get().slot)
));
}

public static AutoVoteProvider getProvider(CubeGame game) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum CubeGame {
SNOWMAN_SURVIVAL("Snowman Survival", true),
LOBBY("Main Lobby", false),
PILLARS_OF_FORTUNE("Pillars of Fortune", true),
BEDWARS("BedWars", true),
NONE("", false);


Expand Down Expand Up @@ -75,6 +76,9 @@ public static CubeGame stringToGame(String s) {
case "pillars of fortune" -> {
return CubeGame.PILLARS_OF_FORTUNE;
}
case "bedwars" -> {
return CubeGame.BEDWARS;
}
default -> {
return CubeGame.NONE;
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/resources/assets/cubepanion/i18n/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@
"none": "Don't vote"
}
},
"bedWarsModifier": {
"name": "BedWars Modifier",
"entries": {
"left": "Normal",
"right": "Faster Gens",
"none": "Don't vote"
}
},
"experiments": {
"name": "Experiments",
"description": "Only turn off, if autovote doesn't work without it. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ public class VersionedVotingLink extends VotingLink {
private LocalPlayer player = null;
private final Task starter = Task.builder(() -> {
this.openVotingMenu(player, this.hotbarSlotIndex);
this.waitForMenuOpenAndMakeFirstChoice(player);

VotePair votePair = this.getNextVotePair();
if (votePair.choiceIndex() == -1) {
this.waitForNewSlotAndClick(player, votePair, false);
} else {
this.waitForMenuOpenAndMakeFirstChoice(player, votePair);
}
}).delay(100, TimeUnit.MILLISECONDS).build();

@Inject
Expand All @@ -69,9 +75,8 @@ public void startAutoVote() {

}

private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player) {
private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player, VotePair votePair) {
Timer timer = new Timer("waitForMenuOpenAndMakeFirstChoice");
VotePair votePair = this.getNextVotePair();
LOGGER.debug(this.getClass(), "Starting vote with pair:", votePair);
VersionedVotingLink votingInterface = this;
timer.schedule(new TimerTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ public class VersionedVotingLink extends VotingLink {
private LocalPlayer player = null;
private final Task starter = Task.builder(() -> {
this.openVotingMenu(player, this.hotbarSlotIndex);
this.waitForMenuOpenAndMakeFirstChoice(player);

VotePair votePair = this.getNextVotePair();
if (votePair.choiceIndex() == -1) {
this.waitForNewSlotAndClick(player, votePair, false);
} else {
this.waitForMenuOpenAndMakeFirstChoice(player, votePair);
}
}).delay(100, TimeUnit.MILLISECONDS).build();

@Inject
Expand All @@ -69,9 +75,8 @@ public void startAutoVote() {

}

private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player) {
private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player, VotePair votePair) {
Timer timer = new Timer("waitForMenuOpenAndMakeFirstChoice");
VotePair votePair = this.getNextVotePair();
LOGGER.debug(this.getClass(), "Starting vote with pair:", votePair);
VersionedVotingLink votingInterface = this;
timer.schedule(new TimerTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ public class VersionedVotingLink extends VotingLink {
private LocalPlayer player = null;
private final Task starter = Task.builder(() -> {
this.openVotingMenu(player, this.hotbarSlotIndex);
this.waitForMenuOpenAndMakeFirstChoice(player);

VotePair votePair = this.getNextVotePair();
if (votePair.choiceIndex() == -1) {
this.waitForNewSlotAndClick(player, votePair, false);
} else {
this.waitForMenuOpenAndMakeFirstChoice(player, votePair);
}
}).delay(100, TimeUnit.MILLISECONDS).build();

@Inject
Expand All @@ -69,9 +75,8 @@ public void startAutoVote() {

}

private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player) {
private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player, VotePair votePair) {
Timer timer = new Timer("waitForMenuOpenAndMakeFirstChoice");
VotePair votePair = this.getNextVotePair();
LOGGER.debug(this.getClass(), "Starting vote with pair:", votePair);
VersionedVotingLink votingInterface = this;
timer.schedule(new TimerTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ public class VersionedVotingLink extends VotingLink {
private LocalPlayer player = null;
private final Task starter = Task.builder(() -> {
this.openVotingMenu(player, this.hotbarSlotIndex);
this.waitForMenuOpenAndMakeFirstChoice(player);

VotePair votePair = this.getNextVotePair();
if (votePair.choiceIndex() == -1) {
this.waitForNewSlotAndClick(player, votePair, false);
} else {
this.waitForMenuOpenAndMakeFirstChoice(player, votePair);
}
}).delay(100, TimeUnit.MILLISECONDS).build();

@Inject
Expand All @@ -69,9 +75,8 @@ public void startAutoVote() {

}

private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player) {
private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player, VotePair votePair) {
Timer timer = new Timer("waitForMenuOpenAndMakeFirstChoice");
VotePair votePair = this.getNextVotePair();
LOGGER.debug(this.getClass(), "Starting vote with pair:", votePair);
VersionedVotingLink votingInterface = this;
timer.schedule(new TimerTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ public class VersionedVotingLink extends VotingLink {
private LocalPlayer player = null;
private final Task starter = Task.builder(() -> {
this.openVotingMenu(player, this.hotbarSlotIndex);
this.waitForMenuOpenAndMakeFirstChoice(player);

VotePair votePair = this.getNextVotePair();
if (votePair.choiceIndex() == -1) {
this.waitForNewSlotAndClick(player, votePair, false);
} else {
this.waitForMenuOpenAndMakeFirstChoice(player, votePair);
}
}).delay(100, TimeUnit.MILLISECONDS).build();

@Inject
Expand All @@ -69,9 +75,8 @@ public void startAutoVote() {

}

private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player) {
private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player, VotePair votePair) {
Timer timer = new Timer("waitForMenuOpenAndMakeFirstChoice");
VotePair votePair = this.getNextVotePair();
LOGGER.debug(this.getClass(), "Starting vote with pair:", votePair);
VersionedVotingLink votingInterface = this;
timer.schedule(new TimerTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ public class VersionedVotingLink extends VotingLink {
private LocalPlayer player = null;
private final Task starter = Task.builder(() -> {
this.openVotingMenu(player, this.hotbarSlotIndex);
this.waitForMenuOpenAndMakeFirstChoice(player);

VotePair votePair = this.getNextVotePair();
if (votePair.choiceIndex() == -1) {
this.waitForNewSlotAndClick(player, votePair, false);
} else {
this.waitForMenuOpenAndMakeFirstChoice(player, votePair);
}
}).delay(100, TimeUnit.MILLISECONDS).build();

@Inject
Expand All @@ -71,9 +77,8 @@ public void startAutoVote() {

}

private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player) {
private void waitForMenuOpenAndMakeFirstChoice(@NotNull LocalPlayer player, VotePair votePair) {
Timer timer = new Timer("waitForMenuOpenAndMakeFirstChoice");
VotePair votePair = this.getNextVotePair();
LOGGER.debug(this.getClass(), "Starting vote with pair:", votePair);
VersionedVotingLink votingInterface = this;
timer.schedule(new TimerTask() {
Expand Down

0 comments on commit 3c72164

Please sign in to comment.