diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index b373a7e..1827ecd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -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; - } + /* + + steamwar + ProtocolLib + 1.0 + system + ${main.basedir}/lib/ProtocolLib.jar + + */ + /*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 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; }