Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23059,7 +23059,7 @@ index cda915fcb4822689f42b25280eb99aee082ddb74..094d2d528cb74b8f1d277cd780bba7f4
thread1 -> {
DedicatedServer dedicatedServer1 = new DedicatedServer(
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3cb4037ede 100644
index b6e4af0482b4d0c8d55a43c84d6d0f1741dc0000..9d8fef4e3ea8eabd63ce368475912c5fc69c493a 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -185,7 +185,7 @@ import net.minecraft.world.scores.ScoreboardSaveData;
Expand All @@ -23071,7 +23071,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
private static MinecraftServer SERVER; // Paper
public static final Logger LOGGER = LogUtils.getLogger();
public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper
@@ -397,6 +397,93 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -398,6 +398,93 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
return minecraftServer;
}

Expand Down Expand Up @@ -23165,7 +23165,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
public MinecraftServer(
// CraftBukkit start
joptsimple.OptionSet options,
@@ -827,7 +914,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -828,7 +915,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
serverLevel.setSpawnSettings(serverLevel.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && serverLevel.getGameRules().get(GameRules.SPAWN_MONSTERS)); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean))
this.updateEffectiveRespawnData();
this.forceTicks = false; // CraftBukkit
Expand All @@ -23174,7 +23174,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
new org.bukkit.event.world.WorldLoadEvent(serverLevel.getWorld()).callEvent(); // Paper - call WorldLoadEvent
}

@@ -850,6 +937,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -851,6 +938,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public abstract boolean shouldRconBroadcast();

public boolean saveAllChunks(boolean suppressLogs, boolean flush, boolean force) {
Expand All @@ -23186,7 +23186,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
this.scoreboard.storeToSaveDataIfDirty(this.overworld().getDataStorage().computeIfAbsent(ScoreboardSaveData.TYPE));
boolean flag = false;

@@ -858,7 +950,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -859,7 +951,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
LOGGER.info("Saving chunks for level '{}'/{}", serverLevel, serverLevel.dimension().identifier());
}

Expand All @@ -23195,7 +23195,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
flag = true;
}

@@ -948,7 +1040,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -949,7 +1041,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}

Expand All @@ -23204,7 +23204,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
this.nextTickTimeNanos = Util.getNanos() + TimeUtil.NANOSECONDS_PER_MILLISECOND;

for (ServerLevel serverLevelx : this.getAllLevels()) {
@@ -958,18 +1050,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -959,18 +1051,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa

this.waitUntilNextTick();
}
Expand All @@ -23230,7 +23230,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c

