Yatopia/patches/server/0041-Add-nspt-command.patch

145 lines
6.5 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Wed, 30 Sep 2020 18:05:45 +0300
Subject: [PATCH] Add nspt command
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft) (#392) * Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 13a476e15 Deprecate PlayerLeaveBedEvent#setBedSpawn 3a1d95c71 [Auto] Updated Upstream (CraftBukkit) d4dcc1a2e Updated Upstream (CraftBukkit) e886d8118 Updated Upstream () 8bc0c6c31 Updated Upstream (CraftBukkit/Spigot) (#5169) 002f65b8b living entity allow attribute registration (#4723) 69a5c67b1 fix calling setSize on dead slimes causing invincibility (fixes #5137) (#5168) Tuinity Changes: 502d57b Updated Upstream (Paper) 87e0cd9 Print exceptions for light scheduling Purpur Changes: 7fc2d31 Updated Upstream (Paper & Tuinity) Airplane Changes: d7d1626 Remove multithreaded entity tracker 677ec73 Ensure armor change event is on main thread c07d254 Fix crash ec7605c Updated Upstream (Tuinity) 2768f39 Update DEAR commit message e975972 Multithreaded entity tracking 98244f9 Updated Upstream (Tuinity) 44b2499 Larger headings 2c4a7fb Merge pull request #6 from Encode42/master cc19631 More changes beba27a Badges and variables 0aeaf12 Improve readability, grammar, etc. Empirecraft Changes: bbc8d297 Updated Paper * Updated Upstream and Sidestream(s) (Paper/Origami) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 3dadd97bb [CI-SKIP] [Meta] Exempt more labels from being marked as stale (#5142) 36a72cad3 [Auto] Updated Upstream (Bukkit/CraftBukkit/Spigot) Origami Changes: 168394a Access config after loading it... fixes velocity auto offline-mode c47b182 Add velocity to automatic offline mode
2021-02-08 16:31:51 +01:00
index 4bacbd38bc0b39724f1c07ec5a266942d2d1ed81..72e093bceb7cbf5b55271bf09d04ee73b79e5d45 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft) (#392) * Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 13a476e15 Deprecate PlayerLeaveBedEvent#setBedSpawn 3a1d95c71 [Auto] Updated Upstream (CraftBukkit) d4dcc1a2e Updated Upstream (CraftBukkit) e886d8118 Updated Upstream () 8bc0c6c31 Updated Upstream (CraftBukkit/Spigot) (#5169) 002f65b8b living entity allow attribute registration (#4723) 69a5c67b1 fix calling setSize on dead slimes causing invincibility (fixes #5137) (#5168) Tuinity Changes: 502d57b Updated Upstream (Paper) 87e0cd9 Print exceptions for light scheduling Purpur Changes: 7fc2d31 Updated Upstream (Paper & Tuinity) Airplane Changes: d7d1626 Remove multithreaded entity tracker 677ec73 Ensure armor change event is on main thread c07d254 Fix crash ec7605c Updated Upstream (Tuinity) 2768f39 Update DEAR commit message e975972 Multithreaded entity tracking 98244f9 Updated Upstream (Tuinity) 44b2499 Larger headings 2c4a7fb Merge pull request #6 from Encode42/master cc19631 More changes beba27a Badges and variables 0aeaf12 Improve readability, grammar, etc. Empirecraft Changes: bbc8d297 Updated Paper * Updated Upstream and Sidestream(s) (Paper/Origami) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 3dadd97bb [CI-SKIP] [Meta] Exempt more labels from being marked as stale (#5142) 36a72cad3 [Auto] Updated Upstream (Bukkit/CraftBukkit/Spigot) Origami Changes: 168394a Access config after loading it... fixes velocity auto offline-mode c47b182 Add velocity to automatic offline mode
2021-02-08 16:31:51 +01:00
@@ -188,6 +188,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
DedicatedServer.LOGGER.error("Unable to load server configuration", e);
return false;
}
+ org.yatopiamc.yatopia.server.YatopiaConfig.registerCommands();
// Yatopia end
Updated Upstream and Sidestream(s) (Tuinity/EMC/Purpur) (FIRST 1.16.4) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Tuinity Changes: d7f2b6e Updated Upstream (Paper) 0850468 Properly ignite entities that stand in fire 4ff2d15 More cleanup to delay chunk unloads 52f4d08 Cleanup post dev branch merge f2eef4a Fixup dev branch patches and store reverted patches in revert folder 85aba13 Merge branch 'dev/some-opts' c3a9e41 Remove deprecated function usage in github actions (#200) dde7028 Merge branch 'master' into dev/some-opts 083e162 Updated Upstream (Paper) - Update to 1.16.4 576e2cc Rate limit incoming packets 7f251e0 Updated Upstream (Paper) 7d45836 Updated Upstream (Paper) cff9ec0 Updated Upstream (Paper) c3d5d24 Merge branch 'master' of https://github.com/Spottedleaf/Tuinity into ver/1.16.3 c12d582 Merge branch 'master' into dev/some-opts cbffdcc Do not mark entities in unloaded chunks as being in blocks 988e550 Updated Upstream (Paper) 84aecdb Merge https://github.com/Spottedleaf/Tuinity into ver/1.16.3 f7b8e25 Split dev branch 3200930 Merge branch 'master' into dev/some-opts 82e5dfb Updated Upstream (Paper) d41103d Updated Upstream (Paper) 1d73f6c Updated Upstream (Paper) 8ba1bab Updated Upstream (Paper) ac6b72e Updated Upstream (Paper) 8d982c4 Updated Upstream (Paper) 2c7bad9 Merge branch 'master' of https://github.com/Spottedleaf/Tuinity into ver/1.16.3 903f580 Merge remote-tracking branch 'origin/dev/some-opts' into dev/some-opts 0179ea8 Re-Add region manager and notify patch 6886867 Merge branch 'master' into dev/some-opts fb292c1 Updated Upstream (Paper) 442890b Fix decompression with Velocity natives (#191) 57fed71 Fix decompression with Velocity natives 102d60b Rebuild patches 968512b Add Velocity natives for encryption and compression (#188) e2dcdd1 Correct return value for ChunkCache#getCubes 4a99f3e Updated Upstream (Paper) f5d537e Merge https://github.com/Spottedleaf/Tuinity into ver/1.16.3 784b838 Some fixes be0b91f Merge branch 'master' into dev/some-opts 2cb36ca Optimise non-flush packet sending be68938 Hey git, may I know what happened here? 1cac0a2 Merge branch 'master' of https://github.com/Spottedleaf/Tuinity into ver/1.16.3 d72e062 Merge branch 'master' into dev/some-opts 76777f0 Updated Upstream (Paper) 6465aba Merge branch 'master' of https://github.com/Spottedleaf/Tuinity into ver/1.16.3 d82174a Merge branch 'master' into dev/some-opts 460581d Fix getClosestEntity not working d39cda0 Updated Upstream (Paper) 2110847 Rewrite getClosestEntity 3e45700 Do not return complex parts for entity by class lookup c9cfdba Updated Upstream (Paper) 5994cb0 Updated Upstream (Paper) 7dfe18c Merge https://github.com/Spottedleaf/Tuinity into ver/1.16.3 363973d Merge branch 'master' into dev/some-opts 1c05858 Updated Upstream (Paper) adaafb4 Git merge doesn't update submodules ab71ded Merge branch 'master' of https://github.com/Spottedleaf/Tuinity into ver/1.16.3 54db338 Merge branch 'master' into dev/some-opts 483289c Updated Upstream (Paper) e36359e Merge branch 'master' of https://github.com/Spottedleaf/Tuinity into ver/1.16.2 ef8cd34 Fix NPE b770af9 Merge branch 'master' into dev/some-opts d479e12 Merge https://github.com/Spottedleaf/Tuinity into ver/1.16.2 a1b90f8 Merge branch 'master' into dev/some-opts 30c5ca5 Merge branch 'master' into dev/some-opts e59b60b Updated Upstream (Paper) 09f62a7 Rebuild patches b041d11 Merge branch 'master' of https://github.com/Spottedleaf/Tuinity into ver/1.16.2 27fca2d Merge branch 'master' into dev/some-opts a218f5d Updated Upstream (Paper) f7c5428 Updated Upstream (Paper) a17dc2c Attempt to fix incorrect nearest village distance tracker updating 8830cef Remove streams for poi searching in some zombie pathfinding 89276ac Fix villagers aggressively looking at people db64f14 Make sure to despawn entities if they are outside the player general area range ba0bfda Updated Upstream (Paper) 200f825 Actually unload POI data 3dc7b9e Updated Upstream (Paper) 30f6ca0 Merge branch 'master' of https://github.com/Spottedleaf/Tuinity into 1.16.2tmp 3b008f5 Optimisations c628aa4 Updated Upstream (Paper) 1ed41fc Updated Upstream (Paper) 193d9bf Updated Upstream (Paper) f2ac649 Updated Upstream (Paper) a63298f Upstream a12e1f6 Merge branch 'ver/1.16.2' of https://github.com/Spottedleaf/Tuinity into 1.16.2tmp 9eed723 Rebuild patches d03dbcc Updated paper c1002c5 Merge branch 'ver/1.16.2' of https://github.com/Spottedleaf/Tuinity into 1.16.2tmp 27084eb Updated paper bfb0ded Merge branch 'ver/1.16.2' of https://github.com/Spottedleaf/Tuinity into 1.16.2tmp 763aa6c Updated Upstream (Paper) 49898d0 Merge branch 'ver/1.16.2' of https://github.com/Spottedleaf/Tuinity into 1.16.2tmp 199edf5 Merge branch 'ver/1.16.2' of https://github.com/Spottedleaf/Tuinity into 1.16.2tmp 78bfcfb Update everything bbbe82e change upstream EMC Changes: 4da58340 clear more entity tasks with reloads 2f3d567f Improve temp meta reloading efd7ea89 Updated Paper 25426b02 Updated Paper 35099319 Fix blockbreaknaturally event not always having the loc stored Purpur Changes: 306e9ac Add missing repos for deps 67be68c Updated Upstream (Tuinity) cf3e3e7 Fix last patch :3 a43bb36 Arrows should not reset despawn counter f0b8bd7 Updated Upstream (Paper) f15d3f0 Updated Upstream (Tuinity) 39ce110 Fix missed obf method rename in Tuinity patches bae5baa Updated Upstream (Paper) 5569d02 Updated Upstream (Paper) 72c4c5e Updated Upstream (Paper) 7fa8baf Update readme 03654a6 Update to 1.16.4 ^_^ 0fa478d Updated Upstream (Paper & Tuinity) 3fec5da Rebuild patches 2f7a0a0 Fix client lag on advancement loading 3f325b8 Fix #86 Move pathfinders into NMS package to satisfy Paper's AI API 7cfd3d7 Updated Upstream (Paper) cc6c167 Updated Upstream (Paper)
2020-11-07 08:02:33 +01:00
de.minebench.origami.OrigamiConfig.init((java.io.File) options.valueOf("origami-settings"));
this.setPVP(dedicatedserverproperties.pvp);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft) (#392) * Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 13a476e15 Deprecate PlayerLeaveBedEvent#setBedSpawn 3a1d95c71 [Auto] Updated Upstream (CraftBukkit) d4dcc1a2e Updated Upstream (CraftBukkit) e886d8118 Updated Upstream () 8bc0c6c31 Updated Upstream (CraftBukkit/Spigot) (#5169) 002f65b8b living entity allow attribute registration (#4723) 69a5c67b1 fix calling setSize on dead slimes causing invincibility (fixes #5137) (#5168) Tuinity Changes: 502d57b Updated Upstream (Paper) 87e0cd9 Print exceptions for light scheduling Purpur Changes: 7fc2d31 Updated Upstream (Paper & Tuinity) Airplane Changes: d7d1626 Remove multithreaded entity tracker 677ec73 Ensure armor change event is on main thread c07d254 Fix crash ec7605c Updated Upstream (Tuinity) 2768f39 Update DEAR commit message e975972 Multithreaded entity tracking 98244f9 Updated Upstream (Tuinity) 44b2499 Larger headings 2c4a7fb Merge pull request #6 from Encode42/master cc19631 More changes beba27a Badges and variables 0aeaf12 Improve readability, grammar, etc. Empirecraft Changes: bbc8d297 Updated Paper * Updated Upstream and Sidestream(s) (Paper/Origami) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 3dadd97bb [CI-SKIP] [Meta] Exempt more labels from being marked as stale (#5142) 36a72cad3 [Auto] Updated Upstream (Bukkit/CraftBukkit/Spigot) Origami Changes: 168394a Access config after loading it... fixes velocity auto offline-mode c47b182 Add velocity to automatic offline mode
2021-02-08 16:31:51 +01:00
index 8ad95d3275fef85deb33fc2794f7bc3b72f917ca..5a539230b5791e0469f8de0c04af68d8895e7847 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft) (#392) * Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 13a476e15 Deprecate PlayerLeaveBedEvent#setBedSpawn 3a1d95c71 [Auto] Updated Upstream (CraftBukkit) d4dcc1a2e Updated Upstream (CraftBukkit) e886d8118 Updated Upstream () 8bc0c6c31 Updated Upstream (CraftBukkit/Spigot) (#5169) 002f65b8b living entity allow attribute registration (#4723) 69a5c67b1 fix calling setSize on dead slimes causing invincibility (fixes #5137) (#5168) Tuinity Changes: 502d57b Updated Upstream (Paper) 87e0cd9 Print exceptions for light scheduling Purpur Changes: 7fc2d31 Updated Upstream (Paper & Tuinity) Airplane Changes: d7d1626 Remove multithreaded entity tracker 677ec73 Ensure armor change event is on main thread c07d254 Fix crash ec7605c Updated Upstream (Tuinity) 2768f39 Update DEAR commit message e975972 Multithreaded entity tracking 98244f9 Updated Upstream (Tuinity) 44b2499 Larger headings 2c4a7fb Merge pull request #6 from Encode42/master cc19631 More changes beba27a Badges and variables 0aeaf12 Improve readability, grammar, etc. Empirecraft Changes: bbc8d297 Updated Paper * Updated Upstream and Sidestream(s) (Paper/Origami) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 3dadd97bb [CI-SKIP] [Meta] Exempt more labels from being marked as stale (#5142) 36a72cad3 [Auto] Updated Upstream (Bukkit/CraftBukkit/Spigot) Origami Changes: 168394a Access config after loading it... fixes velocity auto offline-mode c47b182 Add velocity to automatic offline mode
2021-02-08 16:31:51 +01:00
@@ -920,6 +920,7 @@ public final class CraftServer implements Server {
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
com.destroystokyo.paper.PaperConfig.registerCommands(); // Paper
net.pl3x.purpur.PurpurConfig.registerCommands(); // Purpur
+ org.yatopiamc.yatopia.server.YatopiaConfig.registerCommands(); // Yatopia
overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
ignoreVanillaPermissions = commandsConfiguration.getBoolean("ignore-vanilla-permissions");
diff --git a/src/main/java/org/yatopiamc/yatopia/server/NSPTCommand.java b/src/main/java/org/yatopiamc/yatopia/server/NSPTCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..e6eaa07c57e04bbfba9e4aa8e0e939f85169d0c8
--- /dev/null
+++ b/src/main/java/org/yatopiamc/yatopia/server/NSPTCommand.java
@@ -0,0 +1,59 @@
+package org.yatopiamc.yatopia.server;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+public class NSPTCommand extends Command {
+
+ public NSPTCommand(String name) {
+ super(name);
+ this.description = "View server tick times in nanoseconds";
+ this.usageMessage = "/nspt";
+ this.setPermission("bukkit.command.nspt");
+ }
+
+ @Override
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
+ if (!testPermission(sender)) return true;
+
+ MinecraftServer server = MinecraftServer.getServer();
+
+ List<String> times = new ArrayList<>();
+ times.addAll(eval(server.tickTimes5s.getTimes()));
+ times.addAll(eval(server.tickTimes10s.getTimes()));
+ times.addAll(eval(server.tickTimes60s.getTimes()));
+
+ sender.sendMessage("§6Server tick NS times §e(§7avg§e/§7min§e/§7max§e)§6 from last 5s§7,§6 10s§7,§6 1m§e:");
+ sender.sendMessage(String.format("§6◴ %s§7/%s§7/%s§e, %s§7/%s§7/%s§e, %s§7/%s§7/%s", times.toArray()));
+ return true;
+ }
+
+ private static List<String> eval(long[] times) {
+ long min = Integer.MAX_VALUE;
+ long max = 0L;
+ long total = 0L;
+ for (long value : times) {
+ if (value > 0L && value < min) min = value;
+ if (value > max) max = value;
+ total += value;
+ }
+ double avgD = ((double) total / (double) times.length);
+ return Arrays.asList(getColor(avgD), getColor(min), getColor(max));
+ }
+
+ private static String getColor(double avg) {
+ return ChatColor.COLOR_CHAR + (avg >= 5E+7 ? "c" : avg >= (4E+7) ? "e" : "a") + avg;
+ }
+}
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 003a024da8ab877895244ff9e4e4ff62288622ff..f6a8f3c4e92455eff806978d503751b6723ea858 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -6,11 +6,14 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -24,6 +27,7 @@ public class YatopiaConfig {
public static YamlConfiguration config;
public static int version; // since we're remapping sidestreams' configs we need this public
public static boolean verbose; // since we're remapping sidestreams' configs we need this public
+ private static Map<String, Command> commands;
/*========================================================================*/
public static void init(File configFile) {
@@ -39,6 +43,8 @@ public class YatopiaConfig {
config.options().header(HEADER);
config.options().copyDefaults(true);
verbose = getBoolean("verbose", false);
+ commands = new HashMap<>();
+ commands.put("nspt", new NSPTCommand("nspt"));
version = getInt("config-version", 1);
set("config-version", 1);
@@ -46,6 +52,12 @@ public class YatopiaConfig {
readConfig(YatopiaConfig.class, null);
}
+ public static void registerCommands() {
+ for (Map.Entry<String, Command> entry : commands.entrySet()) {
+ net.minecraft.server.MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Yatopia", entry.getValue());
+ }
+ }
+
private static void removeLeftovers() {
// this method is only to remove non-used values in the config