Randomizes the working sound somewhat

This commit is contained in:
Kristian Knarvik 2024-07-28 17:15:25 +02:00
parent 904adf46f0
commit 384893b01a
2 changed files with 11 additions and 7 deletions

View File

@ -23,13 +23,13 @@ public class NPCSoundEvent extends AbstractBlacksmithPluginEvent implements Canc
/** /**
* Instantiates a new NPC sound event * Instantiates a new NPC sound event
* *
* @param npc <p>The NPC playing the sound</p> * @param npc <p>The NPC playing the sound</p>
* @param player <p>The player whose interaction triggered the sound</p> * @param player <p>The player whose interaction triggered the sound</p>
* @param soundCategory <p>The category the sound is to play in</p> * @param soundCategory <p>The category the sound is to play in</p>
* @param sound <p>The sound to play</p> * @param sound <p>The sound to play</p>
* @param volume <p>The volume of the played sound</p> * @param volume <p>The volume of the played sound</p>
* @param pitch <p>The pitch of the played sound</p> * @param pitch <p>The pitch of the played sound</p>
*/ */
public NPCSoundEvent(@NotNull NPC npc, @NotNull Player player, @NotNull SoundCategory soundCategory, public NPCSoundEvent(@NotNull NPC npc, @NotNull Player player, @NotNull SoundCategory soundCategory,
@NotNull Sound sound, float volume, float pitch) { @NotNull Sound sound, float volume, float pitch) {

View File

@ -108,7 +108,11 @@ public abstract class Session implements Runnable {
taskId = scheduler.scheduleSyncDelayedTask(BlacksmithPlugin.getInstance(), this, actionDelay * 20L); taskId = scheduler.scheduleSyncDelayedTask(BlacksmithPlugin.getInstance(), this, actionDelay * 20L);
int playWorkSound = scheduler.scheduleSyncRepeatingTask(BlacksmithPlugin.getInstance(), int playWorkSound = scheduler.scheduleSyncRepeatingTask(BlacksmithPlugin.getInstance(),
this::playWorkSound, 20, 20); () -> {
if (random.nextInt(100) < 20) {
this.playWorkSound();
}
}, 20, 5);
scheduler.scheduleSyncDelayedTask(BlacksmithPlugin.getInstance(), () -> scheduler.cancelTask(playWorkSound), scheduler.scheduleSyncDelayedTask(BlacksmithPlugin.getInstance(), () -> scheduler.cancelTask(playWorkSound),
(actionDelay * 20L) - 20); (actionDelay * 20L) - 20);
} }