diff --git a/plugin.yml b/plugin.yml index 67a2622..ece4d90 100644 --- a/plugin.yml +++ b/plugin.yml @@ -5,4 +5,6 @@ commands: barcount: usage: Please give a number between 0 and 16. singlemap: - play: \ No newline at end of file + play: + stopplay: + aliases: stopsong \ No newline at end of file diff --git a/src/io/github/norbipeti/audiospectrum/Analyzer.java b/src/io/github/norbipeti/audiospectrum/Analyzer.java index 5bb288a..886b1df 100644 --- a/src/io/github/norbipeti/audiospectrum/Analyzer.java +++ b/src/io/github/norbipeti/audiospectrum/Analyzer.java @@ -4,8 +4,6 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import static jouvieje.bass.Bass.*; import static jouvieje.bass.defines.BASS_MUSIC.BASS_MUSIC_RAMP; -import static jouvieje.bass.defines.BASS_SAMPLE.BASS_SAMPLE_LOOP; - import static jouvieje.bass.defines.BASS_DATA.BASS_DATA_FFT2048; import static jouvieje.bass.utils.BufferUtils.newByteBuffer; import static jouvieje.bass.utils.BufferUtils.SIZEOF_FLOAT; @@ -91,7 +89,7 @@ public class Analyzer //Based on NativeBass example 'Spectrum' if (((BASS_GetVersion() & 0xFFFF0000) >> 16) != BassInit.BASSVERSION()) { printfExit("An incorrect version of BASS.DLL was loaded"); - return false; + return false; //TODO: Decide whether to init in run, or move it out into init(), if no move, stop() should be used instead of stopPlaying() } // initialize BASS @@ -146,8 +144,8 @@ public class Analyzer //Based on NativeBass example 'Spectrum' } HSTREAM stream = null; HMUSIC music = null; - if ((stream = BASS_StreamCreateFile(false, file, 0, 0, BASS_SAMPLE_LOOP)) == null - && (music = BASS_MusicLoad(false, file, 0, 0, BASS_MUSIC_RAMP | BASS_SAMPLE_LOOP, 0)) == null) + if ((stream = BASS_StreamCreateFile(false, file, 0, 0, 0)) == null //No loop + && (music = BASS_MusicLoad(false, file, 0, 0, BASS_MUSIC_RAMP, 0)) == null) //No loop { error("Can't play file", sender); return false; // Can't load the file @@ -160,4 +158,9 @@ public class Analyzer //Based on NativeBass example 'Spectrum' } private Timer timer = new Timer(); + + public boolean stopPlaying() + { + return BASS_ChannelStop(chan); + } } diff --git a/src/io/github/norbipeti/audiospectrum/BarsRenderer.java b/src/io/github/norbipeti/audiospectrum/BarsRenderer.java index 0e3546e..9de5d02 100644 --- a/src/io/github/norbipeti/audiospectrum/BarsRenderer.java +++ b/src/io/github/norbipeti/audiospectrum/BarsRenderer.java @@ -32,7 +32,7 @@ public class BarsRenderer extends BarsRendererBase for (int i = 0; i < 16 && i < count; i++) for (int j = 0; j < 128; j++) for (int k = 0; k < 4; k++) - mc.setPixel(i * 8 + k, 128 - j, j < bars.get(i * 64) / 2 + mc.setPixel(i * 8 + k, 128 - j, j < Math.sqrt(bars.get(i * 64)) * 1280 ? MapPalette.matchColor(j, 255 - j * 2, 0) : MapPalette.matchColor(Color.BLACK)); return; } @@ -41,7 +41,7 @@ public class BarsRenderer extends BarsRendererBase for (int j = 0; j < 128; j++) for (int k = 0; k < 8; k++) mc.setPixel(i * 16 + k, 128 - j, - j < bars.get((offsetx + i) * 64) + offsety + j < Math.sqrt(bars.get((offsetx + i) * 64)) * 1280 + offsety ? MapPalette.matchColor(j - offsety, 255 - j + offsety, 0) : MapPalette.matchColor(Color.BLACK)); } diff --git a/src/io/github/norbipeti/audiospectrum/PluginMain.java b/src/io/github/norbipeti/audiospectrum/PluginMain.java index c60b4f2..23026cf 100644 --- a/src/io/github/norbipeti/audiospectrum/PluginMain.java +++ b/src/io/github/norbipeti/audiospectrum/PluginMain.java @@ -107,6 +107,13 @@ public class PluginMain extends JavaPlugin else sender.sendMessage("§cFailed to play music."); return true; + } else if (command.getName().equalsIgnoreCase("stopplay")) + { + if (an.stopPlaying()) + sender.sendMessage("Stopped playing music"); + else + sender.sendMessage("§cCan't stop the party!"); + return true; } else { sender.sendMessage("Command not implemented!");