diff --git a/src/de/steamwar/spectatesystem/PacketProcessor.java b/src/de/steamwar/spectatesystem/PacketProcessor.java index 198bc60..e4c2e8d 100644 --- a/src/de/steamwar/spectatesystem/PacketProcessor.java +++ b/src/de/steamwar/spectatesystem/PacketProcessor.java @@ -8,9 +8,7 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import net.minecraft.server.v1_15_R1.Block; -import org.bukkit.Bukkit; -import org.bukkit.Particle; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData; import java.io.EOFException; @@ -123,6 +121,25 @@ class PacketProcessor { }); } + private void sound() throws IOException { + double x = source.rDouble(); + double y = source.rDouble(); + double z = source.rDouble(); + + String soundName = source.rString(); + String soundCategory = source.rString(); + + float volume = source.rFloat(); + float pitch = source.rFloat(); + + Sound sound = Sound.valueOf(soundName); + SoundCategory sCategory = SoundCategory.valueOf(soundCategory); + + Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> { + world.playSound(new Location(world, x, y, z), sound, sCategory, volume, pitch); + }); + } + private void process(){ try{ while(!source.isClosed()){ @@ -154,6 +171,9 @@ class PacketProcessor { case 0x31: particle(); break; + case 0x32: + sound(); + break; case (byte) 0xA0: send(ChatMessageType.CHAT); break; diff --git a/src/de/steamwar/spectatesystem/elements/REntity.java b/src/de/steamwar/spectatesystem/elements/REntity.java index 44e39b2..f3892e5 100644 --- a/src/de/steamwar/spectatesystem/elements/REntity.java +++ b/src/de/steamwar/spectatesystem/elements/REntity.java @@ -76,6 +76,11 @@ public abstract class REntity { public void setMotion(double dX, double dY, double dZ) { entity.setMot(dX, dY, dZ); + PacketPlayOutEntityVelocity packet = new PacketPlayOutEntityVelocity(entity); + for(Player player : Bukkit.getOnlinePlayers()){ + PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; + connection.sendPacket(packet); + } } private void sendToPlayer(Player player){