mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-06-21 17:57:50 +02:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@6fe7eb5a Load World Key when its instance is created (#13818) PaperMC/Paper@944ce44a Fix CraftWorld identifier passing PaperMC/Paper@aa6f09b0 Prevent Happy Ghast from playing mount/dismount noises when silenced (#13807) PaperMC/Paper@7b31cc2b Make leaveMessage in PlayerKickEvent nullable (#13804) PaperMC/Paper@65461225 Update health after setPlayerProfile() (#13717) PaperMC/Paper@1a8417b1 [ci/skip] Add Javadocs for PotionEffect withX methods (#13723) PaperMC/Paper@4af86ff3 Handle null ServerLevel in fromGlobalPos (#13703) PaperMC/Paper@c39822ae reset pending keepalive state on listener handoff during reconfiguration (#13712) PaperMC/Paper@dcf5577a Fix PlayerProfile applySkinToPlayerHeadContents (#13692) PaperMC/Paper@dd203a27 chore: Don't log errors for accepting the EULA via the system property (#13681) PaperMC/Paper@d74f6bc7 Support for Kill damageable entities (#13667) PaperMC/Paper@90aee8e0 Update world methods to take in account environment attributes (#13543) PaperMC/Paper@b2b1e177 Improvement to Vehicle damage events (#13572) PaperMC/Paper@49daadd2 Fix insomniaStartTicks option being ignored for phantom spawning (#13609) PaperMC/Paper@57d84f68 Prevent NPE on ThrownPotion#splash (#13683) PaperMC/Paper@4f184db3 Fix memory leak on constantly damage (#13455) PaperMC/Paper@60073714 Update MOJIRA reference in DeOp command response for multiple targets [ci/skip] (#13812) PaperMC/Paper@4aef3f0a Remove already fixed vanilla bug MC-244739 (#13787) PaperMC/Paper@945aea99 Fix Damager for HangingBreakByEntityEvent and minor improvements (#12615) PaperMC/Paper@a8c05a35 Add an option to WorldCreator to avoid spawn location computation on world creation (#13407) PaperMC/Paper@182b2f8a Add Point Of Interest API (#12117) PaperMC/Paper@8021488e Disconnect State Fixes (#13616) PaperMC/Paper@1f819732 Allow ServerboundChangeGameModePacket if player has /gamemode permissions (#13507) PaperMC/Paper@a64ea13e Re-implement per-world and per-player time (#13814) PaperMC/Paper@acfe105b Add options to disable chunk and block entity ticking (#13821) PaperMC/Paper@651d8481 Finish world key initial migration (#13824) PaperMC/Paper@f4e769a7 Improvements checks for arguments numbers (#13290) PaperMC/Paper@5dc4afc1 Promote build channel to BETA PaperMC/Paper@55be6c0e Fix boat and minecart inventories on region switch [ci/skip] (#13826) PaperMC/Paper@7799bf28 Update Paperclip to v3.0.4
98 lines
6.1 KiB
Diff
98 lines
6.1 KiB
Diff
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -320,6 +_,7 @@
|
|
public joptsimple.OptionSet options;
|
|
public org.bukkit.command.ConsoleCommandSender console;
|
|
public static int currentTick; // Paper - improve tick loop
|
|
+ public static final long startTimeMillis = System.currentTimeMillis(); // Purpur - Add uptime command
|
|
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
|
public int autosavePeriod;
|
|
// Paper - don't store the vanilla dispatcher
|
|
@@ -336,6 +_,8 @@
|
|
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
|
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
|
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
|
+ public boolean lagging = false; // Purpur - Lagging threshold
|
|
+ protected boolean upnp = false; // Purpur - UPnP Port Forwarding
|
|
// Paper start - improve tick loop
|
|
public final ca.spottedleaf.moonrise.common.time.TickData tickTimes1s = new ca.spottedleaf.moonrise.common.time.TickData(java.util.concurrent.TimeUnit.SECONDS.toNanos(1L));
|
|
public final ca.spottedleaf.moonrise.common.time.TickData tickTimes5s = new ca.spottedleaf.moonrise.common.time.TickData(java.util.concurrent.TimeUnit.SECONDS.toNanos(5L));
|
|
@@ -420,6 +_,7 @@
|
|
public double[] computeTPS() {
|
|
final long interval = this.tickRateManager().nanosecondsPerTick();
|
|
return new double[] {
|
|
+ getTPS(this.tickTimes5s, interval), // Purpur - Add 5 second tps average in /tps
|
|
getTPS(this.tickTimes1m, interval),
|
|
getTPS(this.tickTimes5m, interval),
|
|
getTPS(this.tickTimes15m, interval)
|
|
@@ -1057,6 +_,15 @@
|
|
|
|
LOGGER.info("Stopping server");
|
|
Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
|
|
+ // Purpur start - UPnP Port Forwarding
|
|
+ if (upnp) {
|
|
+ if (dev.omega24.upnp4j.UPnP4J.close(this.getPort(), dev.omega24.upnp4j.util.Protocol.TCP)) {
|
|
+ LOGGER.info("[UPnP] Port {} closed", this.getPort());
|
|
+ } else {
|
|
+ LOGGER.error("[UPnP] Failed to close port {}", this.getPort());
|
|
+ }
|
|
+ }
|
|
+ // Purpur end - UPnP Port Forwarding
|
|
// CraftBukkit start
|
|
if (this.server != null) {
|
|
this.server.spark.disable(); // Paper - spark
|
|
@@ -1151,6 +_,8 @@
|
|
this.safeShutdown(wait, false);
|
|
}
|
|
public void safeShutdown(final boolean wait, final boolean isRestarting) {
|
|
+ org.purpurmc.purpur.task.BossBarTask.stopAll(); // Purpur - Implement TPSBar
|
|
+ org.purpurmc.purpur.task.BeehiveTask.instance().unregister(); // Purpur - Give bee counts in beehives to Purpur clients
|
|
this.isRestarting = isRestarting;
|
|
this.hasLoggedStop = true; // Paper - Debugging
|
|
if (this.isDebugging()) io.papermc.paper.util.TraceUtil.dumpTraceForThread("Server stopped"); // Paper - Debugging
|
|
@@ -1332,11 +_,21 @@
|
|
}
|
|
// Paper end - Add onboarding message for initial server start
|
|
// Paper start - Improve outdated version checking
|
|
- if (System.getProperty("paper.disableStartupVersionCheck") == null && io.papermc.paper.configuration.GlobalConfiguration.get().updateChecker.enabled) {
|
|
+ if (false && System.getProperty("paper.disableStartupVersionCheck") == null && io.papermc.paper.configuration.GlobalConfiguration.get().updateChecker.enabled) { // Purpur - disable paper startup check
|
|
CompletableFuture.runAsync(com.destroystokyo.paper.PaperVersionFetcher::getUpdateStatusStartupMessage, io.papermc.paper.util.MCUtil.ASYNC_EXECUTOR);
|
|
}
|
|
// Paper end - Improve outdated version checking
|
|
|
|
+ // Purpur start - config for startup commands
|
|
+ if (!Boolean.getBoolean("Purpur.IReallyDontWantStartupCommands") && !org.purpurmc.purpur.PurpurConfig.startupCommands.isEmpty()) {
|
|
+ LOGGER.info("Purpur: Running startup commands specified in purpur.yml.");
|
|
+ for (final String startupCommand : org.purpurmc.purpur.PurpurConfig.startupCommands) {
|
|
+ LOGGER.info("Purpur: Running the following command: \"{}\"", startupCommand);
|
|
+ ((net.minecraft.server.dedicated.DedicatedServer) this).handleConsoleInput(startupCommand, this.createCommandSourceStack());
|
|
+ }
|
|
+ }
|
|
+ // Purpur end - config for startup commands
|
|
+
|
|
while (this.running) {
|
|
final long tickStart = System.nanoTime(); // Paper - improve tick loop
|
|
long thisTickNanos; // Paper - improve tick loop - diff on change, expect this to be tick interval
|
|
@@ -1350,9 +_,11 @@
|
|
final long ticksBehind = Math.max(1L, this.tickSchedule.getPeriodsAhead(thisTickNanos, tickStart));
|
|
final long catchup = (long)Math.max(
|
|
1,
|
|
- 5 //ConfigHolder.getConfig().tickLoop.catchupTicks.getOrDefault(MoonriseConfig.TickLoop.DEFAULT_CATCHUP_TICKS).intValue()
|
|
+ org.purpurmc.purpur.PurpurConfig.tpsCatchup ? 5 : 1 //ConfigHolder.getConfig().tickLoop.catchupTicks.getOrDefault(MoonriseConfig.TickLoop.DEFAULT_CATCHUP_TICKS).intValue() // Purpur - Configurable TPS Catchup
|
|
);
|
|
|
|
+ lagging = getTPS()[0] < org.purpurmc.purpur.PurpurConfig.laggingThreshold; // Purpur - Lagging threshold
|
|
+
|
|
// adjust ticksBehind so that it is not greater-than catchup
|
|
if (ticksBehind - catchup > 0L) {
|
|
final long difference = ticksBehind - catchup;
|
|
@@ -1983,7 +_,7 @@
|
|
}
|
|
|
|
public String getServerModName() {
|
|
- return io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); // Paper
|
|
+ return org.purpurmc.purpur.PurpurConfig.serverModName; // Paper // Purpur - Configurable server mod name
|
|
}
|
|
|
|
public ServerClockManager clockManager() {
|