Skip to content

Commit

Permalink
Changed tips from true random to non-repeating random (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emirlol authored Jan 20, 2024
1 parent fa4063d commit 35ab556
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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 @@ -102,6 +103,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 @@ -408,7 +408,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

0 comments on commit 35ab556

Please sign in to comment.