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