From 8d3e5080645043e26a98cf2154be3d36dea92dff Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 24 Oct 2015 00:52:27 +0200 Subject: [PATCH] The one commit --- .classpath | 7 ++ .project | 17 +++ .settings/org.eclipse.jdt.core.prefs | 11 ++ bin/tk/sznp/audiospectrum/PluginMain$1.class | Bin 0 -> 623 bytes bin/tk/sznp/audiospectrum/PluginMain$2.class | Bin 0 -> 2292 bytes bin/tk/sznp/audiospectrum/PluginMain.class | Bin 0 -> 3230 bytes plugin.yml | 4 + src/tk/sznp/audiospectrum/PluginMain.java | 124 +++++++++++++++++++ 8 files changed, 163 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 bin/tk/sznp/audiospectrum/PluginMain$1.class create mode 100644 bin/tk/sznp/audiospectrum/PluginMain$2.class create mode 100644 bin/tk/sznp/audiospectrum/PluginMain.class create mode 100644 plugin.yml create mode 100644 src/tk/sznp/audiospectrum/PluginMain.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..672ffe6 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..7832a3f --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + AudioSpectrum + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..416f4fb --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/bin/tk/sznp/audiospectrum/PluginMain$1.class b/bin/tk/sznp/audiospectrum/PluginMain$1.class new file mode 100644 index 0000000000000000000000000000000000000000..0fda02775ddc0cd0b23d94f2319a7d066c0a8f20 GIT binary patch literal 623 zcmah`T}uK%6g}gbtLv5@m1dt324>LaTT%2P27*SA_&(~OQ|qkkM-Tn0pbzMwAJC7A z?wC;Y;==CSd+xbs&%N{c_5J~%jy)4GhW+r~2_Dtd;n7ff!Bh-FKbkl|O`JN5-1G9<#W3@Rt2(Ox8SPV5V*WO&JNP+d$v>@ma}-cY2#khZae zgarf3HcYHA7*$Qkw51Z)(WEc@F7La7A>Z}}-0g8+>U<8ywM~Y~!oODPWYh2?Wnmpf z69tCyqQPveVuQR^TiTIz>qY)RTuE&v^Si@iy*xsiYT$Z-RHKdv$KKG!j-DpzsiyiF zz-}oe{D#YeKm;h$@CMx#%VzZkD2mZ*B1w3PqEpH>V%3gb=<^2qX~xNDY*t~^S3s6> zn|d^wL!M4XwpZpVXT;RCbnO{du9$qq+JBi6HE#ZqNzY{rl&CRAwJkd1w6<;RQe=^! HmZaw!gbsy$ literal 0 HcmV?d00001 diff --git a/bin/tk/sznp/audiospectrum/PluginMain$2.class b/bin/tk/sznp/audiospectrum/PluginMain$2.class new file mode 100644 index 0000000000000000000000000000000000000000..c44be1bce6e5cea6c5a535154791d7e48a613e05 GIT binary patch literal 2292 zcma)7TW=dh6#m9`yRox0PSS*w(B?u?oC|esK#D^{oVMV`j?*}Cnx<{CwijpP^=`Vm zF1TDIB-95a9>OmG2^5L9Mvx0gydoj-!XH554lGq zmuElx1Yj5+3-B;>TZORsSlbLsrJSOhn{w7NO2zP;TFNV0LQ=Gz5dl7i;D+=_3agTq z4<|Dll#CE=w$c4G=pzi&&hr; zJSRdxT>xG*i0~uG;0sRdscFej_`G8DahMD}C!X3fLNL8X zNeke4ToBO4(0Ni~B3?i{L!Fe(%BD@mwbP^**NuEQQz{e`D=cf4VwFh=sVo~2KQ5v} zz@=kKq{^lx7e#cUixBE1i=icMOQPuEIYZH`lx4_LF;a(@7|uDNIu)~1E2(M#y?9x` zWrpS&TSSD=#~^I-D5^$*Lr!G71SqVc$>?pH;;hS#gRM^0H&v3guZM8F%wtt$x|mWT)1^oAsBJSgXlM)YYi|%r-c|KJxr+iI>#F_PR zW;v!T$CTt>B-ees>&TPl)wM1{!A7;Zs7y~&n=$7k(y+)+@=nF(c{E+bCLUI!jh!yq zU4Flvu^Axg+{(FFq1(!rvzh32d(4)Q?*N*^M>*;Hp=G+qK zANU?({~pdgwS5}7&0gWVZ=s3iBJJVUW}K&yN*_TdipNVnUNQ~$e+O|Ntv^HD!HZ4Z zyXbjZF&&_vp%I@r(;@F@E;#OdkF7QSZ5&|Shj?YtH@c5&mBnCiJr@jqjoyJBTtC1q z4+ah}$M7Q-mdWDXL;3*A9&BTRJXUQFXKi&4nZ#g?kh!g0 tqCb^Ir+V-w;d+Gkz-YhUUiDA`yiXZ;P$o=(kDBWPLdFY*>Y7G+{sH*xPZj_G literal 0 HcmV?d00001 diff --git a/bin/tk/sznp/audiospectrum/PluginMain.class b/bin/tk/sznp/audiospectrum/PluginMain.class new file mode 100644 index 0000000000000000000000000000000000000000..b556cd439c26bbf409bc64bf10d6d8d59c5de2d3 GIT binary patch literal 3230 zcma)8YgZFj6y3uk6T&DDMMbcJf+kUnB31$W5XFM>(oig7ZHF+zKr)kNCMarO_WiO? zTT5G8*J>AE{7~D1TCKLLAG%h5Q&;W2GYJeVtmMPo=RW7$bN1agfB*aIT>v|9RYs14 zDtjzqoi&mXH9e%8R#J=EsdOUJ6HgE8MyIM9GV&x;o2lW*V0vs!wV%e(u(rcvSu8A?*U9#>O;TLe4;ogu;wDTeZfxwpTZF`*8`m!BC%sy#3~o7CH9S_S6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Tgq`ITk#upoBseD0}X-z literal 0 HcmV?d00001 diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 0000000..0d4c203 --- /dev/null +++ b/plugin.yml @@ -0,0 +1,4 @@ +name: AudioSpectrum +main: tk.sznp.audiospectrum.PluginMain +version: 1.0 +commands: diff --git a/src/tk/sznp/audiospectrum/PluginMain.java b/src/tk/sznp/audiospectrum/PluginMain.java new file mode 100644 index 0000000..2b5a06f --- /dev/null +++ b/src/tk/sznp/audiospectrum/PluginMain.java @@ -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(); + } + } +}