aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCow <cow@volloeko.de>2020-12-20 22:17:09 +0100
committerCow <cow@volloeko.de>2020-12-20 22:17:09 +0100
commit35fda52e2f38a66fb864f8f6a7552ef2078d3dea (patch)
treea4de0da60c3077c183437211000f9165122d71e2
parent609758ab51a46e4ccac2cd37f449f3682bc15770 (diff)
downloadCowlection-35fda52e2f38a66fb864f8f6a7552ef2078d3dea.tar.gz
Cowlection-35fda52e2f38a66fb864f8f6a7552ef2078d3dea.tar.bz2
Cowlection-35fda52e2f38a66fb864f8f6a7552ef2078d3dea.zip
Added sound when a best friend joins
- Toggleable via config (deactivated by default)
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/main/java/de/cowtipper/cowlection/config/MooConfig.java10
-rw-r--r--src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java31
-rw-r--r--src/main/java/de/cowtipper/cowlection/listener/ChatListener.java4
-rw-r--r--src/main/resources/assets/cowlection/lang/en_US.lang2
5 files changed, 46 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f59e1d3..b96f2f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Auto-replacement of `/r ` with `/w <last sender>`
- Short alias `/m` for `/moo` command
- Copy inventories to clipboard as JSON with <kbd>CTRL</kbd> + <kbd>C</kbs>
+- Added sound when a best friend comes online (deactivated by default)
### Changed
- Item age: show timestamp in the local timezone instead of "SkyBlock"-timezone (Eastern Time; also fixed the incorrect 12h ↔ 24h clock conversion)
diff --git a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
index a522dce..6922c2e 100644
--- a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
+++ b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java
@@ -9,6 +9,7 @@ import de.cowtipper.cowlection.data.DataHelper;
import de.cowtipper.cowlection.util.MooChatComponent;
import de.cowtipper.cowlection.util.Utils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.SoundCategory;
import net.minecraft.command.ICommand;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagInt;
@@ -57,6 +58,7 @@ public class MooConfig {
// Category: Notifications
public static boolean doUpdateCheck;
public static boolean showBestFriendNotifications;
+ public static boolean enableBestFriendNotificationSound;
public static boolean showFriendNotifications;
public static boolean showGuildNotifications;
public static boolean doBestFriendsOnlineCheck;
@@ -257,6 +259,10 @@ public class MooConfig {
Property propShowBestFriendNotifications = subCat.addConfigEntry(cfg.get(configCat.getConfigName(),
"showBestFriendNotifications", true, "Set to true to receive best friends' login/logout messages, set to false hide them."),
new MooConfigPreview(new ChatComponentText("§a§lBest friend §a> §6Cow §r§ejoined.")));
+ Property propEnableBestFriendNotificationSound = subCat.addConfigEntry(cfg.get(configCat.getConfigName(),
+ "enableBestFriendNotificationSound", false, "Set to true to play a notification sound when a best friend comes online"),
+ new MooConfigPreview("random.pop", Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.MASTER), 1));
+
Property propShowFriendNotifications = subCat.addConfigEntry(cfg.get(configCat.getConfigName(),
"showFriendNotifications", true, "Set to true to receive friends' login/logout messages, set to false hide them."),
new MooConfigPreview(new ChatComponentText("§aFriend > §r§aBob §ejoined.")));
@@ -442,6 +448,7 @@ public class MooConfig {
// Category: Notifications
doUpdateCheck = propDoUpdateCheck.getBoolean();
showBestFriendNotifications = propShowBestFriendNotifications.getBoolean();
+ enableBestFriendNotificationSound = propEnableBestFriendNotificationSound.getBoolean();
showFriendNotifications = propShowFriendNotifications.getBoolean();
showGuildNotifications = propShowGuildNotifications.getBoolean();
doBestFriendsOnlineCheck = propDoBestFriendsOnlineCheck.getBoolean();
@@ -490,6 +497,7 @@ public class MooConfig {
// Category: Notifications
propDoUpdateCheck.set(doUpdateCheck);
propShowBestFriendNotifications.set(showBestFriendNotifications);
+ propEnableBestFriendNotificationSound.set(enableBestFriendNotificationSound);
propShowFriendNotifications.set(showFriendNotifications);
propShowGuildNotifications.set(showGuildNotifications);
propDoBestFriendsOnlineCheck.set(doBestFriendsOnlineCheck);
@@ -610,7 +618,7 @@ public class MooConfig {
* @return true if notifications should be monitored
*/
public static boolean doMonitorNotifications() {
- return showBestFriendNotifications || !showFriendNotifications || !showGuildNotifications;
+ return showBestFriendNotifications || enableBestFriendNotificationSound || !showFriendNotifications || !showGuildNotifications;
}
// Category: SkyBlock
diff --git a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java
index 66a751b..32fb6d9 100644
--- a/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java
+++ b/src/main/java/de/cowtipper/cowlection/config/gui/MooConfigPreview.java
@@ -24,6 +24,8 @@ public class MooConfigPreview {
private final Type type;
private ItemStack[] items;
private IChatComponent chatComponent;
+ private Runnable previewRunnable;
+ private long nextPreviewAt;
public static ItemStack hoveredItem;
public static IChatComponent hoveredChatComponent;
public static MooConfigGui parent;
@@ -38,6 +40,15 @@ public class MooConfigPreview {
this.items = items;
}
+ public MooConfigPreview(String sound, float volume, float pitch) {
+ this.type = Type.RUNNABLE_ON_HOVER;
+ previewRunnable = () -> {
+ if (Minecraft.getMinecraft().thePlayer != null) {
+ Minecraft.getMinecraft().thePlayer.playSound(sound, volume, pitch);
+ }
+ };
+ }
+
public void drawPreview(int x, int y, int mouseX, int mouseY, boolean enablePreview) {
switch (type) {
case ITEM:
@@ -46,6 +57,9 @@ public class MooConfigPreview {
case CHAT:
drawChatPreview(x, y, mouseX, mouseY, enablePreview);
break;
+ case RUNNABLE_ON_HOVER:
+ drawButtonWithRunnablePreview(x, y, mouseX, mouseY, enablePreview);
+ break;
default:
// do nothing
break;
@@ -173,7 +187,22 @@ public class MooConfigPreview {
return new MooChatComponent(name).darkGreen().setHover(new MooChatComponent(gameMode).yellow().appendFreshSibling(new MooChatComponent("Online for " + onlineTime).white()));
}
+ private void drawButtonWithRunnablePreview(int x, int y, int mouseX, int mouseY, boolean enablePreview) {
+ FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
+ int currentX = x + 15;
+ int chatY = y + 20 / 2 - fontRenderer.FONT_HEIGHT / 2;
+
+ String previewText = "(hover me to preview)";
+ fontRenderer.drawStringWithShadow(previewText, currentX, chatY, 0xffffffff);
+ if (nextPreviewAt < Minecraft.getSystemTime()
+ && mouseY >= chatY && mouseY <= chatY + fontRenderer.FONT_HEIGHT
+ && mouseX > currentX && mouseX < currentX + fontRenderer.getStringWidth(previewText)) {
+ nextPreviewAt = Minecraft.getSystemTime() + 3000;
+ previewRunnable.run();
+ }
+ }
+
private enum Type {
- CHAT, ITEM
+ CHAT, ITEM, RUNNABLE_ON_HOVER
}
}
diff --git a/src/main/java/de/cowtipper/cowlection/listener/ChatListener.java b/src/main/java/de/cowtipper/cowlection/listener/ChatListener.java
index df1c673..0f61bb2 100644
--- a/src/main/java/de/cowtipper/cowlection/listener/ChatListener.java
+++ b/src/main/java/de/cowtipper/cowlection/listener/ChatListener.java
@@ -8,6 +8,7 @@ import de.cowtipper.cowlection.util.ApiUtils;
import de.cowtipper.cowlection.util.MooChatComponent;
import de.cowtipper.cowlection.util.Utils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiControls;
import net.minecraft.client.gui.GuiNewChat;
@@ -68,6 +69,9 @@ public class ChatListener {
switch (joinedLeft) {
case "joined":
main.getPlayerCache().addBestFriend(playerName);
+ if (MooConfig.enableBestFriendNotificationSound && Minecraft.getMinecraft().thePlayer != null) {
+ Minecraft.getMinecraft().thePlayer.playSound("random.pop", Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.MASTER), 1);
+ }
break;
case "left":
main.getPlayerCache().removeBestFriend(playerName);
diff --git a/src/main/resources/assets/cowlection/lang/en_US.lang b/src/main/resources/assets/cowlection/lang/en_US.lang
index c7cc85f..ba15568 100644
--- a/src/main/resources/assets/cowlection/lang/en_US.lang
+++ b/src/main/resources/assets/cowlection/lang/en_US.lang
@@ -22,6 +22,8 @@ cowlection.config.doUpdateCheck=Check for updates
cowlection.config.doUpdateCheck.tooltip=Check for mod updates when launching the game?
cowlection.config.showBestFriendNotifications=Show best friend notifications
cowlection.config.showBestFriendNotifications.tooltip=Set to true to receive best friends' login/logout messages, set to false hide them.
+cowlection.config.enableBestFriendNotificationSound=Play sound when best friend joins
+cowlection.config.enableBestFriendNotificationSound.tooltip=If enabled: plays a notification sound when a best friend comes online.
cowlection.config.showFriendNotifications=Show friend notifications
cowlection.config.showFriendNotifications.tooltip=Set to true to receive friends' login/logout messages, set to false hide them.
cowlection.config.showGuildNotifications=Show guild notifications