It works! After some bugfixes it's ready

This commit is contained in:
Norbi Peti 2017-11-16 22:05:02 +01:00
parent b5ee3f0244
commit f925439328
4 changed files with 20 additions and 8 deletions

View file

@ -6,3 +6,5 @@ commands:
usage: Please give a number between 0 and 16.
singlemap:
play:
stopplay:
aliases: stopsong

View file

@ -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);
}
}

View file

@ -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));
}

View file

@ -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!");