From cc33517e6b23a333b72b9266d1cd1ca596acada8 Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 22 Dec 2020 20:27:27 +0100 Subject: [PATCH 01/11] Add TPSLimit for FallingBlock (Sand, Anvil, Concrete, etc.) --- .../de/steamwar/bausystem/commands/TPSLimit_12.java | 11 +++++------ .../de/steamwar/bausystem/commands/TPSLimit_15.java | 11 +++++------ .../bausystem/commands/CommandTPSLimiter.java | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java index d32d4cb..245e0a9 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -24,6 +24,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; +import org.bukkit.entity.FallingBlock; import org.bukkit.entity.TNTPrimed; import java.util.HashSet; @@ -35,7 +36,7 @@ class TPSLimit_12 { static void createVelocityPacketCache(World world) { velocityPackets.clear(); - world.getEntitiesByClasses(TNTPrimed.class).forEach(entity -> { + world.getEntitiesByClasses(TNTPrimed.class, FallingBlock.class).forEach(entity -> { velocityPackets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), 0, 0, 0)); }); } @@ -49,19 +50,17 @@ class TPSLimit_12 { world.getEntitiesByClasses(TNTPrimed.class).forEach(entity -> { net.minecraft.server.v1_12_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); - packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); }); sendPacketsToPlayer(packets); } - static void sendTntData(World world) { + static void sendTeleports(World world) { Set> packets = new HashSet<>(); - world.getEntitiesByClasses(TNTPrimed.class).forEach(entity -> { - net.minecraft.server.v1_12_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); - packets.add(new PacketPlayOutEntityTeleport(serverEntity)); + world.getEntitiesByClasses(TNTPrimed.class, FallingBlock.class).forEach(entity -> { + packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); }); sendPacketsToPlayer(packets); diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java index cb32794..1215955 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -24,6 +24,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; +import org.bukkit.entity.FallingBlock; import org.bukkit.entity.TNTPrimed; import java.util.HashSet; @@ -36,7 +37,7 @@ class TPSLimit_15 { static void createVelocityPacketCache(World world) { velocityPackets.clear(); - world.getEntitiesByClasses(TNTPrimed.class).forEach(entity -> { + world.getEntitiesByClasses(TNTPrimed.class, FallingBlock.class).forEach(entity -> { velocityPackets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion)); }); } @@ -50,19 +51,17 @@ class TPSLimit_15 { world.getEntitiesByClasses(TNTPrimed.class).forEach(entity -> { net.minecraft.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); - packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); }); sendPacketsToPlayer(packets); } - static void sendTntData(World world) { + static void sendTeleports(World world) { Set> packets = new HashSet<>(); - world.getEntitiesByClasses(TNTPrimed.class).forEach(entity -> { - net.minecraft.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); - packets.add(new PacketPlayOutEntityTeleport(serverEntity)); + world.getEntitiesByClasses(TNTPrimed.class, FallingBlock.class).forEach(entity -> { + packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); }); sendPacketsToPlayer(packets); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 94df329..3453e5a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -166,10 +166,10 @@ public class CommandTPSLimiter implements CommandExecutor { private void sendTntData() { switch (Core.getVersion()) { case 15: - TPSLimit_15.sendTntData(world); + TPSLimit_15.sendTeleports(world); break; default: - TPSLimit_12.sendTntData(world); + TPSLimit_12.sendTeleports(world); } } From d80e6d1a069982ff245b1caf1a92f9661b5d7955 Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 22 Dec 2020 21:01:29 +0100 Subject: [PATCH 02/11] Add 0.5 tps up to 1 --- .../bausystem/commands/CommandTPSLimiter.java | 61 ++++++------------- 1 file changed, 17 insertions(+), 44 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 3453e5a..30d7c30 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -35,7 +35,7 @@ import org.bukkit.scheduler.BukkitTask; public class CommandTPSLimiter implements CommandExecutor { - private static int currentTPSLimit = 20; + private static double currentTPSLimit = 20; private static World world = Bukkit.getWorlds().get(0); private long lastTime = System.nanoTime(); private long currentTime = System.nanoTime(); @@ -71,12 +71,14 @@ public class CommandTPSLimiter implements CommandExecutor { } try { - int tpsLimitInt = Integer.parseInt(tpsLimit); - if (tpsLimitInt < 1 || tpsLimitInt > 20) { + double tpsLimitDouble = Double.parseDouble(tpsLimit.replace(',', '.')); + if (tpsLimitDouble < 0.5 || tpsLimitDouble > 20) { sendInvalidArgumentMessage(player); return false; } - currentTPSLimit = tpsLimitInt; + if (tpsLimitDouble <= 1) tpsLimitDouble = (int)(tpsLimitDouble * 10) / 10.0; + else tpsLimitDouble = (int)tpsLimitDouble; + currentTPSLimit = tpsLimitDouble; sendNewTPSLimitMessage(); tpsLimiter(); } catch (NumberFormatException e) { @@ -91,7 +93,7 @@ public class CommandTPSLimiter implements CommandExecutor { } private void sendInvalidArgumentMessage(Player player) { - player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 1 und 20, und 'default' erlaubt."); + player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0.5 und 1 oder 1 und 20, und 'default' erlaubt."); } private void tpsLimiter() { @@ -102,13 +104,13 @@ public class CommandTPSLimiter implements CommandExecutor { } else { if (tpsLimiter != null) return; tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - sendTntMetaData(); + versionDependantCall(() -> TPSLimit_12.sendTntMetaData(world), () -> TPSLimit_15.sendTntMetaData(world)); - createVelocityData(); + versionDependantCall(() -> TPSLimit_12.createVelocityPacketCache(world), () -> TPSLimit_15.createVelocityPacketCache(world)); for (int i = 0; i < (20 / currentTPSLimit); i++) { sleepUntilNextTick(); - sendTntData(); - sendVelocityData(); + versionDependantCall(() -> TPSLimit_12.sendTeleports(world), () -> TPSLimit_15.sendTeleports(world)); + versionDependantCall(TPSLimit_12::sendVelocityPackets, TPSLimit_15::sendVelocityPackets); } }, 0, 1); } @@ -133,47 +135,18 @@ public class CommandTPSLimiter implements CommandExecutor { } } - private void createVelocityData() { + private void versionDependantCall(Runnable v12, Runnable v15) { switch (Core.getVersion()) { - case 15: - TPSLimit_15.createVelocityPacketCache(world); + case 12: + v12.run(); break; default: - TPSLimit_12.createVelocityPacketCache(world); + v15.run(); + break; } } - private void sendVelocityData() { - switch (Core.getVersion()) { - case 15: - TPSLimit_15.sendVelocityPackets(); - break; - default: - TPSLimit_12.sendVelocityPackets(); - } - } - - private void sendTntMetaData() { - switch (Core.getVersion()) { - case 15: - TPSLimit_15.sendTntMetaData(world); - break; - default: - TPSLimit_12.sendTntMetaData(world); - } - } - - private void sendTntData() { - switch (Core.getVersion()) { - case 15: - TPSLimit_15.sendTeleports(world); - break; - default: - TPSLimit_12.sendTeleports(world); - } - } - - public static int getCurrentTPSLimit() { + public static double getCurrentTPSLimit() { return currentTPSLimit; } From 3f620559fe338327293a593c1be2f7aea9515e9e Mon Sep 17 00:00:00 2001 From: jojo Date: Thu, 24 Dec 2020 11:27:27 +0100 Subject: [PATCH 03/11] Update message --- .../src/de/steamwar/bausystem/commands/CommandTPSLimiter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 30d7c30..7aa70d2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -93,7 +93,7 @@ public class CommandTPSLimiter implements CommandExecutor { } private void sendInvalidArgumentMessage(Player player) { - player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0.5 und 1 oder 1 und 20, und 'default' erlaubt."); + player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0.5 und 20, und 'default' erlaubt."); } private void tpsLimiter() { From e94fe80a49afb4385cf09bc881e83d00e96fa4f8 Mon Sep 17 00:00:00 2001 From: jojo Date: Thu, 24 Dec 2020 14:33:28 +0100 Subject: [PATCH 04/11] Remove cluttered if --- .../src/de/steamwar/bausystem/commands/CommandTPSLimiter.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 7aa70d2..474518b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -76,8 +76,6 @@ public class CommandTPSLimiter implements CommandExecutor { sendInvalidArgumentMessage(player); return false; } - if (tpsLimitDouble <= 1) tpsLimitDouble = (int)(tpsLimitDouble * 10) / 10.0; - else tpsLimitDouble = (int)tpsLimitDouble; currentTPSLimit = tpsLimitDouble; sendNewTPSLimitMessage(); tpsLimiter(); From 7f42fffd0cb226875d9579df4e986132e98e0adc Mon Sep 17 00:00:00 2001 From: jojo Date: Thu, 24 Dec 2020 14:58:50 +0100 Subject: [PATCH 05/11] Fix Kommata --- .../src/de/steamwar/bausystem/commands/CommandTPSLimiter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 474518b..591775c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -91,7 +91,7 @@ public class CommandTPSLimiter implements CommandExecutor { } private void sendInvalidArgumentMessage(Player player) { - player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0.5 und 20, und 'default' erlaubt."); + player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0,5 und 20, und 'default' erlaubt."); } private void tpsLimiter() { From 65456ea19c7d853722a2947c2f5e96d4f337bdb6 Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 25 Dec 2020 18:06:19 +0100 Subject: [PATCH 06/11] Simplify TPSLimit_12 Simplify TPSLimit_15 --- .../bausystem/commands/TPSLimit_12.java | 29 ++++--------------- .../bausystem/commands/TPSLimit_15.java | 29 ++++--------------- .../bausystem/commands/CommandTPSLimiter.java | 7 ++--- 3 files changed, 14 insertions(+), 51 deletions(-) diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java index 245e0a9..e3b5d5a 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -32,37 +32,20 @@ import java.util.Set; class TPSLimit_12 { - private static Set velocityPackets = new HashSet<>(); + private static Set> packets = new HashSet<>(); - static void createVelocityPacketCache(World world) { - velocityPackets.clear(); + static void createTickCache(World world) { + packets.clear(); world.getEntitiesByClasses(TNTPrimed.class, FallingBlock.class).forEach(entity -> { - velocityPackets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), 0, 0, 0)); - }); - } + packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), 0, 0, 0)); + packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); - static void sendVelocityPackets() { - sendPacketsToPlayer(velocityPackets); - } - - static void sendTntMetaData(World world) { - Set> packets = new HashSet<>(); - - world.getEntitiesByClasses(TNTPrimed.class).forEach(entity -> { net.minecraft.server.v1_12_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); }); - - sendPacketsToPlayer(packets); } - static void sendTeleports(World world) { - Set> packets = new HashSet<>(); - - world.getEntitiesByClasses(TNTPrimed.class, FallingBlock.class).forEach(entity -> { - packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); - }); - + static void sendTickPackets() { sendPacketsToPlayer(packets); } diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java index 1215955..efaca78 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -32,38 +32,21 @@ import java.util.Set; class TPSLimit_15 { - private static Set velocityPackets = new HashSet<>(); + private static Set> packets = new HashSet<>(); private static final Vec3D noMotion = new Vec3D(0, 0, 0); - static void createVelocityPacketCache(World world) { - velocityPackets.clear(); + static void createTickCache(World world) { + packets.clear(); world.getEntitiesByClasses(TNTPrimed.class, FallingBlock.class).forEach(entity -> { - velocityPackets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion)); - }); - } + packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion)); + packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); - static void sendVelocityPackets() { - sendPacketsToPlayer(velocityPackets); - } - - static void sendTntMetaData(World world) { - Set> packets = new HashSet<>(); - - world.getEntitiesByClasses(TNTPrimed.class).forEach(entity -> { net.minecraft.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); }); - - sendPacketsToPlayer(packets); } - static void sendTeleports(World world) { - Set> packets = new HashSet<>(); - - world.getEntitiesByClasses(TNTPrimed.class, FallingBlock.class).forEach(entity -> { - packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); - }); - + static void sendTickPackets() { sendPacketsToPlayer(packets); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 591775c..c09bdf3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -102,13 +102,10 @@ public class CommandTPSLimiter implements CommandExecutor { } else { if (tpsLimiter != null) return; tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - versionDependantCall(() -> TPSLimit_12.sendTntMetaData(world), () -> TPSLimit_15.sendTntMetaData(world)); - - versionDependantCall(() -> TPSLimit_12.createVelocityPacketCache(world), () -> TPSLimit_15.createVelocityPacketCache(world)); + versionDependantCall(() -> TPSLimit_12.createTickCache(world), () -> TPSLimit_15.createTickCache(world)); for (int i = 0; i < (20 / currentTPSLimit); i++) { sleepUntilNextTick(); - versionDependantCall(() -> TPSLimit_12.sendTeleports(world), () -> TPSLimit_15.sendTeleports(world)); - versionDependantCall(TPSLimit_12::sendVelocityPackets, TPSLimit_15::sendVelocityPackets); + versionDependantCall(TPSLimit_12::sendTickPackets, TPSLimit_15::sendTickPackets); } }, 0, 1); } From 500d103b49ed2de515f8ef5d79be150e3871f84c Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 25 Dec 2020 23:28:11 +0100 Subject: [PATCH 07/11] Update versioned dependant code to new SpigotCore version dependant calls --- .../bausystem/commands/TPSLimit_12.java | 2 +- .../bausystem/commands/TPSLimit_15.java | 2 +- .../bausystem/commands/CommandTPSLimiter.java | 18 +++++------------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java index e3b5d5a..b84be05 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -49,7 +49,7 @@ class TPSLimit_12 { sendPacketsToPlayer(packets); } - static void sendPacketsToPlayer(Set> packets) { + private static void sendPacketsToPlayer(Set> packets) { Bukkit.getOnlinePlayers().forEach(player -> { PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; for (Packet p : packets) { diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java index efaca78..00855e8 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -50,7 +50,7 @@ class TPSLimit_15 { sendPacketsToPlayer(packets); } - static void sendPacketsToPlayer(Set> packets) { + private static void sendPacketsToPlayer(Set> packets) { Bukkit.getOnlinePlayers().forEach(player -> { PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; for (Packet p : packets) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index c09bdf3..f845e81 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; import de.steamwar.core.Core; +import de.steamwar.core.VersionedRunnable; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -102,10 +103,12 @@ public class CommandTPSLimiter implements CommandExecutor { } else { if (tpsLimiter != null) return; tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - versionDependantCall(() -> TPSLimit_12.createTickCache(world), () -> TPSLimit_15.createTickCache(world)); + VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(world), 8), + new VersionedRunnable(() -> TPSLimit_15.createTickCache(world), 14)); for (int i = 0; i < (20 / currentTPSLimit); i++) { sleepUntilNextTick(); - versionDependantCall(TPSLimit_12::sendTickPackets, TPSLimit_15::sendTickPackets); + VersionedRunnable.call(new VersionedRunnable(TPSLimit_12::sendTickPackets, 8), + new VersionedRunnable(TPSLimit_15::sendTickPackets, 14)); } }, 0, 1); } @@ -130,17 +133,6 @@ public class CommandTPSLimiter implements CommandExecutor { } } - private void versionDependantCall(Runnable v12, Runnable v15) { - switch (Core.getVersion()) { - case 12: - v12.run(); - break; - default: - v15.run(); - break; - } - } - public static double getCurrentTPSLimit() { return currentTPSLimit; } From d316b606fdc51426087060c5521b54c705305e9d Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 26 Dec 2020 22:41:00 +0100 Subject: [PATCH 08/11] Optimize Imports --- .../src/de/steamwar/bausystem/commands/CommandTPSLimiter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index f845e81..051d4f7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; -import de.steamwar.core.Core; import de.steamwar.core.VersionedRunnable; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; From ac399896fc59d6959ce7a8b3191c00c7af3ea880 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 26 Dec 2020 22:42:27 +0100 Subject: [PATCH 09/11] Update TPSLimit_12 Update TPSLimit_15 --- .../src/de/steamwar/bausystem/commands/TPSLimit_12.java | 6 ++++-- .../src/de/steamwar/bausystem/commands/TPSLimit_15.java | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java index b84be05..3393ece 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -27,12 +27,14 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.TNTPrimed; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; class TPSLimit_12 { - private static Set> packets = new HashSet<>(); + private static List> packets = new ArrayList<>(); static void createTickCache(World world) { packets.clear(); @@ -49,7 +51,7 @@ class TPSLimit_12 { sendPacketsToPlayer(packets); } - private static void sendPacketsToPlayer(Set> packets) { + private static void sendPacketsToPlayer(List> packets) { Bukkit.getOnlinePlayers().forEach(player -> { PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; for (Packet p : packets) { diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java index 00855e8..75b42f4 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -27,12 +27,13 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.TNTPrimed; -import java.util.HashSet; +import java.util.ArrayList; +import java.util.List; import java.util.Set; class TPSLimit_15 { - private static Set> packets = new HashSet<>(); + private static List> packets = new ArrayList<>(); private static final Vec3D noMotion = new Vec3D(0, 0, 0); static void createTickCache(World world) { @@ -50,7 +51,7 @@ class TPSLimit_15 { sendPacketsToPlayer(packets); } - private static void sendPacketsToPlayer(Set> packets) { + private static void sendPacketsToPlayer(List> packets) { Bukkit.getOnlinePlayers().forEach(player -> { PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; for (Packet p : packets) { From bdded55b868503907721003bd5be186330cdd672 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 26 Dec 2020 22:43:19 +0100 Subject: [PATCH 10/11] Merge sendTickPackets with sendPacketsToPlayer --- .../src/de/steamwar/bausystem/commands/TPSLimit_12.java | 4 ---- .../src/de/steamwar/bausystem/commands/TPSLimit_15.java | 4 ---- 2 files changed, 8 deletions(-) diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java index 3393ece..6af3b00 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -48,10 +48,6 @@ class TPSLimit_12 { } static void sendTickPackets() { - sendPacketsToPlayer(packets); - } - - private static void sendPacketsToPlayer(List> packets) { Bukkit.getOnlinePlayers().forEach(player -> { PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; for (Packet p : packets) { diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java index 75b42f4..e0a39f6 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -48,10 +48,6 @@ class TPSLimit_15 { } static void sendTickPackets() { - sendPacketsToPlayer(packets); - } - - private static void sendPacketsToPlayer(List> packets) { Bukkit.getOnlinePlayers().forEach(player -> { PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; for (Packet p : packets) { From 445de39eb0d217147cfe5dce08e561a3ebec35ee Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 26 Dec 2020 22:44:01 +0100 Subject: [PATCH 11/11] Optimize EntityMetaDataPackets --- .../src/de/steamwar/bausystem/commands/TPSLimit_12.java | 6 ++++-- .../src/de/steamwar/bausystem/commands/TPSLimit_15.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java index 6af3b00..b2ebadc 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -42,8 +42,10 @@ class TPSLimit_12 { packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), 0, 0, 0)); packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); - net.minecraft.server.v1_12_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); - packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); + if (entity instanceof TNTPrimed) { + net.minecraft.server.v1_12_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); + packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); + } }); } diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java index e0a39f6..a1621dc 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -42,8 +42,10 @@ class TPSLimit_15 { packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion)); packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); - net.minecraft.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); - packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); + if (entity instanceof TNTPrimed) { + net.minecraft.server.v1_15_R1.Entity serverEntity = ((CraftEntity) entity).getHandle(); + packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true)); + } }); }