this.isSaving = false;
this.resources.close();
@@ -989,6 +1077,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -990,6 +1078,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.services().nameToIdCache().save(false); // Paper - Perf: Async GameProfileCache saving
}
// Spigot end
Expand All @@ -23245,7 +23245,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
// Paper start - Improved watchdog support - move final shutdown items here
Util.shutdownExecutors();
try {
@@ -1083,16 +1179,31 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1084,16 +1180,31 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// execute small amounts of other tasks just in case the number of tasks we are
// draining is large - chunk system and packet processing may be latency sensitive

Expand Down Expand Up @@ -23280,15 +23280,15 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
profiler.pop(); // moonrise:run_all_chunk
profiler.pop(); // moonrise:run_all_tasks

@@ -1393,6 +1504,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1394,6 +1505,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa

private boolean pollTaskInternal() {
if (super.pollTask()) {
+ this.moonrise$executeMidTickTasks(); // Paper - rewrite chunk system
return true;
} else {
boolean ret = false; // Paper - force execution of all worlds, do not just bias the first
@@ -1534,6 +1646,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1535,6 +1647,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper - improve tick loop - moved into runAllTasksAtTickStart
this.runAllTasksAtTickStart(); // Paper - improve tick loop
this.tickServer(sprinting ? () -> false : this::haveTime);
Expand All @@ -23302,7 +23302,7 @@ index be6e4b5e485e10d37b5194c214f69b677622cc8a..bdaca3647425711ee8b10eb0593a9c3c
this.tickFrame.end();
this.recordEndOfTick(); // Paper - improve tick loop
profilerFiller.pop();
@@ -2559,6 +2678,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2581,6 +2700,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33353,10 +33353,10 @@ index c9bbf15b75ac4516c7d7fdfaf2390351702ca415..372030b78d25b4ff0b18575d151b0a63
return structureTemplate.save(new CompoundTag());
}
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index bdaca3647425711ee8b10eb0593a9c3cb4037ede..bd910d8263ba8c2bdbeadf33ef5244464a32f8eb 100644
index 9d8fef4e3ea8eabd63ce368475912c5fc69c493a..f1f57ddffa7fd08afb21ae7f0b4614baa5a922f8 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -383,6 +383,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -384,6 +384,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper end - improve tick loop

public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Incremental chunk and player saving


diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index bd910d8263ba8c2bdbeadf33ef5244464a32f8eb..47f34dfddfb1cce87e08c9eb93ad5b2b23c1075b 100644
index f1f57ddffa7fd08afb21ae7f0b4614baa5a922f8..ac3e0c5bf876ad12bd41886dc1e90a5707084def 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -974,7 +974,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -975,7 +975,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
boolean var4;
try {
this.isSaving = true;
Expand All @@ -17,7 +17,7 @@ index bd910d8263ba8c2bdbeadf33ef5244464a32f8eb..47f34dfddfb1cce87e08c9eb93ad5b2b
var4 = this.saveAllChunks(suppressLogs, flush, force);
} finally {
this.isSaving = false;
@@ -1617,9 +1617,29 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1618,9 +1618,29 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}

this.ticksUntilAutosave--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ index 2bc436cdf5180a7943c45fabb9fbbedae6f7db56..f312a7f5b1b2a777ab36b94ce7cbf387

@Override
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 47f34dfddfb1cce87e08c9eb93ad5b2b23c1075b..9934055a994c10d646d97a2d042d0e8b1e7e76c9 100644
index ac3e0c5bf876ad12bd41886dc1e90a5707084def..9b3def0ab384ecbdf3901d88fc9c66afb08a86c8 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1750,33 +1750,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1751,33 +1751,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}

Expand Down
4 changes: 2 additions & 2 deletions paper-server/patches/features/0028-Optimize-Hoppers.patch
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ index 0000000000000000000000000000000000000000..24a2090e068ad3c0d08705050944abdf
+ }
+}
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 9934055a994c10d646d97a2d042d0e8b1e7e76c9..e7d9306dfde918c1abb9e5320d7315810a66a4d7 100644
index 9b3def0ab384ecbdf3901d88fc9c66afb08a86c8..d1b909ba4954de55c992c67b9e8770d4c758dfb2 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1805,6 +1805,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1806,6 +1806,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
serverLevel.updateLagCompensationTick(); // Paper - lag compensation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@
public static final String COMMAND_PREFIX = "/";
private static final ThreadLocal<@Nullable ExecutionContext<CommandSourceStack>> CURRENT_EXECUTION_CONTEXT = new ThreadLocal<>();
private static final Logger LOGGER = LogUtils.getLogger();
@@ -179,6 +_,7 @@
@@ -164,7 +_,7 @@
public static final PermissionCheck LEVEL_ADMINS = new PermissionCheck.Require(Permissions.COMMANDS_ADMIN);
public static final PermissionCheck LEVEL_OWNERS = new PermissionCheck.Require(Permissions.COMMANDS_OWNER);
private static final ClientboundCommandsPacket.NodeInspector<CommandSourceStack> COMMAND_NODE_INSPECTOR = new ClientboundCommandsPacket.NodeInspector<CommandSourceStack>() {
- private final CommandSourceStack noPermissionSource = Commands.createCompilationContext(PermissionSet.NO_PERMISSIONS);
+ private final CommandSourceStack noPermissionSource = Commands.createCompilationContext(PermissionSet.NO_PERMISSIONS); // Paper - diff on change - don't violate API contracts for location nullability

@Override
public @Nullable Identifier suggestionId(ArgumentCommandNode<CommandSourceStack, ?> node) {
@@ -179,13 +_,25 @@

@Override
public boolean isRestricted(CommandNode<CommandSourceStack> node) {
+ if (node.getRequirement() instanceof RestrictedMarker) return true; // Paper - restricted api
Predicate<CommandSourceStack> requirement = node.getRequirement();
+ // Paper start - don't violate API contracts for location nullability
+ final var server = net.minecraft.server.MinecraftServer.getServer();
+ if (server != null) {
+ return !requirement.test(server.getOrCreateNoPermissionsCommandSourceStack());
+ }
+ // Paper end - don't violate API contracts for location nullability
return !requirement.test(this.noPermissionSource);
}
@@ -186,6 +_,11 @@
};
private final CommandDispatcher<CommandSourceStack> dispatcher = new CommandDispatcher<>();

public Commands(Commands.CommandSelection selection, CommandBuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
private int playerIdleTimeout;
private final long[] tickTimesNanos = new long[100];
private long aggregatedTickTimesNanos = 0L;
@@ -281,10 +_,109 @@
@@ -281,10 +_,110 @@
private final DiscontinuousFrame tickFrame;
private final PacketProcessor packetProcessor;

+ private @Nullable CommandSourceStack noPermissionsCommandSourceStack = null; // Paper - don't violate API contracts for location nullability
+ // CraftBukkit start
+ public final WorldLoader.DataLoadContext worldLoaderContext;
+ public org.bukkit.craftbukkit.CraftServer server;
Expand Down Expand Up @@ -1124,7 +1125,7 @@

profilerFiller.popPush("connection");
this.tickConnection();
@@ -1176,9 +_,12 @@
@@ -1176,10 +_,14 @@
this.serverActivityMonitor.tick();
}

Expand All @@ -1137,8 +1138,10 @@
+ respawnData = respawnData.withLevel(serverLevel.dimension());
+ // Paper end - per world respawn data - read "server global" respawn data from overworld dimension reference
this.effectiveRespawnData = serverLevel.getWorldBorderAdjustedRespawnData(respawnData);
+ this.noPermissionsCommandSourceStack = null; // Paper - don't violate API contracts for location nullability
}

