From a41602bd379c0d0a3078cf90f1f4c4ffbdbeef78 Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 18:40:43 +0100 Subject: [PATCH 1/6] Add TPS warping to TPSLimit --- .../steamwar/bausystem/world/TPSLimit_15.java | 34 ++++++++++ .../src/de/steamwar/bausystem/BauSystem.java | 1 + .../bausystem/commands/CommandInfo.java | 27 ++++++-- .../bausystem/commands/CommandTPSLimiter.java | 9 ++- .../CommandTPSLimiterTabComplete.java | 4 +- .../bausystem/world/BauScoreboard.java | 11 +++- .../de/steamwar/bausystem/world/TPSUtils.java | 62 +++++++++++++++++++ 7 files changed, 136 insertions(+), 12 deletions(-) create mode 100644 BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java new file mode 100644 index 0000000..039ef29 --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java @@ -0,0 +1,34 @@ +/* + * + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * / + */ + +package de.steamwar.bausystem.world; + +import net.minecraft.server.v1_15_R1.SystemUtils; + +import java.util.function.LongSupplier; + +public class TPSLimit_15 { + + public static void init(LongSupplier longSupplier) { + SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong(); + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 96bde54..01d66dd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -106,6 +106,7 @@ public class BauSystem extends JavaPlugin implements Listener { new AFKStopper(); autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200); + TPSUtils.init(); } public static BauSystem getPlugin() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 980133b..c3455c4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.world.Region; +import de.steamwar.bausystem.world.TPSUtils; import de.steamwar.core.TPSWatcher; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; @@ -55,12 +56,26 @@ public class CommandInfo implements CommandExecutor { } sender.sendMessage(membermessage.toString()); - sender.sendMessage(BauSystem.PREFIX + "TPS:§e" + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND) + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS) + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE) + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES) + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); + if (TPSUtils.isWarping()) { + sender.sendMessage(BauSystem.PREFIX + "TPS:§e" + + " " + getTps(TPSWatcher.TPSType.ONE_SECOND) + + " " + getTps(TPSWatcher.TPSType.TEN_SECONDS)); + } else { + sender.sendMessage(BauSystem.PREFIX + "TPS:§e" + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND) + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS) + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE) + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES) + + " " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); + } return false; } + + private double getTps(TPSWatcher.TPSType tpsType) { + if (TPSUtils.isWarping()) { + return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20)); + } + return TPSWatcher.getTPS(tpsType); + } + } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 7a749c7..badb079 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -21,7 +21,9 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.world.TPSUtils; import de.steamwar.bausystem.world.Welt; +import de.steamwar.core.TPSWatcher; import de.steamwar.core.VersionedRunnable; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; @@ -77,7 +79,7 @@ public class CommandTPSLimiter implements CommandExecutor { try { double tpsLimitDouble = Double.parseDouble(tpsLimit.replace(',', '.')); - if (tpsLimitDouble < 0.5 || tpsLimitDouble > 20) { + if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 40 : 20)) { sendInvalidArgumentMessage(player); return false; } @@ -104,7 +106,8 @@ public class CommandTPSLimiter implements CommandExecutor { loops = (int)Math.ceil(delay); sleepDelay = (long) (50 * delay) / loops; - if (currentTPSLimit == 20) { + TPSUtils.setTPS(currentTPSLimit); + if (currentTPSLimit >= 20) { if (tpsLimiter == null) return; tpsLimiter.cancel(); tpsLimiter = null; @@ -139,7 +142,7 @@ public class CommandTPSLimiter implements CommandExecutor { } public static double getCurrentTPSLimit() { - return currentTPSLimit; + return (double)Math.round(currentTPSLimit * 10.0D) / 10.0D; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java index 9b401ee..8db0904 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.commands; +import de.steamwar.bausystem.world.TPSUtils; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; @@ -30,6 +31,7 @@ import java.util.List; public class CommandTPSLimiterTabComplete implements TabCompleter { private List arguments = Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"); + private List argumentsWarped = Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40"); @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { @@ -37,7 +39,7 @@ public class CommandTPSLimiterTabComplete implements TabCompleter { return new ArrayList<>(); } List validArguments = new ArrayList<>(arguments.size()); - for (String s : arguments) { + for (String s : TPSUtils.isWarpAllowed() ? argumentsWarped : arguments) { if (s.startsWith(args[0])) { validArguments.add(s); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java index 17873b7..c510a2d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java @@ -73,7 +73,7 @@ public class BauScoreboard implements Listener { } strings.add("§4"); - strings.add("§eTPS§8: " + tpsColor() + TPSWatcher.getTPS() + tpsLimit()); + strings.add("§eTPS§8: " + tpsColor() + getTps() + tpsLimit()); int i = strings.size(); HashMap result = new HashMap<>(); @@ -87,7 +87,7 @@ public class BauScoreboard implements Listener { } private String tpsColor() { - double tps = TPSWatcher.getTPS(); + double tps = getTps(); if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.9) { return "§a"; } @@ -104,4 +104,11 @@ public class BauScoreboard implements Listener { return "§8/§7" + CommandTPSLimiter.getCurrentTPSLimit(); } + private double getTps() { + if (TPSUtils.isWarping()) { + return TPSWatcher.getTPS(Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20)); + } + return TPSWatcher.getTPS(); + } + } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java new file mode 100644 index 0000000..2733a80 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java @@ -0,0 +1,62 @@ +/* + * + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * / + */ + +package de.steamwar.bausystem.world; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.core.VersionedRunnable; +import org.bukkit.Bukkit; + +public class TPSUtils { + + private TPSUtils() { + throw new IllegalStateException("Utility Class"); + } + + private static boolean warp = true; + private static long nanoOffset = 0; + private static long nanoDOffset = 0; + + public static void init() { + Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { + nanoOffset += nanoDOffset; + }, 1, 1); + VersionedRunnable.call(new VersionedRunnable(() -> warp = false, 8), + new VersionedRunnable(() -> TPSLimit_15.init(() -> nanoOffset), 15)); + } + + public static void setTPS(double tps) { + double d = 50 - (50 / (tps / 20.0)); + long nanos = (long) (d * 1000000); + if (nanos < 0) nanos = 0; + if (nanos > 25000000) nanos = 25000000; + nanoDOffset = nanos; + } + + public static boolean isWarpAllowed() { + return warp; + } + + public static boolean isWarping() { + return nanoDOffset > 0; + } + +} -- 2.39.5 From 5372f8440951719012f7e7325ef170b56abe55e6 Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 9 Feb 2021 21:07:24 +0100 Subject: [PATCH 2/6] Optimize CommandInfo --- .../bausystem/commands/CommandInfo.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index c3455c4..7783971 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -56,18 +56,16 @@ public class CommandInfo implements CommandExecutor { } sender.sendMessage(membermessage.toString()); - if (TPSUtils.isWarping()) { - sender.sendMessage(BauSystem.PREFIX + "TPS:§e" + - " " + getTps(TPSWatcher.TPSType.ONE_SECOND) + - " " + getTps(TPSWatcher.TPSType.TEN_SECONDS)); - } else { - sender.sendMessage(BauSystem.PREFIX + "TPS:§e" + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND) + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS) + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE) + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES) + - " " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); + StringBuilder tpsMessage = new StringBuilder(); + tpsMessage.append(BauSystem.PREFIX).append("TPS:§e"); + tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.ONE_SECOND)); + tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.TEN_SECONDS)); + if (!TPSUtils.isWarping()) { + tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE)); + tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)); + tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); } + sender.sendMessage(tpsMessage.toString()); return false; } -- 2.39.5 From 97926c08d5f5dee37a02c3e2f4a3ddcb4e9cb335 Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 9 Feb 2021 21:14:52 +0100 Subject: [PATCH 3/6] Optimize TPSLimit_15 Optimize CommandInfo Optimize CommandTPSLimiter Optimize CommandTPSLimiterTabComplete Optimize BauScoreboard Optimize TPSUtils --- .../steamwar/bausystem/world/TPSLimit_15.java | 1 - .../bausystem/commands/CommandInfo.java | 9 ++------- .../bausystem/commands/CommandTPSLimiter.java | 2 +- .../commands/CommandTPSLimiterTabComplete.java | 6 ++++-- .../steamwar/bausystem/world/BauScoreboard.java | 11 ++--------- .../de/steamwar/bausystem/world/TPSUtils.java | 17 +++++++++-------- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java index 039ef29..452bc74 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java @@ -16,7 +16,6 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * / */ package de.steamwar.bausystem.world; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java index 7783971..6043e74 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandInfo.java @@ -32,6 +32,8 @@ import org.bukkit.entity.Player; import java.util.List; +import static de.steamwar.bausystem.world.TPSUtils.getTps; + public class CommandInfo implements CommandExecutor { @Override @@ -69,11 +71,4 @@ public class CommandInfo implements CommandExecutor { return false; } - private double getTps(TPSWatcher.TPSType tpsType) { - if (TPSUtils.isWarping()) { - return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20)); - } - return TPSWatcher.getTPS(tpsType); - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index badb079..350b421 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -98,7 +98,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 " + (TPSUtils.isWarpAllowed() ? 40 : 20) + ", und 'default' erlaubt."); } private void tpsLimiter() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java index 8db0904..035055d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java @@ -31,7 +31,9 @@ import java.util.List; public class CommandTPSLimiterTabComplete implements TabCompleter { private List arguments = Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"); - private List argumentsWarped = Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40"); + public CommandTPSLimiterTabComplete() { + if (TPSUtils.isWarpAllowed()) arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); + } @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { @@ -39,7 +41,7 @@ public class CommandTPSLimiterTabComplete implements TabCompleter { return new ArrayList<>(); } List validArguments = new ArrayList<>(arguments.size()); - for (String s : TPSUtils.isWarpAllowed() ? argumentsWarped : arguments) { + for (String s : arguments) { if (s.startsWith(args[0])) { validArguments.add(s); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java index c510a2d..0a93414 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java @@ -73,7 +73,7 @@ public class BauScoreboard implements Listener { } strings.add("§4"); - strings.add("§eTPS§8: " + tpsColor() + getTps() + tpsLimit()); + strings.add("§eTPS§8: " + tpsColor() + TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit()); int i = strings.size(); HashMap result = new HashMap<>(); @@ -87,7 +87,7 @@ public class BauScoreboard implements Listener { } private String tpsColor() { - double tps = getTps(); + double tps = TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND); if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.9) { return "§a"; } @@ -104,11 +104,4 @@ public class BauScoreboard implements Listener { return "§8/§7" + CommandTPSLimiter.getCurrentTPSLimit(); } - private double getTps() { - if (TPSUtils.isWarping()) { - return TPSWatcher.getTPS(Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20)); - } - return TPSWatcher.getTPS(); - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java index 2733a80..0c38b78 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java @@ -16,12 +16,13 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * / */ package de.steamwar.bausystem.world; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.commands.CommandTPSLimiter; +import de.steamwar.core.TPSWatcher; import de.steamwar.core.VersionedRunnable; import org.bukkit.Bukkit; @@ -36,19 +37,14 @@ public class TPSUtils { private static long nanoDOffset = 0; public static void init() { - Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - nanoOffset += nanoDOffset; - }, 1, 1); + Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1); VersionedRunnable.call(new VersionedRunnable(() -> warp = false, 8), new VersionedRunnable(() -> TPSLimit_15.init(() -> nanoOffset), 15)); } public static void setTPS(double tps) { double d = 50 - (50 / (tps / 20.0)); - long nanos = (long) (d * 1000000); - if (nanos < 0) nanos = 0; - if (nanos > 25000000) nanos = 25000000; - nanoDOffset = nanos; + nanoDOffset = Math.max(0, Math.min((long) (d * 1000000), 25000000)); } public static boolean isWarpAllowed() { @@ -59,4 +55,9 @@ public class TPSUtils { return nanoDOffset > 0; } + public static double getTps(TPSWatcher.TPSType tpsType) { + if (TPSUtils.isWarping()) return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20)); + return TPSWatcher.getTPS(tpsType); + } + } -- 2.39.5 From 813b8803b4326cba46719cff4e40869d5adc3b03 Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 9 Feb 2021 21:20:36 +0100 Subject: [PATCH 4/6] Fix CommandTPSLimiterTabComplete --- .../bausystem/commands/CommandTPSLimiterTabComplete.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java index 035055d..14401a5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java @@ -30,7 +30,7 @@ import java.util.List; public class CommandTPSLimiterTabComplete implements TabCompleter { - private List arguments = Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"); + private List arguments = new ArrayList<>(Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); public CommandTPSLimiterTabComplete() { if (TPSUtils.isWarpAllowed()) arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); } -- 2.39.5 From 88028286767cf987935aa6a4321edb834550a817 Mon Sep 17 00:00:00 2001 From: jojo Date: Thu, 11 Feb 2021 19:39:06 +0100 Subject: [PATCH 5/6] Fix pr stuff --- .../bausystem/world/{TPSLimit_15.java => TPSUtils_15.java} | 2 +- .../de/steamwar/bausystem/commands/CommandTPSLimiter.java | 1 - .../bausystem/commands/CommandTPSLimiterTabComplete.java | 1 + .../src/de/steamwar/bausystem/world/TPSUtils.java | 6 ++++-- 4 files changed, 6 insertions(+), 4 deletions(-) rename BauSystem_15/src/de/steamwar/bausystem/world/{TPSLimit_15.java => TPSUtils_15.java} (97%) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/TPSUtils_15.java similarity index 97% rename from BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java rename to BauSystem_15/src/de/steamwar/bausystem/world/TPSUtils_15.java index 452bc74..4cfeaac 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/TPSUtils_15.java @@ -24,7 +24,7 @@ import net.minecraft.server.v1_15_R1.SystemUtils; import java.util.function.LongSupplier; -public class TPSLimit_15 { +public class TPSUtils_15 { public static void init(LongSupplier longSupplier) { SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index 350b421..f997911 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.TPSUtils; import de.steamwar.bausystem.world.Welt; -import de.steamwar.core.TPSWatcher; import de.steamwar.core.VersionedRunnable; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java index 14401a5..00dc116 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiterTabComplete.java @@ -31,6 +31,7 @@ import java.util.List; public class CommandTPSLimiterTabComplete implements TabCompleter { private List arguments = new ArrayList<>(Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); + public CommandTPSLimiterTabComplete() { if (TPSUtils.isWarpAllowed()) arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40")); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java index 0c38b78..563e01a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java @@ -37,9 +37,11 @@ public class TPSUtils { private static long nanoDOffset = 0; public static void init() { - Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1); VersionedRunnable.call(new VersionedRunnable(() -> warp = false, 8), - new VersionedRunnable(() -> TPSLimit_15.init(() -> nanoOffset), 15)); + new VersionedRunnable(() -> { + Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1); + TPSUtils_15.init(() -> nanoOffset); + }, 15)); } public static void setTPS(double tps) { -- 2.39.5 From 778e5565c525a26580f367ce16790a3c76eb5df2 Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 12 Feb 2021 11:08:18 +0100 Subject: [PATCH 6/6] Optimize Imports --- .../src/de/steamwar/bausystem/commands/TPSLimit_12.java | 2 -- .../src/de/steamwar/bausystem/commands/TPSLimit_15.java | 1 - 2 files changed, 3 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 b2ebadc..4cd4c22 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -28,9 +28,7 @@ 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 { 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 a1621dc..2860e2a 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -29,7 +29,6 @@ import org.bukkit.entity.TNTPrimed; import java.util.ArrayList; import java.util.List; -import java.util.Set; class TPSLimit_15 { -- 2.39.5