Add Particle
Add TNT Add Motion
Dieser Commit ist enthalten in:
Ursprung
1a1bd8fb54
Commit
d5910ea7b2
@ -2,12 +2,14 @@ package de.steamwar.spectatesystem;
|
|||||||
|
|
||||||
import de.steamwar.spectatesystem.elements.REntity;
|
import de.steamwar.spectatesystem.elements.REntity;
|
||||||
import de.steamwar.spectatesystem.elements.RPlayer;
|
import de.steamwar.spectatesystem.elements.RPlayer;
|
||||||
|
import de.steamwar.spectatesystem.elements.RTnT;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.minecraft.server.v1_15_R1.Block;
|
import net.minecraft.server.v1_15_R1.Block;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||||
|
|
||||||
@ -66,6 +68,24 @@ class PacketProcessor {
|
|||||||
REntity.getEntity(entityId).animation(animation);
|
REntity.getEntity(entityId).animation(animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tntSpawn() throws IOException {
|
||||||
|
int entityId = source.rInt();
|
||||||
|
|
||||||
|
new RTnT(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void entityVelocity() throws IOException {
|
||||||
|
int entityId = source.rInt();
|
||||||
|
|
||||||
|
double dX = source.rDouble();
|
||||||
|
double dY = source.rDouble();
|
||||||
|
double dZ = source.rDouble();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
|
||||||
|
REntity.getEntity(entityId).setMotion(dX, dY, dZ);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void send(ChatMessageType type) throws IOException {
|
private void send(ChatMessageType type) throws IOException {
|
||||||
String message = source.rString();
|
String message = source.rString();
|
||||||
|
|
||||||
@ -73,25 +93,36 @@ class PacketProcessor {
|
|||||||
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(type, text));
|
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(type, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
private World world = null;
|
private static final World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
private void block() throws IOException {
|
private void block() throws IOException {
|
||||||
if (world == null) {
|
|
||||||
world = Bukkit.getWorlds().get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int x = source.rInt();
|
int x = source.rInt();
|
||||||
byte y = source.rByte();
|
byte y = source.rByte();
|
||||||
int z = source.rInt();
|
int z = source.rInt();
|
||||||
|
|
||||||
int blockState = source.rInt();
|
int blockState = source.rInt();
|
||||||
|
|
||||||
|
if (Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) {
|
||||||
|
blockState = Config.ObfuscateWith;
|
||||||
|
}
|
||||||
CraftBlockData craftBlockData = CraftBlockData.fromData(Block.REGISTRY_ID.fromId(blockState));
|
CraftBlockData craftBlockData = CraftBlockData.fromData(Block.REGISTRY_ID.fromId(blockState));
|
||||||
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
|
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
|
||||||
world.getBlockAt(x, y, z).setBlockData(craftBlockData);
|
world.getBlockAt(x, y, z).setBlockData(craftBlockData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void particle() throws IOException {
|
||||||
|
double x = source.rDouble();
|
||||||
|
double y = source.rDouble();
|
||||||
|
double z = source.rDouble();
|
||||||
|
|
||||||
|
String particleName = source.rString();
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
|
||||||
|
world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void process(){
|
private void process(){
|
||||||
try{
|
try{
|
||||||
while(!source.isClosed()){
|
while(!source.isClosed()){
|
||||||
@ -111,9 +142,18 @@ class PacketProcessor {
|
|||||||
case 0x04:
|
case 0x04:
|
||||||
entityAnimation();
|
entityAnimation();
|
||||||
break;
|
break;
|
||||||
|
case 0x05:
|
||||||
|
tntSpawn();
|
||||||
|
break;
|
||||||
|
case 0x06:
|
||||||
|
entityVelocity();
|
||||||
|
break;
|
||||||
case 0x30:
|
case 0x30:
|
||||||
block();
|
block();
|
||||||
break;
|
break;
|
||||||
|
case 0x31:
|
||||||
|
particle();
|
||||||
|
break;
|
||||||
case (byte) 0xA0:
|
case (byte) 0xA0:
|
||||||
send(ChatMessageType.CHAT);
|
send(ChatMessageType.CHAT);
|
||||||
break;
|
break;
|
||||||
|
@ -58,12 +58,12 @@ public abstract class REntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sneak(boolean sneaking) {
|
public void sneak(boolean sneaking) {
|
||||||
entity.setSneaking(sneaking);
|
/*entity.setSneaking(sneaking);
|
||||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(0, entity.getDataWatcher(), sneaking);
|
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(7, entity.getDataWatcher(), sneaking);
|
||||||
for(Player player : Bukkit.getOnlinePlayers()){
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
|
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
|
||||||
connection.sendPacket(packet);
|
connection.sendPacket(packet);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void animation(byte animation) {
|
public void animation(byte animation) {
|
||||||
@ -74,6 +74,10 @@ public abstract class REntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMotion(double dX, double dY, double dZ) {
|
||||||
|
entity.setMot(dX, dY, dZ);
|
||||||
|
}
|
||||||
|
|
||||||
private void sendToPlayer(Player player){
|
private void sendToPlayer(Player player){
|
||||||
spawnEntity(((CraftPlayer)player).getHandle().playerConnection);
|
spawnEntity(((CraftPlayer)player).getHandle().playerConnection);
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,7 @@ package de.steamwar.spectatesystem.elements;
|
|||||||
public class RParticle {
|
public class RParticle {
|
||||||
|
|
||||||
public RParticle() {
|
public RParticle() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
29
src/de/steamwar/spectatesystem/elements/RTnT.java
Normale Datei
29
src/de/steamwar/spectatesystem/elements/RTnT.java
Normale Datei
@ -0,0 +1,29 @@
|
|||||||
|
package de.steamwar.spectatesystem.elements;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_15_R1.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
|
|
||||||
|
public class RTnT extends REntity {
|
||||||
|
|
||||||
|
private static World world = null;
|
||||||
|
|
||||||
|
public RTnT(int internalId) {
|
||||||
|
super(internalId, createTnT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void spawnEntity(PlayerConnection connection) {
|
||||||
|
connection.sendPacket(new PacketPlayOutSpawnEntity(entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static EntityTNTPrimed createTnT() {
|
||||||
|
if (world == null) {
|
||||||
|
MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
|
world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
||||||
|
}
|
||||||
|
return new EntityTNTPrimed(world, 0, 0, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren