Fixes, fixes, fixes

This commit is contained in:
Norbi Peti 2017-11-20 13:14:31 +01:00
parent 410e1351ee
commit e1d185dbe9
4 changed files with 6 additions and 12 deletions

View file

@ -75,7 +75,7 @@ public class Analyzer //Based on NativeBass example 'Spectrum'
return floats;
}
private ByteBuffer buffer;
private volatile ByteBuffer buffer;
private TimerTask tt;
public boolean run(CommandSender sender)
@ -104,13 +104,10 @@ public class Analyzer //Based on NativeBass example 'Spectrum'
public boolean start(CommandSender sender, String file)
{
if (playing)
tt.cancel();
if (!playFile(sender, file))
{
// start a file playing
BASS_Free();
stop();
return false;
}
// setup update timer (50hz)
timer.scheduleAtFixedRate(tt = new TimerTask()
{

View file

@ -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 < Math.sqrt(an.playing() ? bars.get((offsetx + i) * 64) : 0) * 1280 + offsety
j < Math.sqrt(an.playing() ? bars.get((offsetx + i) * 64) : 0) * 2560 + offsety
? MapPalette.matchColor(j - offsety, 255 - j + offsety, 0)
: MapPalette.matchColor(Color.BLACK));
}

View file

@ -6,7 +6,7 @@ import org.bukkit.map.MapRenderer;
public abstract class BarsRendererBase extends MapRenderer
{
protected FloatBuffer bars;
protected volatile FloatBuffer bars;
protected byte firstrender = 0;
protected byte count = 16;

View file

@ -5,7 +5,6 @@ import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.FloatBuffer;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Enumeration;
@ -21,8 +20,6 @@ import org.bukkit.plugin.java.JavaPlugin;
public class PluginMain extends JavaPlugin
{
@SuppressWarnings("unused") //Assignment in method call isn't counted as use
private volatile FloatBuffer bars;
private BarsRenderer br;
private Analyzer an;
@ -56,7 +53,7 @@ public class PluginMain extends JavaPlugin
jar.close();
for (File f : getDataFolder().listFiles())
addLibraryPath(f.getAbsolutePath());
br = new BarsRenderer(bars = an.init(), an);
br = new BarsRenderer(an.init(), an);
for (short i = 0; i < 4; i++)
{
MapView map = Bukkit.getMap(i);