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 net.md_5.bungee.api.ChatMessageType;
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.Location;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.block.data.type.TNT;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
@ -50,27 +46,50 @@ public class CommandTPSLimiter implements CommandExecutor {
private BukkitTask tpsLimiter = null;
public CommandTPSLimiter() {
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
if (currentTPSLimit == 20) {
return;
}
/*
<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;
}
/*PacketPlayOutEntityVelocity packet = new PacketPlayOutEntityVelocity(entity);
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));*/
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);
});
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
if (currentTPSLimit == 20) {
return;
}
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);
});
}, 0, 1);
}
private boolean permissionCheck(Player player) {
if(Welt.noPermission(player, Permission.world)){
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TPS-Limiter nutzen");
return false;
}