Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed tips from true random to non-repeating random #501

Merged
merged 3 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/de/hysky/skyblocker/skyblock/Tips.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

public class Tips {
private static final Random RANDOM = new Random();
private static int previousTipIndex = -1;
private static final List<Supplier<Text>> TIPS = List.of(
getTipFactory("skyblocker.tips.customItemNames", ClickEvent.Action.SUGGEST_COMMAND, "/skyblocker custom renameItem"),
getTipFactory("skyblocker.tips.customArmorDyeColors", ClickEvent.Action.SUGGEST_COMMAND, "/skyblocker custom dyeColor"),
Expand Down Expand Up @@ -101,6 +102,9 @@ private static Text nextTip() {
}

private static Text nextTipInternal() {
return TIPS.get(RANDOM.nextInt(TIPS.size())).get();
int randomInt = RANDOM.nextInt(TIPS.size());
while (randomInt == previousTipIndex) randomInt = RANDOM.nextInt(TIPS.size());
previousTipIndex = randomInt;
return TIPS.get(randomInt).get();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
"skyblocker.tips.customItemNames": "Customize the names of your items with /skyblocker custom renameItem",
"skyblocker.tips.customArmorDyeColors": "Apply a custom dye color to your leather armour with /skyblocker custom dyeColor",
"skyblocker.tips.customArmorTrims": "You can set custom armor trims on your armor using /skyblocker custom armorTrim.",
"skyblocker.tips.fancyTabExtraInfo": "Did you know you can see extra info on our fancy tab menu when holding N or M?\n",
"skyblocker.tips.fancyTabExtraInfo": "Did you know you can see extra info on our fancy tab menu when holding N or M?",
"skyblocker.tips.helpCommand": "Use command /skyblocker help and you might find some more nifty features!",
"skyblocker.tips.discordRichPresence": "Use Discord Rich Presence to show your friends how loaded you are!",
"skyblocker.tips.customDungeonSecretWaypoints": "You can add custom secret waypoints to any dungeon room with /skyblocker dungeons secrets addWaypoint.",
Expand Down