The one commit

This commit is contained in:
Norbi Peti 2015-10-24 00:52:27 +02:00
commit 8d3e508064
8 changed files with 163 additions and 0 deletions

7
.classpath Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="lib" path="D:/Z - Norbi cucca/0 Projektek/TheButtonMCAutoFlairProto/Spigot server (build)/Spigot/Spigot-API/target/spigot-api-1.8.7-R0.1-SNAPSHOT-shaded.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
.project Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AudioSpectrum</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5

Binary file not shown.

Binary file not shown.

Binary file not shown.

4
plugin.yml Normal file
View file

@ -0,0 +1,4 @@
name: AudioSpectrum
main: tk.sznp.audiospectrum.PluginMain
version: 1.0
commands:

View file

@ -0,0 +1,124 @@
package tk.sznp.audiospectrum;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.java.JavaPlugin;
public class PluginMain extends JavaPlugin {
private Thread thread;
private boolean running = false;
// Fired when plugin is first enabled
@Override
public void onEnable() {
thread = new Thread() {
// Runnable runnable=new Runnable() {
public void run() {
PluginMain.this.run(5896);
}
};
running = true;
thread.start();
// runnable.run();
}
// Fired when plugin is disabled
@Override
public void onDisable() {
running = false;
}
private volatile Player player;
private volatile int moveup;
private volatile byte[] packet;
private volatile boolean runningtask;
public void run(int port) {
DatagramSocket serverSocket = null;
try {
serverSocket = new DatagramSocket(port);
byte[] receiveData = new byte[8];
System.out.printf("Listening on udp:%s:%d%n", InetAddress
.getLocalHost().getHostAddress(), port);
DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length);
while (running) {
serverSocket.receive(receivePacket);
packet = receivePacket.getData();
player = null;
try {
player = Bukkit.getPlayer("NorbiPeti");
} catch (Exception e) {
}
/*
* getServer().dispatchCommand( getServer().getConsoleSender(),
* String.format("scoreboard players set t%d tracks %d",
* packet[0], Byte.toUnsignedInt(packet[1]))); //TODO: Teljesen
* szerveroldali legyen
*/
if (player == null)
continue;
moveup = 0;
// System.out.println("Packet[1]: " + packet[1]);
Runnable runnable = new Runnable() {
public void run() {
while (true) {
if (player == null) {
System.out.println("Player is null");
return;
}
Block block = player.getWorld().getBlockAt(
129 - packet[0], 56 + moveup, -654);
if (Byte.toUnsignedInt(packet[1]) - moveup * 16 > 16) {
block.setType(Material.SNOW_BLOCK);
block.getState().setData(
new MaterialData(Material.SNOW_BLOCK,
(byte) 0));
} else {
block.setType(Material.SNOW);
MaterialData data = new MaterialData(
Material.SNOW);
data.setData((byte) (Byte
.toUnsignedInt(packet[1]) - moveup));
block.getState().setData(data);
}
if (Byte.toUnsignedInt(packet[1]) - moveup * 16 > 16)
moveup += 1;
else
break;
}
for(int i=56+moveup+1; i<255; i++)
{
Block block = player.getWorld().getBlockAt(
129 - packet[0], i, -654);
block.setType(Material.AIR);
}
runningtask = false;
}
};
try {
runningtask = true;
getServer().getScheduler().runTask(this, runnable);
while (runningtask)
;
} catch (Exception e) {
}
}
} catch (IOException e) {
System.out.println(e);
} finally {
serverSocket.close();
}
}
}