SteamWar/BauSystem
Archiviert
13
0

Fix CommandTPSLimiter

Dieser Commit ist enthalten in:
jojo 2020-11-16 07:28:49 +01:00
Ursprung ab170426cb
Commit 36d6c6bedb

Datei anzeigen

@ -32,8 +32,6 @@ import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; 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.craftbukkit.v1_15_R1.entity.CraftTNTPrimed;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import java.util.List; import java.util.List;
@ -64,11 +61,11 @@ public class CommandTPSLimiter implements CommandExecutor {
// if (tpsLimiterNotActive()) return; // if (tpsLimiterNotActive()) return;
if (event.getPacket().getEntityModifier(world).read(0) == null) return; if (event.getPacket().getEntityModifier(world).read(0) == null) return;
if (!(event.getPacket().getEntityModifier(world).read(0) instanceof CraftTNTPrimed)) 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<WrappedWatchableObject> dataWatcherObjectList = event.getPacket().getWatchableCollectionModifier().read(0); List<WrappedWatchableObject> 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)); getByIndex(dataWatcherObjectList, 7).setValue((int) ((20.0 / currentTPSLimit) * 80));
System.out.println(dataWatcherObjectList); // System.out.println(dataWatcherObjectList);
event.getPacket().getWatchableCollectionModifier().write(0, dataWatcherObjectList); event.getPacket().getWatchableCollectionModifier().write(0, dataWatcherObjectList);
} }
}); });
@ -78,14 +75,14 @@ public class CommandTPSLimiter implements CommandExecutor {
if (tpsLimiterNotActive()) return; if (tpsLimiterNotActive()) return;
if (event.getPacket().getEntityModifier(world).read(0) == null) return; if (event.getPacket().getEntityModifier(world).read(0) == null) return;
if (!(event.getPacket().getEntityModifier(world).read(0) instanceof CraftTNTPrimed)) 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<Integer> structureModifier = event.getPacket().getIntegers(); StructureModifier<Integer> structureModifier = event.getPacket().getIntegers();
// structureModifier.write(1, 0); // structureModifier.write(1, 0);
// structureModifier.write(2, 0); // structureModifier.write(2, 0);
// structureModifier.write(3, 0); // structureModifier.write(3, 0);
Entity entity = event.getPacket().getEntityModifier(world).read(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(); net.minecraft.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle();
PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(serverEntity); PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(serverEntity);
@ -95,7 +92,7 @@ public class CommandTPSLimiter implements CommandExecutor {
sendPlayers(packetPlayOutEntityMetadata); sendPlayers(packetPlayOutEntityMetadata);
Vec3D vec3D = serverEntity.getMot(); 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); sendPlayers(packetPlayOutEntityVelocity);
} }
}); });