aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/cowtipper/cowlection
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/cowtipper/cowlection')
-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
3 files changed, 43 insertions, 2 deletions
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);