Fixes, it kind of works with maps

This commit is contained in:
Norbi Peti 2017-11-06 22:53:39 +01:00
parent 3d36ca8079
commit f410469b61
5 changed files with 27 additions and 10 deletions

View file

@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>

View file

@ -1,4 +1,4 @@
name: AudioSpectrum name: AudioSpectrum
main: tk.sznp.audiospectrum.PluginMain main: io.github.norbipeti.audiospectrum.PluginMain
version: 1.0 version: 4.0
commands: commands:

View file

@ -16,6 +16,14 @@
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<resources>
<resource>
<directory>.</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>
</build> </build>
<repositories> <repositories>
<repository> <repository>

View file

@ -1,9 +1,7 @@
package io.github.norbipeti.audiospectrum; package io.github.norbipeti.audiospectrum;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas; import org.bukkit.map.*;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
public class BarsRenderer extends MapRenderer public class BarsRenderer extends MapRenderer
{ {
@ -14,9 +12,15 @@ public class BarsRenderer extends MapRenderer
this.bars = bars; this.bars = bars;
} }
@SuppressWarnings("deprecation")
@Override @Override
public void render(MapView arg0, MapCanvas arg1, Player arg2) public void render(MapView mv, MapCanvas mc, Player pl)
{ { //Width: 16, empty space: 16, count per map: 8
int offsetx = mv.getId() % 2 * 8, offsety = mv.getId() < 2 ? -128 : 0;
//System.out.println("OX: " + offsetx + " OY: " + offsety + " ID: " + mv.getId());
for (int i = offsetx; i < offsetx + 8; i++)
for (int j = 0; j < bars[i] + offsety; j++)
for (int k = 0; k < 16; k++)
mc.setPixel(i * 32 + k, 128 - j, MapPalette.matchColor(255 - j + offsety, j - offsety, 0)); //TODO: Fix
} }
} }

View file

@ -4,6 +4,8 @@ import java.io.IOException;
import java.net.DatagramPacket; import java.net.DatagramPacket;
import java.net.DatagramSocket; import java.net.DatagramSocket;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Arrays;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.map.MapView; import org.bukkit.map.MapView;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -61,7 +63,10 @@ public class PluginMain extends JavaPlugin
while (running) while (running)
{ {
serverSocket.receive(receivePacket); serverSocket.receive(receivePacket);
bars[Byte.toUnsignedInt(packet[0])] = Byte.toUnsignedInt(packet[1]); //bars[Byte.toUnsignedInt(packet[0])] = Byte.toUnsignedInt(packet[1]);
//System.out.println("Index: " + Byte.toUnsignedInt(packet[0]) + " Value: " + bars[Byte.toUnsignedInt(packet[0])]);
for (int i = 0; i < packet.length && i < bars.length; i++)
bars[i] = Byte.toUnsignedInt(packet[i]);
} }
} catch (IOException e) } catch (IOException e)
{ {