From 36d6c6bedbd6ee24e8adec7fcb4b5768ad3f1436 Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 16 Nov 2020 07:28:49 +0100 Subject: [PATCH] Fix CommandTPSLimiter --- .../bausystem/commands/CommandTPSLimiter.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 0d91d83..093182c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -32,8 +32,6 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import net.minecraft.server.v1_15_R1.*; import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -43,7 +41,6 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftTNTPrimed; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; import org.bukkit.scheduler.BukkitTask; import java.util.List; @@ -64,11 +61,11 @@ public class CommandTPSLimiter implements CommandExecutor { // if (tpsLimiterNotActive()) return; if (event.getPacket().getEntityModifier(world).read(0) == null) return; if (!(event.getPacket().getEntityModifier(world).read(0) instanceof CraftTNTPrimed)) return; - System.out.println("META: " + event.getPacket().getIntegers().read(0)); + System.out.println("ENTITY_METADATA: " + event.getPacket().getIntegers().read(0)); List dataWatcherObjectList = event.getPacket().getWatchableCollectionModifier().read(0); - getByIndex(dataWatcherObjectList, 5).setValue(true); + // getByIndex(dataWatcherObjectList, 5).setValue(true); getByIndex(dataWatcherObjectList, 7).setValue((int) ((20.0 / currentTPSLimit) * 80)); - System.out.println(dataWatcherObjectList); + // System.out.println(dataWatcherObjectList); event.getPacket().getWatchableCollectionModifier().write(0, dataWatcherObjectList); } }); @@ -78,14 +75,14 @@ public class CommandTPSLimiter implements CommandExecutor { if (tpsLimiterNotActive()) return; if (event.getPacket().getEntityModifier(world).read(0) == null) return; if (!(event.getPacket().getEntityModifier(world).read(0) instanceof CraftTNTPrimed)) return; - System.out.println(event.getPacket().getIntegers().read(0)); + System.out.println("REL_ENTITY_MOVE: " + event.getPacket().getIntegers().read(0)); StructureModifier structureModifier = event.getPacket().getIntegers(); // structureModifier.write(1, 0); // structureModifier.write(2, 0); // structureModifier.write(3, 0); Entity entity = event.getPacket().getEntityModifier(world).read(0); - System.out.println(entity.getLocation()); + // System.out.println(entity.getLocation()); net.minecraft.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(serverEntity); @@ -95,7 +92,7 @@ public class CommandTPSLimiter implements CommandExecutor { sendPlayers(packetPlayOutEntityMetadata); Vec3D vec3D = serverEntity.getMot(); - PacketPlayOutEntityVelocity packetPlayOutEntityVelocity = new PacketPlayOutEntityVelocity(serverEntity.getId(), new Vec3D(vec3D.x / (20 - currentTPSLimit), vec3D.y / (20 - currentTPSLimit), vec3D.z / (20 - currentTPSLimit))); + PacketPlayOutEntityVelocity packetPlayOutEntityVelocity = new PacketPlayOutEntityVelocity(serverEntity.getId(), new Vec3D(vec3D.x / (20.0 / currentTPSLimit), vec3D.y / (20.0 / currentTPSLimit), vec3D.z / (20.0 / currentTPSLimit))); sendPlayers(packetPlayOutEntityVelocity); } });