aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-07-08 17:20:55 +0800
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-07-08 18:18:17 +0800
commit796177d64aac6c64949973a5604aedc0d1f2651f (patch)
treed42c42a0322d29d0ee0399b771b1de684cd925fb /src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
parentaed3973ad0cc33b3d3128695e6f660dc304bc9d6 (diff)
downloadSkyblocker-796177d64aac6c64949973a5604aedc0d1f2651f.tar.gz
Skyblocker-796177d64aac6c64949973a5604aedc0d1f2651f.tar.bz2
Skyblocker-796177d64aac6c64949973a5604aedc0d1f2651f.zip
Refactor Title Container
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
index 4a151129..6fa93735 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderHelper.java
@@ -53,14 +53,29 @@ public class RenderHelper {
playNotificationSound();
}
+ /**
+ * Adds the title to {@link TitleContainer} and {@link #playNotificationSound() plays the notification sound} if the title is not in the {@link TitleContainer} already.
+ * No checking needs to be done on whether the title is in the {@link TitleContainer} already by the caller.
+ *
+ * @param title the title
+ */
public static void displayInTitleContainerAndPlaySound(Title title) {
- TitleContainer.addTitle(title);
- playNotificationSound();
+ if (TitleContainer.addTitle(title)) {
+ playNotificationSound();
+ }
}
- public static void displayInTitleContainerWDismissAndPlaySound(Title title, int ticks) {
- TitleContainer.addTitleWithDismiss(title, ticks);
- playNotificationSound();
+ /**
+ * Adds the title to {@link TitleContainer} for a set number of ticks and {@link #playNotificationSound() plays the notification sound} if the title is not in the {@link TitleContainer} already.
+ * No checking needs to be done on whether the title is in the {@link TitleContainer} already by the caller.
+ *
+ * @param title the title
+ * @param ticks the number of ticks the title will remain
+ */
+ public static void displayInTitleContainerAndPlaySound(Title title, int ticks) {
+ if (TitleContainer.addTitle(title, ticks)) {
+ playNotificationSound();
+ }
}
private static void playNotificationSound() {