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 e9facf92ca werden angezeigt - Alle Commits anzeigen

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);