Skip to content

Commit f988404

Browse files
committed
Add sound effect volume control & bump version to 1.2.1
1 parent fee9f5d commit f988404

5 files changed

Lines changed: 54 additions & 6 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ org.gradle.daemon=false
55

66
modId = streamchatmod
77
modName = StreamChat
8-
version = 1.2
8+
version = 1.2.1
99
minecraftVersion = 1.8.9
1010
forgeVersion = 11.15.1.2318-1.8.9
1111
mappings = stable_22

src/main/java/me/mini_bomba/streamchatmod/StreamChatMod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void onTwitchMessage(ChannelMessageEvent event) {
117117
ChatStyle style = new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/twitch delete " + event.getChannel().getName() + " " + event.getMessageEvent().getMessageId().orElse("")));
118118
component.setChatStyle(style);
119119
StreamUtils.addMessage(component);
120-
if (this.config.playSoundOnMessage.getBoolean()) StreamUtils.playSound("note.pling", 0.1f, 1.25f);
120+
if (this.config.playSoundOnMessage.getBoolean()) StreamUtils.playSound("note.pling", (float) config.messageSoundVolume.getDouble(), 1.25f);
121121
}
122122

123123
private void onTwitchFollow(FollowEvent event) {

src/main/java/me/mini_bomba/streamchatmod/StreamConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class StreamConfig {
1515
public final Property playSoundOnMessage;
1616
public final Property playSoundOnFollow;
1717
public final Property followEventEnabled;
18+
public final Property messageSoundVolume;
19+
public final Property eventSoundVolume;
1820

1921
public StreamConfig(File configFile) {
2022
config = new Configuration(configFile);
@@ -25,6 +27,8 @@ public StreamConfig(File configFile) {
2527
twitchSelectedChannel = config.get("twitch", "selectedChannel", "");
2628
playSoundOnMessage = config.get("sounds", "onMessage", true);
2729
playSoundOnFollow = config.get("sounds", "onFollow", true);
30+
messageSoundVolume = config.get("sounds", "messageVolume", 1.0d);
31+
eventSoundVolume = config.get("sounds", "eventVolume", 1.0d);
2832
followEventEnabled = config.get("twitchEvents", "followers", true);
2933
saveIfChanged();
3034
}

src/main/java/me/mini_bomba/streamchatmod/StreamEvents.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public void onTick(TickEvent.ClientTickEvent event){
3030
if (mod.eventSoundTimer > -1) {
3131
int timer = mod.eventSoundTimer;
3232
if (timer == 0) {
33-
StreamUtils.playSound("note.harp", 0.25f, 1.0f);
33+
StreamUtils.playSound("note.harp", (float) mod.config.eventSoundVolume.getDouble(), 1.0f);
3434
} else if (timer == 5) {
35-
StreamUtils.playSound("note.harp", 0.25f, 1.25f);
35+
StreamUtils.playSound("note.harp", (float) mod.config.eventSoundVolume.getDouble(), 1.25f);
3636
} else if (timer == 10) {
37-
StreamUtils.playSound("note.harp", 0.25f, 1.5f);
37+
StreamUtils.playSound("note.harp", (float) mod.config.eventSoundVolume.getDouble(), 1.5f);
3838
}
3939
mod.eventSoundTimer++;
4040
if (mod.eventSoundTimer >= 11) mod.eventSoundTimer = -1;

src/main/java/me/mini_bomba/streamchatmod/commands/TwitchCommand.java

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,55 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
128128
}
129129
}
130130
break;
131+
case "messagevolume":
132+
case "msgvolume":
133+
case "mvolume":
134+
case "messagev":
135+
case "msgv":
136+
case "mv":
137+
if (args.length == 2)
138+
StreamUtils.addMessage(EnumChatFormatting.AQUA + "Volume for message sound effects: " + EnumChatFormatting.GREEN + mod.config.messageSoundVolume.getDouble() * 100 + "%");
139+
else {
140+
double newState;
141+
try {
142+
newState = Double.parseDouble(args[2]);
143+
} catch (NumberFormatException e) {
144+
throw new CommandException("Invalid double value: " + args[2]);
145+
}
146+
if (newState > 1) newState /= 100;
147+
mod.config.messageSoundVolume.set(newState);
148+
mod.config.saveIfChanged();
149+
StreamUtils.addMessage(EnumChatFormatting.GREEN + "Volume for message sound effects has been set to " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD + newState * 100 + "%");
150+
}
151+
break;
152+
case "eventvolume":
153+
case "eventsvolume":
154+
case "evolume":
155+
case "eventv":
156+
case "eventsv":
157+
case "ev":
158+
if (args.length == 2)
159+
StreamUtils.addMessage(EnumChatFormatting.AQUA + "Volume for event sound effects: " + EnumChatFormatting.GREEN + mod.config.eventSoundVolume.getDouble() * 100 + "%");
160+
else {
161+
double newState;
162+
try {
163+
newState = Double.parseDouble(args[2]);
164+
} catch (NumberFormatException e) {
165+
throw new CommandException("Invalid double value: " + args[2]);
166+
}
167+
if (newState > 1) newState /= 100;
168+
mod.config.eventSoundVolume.set(newState);
169+
mod.config.saveIfChanged();
170+
StreamUtils.addMessage(EnumChatFormatting.GREEN + "Volume for event sound effects has been set to " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD + newState * 100 + "%");
171+
}
172+
break;
131173
default:
132174
StreamUtils.addMessages(sender, new String[]{
133175
EnumChatFormatting.GREEN + "Usage of /twitch sounds:",
134176
EnumChatFormatting.GRAY + "/twitch sounds message [enable/disable]"+EnumChatFormatting.WHITE+" - "+EnumChatFormatting.AQUA+"Enables/disables sound effect on new twitch chat message.",
135-
EnumChatFormatting.GRAY + "/twitch sounds follow [enable/disable]"+EnumChatFormatting.WHITE+" - "+EnumChatFormatting.AQUA+"Enables/disables sound effect on new twitch follower."
177+
EnumChatFormatting.GRAY + "/twitch sounds follow [enable/disable]"+EnumChatFormatting.WHITE+" - "+EnumChatFormatting.AQUA+"Enables/disables sound effect on new twitch follower.",
178+
EnumChatFormatting.GRAY + "/twitch sounds messagevolume [new volume]"+EnumChatFormatting.WHITE+" - "+EnumChatFormatting.AQUA+"Controls the volume of sounds effects for new messages.",
179+
EnumChatFormatting.GRAY + "/twitch sounds eventvolume [new volume]"+EnumChatFormatting.WHITE+" - "+EnumChatFormatting.AQUA+"Controls the volume of sounds effects for events like new followers."
136180
});
137181
}
138182
break;

0 commit comments

Comments
 (0)