SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
jojo 2020-11-15 19:35:32 +01:00
Ursprung e9facf92ca
Commit 9388e1abd5

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
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;
@ -31,6 +32,8 @@ import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
@ -46,41 +49,38 @@ public class CommandTPSLimiter implements CommandExecutor {
private BukkitTask tpsLimiter = null;
public CommandTPSLimiter() {
/*
<dependency>
<groupId>steamwar</groupId>
<artifactId>ProtocolLib</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${main.basedir}/lib/ProtocolLib.jar</systemPath>
</dependency>
*/
/*ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Core.getInstance(), PacketType.Play.Server.ENTITY_VELOCITY) {
@Override
public void onPacketSending(PacketEvent event) {
if (currentTPSLimit == 20) {
return;
}
StructureModifier<Integer> structureModifier = event.getPacket().getIntegers();
structureModifier.write(1, 0);
structureModifier.write(2, 0);
structureModifier.write(3, 0);
// PacketPlayOutEntityVelocity packet = new PacketPlayOutEntityVelocity()
}
});*/
/*PacketPlayOutEntityVelocity packet = new PacketPlayOutEntityVelocity(entity);
for(Player player : Bukkit.getOnlinePlayers()){
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(packet);
}
world.getEntities().stream().filter(entity -> entity instanceof TNT).forEach(entity -> entity.setVelocity(0, 0, 0));*/
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
if (currentTPSLimit == 20) {
return;
}
world.getEntities().stream().filter(entity -> entity instanceof TNTPrimed).forEach(entity -> {
/*DataWatcher dataWatcher = new DataWatcher(entity);
System.out.println("Let " + entity.getName() + " sneak " + sneaking);
dataWatcher.register(new DataWatcherObject<>(0, DataWatcherRegistry.a), sneaking ? (byte)0x02 : (byte)0x40);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false);
for(Player player : Bukkit.getOnlinePlayers()){
((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
}*/
net.minecraft.server.v1_15_R1.Entity serverEntitiy = ((CraftEntity) entity).getHandle();
PacketPlayOutEntityVelocity packet1 = new PacketPlayOutEntityVelocity(entity.getEntityId(), new Vec3D(0, 0, 0));
PacketPlayOutEntityTeleport packet2 = new PacketPlayOutEntityTeleport(serverEntitiy);
DataWatcher dataWatcher = new DataWatcher(serverEntitiy);
dataWatcher.register(new DataWatcherObject<>(5, DataWatcherRegistry.i), true);
dataWatcher.register(new DataWatcherObject<>(7, DataWatcherRegistry.b), 80);
PacketPlayOutEntityMetadata packet3 = new PacketPlayOutEntityMetadata(serverEntitiy.getId(), dataWatcher, false);
Bukkit.getOnlinePlayers().forEach(player -> {
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(packet1);
connection.sendPacket(packet2);
connection.sendPacket(packet3);
});
});
world.getEntities().stream().filter(entity -> entity instanceof TNTPrimed).forEach(entity -> {
Location location = entity.getLocation();
world.spawnParticle(Particle.BARRIER, location.getX(), location.getY() + 0.49, location.getZ(), 1);