SteamWar/BauSystem
Archiviert
13
0

Add /tpslimit Command #113

Manuell gemergt
YoyoNow hat 13 Commits von TPSLimiter nach master 2020-11-16 14:32:47 +01:00 zusammengeführt
Nur Änderungen aus Commit 36d6c6bedb werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -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<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));
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<Integer> 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);
Veraltet
Review

§c

§c
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);
}
});