Skip to content

Conversation

@IndrajeethY
Copy link

No description provided.

@zefir-git zefir-git self-requested a review October 29, 2025 15:41
@zefir-git zefir-git added the feature A request, idea, or new functionality label Oct 29, 2025
@zefir-git zefir-git linked an issue Oct 29, 2025 that may be closed by this pull request
@zefir-git
Copy link
Member

For a873dd3 please open another PR

@IndrajeethY IndrajeethY force-pushed the main branch 2 times, most recently from 6716aee to d29225e Compare October 29, 2025 19:20
Comment on lines +95 to +99
if (!CloudnodeMSG.getInstance().getConfig().getBoolean("pm-sound.enabled", true)) return;

final String soundName = CloudnodeMSG.getInstance().getConfig().getString("pm-sound.sound", "BLOCK_NOTE_BLOCK_PLING");
final float volume = (float) CloudnodeMSG.getInstance().getConfig().getDouble("pm-sound.volume", 1.0);
final float pitch = (float) CloudnodeMSG.getInstance().getConfig().getDouble("pm-sound.pitch", 1.0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the pro.cloudnode.smp.cloudnodemsg.PluginConfig class for accessing the config

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sure, my bad didn't noticed it

Comment on lines +104 to +111
} catch (IllegalArgumentException | NoSuchFieldError | NullPointerException e) {
// fallback to a safe default if configured sound isn't available on this server version
try {
recPlayer.playSound(recPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, volume, pitch);
} catch (Throwable ignored) {
// silently ignore if no sound is available
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to log and do nothing, so e.g. something like

Suggested change
} catch (IllegalArgumentException | NoSuchFieldError | NullPointerException e) {
// fallback to a safe default if configured sound isn't available on this server version
try {
recPlayer.playSound(recPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, volume, pitch);
} catch (Throwable ignored) {
// silently ignore if no sound is available
}
}
} catch (Throwable e) {
CloudnodeMSG.getInstance().getLogger().log(Level.SEVERE, "Failed to play sound", e);
}

Comment on lines +112 to +114
} catch (Throwable ignored) {
// Ensure message sending never fails because of sound errors
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try/catch should not be needed as it would only cover the config access

Comment on lines -334 to +363
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty line at the end of the file should not be removed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry but, I don't see any empty lines there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 335 should be an empty line, you can just add it manually.

If you’re using IntelliJ, it’s possible to enable this setting:
image

Comment on lines +155 to +157


pm-sound:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should also be a way to do this for team messages, and make the config like.

sound:
  private:
    #
  team:
    #

Also I think it would be best to move this above the errors section so it’s not buried by all the errors.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, sounds reasonable, my personal intention was just to notify players about pm notification only since team message can be more spammy sometimes, but still yeah config might be a better choice for server owners to pick

Comment on lines +158 to +166
# Enable or disable playing a sound when a private message is received
enabled: true
# Sound to play on private message (Minecraft sound identifier)
# Examples: ENTITY_ALLAY_AMBIENT_WITH_ITEM, ENTITY_PLAYER_LEVELUP, etc.
sound: BLOCK_NOTE_BLOCK_PLINGt
# Volume of the sound (float). 1.0 is normal volume, increase to be louder.
volume: 1.0
# Pitch of the sound (float). 1.0 is normal pitch, lower for deeper, higher for sharper.
pitch: 1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some rewording of the explanations to be more consistent with the rest of the config.

Suggested change
# Enable or disable playing a sound when a private message is received
enabled: true
# Sound to play on private message (Minecraft sound identifier)
# Examples: ENTITY_ALLAY_AMBIENT_WITH_ITEM, ENTITY_PLAYER_LEVELUP, etc.
sound: BLOCK_NOTE_BLOCK_PLINGt
# Volume of the sound (float). 1.0 is normal volume, increase to be louder.
volume: 1.0
# Pitch of the sound (float). 1.0 is normal pitch, lower for deeper, higher for sharper.
pitch: 1.0
# Whether to play a sound when receiving a private message
enabled: false
# Minecraft sound identifier from https://jd.papermc.io/paper/1.20.4/org/bukkit/Sound.html
sound: BLOCK_NOTE_BLOCK_PLING
# Volume of the sound from 0.0 to 1.0. Decrease to be quieter.
volume: 1.0
# Pitch of the sound from 0.5 to 2.0. Values below 1.0 lower the pitch and increase the duration; values above 1.0 raise the pitch and reduce the duration.
pitch: 1.0

@zefir-git
Copy link
Member

I was also thinking about a command to let players toggle the sound for themselves. Feel free to add that if you want. Or I can just add it myself in another PR.

@zefir-git zefir-git changed the title Implemented notification sound for incoming pm msgs closes #70 Implemented notification sound for incoming messages Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A request, idea, or new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notification sound

2 participants