SteamWar/BauSystem
Archiviert
13
0

Add velocity (commented)

Dieser Commit ist enthalten in:
jojo 2020-11-15 15:55:34 +01:00
Ursprung d23875cc3a
Commit e9facf92ca

Datei anzeigen

@ -24,17 +24,13 @@ import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.Welt;
import net.md_5.bungee.api.ChatMessageType; 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.PacketPlayOutEntityVelocity;
import net.minecraft.server.v1_15_R1.PlayerConnection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.data.type.TNT;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
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.entity.TNTPrimed;
@ -50,18 +46,41 @@ public class CommandTPSLimiter implements CommandExecutor {
private BukkitTask tpsLimiter = null; private BukkitTask tpsLimiter = null;
public CommandTPSLimiter() { public CommandTPSLimiter() {
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { /*
<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) { if (currentTPSLimit == 20) {
return; 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); /*PacketPlayOutEntityVelocity packet = new PacketPlayOutEntityVelocity(entity);
for(Player player : Bukkit.getOnlinePlayers()){ for(Player player : Bukkit.getOnlinePlayers()){
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(packet); connection.sendPacket(packet);
} }
world.getEntities().stream().filter(entity -> entity instanceof TNT).forEach(entity -> entity.setVelocity(0, 0, 0));*/ 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 -> { world.getEntities().stream().filter(entity -> entity instanceof TNTPrimed).forEach(entity -> {
Location location = entity.getLocation(); Location location = entity.getLocation();
world.spawnParticle(Particle.BARRIER, location.getX(), location.getY() + 0.49, location.getZ(), 1); world.spawnParticle(Particle.BARRIER, location.getX(), location.getY() + 0.49, location.getZ(), 1);