public void tickConnection() {
@@ -1228,6 +_,22 @@
return this.levels.get(dimension);
}
Expand Down Expand Up @@ -1363,6 +1366,42 @@
}
}
}
@@ -1718,6 +_,26 @@
return this.resources.managers.getCommands();
}

+ // Paper start - don't violate API contracts for location nullability
+ public CommandSourceStack getOrCreateNoPermissionsCommandSourceStack() {
+ if (this.noPermissionsCommandSourceStack != null) {
+ return this.noPermissionsCommandSourceStack;
+ }
+ ServerLevel serverLevel = this.findRespawnDimension();
+ this.noPermissionsCommandSourceStack = new CommandSourceStack(
+ this,
+ Vec3.atLowerCornerOf(this.getRespawnData().pos()),
+ Vec2.ZERO,
+ serverLevel,
+ PermissionSet.NO_PERMISSIONS,
+ "",
+ net.minecraft.network.chat.CommonComponents.EMPTY,
+ this,
+ null
+ );
+ return this.noPermissionsCommandSourceStack;
+ }
+ // Paper end - don't violate API contracts for location nullability
public CommandSourceStack createCommandSourceStack() {
ServerLevel serverLevel = this.findRespawnDimension();
return new CommandSourceStack(
@@ -1725,7 +_,7 @@
Vec3.atLowerCornerOf(this.getRespawnData().pos()),
Vec2.ZERO,
serverLevel,
- LevelBasedPermissionSet.OWNER,
+ PermissionSet.NO_PERMISSIONS,
"Server",
Component.literal("Server"),
this,
@@ -1734,12 +_,12 @@
}

Expand Down
Loading