Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SoundCategory;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

Expand All @@ -13,6 +14,10 @@ public NoteBlockSongPlayer(Song song) {
super(song);
}

public NoteBlockSongPlayer(Song song, SoundCategory soundCategory) {
super(song, soundCategory);
}

public Block getNoteBlock() {
return noteBlock;
}
Expand Down Expand Up @@ -44,7 +49,7 @@ public void playTick(Player p, int tick) {
if (song.getCustomInstruments()[note.getInstrument() - Instrument.getCustomInstrumentFirstIndex()].getSound() != null){
p.playSound(noteBlock.getLocation(),
song.getCustomInstruments()[note.getInstrument() - Instrument.getCustomInstrumentFirstIndex()].getSound(),
((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
this.soundCategory,((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
NotePitch.getPitch(note.getKey() - 33));
}else {
p.playSound(noteBlock.getLocation(),
Expand All @@ -56,7 +61,7 @@ public void playTick(Player p, int tick) {
}else {
p.playSound(noteBlock.getLocation(),
Instrument.getInstrument(note.getInstrument()),
((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
this.soundCategory,((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
NotePitch.getPitch(note.getKey() - 33));
}

Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/xxmicloxx/NoteBlockAPI/PositionSongPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.SoundCategory;
import org.bukkit.entity.Player;

public class PositionSongPlayer extends SongPlayer {
Expand All @@ -13,6 +14,10 @@ public PositionSongPlayer(Song song) {
super(song);
}

public PositionSongPlayer(Song song, SoundCategory soundCategory) {
super(song, soundCategory);
}

public Location getTargetLocation() {
return targetLocation;
}
Expand All @@ -39,19 +44,19 @@ public void playTick(Player p, int tick) {
if (song.getCustomInstruments()[note.getInstrument() - Instrument.getCustomInstrumentFirstIndex()].getSound() != null){
p.playSound(targetLocation,
song.getCustomInstruments()[note.getInstrument() - Instrument.getCustomInstrumentFirstIndex()].getSound(),
((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
this.soundCategory,((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
NotePitch.getPitch(note.getKey() - 33));
}else {
p.playSound(targetLocation,
song.getCustomInstruments()[note.getInstrument() - Instrument.getCustomInstrumentFirstIndex()].getSoundfile(),
((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
this.soundCategory,((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
NotePitch.getPitch(note.getKey() - 33));
}

}else {
p.playSound(targetLocation,
Instrument.getInstrument(note.getInstrument()),
((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
this.soundCategory,((l.getVolume() * (int) volume * (int) playerVolume) / 1000000f) * ((1f/16f) * distance),
NotePitch.getPitch(note.getKey() - 33));
}

Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/xxmicloxx/NoteBlockAPI/RadioSongPlayer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xxmicloxx.NoteBlockAPI;

import org.bukkit.SoundCategory;
import org.bukkit.entity.Player;

public class RadioSongPlayer extends SongPlayer {
Expand All @@ -8,6 +9,10 @@ public RadioSongPlayer(Song song) {
super(song);
}

public RadioSongPlayer(Song song, SoundCategory soundCategory) {
super(song, soundCategory);
}

@Override
public void playTick(Player p, int tick) {
byte playerVolume = NoteBlockPlayerMain.getPlayerVolume(p);
Expand All @@ -21,19 +26,19 @@ public void playTick(Player p, int tick) {
if (song.getCustomInstruments()[note.getInstrument() - Instrument.getCustomInstrumentFirstIndex()].getSound() != null){
p.playSound(p.getEyeLocation(),
song.getCustomInstruments()[note.getInstrument() - Instrument.getCustomInstrumentFirstIndex()].getSound(),
(l.getVolume() * (int) volume * (int) playerVolume) / 1000000f,
this.soundCategory,(l.getVolume() * (int) volume * (int) playerVolume) / 1000000f,
NotePitch.getPitch(note.getKey() - 33));
}else {
p.playSound(p.getEyeLocation(),
song.getCustomInstruments()[note.getInstrument() - Instrument.getCustomInstrumentFirstIndex()].getSoundfile(),
(l.getVolume() * (int) volume * (int) playerVolume) / 1000000f,
this.soundCategory,(l.getVolume() * (int) volume * (int) playerVolume) / 1000000f,
NotePitch.getPitch(note.getKey() - 33));
}

}else {
p.playSound(p.getEyeLocation(),
Instrument.getInstrument(note.getInstrument()),
(l.getVolume() * (int) volume * (int) playerVolume) / 1000000f,
this.soundCategory,(l.getVolume() * (int) volume * (int) playerVolume) / 1000000f,
NotePitch.getPitch(note.getKey() - 33));
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/xxmicloxx/NoteBlockAPI/SongPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.concurrent.locks.ReentrantLock;

import org.bukkit.Bukkit;
import org.bukkit.SoundCategory;
import org.bukkit.entity.Player;

public abstract class SongPlayer {
Expand All @@ -28,9 +29,15 @@ public abstract class SongPlayer {
protected FadeType fadeType = FadeType.FADE_LINEAR;
private final Lock lock = new ReentrantLock();
protected NoteBlockPlayerMain plugin;
protected SoundCategory soundCategory;

public SongPlayer(Song song) {
this(song, SoundCategory.MASTER);
}

public SongPlayer(Song song, SoundCategory soundCategory) {
this.song = song;
this.soundCategory = soundCategory;
plugin = NoteBlockPlayerMain.plugin;
start();
}
Expand Down Expand Up @@ -258,4 +265,12 @@ public void setVolume(byte volume) {
public Song getSong() {
return song;
}

public SoundCategory getCategory() {
return soundCategory;
}

public void setCategory(SoundCategory soundCategory) {
this.soundCategory = soundCategory;
}
}