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.RPlayer;
|
||||
import de.steamwar.spectatesystem.elements.RTnT;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
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.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||
|
||||
@ -66,6 +68,24 @@ class PacketProcessor {
|
||||
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 {
|
||||
String message = source.rString();
|
||||
|
||||
@ -73,25 +93,36 @@ class PacketProcessor {
|
||||
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 {
|
||||
if (world == null) {
|
||||
world = Bukkit.getWorlds().get(0);
|
||||
}
|
||||
|
||||
int x = source.rInt();
|
||||
byte y = source.rByte();
|
||||
int z = 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));
|
||||
Bukkit.getScheduler().runTask(SpectateSystem.get(), () -> {
|
||||
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(){
|
||||
try{
|
||||
while(!source.isClosed()){
|
||||
@ -111,9 +142,18 @@ class PacketProcessor {
|
||||
case 0x04:
|
||||
entityAnimation();
|
||||
break;
|
||||
case 0x05:
|
||||
tntSpawn();
|
||||
break;
|
||||
case 0x06:
|
||||
entityVelocity();
|
||||
break;
|
||||
case 0x30:
|
||||
block();
|
||||
break;
|
||||
case 0x31:
|
||||
particle();
|
||||
break;
|
||||
case (byte) 0xA0:
|
||||
send(ChatMessageType.CHAT);
|
||||
break;
|
||||
|
@ -58,12 +58,12 @@ public abstract class REntity {
|
||||
}
|
||||
|
||||
public void sneak(boolean sneaking) {
|
||||
entity.setSneaking(sneaking);
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(0, entity.getDataWatcher(), sneaking);
|
||||
/*entity.setSneaking(sneaking);
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(7, entity.getDataWatcher(), sneaking);
|
||||
for(Player player : Bukkit.getOnlinePlayers()){
|
||||
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
|
||||
connection.sendPacket(packet);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
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){
|
||||
spawnEntity(((CraftPlayer)player).getHandle().playerConnection);
|
||||
}
|
||||
|
@ -3,5 +3,7 @@ package de.steamwar.spectatesystem.elements;
|
||||
public class 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