mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Bundle spark
This commit is contained in:
parent
29e03d0439
commit
855db272b1
6 changed files with 321 additions and 69 deletions
|
@ -72,6 +72,10 @@ dependencies {
|
||||||
implementation("io.papermc:reflection-rewriter-runtime:$reflectionRewriterVersion")
|
implementation("io.papermc:reflection-rewriter-runtime:$reflectionRewriterVersion")
|
||||||
implementation("io.papermc:reflection-rewriter-proxy-generator:$reflectionRewriterVersion")
|
implementation("io.papermc:reflection-rewriter-proxy-generator:$reflectionRewriterVersion")
|
||||||
// Paper end - Remap reflection
|
// Paper end - Remap reflection
|
||||||
|
// Paper start - spark
|
||||||
|
implementation("me.lucko:spark-api:0.1-20240720.200737-2")
|
||||||
|
implementation("me.lucko:spark-paper:1.10.119-SNAPSHOT")
|
||||||
|
// Paper end - spark
|
||||||
}
|
}
|
||||||
|
|
||||||
paperweight {
|
paperweight {
|
||||||
|
|
|
@ -308,7 +308,7 @@
|
||||||
if (profiledduration != null) {
|
if (profiledduration != null) {
|
||||||
profiledduration.finish(true);
|
profiledduration.finish(true);
|
||||||
}
|
}
|
||||||
@@ -387,23 +468,244 @@
|
@@ -387,23 +468,246 @@
|
||||||
|
|
||||||
protected void forceDifficulty() {}
|
protected void forceDifficulty() {}
|
||||||
|
|
||||||
|
@ -547,6 +547,8 @@
|
||||||
+ // Paper end - Configurable player collision
|
+ // Paper end - Configurable player collision
|
||||||
+
|
+
|
||||||
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
||||||
|
+ this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
|
||||||
|
+ this.server.spark.enableAfterPlugins(this.server); // Paper - spark
|
||||||
+ if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
|
+ if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
|
||||||
+ io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // Paper - reset invalid state for event fire below
|
+ io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // Paper - reset invalid state for event fire below
|
||||||
+ io.papermc.paper.plugin.lifecycle.event.LifecycleEventRunner.INSTANCE.callReloadableRegistrarEvent(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, io.papermc.paper.command.brigadier.PaperCommands.INSTANCE, org.bukkit.plugin.Plugin.class, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.INITIAL); // Paper - call commands event for regular plugins
|
+ io.papermc.paper.plugin.lifecycle.event.LifecycleEventRunner.INSTANCE.callReloadableRegistrarEvent(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, io.papermc.paper.command.brigadier.PaperCommands.INSTANCE, org.bukkit.plugin.Plugin.class, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.INITIAL); // Paper - call commands event for regular plugins
|
||||||
|
@ -567,7 +569,7 @@
|
||||||
|
|
||||||
if (!iworlddataserver.isInitialized()) {
|
if (!iworlddataserver.isInitialized()) {
|
||||||
try {
|
try {
|
||||||
@@ -427,30 +729,8 @@
|
@@ -427,30 +731,8 @@
|
||||||
iworlddataserver.setInitialized(true);
|
iworlddataserver.setInitialized(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +601,7 @@
|
||||||
|
|
||||||
private static void setInitialSpawn(ServerLevel world, ServerLevelData worldProperties, boolean bonusChest, boolean debugWorld) {
|
private static void setInitialSpawn(ServerLevel world, ServerLevelData worldProperties, boolean bonusChest, boolean debugWorld) {
|
||||||
if (debugWorld) {
|
if (debugWorld) {
|
||||||
@@ -458,6 +738,21 @@
|
@@ -458,6 +740,21 @@
|
||||||
} else {
|
} else {
|
||||||
ServerChunkCache chunkproviderserver = world.getChunkSource();
|
ServerChunkCache chunkproviderserver = world.getChunkSource();
|
||||||
ChunkPos chunkcoordintpair = new ChunkPos(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
ChunkPos chunkcoordintpair = new ChunkPos(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||||
|
@ -621,7 +623,7 @@
|
||||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(world);
|
int i = chunkproviderserver.getGenerator().getSpawnHeight(world);
|
||||||
|
|
||||||
if (i < world.getMinY()) {
|
if (i < world.getMinY()) {
|
||||||
@@ -516,31 +811,36 @@
|
@@ -516,31 +813,36 @@
|
||||||
iworlddataserver.setGameType(GameType.SPECTATOR);
|
iworlddataserver.setGameType(GameType.SPECTATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,7 +671,7 @@
|
||||||
ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) worldserver1.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks");
|
ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) worldserver1.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks");
|
||||||
|
|
||||||
if (forcedchunk != null) {
|
if (forcedchunk != null) {
|
||||||
@@ -555,10 +855,17 @@
|
@@ -555,10 +857,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,7 +693,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameType getDefaultGameType() {
|
public GameType getDefaultGameType() {
|
||||||
@@ -588,12 +895,16 @@
|
@@ -588,12 +897,16 @@
|
||||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force);
|
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +712,7 @@
|
||||||
if (flush) {
|
if (flush) {
|
||||||
Iterator iterator1 = this.getAllLevels().iterator();
|
Iterator iterator1 = this.getAllLevels().iterator();
|
||||||
|
|
||||||
@@ -628,18 +939,45 @@
|
@@ -628,18 +941,46 @@
|
||||||
this.stopServer();
|
this.stopServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,6 +743,7 @@
|
||||||
+ Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
|
+ Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (this.server != null) {
|
+ if (this.server != null) {
|
||||||
|
+ this.server.spark.disable(); // Paper - spark
|
||||||
+ this.server.disablePlugins();
|
+ this.server.disablePlugins();
|
||||||
+ this.server.waitForAsyncTasksShutdown(); // Paper - Wait for Async Tasks during shutdown
|
+ this.server.waitForAsyncTasksShutdown(); // Paper - Wait for Async Tasks during shutdown
|
||||||
+ }
|
+ }
|
||||||
|
@ -757,7 +760,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
MinecraftServer.LOGGER.info("Saving worlds");
|
MinecraftServer.LOGGER.info("Saving worlds");
|
||||||
@@ -693,6 +1031,15 @@
|
@@ -693,6 +1034,15 @@
|
||||||
} catch (IOException ioexception1) {
|
} catch (IOException ioexception1) {
|
||||||
MinecraftServer.LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception1);
|
MinecraftServer.LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception1);
|
||||||
}
|
}
|
||||||
|
@ -773,7 +776,7 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,6 +1056,14 @@
|
@@ -709,6 +1059,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void halt(boolean waitForShutdown) {
|
public void halt(boolean waitForShutdown) {
|
||||||
|
@ -788,7 +791,7 @@
|
||||||
this.running = false;
|
this.running = false;
|
||||||
if (waitForShutdown) {
|
if (waitForShutdown) {
|
||||||
try {
|
try {
|
||||||
@@ -720,6 +1075,64 @@
|
@@ -720,6 +1078,64 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,14 +856,15 @@
|
||||||
protected void runServer() {
|
protected void runServer() {
|
||||||
try {
|
try {
|
||||||
if (!this.initServer()) {
|
if (!this.initServer()) {
|
||||||
@@ -727,8 +1140,25 @@
|
@@ -727,9 +1143,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nextTickTimeNanos = Util.getNanos();
|
this.nextTickTimeNanos = Util.getNanos();
|
||||||
- this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse((Object) null);
|
- this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse((Object) null);
|
||||||
+ this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error
|
+ this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error
|
||||||
this.status = this.buildServerStatus();
|
this.status = this.buildServerStatus();
|
||||||
+
|
|
||||||
|
+ this.server.spark.enableBeforePlugins(); // Paper - spark
|
||||||
+ // Spigot start
|
+ // Spigot start
|
||||||
+ org.spigotmc.WatchdogThread.hasStarted = true; // Paper
|
+ org.spigotmc.WatchdogThread.hasStarted = true; // Paper
|
||||||
+ Arrays.fill( this.recentTps, 20 );
|
+ Arrays.fill( this.recentTps, 20 );
|
||||||
|
@ -877,10 +881,11 @@
|
||||||
+ LOGGER.info("*************************************************************************************");
|
+ LOGGER.info("*************************************************************************************");
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Add onboarding message for initial server start
|
+ // Paper end - Add onboarding message for initial server start
|
||||||
|
+
|
||||||
while (this.running) {
|
while (this.running) {
|
||||||
long i;
|
long i;
|
||||||
@@ -744,11 +1174,30 @@
|
|
||||||
|
@@ -744,12 +1178,31 @@
|
||||||
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
|
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
|
||||||
long k = j / i;
|
long k = j / i;
|
||||||
|
|
||||||
|
@ -889,7 +894,7 @@
|
||||||
this.nextTickTimeNanos += k * i;
|
this.nextTickTimeNanos += k * i;
|
||||||
this.lastOverloadWarningNanos = this.nextTickTimeNanos;
|
this.lastOverloadWarningNanos = this.nextTickTimeNanos;
|
||||||
}
|
}
|
||||||
+ }
|
}
|
||||||
+ // Spigot start
|
+ // Spigot start
|
||||||
+ // Paper start - further improve server tick loop
|
+ // Paper start - further improve server tick loop
|
||||||
+ currentTime = Util.getNanos();
|
+ currentTime = Util.getNanos();
|
||||||
|
@ -899,19 +904,20 @@
|
||||||
+ tps1.add(currentTps, diff);
|
+ tps1.add(currentTps, diff);
|
||||||
+ tps5.add(currentTps, diff);
|
+ tps5.add(currentTps, diff);
|
||||||
+ tps15.add(currentTps, diff);
|
+ tps15.add(currentTps, diff);
|
||||||
+
|
|
||||||
+ // Backwards compat with bad plugins
|
+ // Backwards compat with bad plugins
|
||||||
+ this.recentTps[0] = tps1.getAverage();
|
+ this.recentTps[0] = tps1.getAverage();
|
||||||
+ this.recentTps[1] = tps5.getAverage();
|
+ this.recentTps[1] = tps5.getAverage();
|
||||||
+ this.recentTps[2] = tps15.getAverage();
|
+ this.recentTps[2] = tps15.getAverage();
|
||||||
+ tickSection = currentTime;
|
+ tickSection = currentTime;
|
||||||
}
|
+ }
|
||||||
+ // Paper end - further improve server tick loop
|
+ // Paper end - further improve server tick loop
|
||||||
+ // Spigot end
|
+ // Spigot end
|
||||||
|
+
|
||||||
boolean flag = i == 0L;
|
boolean flag = i == 0L;
|
||||||
|
|
||||||
@@ -757,6 +1206,8 @@
|
if (this.debugCommandProfilerDelayStart) {
|
||||||
|
@@ -757,6 +1210,8 @@
|
||||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
|
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,7 +926,7 @@
|
||||||
this.nextTickTimeNanos += i;
|
this.nextTickTimeNanos += i;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -830,6 +1281,14 @@
|
@@ -830,6 +1285,14 @@
|
||||||
this.services.profileCache().clearExecutor();
|
this.services.profileCache().clearExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,7 +941,7 @@
|
||||||
this.onServerExit();
|
this.onServerExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,9 +1348,16 @@
|
@@ -889,9 +1352,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean haveTime() {
|
private boolean haveTime() {
|
||||||
|
@ -953,7 +959,7 @@
|
||||||
public static boolean throwIfFatalException() {
|
public static boolean throwIfFatalException() {
|
||||||
RuntimeException runtimeexception = (RuntimeException) MinecraftServer.fatalException.get();
|
RuntimeException runtimeexception = (RuntimeException) MinecraftServer.fatalException.get();
|
||||||
|
|
||||||
@@ -903,7 +1369,7 @@
|
@@ -903,7 +1373,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFatalException(RuntimeException exception) {
|
public static void setFatalException(RuntimeException exception) {
|
||||||
|
@ -962,7 +968,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -961,6 +1427,7 @@
|
@@ -961,6 +1431,7 @@
|
||||||
if (super.pollTask()) {
|
if (super.pollTask()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -970,7 +976,7 @@
|
||||||
if (this.tickRateManager.isSprinting() || this.haveTime()) {
|
if (this.tickRateManager.isSprinting() || this.haveTime()) {
|
||||||
Iterator iterator = this.getAllLevels().iterator();
|
Iterator iterator = this.getAllLevels().iterator();
|
||||||
|
|
||||||
@@ -968,16 +1435,16 @@
|
@@ -968,16 +1439,16 @@
|
||||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||||
|
|
||||||
if (worldserver.getChunkSource().pollTask()) {
|
if (worldserver.getChunkSource().pollTask()) {
|
||||||
|
@ -990,7 +996,7 @@
|
||||||
Profiler.get().incrementCounter("runTask");
|
Profiler.get().incrementCounter("runTask");
|
||||||
super.doRunTask(ticktask);
|
super.doRunTask(ticktask);
|
||||||
}
|
}
|
||||||
@@ -1025,6 +1492,7 @@
|
@@ -1025,6 +1496,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tickServer(BooleanSupplier shouldKeepTicking) {
|
public void tickServer(BooleanSupplier shouldKeepTicking) {
|
||||||
|
@ -998,21 +1004,30 @@
|
||||||
long i = Util.getNanos();
|
long i = Util.getNanos();
|
||||||
int j = this.pauseWhileEmptySeconds() * 20;
|
int j = this.pauseWhileEmptySeconds() * 20;
|
||||||
|
|
||||||
@@ -1041,11 +1509,13 @@
|
@@ -1036,16 +1508,22 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.emptyTicks >= j) {
|
||||||
|
+ this.server.spark.tickStart(); // Paper - spark
|
||||||
|
if (this.emptyTicks == j) {
|
||||||
|
MinecraftServer.LOGGER.info("Server empty for {} seconds, pausing", this.pauseWhileEmptySeconds());
|
||||||
this.autoSave();
|
this.autoSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
+ this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
|
+ this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
|
||||||
|
+ this.server.spark.executeMainThreadTasks(); // Paper - spark
|
||||||
this.tickConnection();
|
this.tickConnection();
|
||||||
|
+ this.server.spark.tickEnd(((double)(System.nanoTime() - lastTick) / 1000000D)); // Paper - spark
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ this.server.spark.tickStart(); // Paper - spark
|
||||||
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper - Server Tick Events
|
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper - Server Tick Events
|
||||||
++this.tickCount;
|
++this.tickCount;
|
||||||
this.tickRateManager.tick();
|
this.tickRateManager.tick();
|
||||||
this.tickChildren(shouldKeepTicking);
|
this.tickChildren(shouldKeepTicking);
|
||||||
@@ -1055,12 +1525,18 @@
|
@@ -1055,12 +1533,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
--this.ticksUntilAutosave;
|
--this.ticksUntilAutosave;
|
||||||
|
@ -1024,15 +1039,17 @@
|
||||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||||
|
|
||||||
+ this.runAllTasks(); // Paper - move runAllTasks() into full server tick (previously for timings)
|
+ this.runAllTasks(); // Paper - move runAllTasks() into full server tick (previously for timings)
|
||||||
|
+ this.server.spark.executeMainThreadTasks(); // Paper - spark
|
||||||
+ // Paper start - Server Tick Events
|
+ // Paper start - Server Tick Events
|
||||||
+ long endTime = System.nanoTime();
|
+ long endTime = System.nanoTime();
|
||||||
+ long remaining = (TICK_TIME - (endTime - lastTick)) - catchupTime;
|
+ long remaining = (TICK_TIME - (endTime - lastTick)) - catchupTime;
|
||||||
+ new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.tickCount, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent();
|
+ new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.tickCount, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent();
|
||||||
+ // Paper end - Server Tick Events
|
+ // Paper end - Server Tick Events
|
||||||
|
+ this.server.spark.tickEnd(((double)(endTime - lastTick) / 1000000D)); // Paper - spark
|
||||||
gameprofilerfiller.push("tallying");
|
gameprofilerfiller.push("tallying");
|
||||||
long k = Util.getNanos() - i;
|
long k = Util.getNanos() - i;
|
||||||
int l = this.tickCount % 100;
|
int l = this.tickCount % 100;
|
||||||
@@ -1069,12 +1545,17 @@
|
@@ -1069,12 +1555,17 @@
|
||||||
this.aggregatedTickTimesNanos += k;
|
this.aggregatedTickTimesNanos += k;
|
||||||
this.tickTimesNanos[l] = k;
|
this.tickTimesNanos[l] = k;
|
||||||
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
|
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
|
||||||
|
@ -1051,7 +1068,7 @@
|
||||||
MinecraftServer.LOGGER.debug("Autosave started");
|
MinecraftServer.LOGGER.debug("Autosave started");
|
||||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||||
|
|
||||||
@@ -1123,7 +1604,7 @@
|
@@ -1123,7 +1614,7 @@
|
||||||
private ServerStatus buildServerStatus() {
|
private ServerStatus buildServerStatus() {
|
||||||
ServerStatus.Players serverping_serverpingplayersample = this.buildPlayerStatus();
|
ServerStatus.Players serverping_serverpingplayersample = this.buildPlayerStatus();
|
||||||
|
|
||||||
|
@ -1060,7 +1077,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerStatus.Players buildPlayerStatus() {
|
private ServerStatus.Players buildPlayerStatus() {
|
||||||
@@ -1133,7 +1614,7 @@
|
@@ -1133,7 +1624,7 @@
|
||||||
if (this.hidesOnlinePlayers()) {
|
if (this.hidesOnlinePlayers()) {
|
||||||
return new ServerStatus.Players(i, list.size(), List.of());
|
return new ServerStatus.Players(i, list.size(), List.of());
|
||||||
} else {
|
} else {
|
||||||
|
@ -1069,7 +1086,7 @@
|
||||||
ObjectArrayList<GameProfile> objectarraylist = new ObjectArrayList(j);
|
ObjectArrayList<GameProfile> objectarraylist = new ObjectArrayList(j);
|
||||||
int k = Mth.nextInt(this.random, 0, list.size() - j);
|
int k = Mth.nextInt(this.random, 0, list.size() - j);
|
||||||
|
|
||||||
@@ -1154,24 +1635,72 @@
|
@@ -1154,24 +1645,72 @@
|
||||||
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
||||||
entityplayer.connection.suspendFlushing();
|
entityplayer.connection.suspendFlushing();
|
||||||
});
|
});
|
||||||
|
@ -1094,7 +1111,7 @@
|
||||||
gameprofilerfiller.popPush("levels");
|
gameprofilerfiller.popPush("levels");
|
||||||
- Iterator iterator = this.getAllLevels().iterator();
|
- Iterator iterator = this.getAllLevels().iterator();
|
||||||
+ //Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; moved down
|
+ //Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; moved down
|
||||||
+
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ // Run tasks that are waiting on processing
|
+ // Run tasks that are waiting on processing
|
||||||
+ while (!this.processQueue.isEmpty()) {
|
+ while (!this.processQueue.isEmpty()) {
|
||||||
|
@ -1120,7 +1137,7 @@
|
||||||
+ // Paper end - Perf: Optimize time updates
|
+ // Paper end - Perf: Optimize time updates
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ this.isIteratingOverLevels = true; // Paper - Throw exception on world create while being ticked
|
+ this.isIteratingOverLevels = true; // Paper - Throw exception on world create while being ticked
|
||||||
+ Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; move down
|
+ Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; move down
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -1143,7 +1160,7 @@
|
||||||
|
|
||||||
gameprofilerfiller.push("tick");
|
gameprofilerfiller.push("tick");
|
||||||
|
|
||||||
@@ -1186,7 +1715,9 @@
|
@@ -1186,7 +1725,9 @@
|
||||||
|
|
||||||
gameprofilerfiller.pop();
|
gameprofilerfiller.pop();
|
||||||
gameprofilerfiller.pop();
|
gameprofilerfiller.pop();
|
||||||
|
@ -1153,7 +1170,7 @@
|
||||||
|
|
||||||
gameprofilerfiller.popPush("connection");
|
gameprofilerfiller.popPush("connection");
|
||||||
this.tickConnection();
|
this.tickConnection();
|
||||||
@@ -1267,6 +1798,22 @@
|
@@ -1267,6 +1808,22 @@
|
||||||
return (ServerLevel) this.levels.get(key);
|
return (ServerLevel) this.levels.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1176,7 +1193,7 @@
|
||||||
public Set<ResourceKey<Level>> levelKeys() {
|
public Set<ResourceKey<Level>> levelKeys() {
|
||||||
return this.levels.keySet();
|
return this.levels.keySet();
|
||||||
}
|
}
|
||||||
@@ -1296,7 +1843,7 @@
|
@@ -1296,7 +1853,7 @@
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
public String getServerModName() {
|
public String getServerModName() {
|
||||||
|
@ -1185,7 +1202,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemReport fillSystemReport(SystemReport details) {
|
public SystemReport fillSystemReport(SystemReport details) {
|
||||||
@@ -1347,7 +1894,7 @@
|
@@ -1347,7 +1904,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendSystemMessage(Component message) {
|
public void sendSystemMessage(Component message) {
|
||||||
|
@ -1194,7 +1211,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyPair getKeyPair() {
|
public KeyPair getKeyPair() {
|
||||||
@@ -1385,11 +1932,14 @@
|
@@ -1385,11 +1942,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1214,7 +1231,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1403,7 +1953,7 @@
|
@@ -1403,7 +1963,7 @@
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||||
|
|
||||||
|
@ -1223,7 +1240,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1481,10 +2031,20 @@
|
@@ -1481,10 +2041,20 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMotd() {
|
public String getMotd() {
|
||||||
|
@ -1245,7 +1262,7 @@
|
||||||
this.motd = motd;
|
this.motd = motd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1507,7 +2067,7 @@
|
@@ -1507,7 +2077,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerConnectionListener getConnection() {
|
public ServerConnectionListener getConnection() {
|
||||||
|
@ -1254,7 +1271,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReady() {
|
public boolean isReady() {
|
||||||
@@ -1593,7 +2153,7 @@
|
@@ -1593,7 +2163,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void executeIfPossible(Runnable runnable) {
|
public void executeIfPossible(Runnable runnable) {
|
||||||
if (this.isStopped()) {
|
if (this.isStopped()) {
|
||||||
|
@ -1263,7 +1280,7 @@
|
||||||
} else {
|
} else {
|
||||||
super.executeIfPossible(runnable);
|
super.executeIfPossible(runnable);
|
||||||
}
|
}
|
||||||
@@ -1632,13 +2192,19 @@
|
@@ -1632,13 +2202,19 @@
|
||||||
return this.functionManager;
|
return this.functionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,7 +1302,7 @@
|
||||||
}, this).thenCompose((immutablelist) -> {
|
}, this).thenCompose((immutablelist) -> {
|
||||||
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
|
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
|
||||||
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
|
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
|
||||||
@@ -1652,6 +2218,7 @@
|
@@ -1652,6 +2228,7 @@
|
||||||
return new MinecraftServer.ReloadableResources(resourcemanager, datapackresources);
|
return new MinecraftServer.ReloadableResources(resourcemanager, datapackresources);
|
||||||
});
|
});
|
||||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||||
|
@ -1293,7 +1310,7 @@
|
||||||
this.resources.close();
|
this.resources.close();
|
||||||
this.resources = minecraftserver_reloadableresources;
|
this.resources = minecraftserver_reloadableresources;
|
||||||
this.packRepository.setSelected(dataPacks);
|
this.packRepository.setSelected(dataPacks);
|
||||||
@@ -1660,11 +2227,23 @@
|
@@ -1660,11 +2237,23 @@
|
||||||
this.worldData.setDataConfiguration(worlddataconfiguration);
|
this.worldData.setDataConfiguration(worlddataconfiguration);
|
||||||
this.resources.managers.updateStaticRegistryTags();
|
this.resources.managers.updateStaticRegistryTags();
|
||||||
this.resources.managers.getRecipeManager().finalizeRecipeLoading(this.worldData.enabledFeatures());
|
this.resources.managers.getRecipeManager().finalizeRecipeLoading(this.worldData.enabledFeatures());
|
||||||
|
@ -1317,7 +1334,7 @@
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
if (this.isSameThread()) {
|
if (this.isSameThread()) {
|
||||||
@@ -1789,14 +2368,15 @@
|
@@ -1789,14 +2378,15 @@
|
||||||
if (this.isEnforceWhitelist()) {
|
if (this.isEnforceWhitelist()) {
|
||||||
PlayerList playerlist = source.getServer().getPlayerList();
|
PlayerList playerlist = source.getServer().getPlayerList();
|
||||||
UserWhiteList whitelist = playerlist.getWhiteList();
|
UserWhiteList whitelist = playerlist.getWhiteList();
|
||||||
|
@ -1335,7 +1352,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1952,7 +2532,7 @@
|
@@ -1952,7 +2542,7 @@
|
||||||
final List<String> list = Lists.newArrayList();
|
final List<String> list = Lists.newArrayList();
|
||||||
final GameRules gamerules = this.getGameRules();
|
final GameRules gamerules = this.getGameRules();
|
||||||
|
|
||||||
|
@ -1344,7 +1361,7 @@
|
||||||
@Override
|
@Override
|
||||||
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
|
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
|
||||||
list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key)));
|
list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key)));
|
||||||
@@ -2058,7 +2638,7 @@
|
@@ -2058,7 +2648,7 @@
|
||||||
try {
|
try {
|
||||||
label51:
|
label51:
|
||||||
{
|
{
|
||||||
|
@ -1353,19 +1370,22 @@
|
||||||
|
|
||||||
try {
|
try {
|
||||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||||
@@ -2108,6 +2688,21 @@
|
@@ -2105,9 +2695,24 @@
|
||||||
|
if (bufferedwriter != null) {
|
||||||
|
bufferedwriter.close();
|
||||||
}
|
}
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ public boolean isDebugging() {
|
+ public boolean isDebugging() {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ public static MinecraftServer getServer() {
|
+ public static MinecraftServer getServer() {
|
||||||
+ return SERVER; // Paper
|
+ return SERVER; // Paper
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
+ public static RegistryAccess getDefaultRegistryAccess() {
|
+ public static RegistryAccess getDefaultRegistryAccess() {
|
||||||
+ return CraftRegistry.getMinecraftRegistry();
|
+ return CraftRegistry.getMinecraftRegistry();
|
||||||
|
@ -1375,7 +1395,7 @@
|
||||||
private ProfilerFiller createProfiler() {
|
private ProfilerFiller createProfiler() {
|
||||||
if (this.willStartRecordingMetrics) {
|
if (this.willStartRecordingMetrics) {
|
||||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||||
@@ -2225,18 +2820,24 @@
|
@@ -2225,18 +2830,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) {
|
public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) {
|
||||||
|
@ -1404,7 +1424,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean logIPs() {
|
public boolean logIPs() {
|
||||||
@@ -2379,4 +2980,30 @@
|
@@ -2379,4 +2990,30 @@
|
||||||
public static record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) {
|
public static record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@
|
||||||
DedicatedServer.LOGGER.info("Loading properties");
|
DedicatedServer.LOGGER.info("Loading properties");
|
||||||
DedicatedServerProperties dedicatedserverproperties = this.settings.getProperties();
|
DedicatedServerProperties dedicatedserverproperties = this.settings.getProperties();
|
||||||
|
|
||||||
@@ -126,14 +213,49 @@
|
@@ -126,14 +213,51 @@
|
||||||
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
|
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
|
||||||
this.setLocalIp(dedicatedserverproperties.serverIp);
|
this.setLocalIp(dedicatedserverproperties.serverIp);
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,7 @@
|
||||||
+ this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
+ this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
||||||
+ this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
+ this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||||
+ // Paper end - initialize global and world-defaults configuration
|
+ // Paper end - initialize global and world-defaults configuration
|
||||||
|
+ this.server.spark.enableEarlyIfRequested(); // Paper - spark
|
||||||
+ // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
+ // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||||
+ if (this.convertOldUsers()) {
|
+ if (this.convertOldUsers()) {
|
||||||
+ this.getProfileCache().save(false); // Paper
|
+ this.getProfileCache().save(false); // Paper
|
||||||
|
@ -186,6 +187,7 @@
|
||||||
+ org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread
|
+ org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread
|
||||||
+ thread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized
|
+ thread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized
|
||||||
+ io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
|
+ io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
|
||||||
|
+ this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
|
||||||
+ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
+ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
||||||
+ com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
+ com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
||||||
|
|
||||||
|
@ -214,7 +216,7 @@
|
||||||
InetAddress inetaddress = null;
|
InetAddress inetaddress = null;
|
||||||
|
|
||||||
if (!this.getLocalIp().isEmpty()) {
|
if (!this.getLocalIp().isEmpty()) {
|
||||||
@@ -143,34 +265,55 @@
|
@@ -143,34 +267,55 @@
|
||||||
if (this.getPort() < 0) {
|
if (this.getPort() < 0) {
|
||||||
this.setPort(dedicatedserverproperties.serverPort);
|
this.setPort(dedicatedserverproperties.serverPort);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +278,7 @@
|
||||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||||
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
||||||
long i = Util.getNanos();
|
long i = Util.getNanos();
|
||||||
@@ -178,13 +321,13 @@
|
@@ -178,13 +323,13 @@
|
||||||
SkullBlockEntity.setup(this.services, this);
|
SkullBlockEntity.setup(this.services, this);
|
||||||
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
||||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||||
|
@ -292,7 +294,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dedicatedserverproperties.enableQuery) {
|
if (dedicatedserverproperties.enableQuery) {
|
||||||
@@ -197,7 +340,7 @@
|
@@ -197,7 +342,7 @@
|
||||||
this.rconThread = RconThread.create(this);
|
this.rconThread = RconThread.create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +303,7 @@
|
||||||
Thread thread1 = new Thread(new ServerWatchdog(this));
|
Thread thread1 = new Thread(new ServerWatchdog(this));
|
||||||
|
|
||||||
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
|
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
|
||||||
@@ -215,6 +358,12 @@
|
@@ -215,6 +360,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +316,7 @@
|
||||||
@Override
|
@Override
|
||||||
public boolean isSpawningMonsters() {
|
public boolean isSpawningMonsters() {
|
||||||
return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters();
|
return this.settings.getProperties().spawnMonsters && super.isSpawningMonsters();
|
||||||
@@ -227,7 +376,7 @@
|
@@ -227,7 +378,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forceDifficulty() {
|
public void forceDifficulty() {
|
||||||
|
@ -323,7 +325,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,13 +435,14 @@
|
@@ -286,13 +437,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.rconThread != null) {
|
if (this.rconThread != null) {
|
||||||
|
@ -340,7 +342,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -302,19 +452,29 @@
|
@@ -302,19 +454,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -376,7 +378,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -383,7 +543,7 @@
|
@@ -383,7 +545,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
||||||
|
@ -385,7 +387,7 @@
|
||||||
return false;
|
return false;
|
||||||
} else if (this.getPlayerList().getOps().isEmpty()) {
|
} else if (this.getPlayerList().getOps().isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -453,7 +613,11 @@
|
@@ -453,7 +615,11 @@
|
||||||
public boolean enforceSecureProfile() {
|
public boolean enforceSecureProfile() {
|
||||||
DedicatedServerProperties dedicatedserverproperties = this.getProperties();
|
DedicatedServerProperties dedicatedserverproperties = this.getProperties();
|
||||||
|
|
||||||
|
@ -398,7 +400,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -541,16 +705,52 @@
|
@@ -541,16 +707,52 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPluginNames() {
|
public String getPluginNames() {
|
||||||
|
@ -455,7 +457,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeUsingWhiteList(boolean useWhitelist) {
|
public void storeUsingWhiteList(boolean useWhitelist) {
|
||||||
@@ -660,4 +860,15 @@
|
@@ -660,4 +862,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
211
paper-server/src/main/java/io/papermc/paper/SparksFly.java
Normal file
211
paper-server/src/main/java/io/papermc/paper/SparksFly.java
Normal file
|
@ -0,0 +1,211 @@
|
||||||
|
package io.papermc.paper;
|
||||||
|
|
||||||
|
import io.papermc.paper.configuration.GlobalConfiguration;
|
||||||
|
import io.papermc.paper.plugin.entrypoint.classloader.group.PaperPluginClassLoaderStorage;
|
||||||
|
import io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader;
|
||||||
|
import io.papermc.paper.plugin.provider.classloader.PaperClassLoaderStorage;
|
||||||
|
import io.papermc.paper.util.MCUtil;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import me.lucko.spark.paper.api.Compatibility;
|
||||||
|
import me.lucko.spark.paper.api.PaperClassLookup;
|
||||||
|
import me.lucko.spark.paper.api.PaperScheduler;
|
||||||
|
import me.lucko.spark.paper.api.PaperSparkModule;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
import net.minecraft.util.ExceptionCollector;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
|
||||||
|
// It's like electricity.
|
||||||
|
public final class SparksFly {
|
||||||
|
public static final String ID = "spark";
|
||||||
|
public static final String COMMAND_NAME = "spark";
|
||||||
|
|
||||||
|
private static final String PREFER_SPARK_PLUGIN_PROPERTY = "paper.preferSparkPlugin";
|
||||||
|
|
||||||
|
private static final int SPARK_YELLOW = 0xffc93a;
|
||||||
|
|
||||||
|
private final Logger logger;
|
||||||
|
private final PaperSparkModule spark;
|
||||||
|
private final ConcurrentLinkedQueue<Runnable> mainThreadTaskQueue;
|
||||||
|
|
||||||
|
private boolean enabled;
|
||||||
|
private boolean disabledInConfigurationWarningLogged;
|
||||||
|
|
||||||
|
public SparksFly(final Server server) {
|
||||||
|
this.mainThreadTaskQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
this.logger = Logger.getLogger(ID);
|
||||||
|
this.logger.log(Level.INFO, "This server bundles the spark profiler. For more information please visit https://docs.papermc.io/paper/profiling");
|
||||||
|
this.spark = PaperSparkModule.create(Compatibility.VERSION_1_0, server, this.logger, new PaperScheduler() {
|
||||||
|
@Override
|
||||||
|
public void executeAsync(final Runnable runnable) {
|
||||||
|
MCUtil.scheduleAsyncTask(this.catching(runnable, "asynchronous"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeSync(final Runnable runnable) {
|
||||||
|
SparksFly.this.mainThreadTaskQueue.offer(this.catching(runnable, "synchronous"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Runnable catching(final Runnable runnable, final String type) {
|
||||||
|
return () -> {
|
||||||
|
try {
|
||||||
|
runnable.run();
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
SparksFly.this.logger.log(Level.SEVERE, "An exception was encountered while executing a " + type + " spark task", t);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, new PaperClassLookup() {
|
||||||
|
@Override
|
||||||
|
public Class<?> lookup(final String className) throws Exception {
|
||||||
|
final ExceptionCollector<ClassNotFoundException> exceptions = new ExceptionCollector<>();
|
||||||
|
try {
|
||||||
|
return Class.forName(className);
|
||||||
|
} catch (final ClassNotFoundException e) {
|
||||||
|
exceptions.add(e);
|
||||||
|
for (final ConfiguredPluginClassLoader loader : ((PaperPluginClassLoaderStorage) PaperClassLoaderStorage.instance()).getGlobalGroup().getClassLoaders()) {
|
||||||
|
try {
|
||||||
|
final Class<?> loadedClass = loader.loadClass(className, true, false, true);
|
||||||
|
if (loadedClass != null) {
|
||||||
|
return loadedClass;
|
||||||
|
}
|
||||||
|
} catch (final ClassNotFoundException exception) {
|
||||||
|
exceptions.add(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exceptions.throwIfPresent();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeMainThreadTasks() {
|
||||||
|
Runnable task;
|
||||||
|
while ((task = this.mainThreadTaskQueue.poll()) != null) {
|
||||||
|
task.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableEarlyIfRequested() {
|
||||||
|
if (!isPluginPreferred() && shouldEnableImmediately()) {
|
||||||
|
this.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableBeforePlugins() {
|
||||||
|
if (!isPluginPreferred()) {
|
||||||
|
this.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableAfterPlugins(final Server server) {
|
||||||
|
final boolean isPluginPreferred = isPluginPreferred();
|
||||||
|
final boolean isPluginEnabled = isPluginEnabled(server);
|
||||||
|
if (!isPluginPreferred || !isPluginEnabled) {
|
||||||
|
if (isPluginPreferred && !this.enabled) {
|
||||||
|
this.logger.log(Level.INFO, "The spark plugin has been preferred but was not loaded. The bundled spark profiler will enabled instead.");
|
||||||
|
}
|
||||||
|
this.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enable() {
|
||||||
|
if (!this.enabled) {
|
||||||
|
if (GlobalConfiguration.get().spark.enabled) {
|
||||||
|
this.enabled = true;
|
||||||
|
this.spark.enable();
|
||||||
|
} else {
|
||||||
|
if (!this.disabledInConfigurationWarningLogged) {
|
||||||
|
this.logger.log(Level.INFO, "The spark profiler will not be enabled because it is currently disabled in the configuration.");
|
||||||
|
this.disabledInConfigurationWarningLogged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disable() {
|
||||||
|
if (this.enabled) {
|
||||||
|
this.spark.disable();
|
||||||
|
this.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerCommandBeforePlugins(final Server server) {
|
||||||
|
if (!isPluginPreferred()) {
|
||||||
|
this.registerCommand(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerCommandAfterPlugins(final Server server) {
|
||||||
|
if ((!isPluginPreferred() || !isPluginEnabled(server)) && server.getCommandMap().getCommand(COMMAND_NAME) == null) {
|
||||||
|
this.registerCommand(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerCommand(final Server server) {
|
||||||
|
server.getCommandMap().register(COMMAND_NAME, "paper", new CommandImpl(COMMAND_NAME, this.spark.getPermissions()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tickStart() {
|
||||||
|
this.spark.onServerTickStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tickEnd(final double duration) {
|
||||||
|
this.spark.onServerTickEnd(duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void executeCommand(final CommandSender sender, final String[] args) {
|
||||||
|
this.spark.executeCommand(sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> tabComplete(final CommandSender sender, final String[] args) {
|
||||||
|
return this.spark.tabComplete(sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPluginPreferred() {
|
||||||
|
return Boolean.getBoolean(PREFER_SPARK_PLUGIN_PROPERTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isPluginEnabled(final Server server) {
|
||||||
|
return server.getPluginManager().isPluginEnabled(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean shouldEnableImmediately() {
|
||||||
|
return GlobalConfiguration.get().spark.enableImmediately;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class CommandImpl extends Command {
|
||||||
|
CommandImpl(final String name, final Collection<String> permissions) {
|
||||||
|
super(name);
|
||||||
|
this.setPermission(String.join(";", permissions));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(final CommandSender sender, final String commandLabel, final String[] args) {
|
||||||
|
final SparksFly spark = ((CraftServer) sender.getServer()).spark;
|
||||||
|
if (spark.enabled) {
|
||||||
|
spark.executeCommand(sender, args);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(Component.text("The spark profiler is currently disabled.", TextColor.color(SPARK_YELLOW)));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(final CommandSender sender, final String alias, final String[] args) throws IllegalArgumentException {
|
||||||
|
final SparksFly spark = ((CraftServer) sender.getServer()).spark;
|
||||||
|
if (spark.enabled) {
|
||||||
|
return spark.tabComplete(sender, args);
|
||||||
|
}
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
package io.papermc.paper.plugin.provider.source;
|
package io.papermc.paper.plugin.provider.source;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import io.papermc.paper.SparksFly;
|
||||||
import io.papermc.paper.plugin.PluginInitializerManager;
|
import io.papermc.paper.plugin.PluginInitializerManager;
|
||||||
|
import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||||
import io.papermc.paper.plugin.entrypoint.EntrypointHandler;
|
import io.papermc.paper.plugin.entrypoint.EntrypointHandler;
|
||||||
import io.papermc.paper.plugin.provider.type.PluginFileType;
|
import io.papermc.paper.plugin.provider.type.PluginFileType;
|
||||||
import org.bukkit.plugin.InvalidPluginException;
|
import org.bukkit.plugin.InvalidPluginException;
|
||||||
|
@ -17,12 +20,14 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a plugin provider at the given plugin jar file path.
|
* Loads a plugin provider at the given plugin jar file path.
|
||||||
*/
|
*/
|
||||||
public class FileProviderSource implements ProviderSource<Path, Path> {
|
public class FileProviderSource implements ProviderSource<Path, Path> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||||
private final Function<Path, String> contextChecker;
|
private final Function<Path, String> contextChecker;
|
||||||
private final boolean applyRemap;
|
private final boolean applyRemap;
|
||||||
|
|
||||||
|
@ -82,6 +87,12 @@ public class FileProviderSource implements ProviderSource<Path, Path> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final PluginMeta config = type.getConfig(file);
|
||||||
|
if ((config.getName().equals("spark") && config.getMainClass().equals("me.lucko.spark.bukkit.BukkitSparkPlugin")) && !SparksFly.isPluginPreferred()) {
|
||||||
|
LOGGER.info("The spark plugin will not be loaded as this server bundles the spark profiler.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
type.register(entrypointHandler, file, context);
|
type.register(entrypointHandler, file, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,6 +312,7 @@ public final class CraftServer implements Server {
|
||||||
public static Exception excessiveVelEx; // Paper - Velocity warnings
|
public static Exception excessiveVelEx; // Paper - Velocity warnings
|
||||||
private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
|
private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
|
||||||
private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes
|
private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes
|
||||||
|
public final io.papermc.paper.SparksFly spark; // Paper - spark
|
||||||
|
|
||||||
// Paper start - Folia region threading API
|
// Paper start - Folia region threading API
|
||||||
private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler();
|
private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler();
|
||||||
|
@ -489,6 +490,7 @@ public final class CraftServer implements Server {
|
||||||
}
|
}
|
||||||
this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes
|
this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes
|
||||||
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
|
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
|
||||||
|
this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getCommandBlockOverride(String command) {
|
public boolean getCommandBlockOverride(String command) {
|
||||||
|
@ -1115,6 +1117,7 @@ public final class CraftServer implements Server {
|
||||||
this.reloadData();
|
this.reloadData();
|
||||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||||
|
this.spark.registerCommandBeforePlugins(this); // Paper - spark
|
||||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||||
|
|
||||||
|
@ -1143,6 +1146,7 @@ public final class CraftServer implements Server {
|
||||||
this.loadPlugins();
|
this.loadPlugins();
|
||||||
this.enablePlugins(PluginLoadOrder.STARTUP);
|
this.enablePlugins(PluginLoadOrder.STARTUP);
|
||||||
this.enablePlugins(PluginLoadOrder.POSTWORLD);
|
this.enablePlugins(PluginLoadOrder.POSTWORLD);
|
||||||
|
this.spark.registerCommandAfterPlugins(this); // Paper - spark
|
||||||
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
|
if (io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper != null) io.papermc.paper.plugin.PluginInitializerManager.instance().pluginRemapper.pluginsEnabled(); // Paper - Remap plugins
|
||||||
// Paper start - brigadier command API
|
// Paper start - brigadier command API
|
||||||
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // to clear invalid state for event fire below
|
io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setValid(); // to clear invalid state for event fire below
|
||||||
|
|
Loading…
Reference in a new issue