Yatopia/patches/server/0040-Add-nspt-command.patch
Simon Gardling 99a93cf526
upstream (#421)
* Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Airplane/Empirecraft/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:
d23f8b62e fix? #5222
0f2575de2 fix? #5222
7c3499702 fix? #5218
c8eec830b fix #5217
a235c77ce Adventure 4.5.0
511cd52f0 fix #5214
33d4f608b fix stupid legacy chat garbage
a1eebfea9 fix #5212 and #5213
466820160 Upstream Update (#5211)
2a0ee4b65 Add support for hex color codes in console
4e958e229 We're going on an Adventure! (#4842)
1a9735611 Stop loop when flags set to false (#5101)
a5928db4a [Auto] Updated Upstream (CraftBukkit)
5fd19303f Call PreCreatureSpawnEvent for more spawn reasons (#5201)

Tuinity Changes:
2f298d3 Fix getEntities for ender dragon parts

Purpur Changes:
55af107 Updated Upstream (Paper)
8369588 Updated Upstream (Paper & Tuinity)
14906a1 Allow for removing italics from items renamed in the anvil by starting the text with '&r'
f599c59 Update silk touch spawners patch to use adventure
e17ee14 Update anvil colors patch to use adventure
b538cd9 Updated Upstream (Paper)
c08f028 Updated Upstream (Tuinity)
90f67f8 Updated Upstream (Paper)
c98cc6b Configs for if Wither/Ender Dragon can ride vehicles
2d2e1d4 Fix Wither and Ender Dragon being able to ride boats when they cannot in Paper/Vanilla

Airplane Changes:
3fc432c [skip ci] Add Patrons section
4b9dd63 Skip POI finding if stuck in vehicle
1ba97ae Updated Upstream (Tuinity)

Empirecraft Changes:
58dee2db Updated Paper
48c1161a Updated Paper

Origami Changes:
654b344 Only try to update below hopper if non-ticking is enabled

* Updated Upstream and Sidestream(s) (Paper)

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:
d5cb9308f fix #5224

* it works, finally

* I think everything is fixed now....

* 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:
2dd5dccf0 Add config option for displayname in quit message (#5260)
63fe5e4b7 Fix further issues with rgb text pattern matching
89be8185d Don't grab the threads stacktrace when dumping same thread
ca4c781d8 [Auto] Updated Upstream (Bukkit/CraftBukkit)
6ae212125 Display name should never be null
bf2f8aeaf Add @NotNull to Key in org.bukkit.sound (#5241)
01f9b65f9 Sound can implement Adventure's Sound.Type
aa282a1a0 Don't try to deserialize a null string in legacy method
9bcd08cb3 [CI-SKIP] [Auto] Rebuild Patches
ea6fd6076 [Auto] Updated Upstream (Bukkit)
d9b02e94d Misc thread dumps (#5200)
a0093e142 Adventure 4.5.1
afea0e8ab Add links to the Adventure javadocs
846783c8a Fix a couple of typos in the javadoc for Player (#5235)
a2574d8f5 Replace usages of LegacyComponentSerializer.legacySection() in Paper-Server with PaperAdventure.LEGACY_SECTION_UXRC (#5233)
cae142b85 Enable Hex colors on PaperAdventure.LEGACY_SECTION_UXRC, and use it for sending messages to console command sender (#5230)
c1635eabb PlayerDeathEvent#getDeathMessage should provide translation for legacy reasons #5227
3f74af202 Fix Log4J converter not parsing hex without named colors (#5228)

Tuinity Changes:
7734ef0 Detail player ticking in watchdog dumps

Purpur Changes:
529c260 [ci-skip] Update Gradle to 6.8.3
831b8d7 Updated Upstream (Paper)
d3c8fb2 Updated Upstream (Paper)
4602b9b Updated Upstream (Paper)
18f97a9 Make fox breeding cooldown work, add villager breeding cooldown config
868c9ca Updated Upstream (Paper)
274c7b2 Updated Upstream (Paper)

Airplane Changes:
9f3cad3 Updated Upstream (Tuinity)

Empirecraft Changes:
3e3e8e5e Updated Paper

* Updated Upstream and Sidestream(s) (Paper/Purpur/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:
df4c68b66 fix #5279 - clickable links again
ff5ff3af4 Print command usage for /paper entity list at more places (#5282)
5d779a621 Implements PlayerHandshakeEvent#getOriginalSocketAddressHostname and deprecates PlayerHandshakeEvent(String, boolean) in favour of PlayerHandshakeEvent(String, String, boolean)
6fab1ee3a Expose Tracked Players
b53a650a5 Clear SyncLoadInfo
c02c22fde fix: legacy component serialisation was wiped out

Purpur Changes:
a5fa038 Updated Upstream (Paper)

Empirecraft Changes:
95ac7f87 Updated Paper

* Updated Upstream and Sidestream(s) (Paper)

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:
06900aef5 Fix username connecting with no texture being overwritten by usercache (#4970)

* Updated Upstream and Sidestream(s) (Paper/Purpur)

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:
9907cedec New chat events for better Adventure support (#5289)

Purpur Changes:
34f0e57 Updated Upstream (Paper)

* Updated Upstream and Sidestream(s) (Paper/Purpur/Paper)

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:
9907cedec New chat events for better Adventure support (#5289)

Purpur Changes:
34f0e57 Updated Upstream (Paper)

Paper Changes:
60e92c061 fix #5292 with help from @JRoy

* that doesn't need to be there

* Updated Upstream and Sidestream(s) (Paper/Purpur/Airplane)

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:
7d56f38ed Do not use the bukkit singleton for the GUI (Fixes #5301)
4c9bdf53a Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5299)
8647bd130 Improve ServerGUI
fcc6d3359 Throw proper exception on empty JsonList file
17d2e1291 Fix interact event in adventure mode
964e0bf42 MC-29274: Fix Wither hostility towards players
9e24a5213 Fixed furnace cook-speed multiplier losing precision when calculating cook time
c7e42faa3 Do not create unnecessary copies of the passenger list
40881ad67 added tnt minecarts to the tnt height nerf
26be708f4 Remove streams from SensorNearest
5b5989b21 fix nullability of playerlist header/footer, closes #5290
45bc531dd Fix Material#getTranslationKey for Block Materials (#5294)

Purpur Changes:
68ff99e Updated Upstream (Paper)

Airplane Changes:
80d65be Add more licenses
4d27e5b Use our own bstats, move mcdev fixes

* whoops

* Updated Upstream and Sidestream(s) (Airplane)

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.

Airplane Changes:
d50d4e1 Rewrite disabling of POI searching when stuck

* Updated Upstream and Sidestream(s) (Paper)

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:
be1687914 stop firing pressure plate EntityInteractEvent for ignored entities (fixes #4962)

* Updated Upstream and Sidestream(s) (Paper/Paper)

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:
be1687914 stop firing pressure plate EntityInteractEvent for ignored entities (fixes #4962)

Paper Changes:
aaef1d5cc fix file conversion
674d8f7f7 Make discovered maps config work in treasure maps from loot tables too

* Updated Upstream and Sidestream(s) (Paper)

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:
616b1f3cd consider enchants for destroy speed

* Updated Upstream and Sidestream(s) (Paper/Purpur/Airplane)

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:
5b20df6bf added PlayerNameEntityEvent
ff9c82444 Add worldborder events

Purpur Changes:
d93887a Updated Upstream (Paper)

Airplane Changes:
02743da Complete /airplane command
a2be422 Add /airplane command
3b90baf [SKIP-CI] Use patreon for sponsor button

* Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur)

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:
be7cde2c7 [CI-SKIP] Always check PATH for JDK (#5315)

Tuinity Changes:
09e1a10 Fix NPE in light exception handler
0ae7c2c Dump even more info for ticking entities
2e4a930 Store changed positions inside field on light engine

Purpur Changes:
c54e65f Add config for snow on blue ice
2fdd7d4 One Punch Man! (#185)
c2bd3de Dont run with scissors (#184)

* Updated Upstream and Sidestream(s) (Paper)

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:
54ec85949 Prevent grindstones from overstacking items
d7795080c Fix NPE for AIR in meta operations in ItemStack
2e70796c7 [CI-SKIP] Improve documentation of PreCreatureSpawnEvent (#5244)
7bb92e750 [CI-SKIP] Add JavaDoc links to Tag class pointing to custom Paper tags (#5285)
28cd686bf fix per-world difficulty command (#5306)

* Updated Upstream and Sidestream(s) (Tuinity/Airplane/Akarin/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.

Tuinity Changes:
71b089f Do not run raytrace logic for AIR

Airplane Changes:
815b461 Flare

Akarin Changes:
62342de Update README.md
dfcbbf5 Update SUPPORT.md
4225fcf Updated Tuinity's Paper
3950fd5 Updated build badge
f2d367c Merge branch 'ver/1.15.2' into ver/1.16.4

Empirecraft Changes:
3718e178 Updated Paper

* whoops

* Updated Upstream and Sidestream(s) (Tuinity)

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:
f87cb79 Make entity tracker use highest range of passengers

* Updated Upstream and Sidestream(s) (Airplane)

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.

Airplane Changes:
dd6a75c Updated Upstream (Tuinity)
48ff3e0 Some tweaks to increase Flare's compatibility

* Updated Upstream and Sidestream(s) (Airplane/Airplane)

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.

Airplane Changes:
dd6a75c Updated Upstream (Tuinity)
48ff3e0 Some tweaks to increase Flare's compatibility

Airplane Changes:
e7fc41a Update to latest version of Flare

* Updated Upstream and Sidestream(s) (Airplane)

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.

Airplane Changes:
86781ec Multithreaded Tracker!

* Updated Upstream and Sidestream(s) (Paper)

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:
7f72c4675 Use implementation-provided legacy serializer for events
27a8d99ec Adventure 4.7.0
e65bd35a1 Respect teams in legacy chat name if configured (#5321)
b31089a92 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5325)
a52b30814 Fix title swapping fadeIn and stay

* Updated Upstream and Sidestream(s) (Paper)

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:
e4d8a6279 Implement Keyed on World
bcb63dab7 [CI-SKIP] [Auto] Rebuild Patches
48342b06c Allow signs that are inside of the spawn protection to be right clicked to use their run_command tag
c229f90c1 Add Block#isValidTool
20e709c1d Add recipe to cook events
2dcf8bff4 legacy formatting will be the death of me
f597fea0d legacy formatting is worse than walking around in wet socks

* Updated Upstream and Sidestream(s) (Paper/Purpur)

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:
e4d8a6279 Implement Keyed on World
bcb63dab7 [CI-SKIP] [Auto] Rebuild Patches
48342b06c Allow signs that are inside of the spawn protection to be right clicked to use their run_command tag
c229f90c1 Add Block#isValidTool
20e709c1d Add recipe to cook events
2dcf8bff4 legacy formatting will be the death of me
f597fea0d legacy formatting is worse than walking around in wet socks

Purpur Changes:
63c370c One Punch Man 2: Electric Boogaloo (#187)
2021-03-09 15:11:49 -06:00

145 lines
6.5 KiB
Diff

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
index f6c6fde2e4157b4723706c2d390942026839df98..bd43204760663363fcc53c1a8c175668809f96b0 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -196,6 +196,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
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
index 89456056da3420055a9366fdddfa858e78664329..300139b0a08a83647f6e010191c475cc65106a58 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -924,6 +924,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