mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Spigot Timings
Overhauls the Timings System adding performance tracking all around the Minecraft Server By: Aikar <aikar@aikar.co>
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
import net.minecraft.util.debugchart.RemoteDebugSampleType;
|
||||
import net.minecraft.util.debugchart.SampleLogger;
|
||||
import net.minecraft.util.debugchart.TpsDebugDimensions;
|
||||
@@ -156,29 +146,62 @@
|
||||
@@ -156,37 +146,72 @@
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.FuelValues;
|
||||
@@ -94,9 +94,11 @@
|
||||
+import org.bukkit.event.server.ServerLoadEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
+
|
||||
public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements ServerInfo, ChunkIOErrorReporter, CommandSource {
|
||||
|
||||
@@ -186,7 +209,7 @@
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final String VANILLA_BRAND = "vanilla";
|
||||
private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F;
|
||||
private static final int TICK_STATS_SPAN = 100;
|
||||
@@ -105,10 +107,11 @@
|
||||
private static final int OVERLOADED_TICKS_THRESHOLD = 20;
|
||||
private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND;
|
||||
private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100;
|
||||
@@ -277,6 +300,19 @@
|
||||
@@ -276,6 +301,19 @@
|
||||
private static final AtomicReference<RuntimeException> fatalException = new AtomicReference();
|
||||
private final SuppressedExceptionCollector suppressedExceptions;
|
||||
private final DiscontinuousFrame tickFrame;
|
||||
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public final WorldLoader.DataLoadContext worldLoader;
|
||||
+ public org.bukkit.craftbukkit.CraftServer server;
|
||||
@@ -121,11 +124,10 @@
|
||||
+ public Commands vanillaCommandDispatcher;
|
||||
+ private boolean forceTicks;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -290,14 +326,14 @@
|
||||
@@ -290,14 +328,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@@ -142,7 +144,7 @@
|
||||
super("Server");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.onMetricsRecordingStopped = (methodprofilerresults) -> {
|
||||
@@ -319,36 +355,63 @@
|
||||
@@ -319,36 +357,63 @@
|
||||
this.scoreboard = new ServerScoreboard(this);
|
||||
this.customBossEvents = new CustomBossEvents();
|
||||
this.suppressedExceptions = new SuppressedExceptionCollector();
|
||||
@@ -220,7 +222,7 @@
|
||||
}
|
||||
|
||||
private void readScoreboard(DimensionDataStorage persistentStateManager) {
|
||||
@@ -357,7 +420,7 @@
|
||||
@@ -357,7 +422,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@@ -229,7 +231,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -365,12 +428,8 @@
|
||||
@@ -365,12 +430,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@@ -243,7 +245,7 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish(true);
|
||||
}
|
||||
@@ -387,23 +446,217 @@
|
||||
@@ -387,23 +448,217 @@
|
||||
|
||||
protected void forceDifficulty() {}
|
||||
|
||||
@@ -475,7 +477,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -427,30 +680,8 @@
|
||||
@@ -427,30 +682,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@@ -507,7 +509,7 @@
|
||||
|
||||
private static void setInitialSpawn(ServerLevel world, ServerLevelData worldProperties, boolean bonusChest, boolean debugWorld) {
|
||||
if (debugWorld) {
|
||||
@@ -458,6 +689,21 @@
|
||||
@@ -458,6 +691,21 @@
|
||||
} else {
|
||||
ServerChunkCache chunkproviderserver = world.getChunkSource();
|
||||
ChunkPos chunkcoordintpair = new ChunkPos(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@@ -529,7 +531,7 @@
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(world);
|
||||
|
||||
if (i < world.getMinY()) {
|
||||
@@ -516,31 +762,36 @@
|
||||
@@ -516,31 +764,36 @@
|
||||
iworlddataserver.setGameType(GameType.SPECTATOR);
|
||||
}
|
||||
|
||||
@@ -577,7 +579,7 @@
|
||||
ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) worldserver1.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -555,10 +806,17 @@
|
||||
@@ -555,10 +808,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,7 +601,7 @@
|
||||
}
|
||||
|
||||
public GameType getDefaultGameType() {
|
||||
@@ -588,12 +846,16 @@
|
||||
@@ -588,12 +848,16 @@
|
||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force);
|
||||
}
|
||||
|
||||
@@ -618,10 +620,11 @@
|
||||
if (flush) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -627,19 +889,41 @@
|
||||
@@ -626,20 +890,42 @@
|
||||
@Override
|
||||
public void close() {
|
||||
this.stopServer();
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ private boolean hasStopped = false;
|
||||
@@ -630,7 +633,7 @@
|
||||
+ synchronized (this.stopLock) {
|
||||
+ return this.hasStopped;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
public void stopServer() {
|
||||
@@ -660,7 +663,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -727,7 +1011,7 @@
|
||||
@@ -727,7 +1013,7 @@
|
||||
}
|
||||
|
||||
this.nextTickTimeNanos = Util.getNanos();
|
||||
@@ -669,7 +672,7 @@
|
||||
this.status = this.buildServerStatus();
|
||||
|
||||
while (this.running) {
|
||||
@@ -744,6 +1028,7 @@
|
||||
@@ -744,6 +1030,7 @@
|
||||
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
|
||||
long k = j / i;
|
||||
|
||||
@@ -677,7 +680,7 @@
|
||||
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", j / TimeUtil.NANOSECONDS_PER_MILLISECOND, k);
|
||||
this.nextTickTimeNanos += k * i;
|
||||
this.lastOverloadWarningNanos = this.nextTickTimeNanos;
|
||||
@@ -757,6 +1042,7 @@
|
||||
@@ -757,6 +1044,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
@@ -685,7 +688,7 @@
|
||||
this.nextTickTimeNanos += i;
|
||||
|
||||
try {
|
||||
@@ -830,6 +1116,12 @@
|
||||
@@ -830,6 +1118,12 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
@@ -698,7 +701,7 @@
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -889,9 +1181,16 @@
|
||||
@@ -889,9 +1183,16 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
@@ -716,7 +719,7 @@
|
||||
public static boolean throwIfFatalException() {
|
||||
RuntimeException runtimeexception = (RuntimeException) MinecraftServer.fatalException.get();
|
||||
|
||||
@@ -903,7 +1202,7 @@
|
||||
@@ -903,7 +1204,7 @@
|
||||
}
|
||||
|
||||
public static void setFatalException(RuntimeException exception) {
|
||||
@@ -725,7 +728,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -977,7 +1276,7 @@
|
||||
@@ -977,7 +1278,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,7 +737,7 @@
|
||||
Profiler.get().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -1041,6 +1340,7 @@
|
||||
@@ -1041,11 +1342,13 @@
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
@@ -742,7 +745,13 @@
|
||||
this.tickConnection();
|
||||
return;
|
||||
}
|
||||
@@ -1055,7 +1355,7 @@
|
||||
}
|
||||
|
||||
+ SpigotTimings.serverTickTimer.startTiming(); // Spigot
|
||||
++this.tickCount;
|
||||
this.tickRateManager.tick();
|
||||
this.tickChildren(shouldKeepTicking);
|
||||
@@ -1055,7 +1358,7 @@
|
||||
}
|
||||
|
||||
--this.ticksUntilAutosave;
|
||||
@@ -751,31 +760,52 @@
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
@@ -1074,7 +1374,7 @@
|
||||
@@ -1071,10 +1374,13 @@
|
||||
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
|
||||
this.logTickMethodTime(i);
|
||||
gameprofilerfiller.pop();
|
||||
+ SpigotTimings.serverTickTimer.stopTiming(); // Spigot
|
||||
+ org.spigotmc.CustomTimingsHandler.tick(); // Spigot
|
||||
}
|
||||
|
||||
private void autoSave() {
|
||||
- this.ticksUntilAutosave = this.computeNextAutosaveInterval();
|
||||
+ this.ticksUntilAutosave = this.autosavePeriod; // CraftBukkit
|
||||
+ SpigotTimings.worldSaveTimer.startTiming(); // Spigot
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
@@ -1154,11 +1454,26 @@
|
||||
@@ -1082,6 +1388,7 @@
|
||||
this.saveEverything(true, false, false);
|
||||
gameprofilerfiller.pop();
|
||||
MinecraftServer.LOGGER.debug("Autosave finished");
|
||||
+ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
|
||||
}
|
||||
|
||||
private void logTickMethodTime(long tickStartTime) {
|
||||
@@ -1154,11 +1461,34 @@
|
||||
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
||||
entityplayer.connection.suspendFlushing();
|
||||
});
|
||||
+ SpigotTimings.schedulerTimer.startTiming(); // Spigot
|
||||
+ this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
|
||||
+ SpigotTimings.schedulerTimer.stopTiming(); // Spigot
|
||||
gameprofilerfiller.push("commandFunctions");
|
||||
+ SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot
|
||||
this.getFunctions().tick();
|
||||
+ SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
|
||||
gameprofilerfiller.popPush("levels");
|
||||
Iterator iterator = this.getAllLevels().iterator();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ // Run tasks that are waiting on processing
|
||||
+ SpigotTimings.processQueueTimer.startTiming(); // Spigot
|
||||
+ while (!this.processQueue.isEmpty()) {
|
||||
+ this.processQueue.remove().run();
|
||||
+ }
|
||||
+ SpigotTimings.processQueueTimer.stopTiming(); // Spigot
|
||||
+
|
||||
+ SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
|
||||
+ // Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
+ if (this.tickCount % 20 == 0) {
|
||||
+ for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
|
||||
@@ -783,11 +813,12 @@
|
||||
+ entityplayer.connection.send(new ClientboundSetTimePacket(entityplayer.level().getGameTime(), entityplayer.getPlayerTime(), entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time
|
||||
+ }
|
||||
+ }
|
||||
+ SpigotTimings.timeUpdateTimer.stopTiming(); // Spigot
|
||||
+
|
||||
while (iterator.hasNext()) {
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
|
||||
@@ -1167,11 +1482,13 @@
|
||||
@@ -1167,16 +1497,20 @@
|
||||
|
||||
return s + " " + String.valueOf(worldserver.dimension().location());
|
||||
});
|
||||
@@ -801,7 +832,39 @@
|
||||
|
||||
gameprofilerfiller.push("tick");
|
||||
|
||||
@@ -1265,7 +1582,23 @@
|
||||
try {
|
||||
+ worldserver.timings.doTick.startTiming(); // Spigot
|
||||
worldserver.tick(shouldKeepTicking);
|
||||
+ worldserver.timings.doTick.stopTiming(); // Spigot
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
||||
|
||||
@@ -1189,18 +1523,24 @@
|
||||
}
|
||||
|
||||
gameprofilerfiller.popPush("connection");
|
||||
+ SpigotTimings.connectionTimer.startTiming(); // Spigot
|
||||
this.tickConnection();
|
||||
+ SpigotTimings.connectionTimer.stopTiming(); // Spigot
|
||||
gameprofilerfiller.popPush("players");
|
||||
+ SpigotTimings.playerListTimer.startTiming(); // Spigot
|
||||
this.playerList.tick();
|
||||
+ SpigotTimings.playerListTimer.stopTiming(); // Spigot
|
||||
if (SharedConstants.IS_RUNNING_IN_IDE && this.tickRateManager.runsNormally()) {
|
||||
GameTestTicker.SINGLETON.tick();
|
||||
}
|
||||
|
||||
gameprofilerfiller.popPush("server gui refresh");
|
||||
|
||||
+ SpigotTimings.tickablesTimer.startTiming(); // Spigot
|
||||
for (int i = 0; i < this.tickables.size(); ++i) {
|
||||
((Runnable) this.tickables.get(i)).run();
|
||||
}
|
||||
+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot
|
||||
|
||||
gameprofilerfiller.popPush("send chunks");
|
||||
iterator = this.playerList.getPlayers().iterator();
|
||||
@@ -1265,7 +1605,23 @@
|
||||
@Nullable
|
||||
public ServerLevel getLevel(ResourceKey<Level> key) {
|
||||
return (ServerLevel) this.levels.get(key);
|
||||
@@ -825,7 +888,7 @@
|
||||
|
||||
public Set<ResourceKey<Level>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
@@ -1296,7 +1629,7 @@
|
||||
@@ -1296,7 +1652,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@@ -834,7 +897,7 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
@@ -1634,11 +1967,11 @@
|
||||
@@ -1634,11 +1990,11 @@
|
||||
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@@ -848,7 +911,7 @@
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
|
||||
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
|
||||
@@ -1654,6 +1987,7 @@
|
||||
@@ -1654,6 +2010,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@@ -856,7 +919,7 @@
|
||||
this.packRepository.setSelected(dataPacks);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(MinecraftServer.getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1952,7 +2286,7 @@
|
||||
@@ -1952,7 +2309,7 @@
|
||||
final List<String> list = Lists.newArrayList();
|
||||
final GameRules gamerules = this.getGameRules();
|
||||
|
||||
@@ -865,7 +928,7 @@
|
||||
@Override
|
||||
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)));
|
||||
@@ -2058,7 +2392,7 @@
|
||||
@@ -2058,7 +2415,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@@ -874,18 +937,15 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -2105,8 +2439,24 @@
|
||||
if (bufferedwriter != null) {
|
||||
bufferedwriter.close();
|
||||
}
|
||||
+
|
||||
+ }
|
||||
+
|
||||
@@ -2108,6 +2465,22 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean isDebugging() {
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static MinecraftServer getServer() {
|
||||
+ return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
|
||||
@@ -894,20 +954,21 @@
|
||||
+ @Deprecated
|
||||
+ public static RegistryAccess getDefaultRegistryAccess() {
|
||||
+ return CraftRegistry.getMinecraftRegistry();
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
private ProfilerFiller createProfiler() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
@@ -2235,6 +2585,11 @@
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
@@ -2234,6 +2607,11 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
|
||||
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").build());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
public ChatDecorator getChatDecorator() {
|
||||
return ChatDecorator.PLAIN;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -54,11 +54,22 @@
|
||||
@@ -54,11 +54,23 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.GameType;
|
||||
@@ -15,6 +15,7 @@
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.io.IoBuilder;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
+import org.bukkit.craftbukkit.util.TerminalCompletionHandler;
|
||||
+import org.bukkit.craftbukkit.util.TerminalConsoleWriterThread;
|
||||
+import org.bukkit.event.server.ServerCommandEvent;
|
||||
@@ -24,7 +25,7 @@
|
||||
public class DedicatedServer extends MinecraftServer implements ServerInterface {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -67,7 +78,7 @@
|
||||
@@ -67,7 +79,7 @@
|
||||
private final List<ConsoleInput> consoleInput = Collections.synchronizedList(Lists.newArrayList());
|
||||
@Nullable
|
||||
private QueryThreadGs4 queryThreadGs4;
|
||||
@@ -33,7 +34,7 @@
|
||||
@Nullable
|
||||
private RconThread rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -81,25 +92,58 @@
|
||||
@@ -81,25 +93,58 @@
|
||||
private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker;
|
||||
public ServerLinks serverLinks;
|
||||
|
||||
@@ -101,7 +102,7 @@
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
||||
@@ -108,6 +152,29 @@
|
||||
@@ -108,6 +153,29 @@
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,7 +132,7 @@
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||
thread.start();
|
||||
@@ -126,13 +193,18 @@
|
||||
@@ -126,13 +194,18 @@
|
||||
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
|
||||
this.setLocalIp(dedicatedserverproperties.serverIp);
|
||||
}
|
||||
@@ -151,7 +152,7 @@
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -156,6 +228,12 @@
|
||||
@@ -156,6 +229,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@
|
||||
if (!this.usesAuthentication()) {
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
@@ -170,7 +248,7 @@
|
||||
@@ -170,7 +249,7 @@
|
||||
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -173,7 +174,7 @@
|
||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
||||
long i = Util.getNanos();
|
||||
@@ -178,13 +256,13 @@
|
||||
@@ -178,13 +257,13 @@
|
||||
SkullBlockEntity.setup(this.services, this);
|
||||
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
@@ -189,7 +190,7 @@
|
||||
}
|
||||
|
||||
if (dedicatedserverproperties.enableQuery) {
|
||||
@@ -293,6 +371,7 @@
|
||||
@@ -293,6 +372,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
@@ -197,7 +198,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,8 +381,8 @@
|
||||
@@ -302,8 +382,8 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,7 +209,11 @@
|
||||
}
|
||||
|
||||
public void handleConsoleInput(String command, CommandSourceStack commandSource) {
|
||||
@@ -314,7 +393,15 @@
|
||||
@@ -311,12 +391,22 @@
|
||||
}
|
||||
|
||||
public void handleConsoleInputs() {
|
||||
+ SpigotTimings.serverCommandTimer.startTiming(); // Spigot
|
||||
while (!this.consoleInput.isEmpty()) {
|
||||
ConsoleInput servercommand = (ConsoleInput) this.consoleInput.remove(0);
|
||||
|
||||
@@ -224,8 +229,11 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
+ SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
|
||||
}
|
||||
@@ -383,7 +470,7 @@
|
||||
|
||||
@Override
|
||||
@@ -383,7 +473,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
||||
@@ -234,7 +242,7 @@
|
||||
return false;
|
||||
} else if (this.getPlayerList().getOps().isEmpty()) {
|
||||
return false;
|
||||
@@ -541,16 +628,52 @@
|
||||
@@ -541,16 +631,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@@ -291,7 +299,7 @@
|
||||
}
|
||||
|
||||
public void storeUsingWhiteList(boolean useWhitelist) {
|
||||
@@ -660,4 +783,15 @@
|
||||
@@ -660,4 +786,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
@Override
|
||||
public ThreadedLevelLightEngine getLightEngine() {
|
||||
return this.lightEngine;
|
||||
@@ -138,7 +148,7 @@
|
||||
@@ -138,20 +148,22 @@
|
||||
if (k == this.lastChunkPos[l] && leastStatus == this.lastChunkStatus[l]) {
|
||||
ChunkAccess ichunkaccess = this.lastChunk[l];
|
||||
|
||||
@@ -26,16 +26,23 @@
|
||||
return ichunkaccess;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +161,7 @@
|
||||
}
|
||||
|
||||
gameprofilerfiller.incrementCounter("getChunkCacheMiss");
|
||||
+ this.level.timings.syncChunkLoadTimer.startTiming(); // Spigot
|
||||
CompletableFuture<ChunkResult<ChunkAccess>> completablefuture = this.getChunkFutureMainThread(x, z, leastStatus, create);
|
||||
ServerChunkCache.MainThreadExecutor chunkproviderserver_b = this.mainThreadProcessor;
|
||||
|
||||
Objects.requireNonNull(completablefuture);
|
||||
chunkproviderserver_b.managedBlock(completablefuture::isDone);
|
||||
+ this.level.timings.syncChunkLoadTimer.stopTiming(); // Spigot
|
||||
ChunkResult<ChunkAccess> chunkresult = (ChunkResult) completablefuture.join();
|
||||
- ChunkAccess ichunkaccess1 = (ChunkAccess) chunkresult.orElse((Object) null);
|
||||
+ ChunkAccess ichunkaccess1 = (ChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess1 == null && create) {
|
||||
throw (IllegalStateException) Util.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkresult.getError()));
|
||||
@@ -231,7 +241,15 @@
|
||||
@@ -231,7 +243,15 @@
|
||||
int l = ChunkLevel.byStatus(leastStatus);
|
||||
ChunkHolder playerchunk = this.getVisibleChunkIfPresent(k);
|
||||
|
||||
@@ -52,7 +59,7 @@
|
||||
this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
if (this.chunkAbsent(playerchunk, l)) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
@@ -250,7 +268,7 @@
|
||||
@@ -250,7 +270,7 @@
|
||||
}
|
||||
|
||||
private boolean chunkAbsent(@Nullable ChunkHolder holder, int maxLevel) {
|
||||
@@ -61,7 +68,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -309,11 +327,33 @@
|
||||
@@ -309,30 +329,58 @@
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
@@ -96,7 +103,32 @@
|
||||
|
||||
@Override
|
||||
public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) {
|
||||
@@ -401,14 +441,14 @@
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("purge");
|
||||
+ this.level.timings.doChunkMap.startTiming(); // Spigot
|
||||
if (this.level.tickRateManager().runsNormally() || !tickChunks) {
|
||||
this.distanceManager.purgeStaleTickets();
|
||||
}
|
||||
|
||||
this.runDistanceManagerUpdates();
|
||||
+ this.level.timings.doChunkMap.stopTiming(); // Spigot
|
||||
gameprofilerfiller.popPush("chunks");
|
||||
if (tickChunks) {
|
||||
this.tickChunks();
|
||||
+ this.level.timings.tracker.startTiming(); // Spigot
|
||||
this.chunkMap.tick();
|
||||
+ this.level.timings.tracker.stopTiming(); // Spigot
|
||||
}
|
||||
|
||||
+ this.level.timings.doChunkUnload.startTiming(); // Spigot
|
||||
gameprofilerfiller.popPush("unload");
|
||||
this.chunkMap.tick(shouldKeepTicking);
|
||||
+ this.level.timings.doChunkUnload.stopTiming(); // Spigot
|
||||
gameprofilerfiller.pop();
|
||||
this.clearCache();
|
||||
}
|
||||
@@ -401,14 +449,14 @@
|
||||
|
||||
this.lastSpawnState = spawnercreature_d;
|
||||
profiler.popPush("spawnAndTick");
|
||||
@@ -114,7 +146,17 @@
|
||||
} else {
|
||||
list1 = List.of();
|
||||
}
|
||||
@@ -541,10 +581,16 @@
|
||||
@@ -425,7 +473,9 @@
|
||||
}
|
||||
|
||||
if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) {
|
||||
+ this.level.timings.doTickTiles.startTiming(); // Spigot
|
||||
this.level.tickChunk(chunk, k);
|
||||
+ this.level.timings.doTickTiles.stopTiming(); // Spigot
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,10 +591,16 @@
|
||||
|
||||
@Override
|
||||
public void setSpawnSettings(boolean spawnMonsters) {
|
||||
@@ -133,7 +175,7 @@
|
||||
public String getChunkDebugData(ChunkPos pos) {
|
||||
return this.chunkMap.getChunkDebugData(pos);
|
||||
}
|
||||
@@ -618,14 +664,20 @@
|
||||
@@ -618,14 +674,20 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -35,12 +35,13 @@
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.shapes.BooleanOp;
|
||||
@@ -173,6 +175,16 @@
|
||||
@@ -173,6 +175,17 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.ticks.LevelTicks;
|
||||
import org.slf4j.Logger;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.WeatherType;
|
||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.generator.CustomWorldChunkManager;
|
||||
+import org.bukkit.craftbukkit.util.WorldUUID;
|
||||
@@ -52,7 +53,7 @@
|
||||
|
||||
public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLevel {
|
||||
|
||||
@@ -187,7 +199,7 @@
|
||||
@@ -187,7 +200,7 @@
|
||||
final List<ServerPlayer> players = Lists.newArrayList();
|
||||
public final ServerChunkCache chunkSource;
|
||||
private final MinecraftServer server;
|
||||
@@ -61,7 +62,7 @@
|
||||
private int lastSpawnChunkRadius;
|
||||
final EntityTickList entityTickList = new EntityTickList();
|
||||
public final PersistentEntitySectionManager<Entity> entityManager;
|
||||
@@ -214,52 +226,87 @@
|
||||
@@ -214,52 +227,87 @@
|
||||
private final boolean tickTime;
|
||||
private final RandomSequences randomSequences;
|
||||
|
||||
@@ -78,7 +79,7 @@
|
||||
+ // CraftBukkit start
|
||||
+ public final LevelStorageSource.LevelStorageAccess convertable;
|
||||
+ public final UUID uuid;
|
||||
|
||||
+
|
||||
+ public LevelChunk getChunkIfLoaded(int x, int z) {
|
||||
+ return this.chunkSource.getChunk(x, z, false);
|
||||
+ }
|
||||
@@ -102,7 +103,7 @@
|
||||
+ ChunkGenerator chunkgenerator = worlddimension.generator();
|
||||
+ // CraftBukkit start
|
||||
+ this.serverLevelData.setWorld(this);
|
||||
+
|
||||
|
||||
+ if (biomeProvider != null) {
|
||||
+ BiomeSource worldChunkManager = new CustomWorldChunkManager(this.getWorld(), biomeProvider, this.server.registryAccess().lookupOrThrow(Registries.BIOME));
|
||||
+ if (chunkgenerator instanceof NoiseBasedChunkGenerator cga) {
|
||||
@@ -173,17 +174,16 @@
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@@ -305,12 +352,20 @@
|
||||
@@ -305,12 +353,20 @@
|
||||
long j;
|
||||
|
||||
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
|
||||
- if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
- j = this.levelData.getDayTime() + 24000L;
|
||||
- this.setDayTime(j - j % 24000L);
|
||||
+ // CraftBukkit start
|
||||
+ j = this.levelData.getDayTime() + 24000L;
|
||||
+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime());
|
||||
+ if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
- j = this.levelData.getDayTime() + 24000L;
|
||||
- this.setDayTime(j - j % 24000L);
|
||||
+ this.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.setDayTime(this.getDayTime() + event.getSkipAmount());
|
||||
@@ -198,7 +198,30 @@
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -345,7 +400,7 @@
|
||||
@@ -322,6 +378,7 @@
|
||||
}
|
||||
|
||||
gameprofilerfiller.push("tickPending");
|
||||
+ this.timings.doTickPending.startTiming(); // Spigot
|
||||
if (!this.isDebug() && flag) {
|
||||
j = this.getGameTime();
|
||||
gameprofilerfiller.push("blockTicks");
|
||||
@@ -330,6 +387,7 @@
|
||||
this.fluidTicks.tick(j, 65536, this::tickFluid);
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
+ this.timings.doTickPending.stopTiming(); // Spigot
|
||||
|
||||
gameprofilerfiller.popPush("raid");
|
||||
if (flag) {
|
||||
@@ -340,12 +398,14 @@
|
||||
this.getChunkSource().tick(shouldKeepTicking, true);
|
||||
gameprofilerfiller.popPush("blockEvents");
|
||||
if (flag) {
|
||||
+ this.timings.doSounds.startTiming(); // Spigot
|
||||
this.runBlockEvents();
|
||||
+ this.timings.doSounds.stopTiming(); // Spigot
|
||||
}
|
||||
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.pop();
|
||||
@@ -207,7 +230,31 @@
|
||||
|
||||
if (flag1) {
|
||||
this.resetEmptyTime();
|
||||
@@ -429,7 +484,7 @@
|
||||
@@ -353,12 +413,14 @@
|
||||
|
||||
if (flag1 || this.emptyTime++ < 300) {
|
||||
gameprofilerfiller.push("entities");
|
||||
+ this.timings.tickEntities.startTiming(); // Spigot
|
||||
if (this.dragonFight != null && flag) {
|
||||
gameprofilerfiller.push("dragonFight");
|
||||
this.dragonFight.tick();
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
|
||||
+ this.timings.entityTick.startTiming(); // Spigot
|
||||
this.entityTickList.forEach((entity) -> {
|
||||
if (!entity.isRemoved()) {
|
||||
if (!tickratemanager.isEntityFrozen(entity)) {
|
||||
@@ -383,6 +445,8 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
+ this.timings.entityTick.stopTiming(); // Spigot
|
||||
+ this.timings.tickEntities.stopTiming(); // Spigot
|
||||
gameprofilerfiller.pop();
|
||||
this.tickBlockEntities();
|
||||
}
|
||||
@@ -429,7 +493,7 @@
|
||||
|
||||
private void wakeUpAllPlayers() {
|
||||
this.sleepStatus.removeAllSleepers();
|
||||
@@ -216,7 +263,7 @@
|
||||
entityplayer.stopSleepInBed(false, false);
|
||||
});
|
||||
}
|
||||
@@ -456,7 +511,7 @@
|
||||
@@ -456,7 +520,7 @@
|
||||
entityhorseskeleton.setTrap(true);
|
||||
entityhorseskeleton.setAge(0);
|
||||
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
@@ -225,7 +272,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,7 +520,7 @@
|
||||
@@ -465,7 +529,7 @@
|
||||
if (entitylightning != null) {
|
||||
entitylightning.moveTo(Vec3.atBottomCenterOf(blockposition));
|
||||
entitylightning.setVisualOnly(flag1);
|
||||
@@ -234,7 +281,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -521,7 +576,7 @@
|
||||
@@ -521,7 +585,7 @@
|
||||
Biome biomebase = (Biome) this.getBiome(blockposition1).value();
|
||||
|
||||
if (biomebase.shouldFreeze(this, blockposition2)) {
|
||||
@@ -243,7 +290,7 @@
|
||||
}
|
||||
|
||||
if (this.isRaining()) {
|
||||
@@ -537,10 +592,10 @@
|
||||
@@ -537,10 +601,10 @@
|
||||
BlockState iblockdata1 = (BlockState) iblockdata.setValue(SnowLayerBlock.LAYERS, j + 1);
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
|
||||
@@ -256,7 +303,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,33 +756,67 @@
|
||||
@@ -701,33 +765,67 @@
|
||||
this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -290,8 +337,8 @@
|
||||
+ if (((ServerPlayer) this.players.get(idx)).level() == this) {
|
||||
+ ((ServerPlayer) this.players.get(idx)).tickWeather();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ if (flag != this.isRaining()) {
|
||||
+ // Only send weather packets to those affected
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
@@ -299,14 +346,14 @@
|
||||
+ ((ServerPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ }
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
+ if (((ServerPlayer) this.players.get(idx)).level() == this) {
|
||||
+ ((ServerPlayer) this.players.get(idx)).updateWeather(this.oRainLevel, this.rainLevel, this.oThunderLevel, this.thunderLevel);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -332,7 +379,15 @@
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -763,6 +852,7 @@
|
||||
@@ -754,6 +852,7 @@
|
||||
}
|
||||
|
||||
public void tickNonPassenger(Entity entity) {
|
||||
+ entity.tickTimer.startTiming(); // Spigot
|
||||
entity.setOldPosAndRot();
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
@@ -763,6 +862,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickNonPassenger");
|
||||
entity.tick();
|
||||
@@ -340,7 +395,15 @@
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
@@ -786,6 +876,7 @@
|
||||
@@ -771,6 +871,7 @@
|
||||
|
||||
this.tickPassenger(entity, entity1);
|
||||
}
|
||||
+ entity.tickTimer.stopTiming(); // Spigot
|
||||
|
||||
}
|
||||
|
||||
@@ -786,6 +887,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickPassenger");
|
||||
passenger.rideTick();
|
||||
@@ -348,7 +411,7 @@
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = passenger.getPassengers().iterator();
|
||||
|
||||
@@ -810,6 +901,7 @@
|
||||
@@ -810,6 +912,7 @@
|
||||
ServerChunkCache chunkproviderserver = this.getChunkSource();
|
||||
|
||||
if (!savingDisabled) {
|
||||
@@ -356,7 +419,7 @@
|
||||
if (progressListener != null) {
|
||||
progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel"));
|
||||
}
|
||||
@@ -827,11 +919,19 @@
|
||||
@@ -827,11 +930,19 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -377,7 +440,7 @@
|
||||
}
|
||||
|
||||
DimensionDataStorage worldpersistentdata = this.getChunkSource().getDataStorage();
|
||||
@@ -903,18 +1003,40 @@
|
||||
@@ -903,18 +1014,40 @@
|
||||
|
||||
@Override
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
@@ -421,7 +484,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -939,24 +1061,38 @@
|
||||
@@ -939,24 +1072,38 @@
|
||||
this.entityManager.addNewEntity(player);
|
||||
}
|
||||
|
||||
@@ -464,7 +527,7 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -967,13 +1103,35 @@
|
||||
@@ -967,13 +1114,35 @@
|
||||
}
|
||||
|
||||
public void removePlayerImmediately(ServerPlayer player, Entity.RemovalReason reason) {
|
||||
@@ -501,7 +564,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
||||
|
||||
@@ -982,6 +1140,12 @@
|
||||
@@ -982,6 +1151,12 @@
|
||||
double d1 = (double) pos.getY() - entityplayer.getY();
|
||||
double d2 = (double) pos.getZ() - entityplayer.getZ();
|
||||
|
||||
@@ -514,7 +577,7 @@
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.connection.send(new ClientboundBlockDestructionPacket(entityId, pos, progress));
|
||||
}
|
||||
@@ -1060,7 +1224,18 @@
|
||||
@@ -1060,7 +1235,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -534,7 +597,7 @@
|
||||
PathNavigation navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (navigationabstract.shouldRecomputePath(pos)) {
|
||||
@@ -1126,9 +1301,15 @@
|
||||
@@ -1126,9 +1312,15 @@
|
||||
|
||||
@Override
|
||||
public void explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions smallParticle, ParticleOptions largeParticle, Holder<SoundEvent> soundEvent) {
|
||||
@@ -551,7 +614,7 @@
|
||||
case NONE:
|
||||
explosion_effect = Explosion.BlockInteraction.KEEP;
|
||||
break;
|
||||
@@ -1144,16 +1325,26 @@
|
||||
@@ -1144,16 +1336,26 @@
|
||||
case TRIGGER:
|
||||
explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK;
|
||||
break;
|
||||
@@ -581,7 +644,7 @@
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -1162,10 +1353,11 @@
|
||||
@@ -1162,10 +1364,11 @@
|
||||
if (entityplayer.distanceToSqr(vec3d) < 4096.0D) {
|
||||
Optional<Vec3> optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer));
|
||||
|
||||
@@ -594,7 +657,7 @@
|
||||
}
|
||||
|
||||
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayRule) {
|
||||
@@ -1226,17 +1418,24 @@
|
||||
@@ -1226,17 +1429,24 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleOptions> int sendParticles(T parameters, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double speed) {
|
||||
@@ -622,7 +685,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1292,7 +1491,7 @@
|
||||
@@ -1292,7 +1502,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipReferencedStructures) {
|
||||
@@ -631,7 +694,7 @@
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag);
|
||||
@@ -1334,11 +1533,22 @@
|
||||
@@ -1334,11 +1544,22 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public MapItemSavedData getMapData(MapId id) {
|
||||
@@ -655,7 +718,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(id.key(), state);
|
||||
}
|
||||
|
||||
@@ -1649,6 +1859,11 @@
|
||||
@@ -1649,6 +1870,11 @@
|
||||
@Override
|
||||
public void blockUpdated(BlockPos pos, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
@@ -667,7 +730,7 @@
|
||||
this.updateNeighborsAt(pos, block);
|
||||
}
|
||||
|
||||
@@ -1668,12 +1883,12 @@
|
||||
@@ -1668,12 +1894,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@@ -682,7 +745,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1696,7 +1911,7 @@
|
||||
@@ -1696,7 +1922,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> items, Function<T, String> classifier) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@@ -691,7 +754,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1705,7 +1920,7 @@
|
||||
@@ -1705,7 +1931,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@@ -700,7 +763,7 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1717,6 +1932,7 @@
|
||||
@@ -1717,6 +1943,7 @@
|
||||
|
||||
@Override
|
||||
public LevelEntityGetter<Entity> getEntities() {
|
||||
@@ -708,7 +771,7 @@
|
||||
return this.entityManager.getEntityGetter();
|
||||
}
|
||||
|
||||
@@ -1836,6 +2052,7 @@
|
||||
@@ -1836,6 +2063,7 @@
|
||||
}
|
||||
|
||||
public void onTrackingStart(Entity entity) {
|
||||
@@ -716,7 +779,7 @@
|
||||
ServerLevel.this.getChunkSource().addEntity(entity);
|
||||
if (entity instanceof ServerPlayer entityplayer) {
|
||||
ServerLevel.this.players.add(entityplayer);
|
||||
@@ -1864,9 +2081,12 @@
|
||||
@@ -1864,9 +2092,12 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@@ -729,7 +792,7 @@
|
||||
ServerLevel.this.getChunkSource().removeEntity(entity);
|
||||
if (entity instanceof ServerPlayer entityplayer) {
|
||||
ServerLevel.this.players.remove(entityplayer);
|
||||
@@ -1895,6 +2115,14 @@
|
||||
@@ -1895,6 +2126,14 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
|
@@ -120,7 +120,7 @@
|
||||
this.chunkSender = new PlayerChunkSender(connection.isMemoryConnection());
|
||||
this.player = player;
|
||||
player.connection = this;
|
||||
@@ -256,9 +317,25 @@
|
||||
@@ -256,11 +317,28 @@
|
||||
|
||||
Objects.requireNonNull(server);
|
||||
this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(uuid, server::enforceSecureProfile);
|
||||
@@ -146,16 +146,22 @@
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.startTiming(); // Spigot
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -313,6 +390,7 @@
|
||||
this.send(new ClientboundBlockChangedAckPacket(this.ackBlockChangesUpTo));
|
||||
this.ackBlockChangesUpTo = -1;
|
||||
@@ -313,8 +391,10 @@
|
||||
this.chatSpamThrottler.tick();
|
||||
this.dropSpamThrottler.tick();
|
||||
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) {
|
||||
+ this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
||||
this.disconnect((Component) Component.translatable("multiplayer.disconnect.idling"));
|
||||
}
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.stopTiming(); // Spigot
|
||||
|
||||
@@ -376,6 +454,12 @@
|
||||
}
|
||||
|
||||
@@ -376,6 +456,12 @@
|
||||
@Override
|
||||
public void handlePlayerInput(ServerboundPlayerInputPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -168,7 +174,7 @@
|
||||
this.player.setLastClientInput(packet.input());
|
||||
}
|
||||
|
||||
@@ -401,6 +485,13 @@
|
||||
@@ -401,6 +487,13 @@
|
||||
|
||||
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -182,7 +188,7 @@
|
||||
double d0 = entity.getX();
|
||||
double d1 = entity.getY();
|
||||
double d2 = entity.getZ();
|
||||
@@ -415,7 +506,33 @@
|
||||
@@ -415,7 +508,33 @@
|
||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
@@ -217,7 +223,7 @@
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
|
||||
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
|
||||
return;
|
||||
@@ -455,13 +572,66 @@
|
||||
@@ -455,14 +574,67 @@
|
||||
}
|
||||
|
||||
entity.absMoveTo(d3, d4, d5, f, f1);
|
||||
@@ -229,8 +235,8 @@
|
||||
+ this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
|
||||
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
|
||||
return;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - fire PlayerMoveEvent
|
||||
+ Player player = this.getCraftPlayer();
|
||||
+ if (!this.hasMoved) {
|
||||
@@ -279,12 +285,13 @@
|
||||
+ this.justTeleported = false;
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position());
|
||||
@@ -499,6 +669,7 @@
|
||||
Vec3 vec3d = new Vec3(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
|
||||
@@ -499,6 +671,7 @@
|
||||
this.lastGoodZ = this.awaitingPositionFromClient.z;
|
||||
this.player.hasChangedDimension();
|
||||
this.awaitingPositionFromClient = null;
|
||||
@@ -292,7 +299,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -528,6 +699,7 @@
|
||||
@@ -528,6 +701,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -300,7 +307,7 @@
|
||||
this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering());
|
||||
}
|
||||
|
||||
@@ -548,6 +720,12 @@
|
||||
@@ -548,6 +722,12 @@
|
||||
@Override
|
||||
public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -313,7 +320,7 @@
|
||||
StringReader stringreader = new StringReader(packet.getCommand());
|
||||
|
||||
if (stringreader.canRead() && stringreader.peek() == '/') {
|
||||
@@ -557,6 +735,7 @@
|
||||
@@ -557,6 +737,7 @@
|
||||
ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
||||
|
||||
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
||||
@@ -321,7 +328,7 @@
|
||||
Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000));
|
||||
|
||||
this.send(new ClientboundCommandSuggestionsPacket(packet.getId(), suggestions1));
|
||||
@@ -866,6 +1045,13 @@
|
||||
@@ -866,6 +1047,13 @@
|
||||
AbstractContainerMenu container = this.player.containerMenu;
|
||||
|
||||
if (container instanceof MerchantMenu containermerchant) {
|
||||
@@ -335,7 +342,7 @@
|
||||
if (!containermerchant.stillValid(this.player)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
|
||||
return;
|
||||
@@ -879,6 +1065,13 @@
|
||||
@@ -879,6 +1067,13 @@
|
||||
|
||||
@Override
|
||||
public void handleEditBook(ServerboundEditBookPacket packet) {
|
||||
@@ -349,7 +356,7 @@
|
||||
int i = packet.slot();
|
||||
|
||||
if (Inventory.isHotbarSlot(i) || i == 40) {
|
||||
@@ -899,12 +1092,16 @@
|
||||
@@ -899,12 +1094,16 @@
|
||||
}
|
||||
|
||||
private void updateBookContents(List<FilteredText> pages, int slotId) {
|
||||
@@ -367,7 +374,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -915,12 +1112,13 @@
|
||||
@@ -915,12 +1114,13 @@
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
|
||||
|
||||
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
|
||||
@@ -383,7 +390,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -982,7 +1180,7 @@
|
||||
@@ -982,7 +1182,7 @@
|
||||
} else {
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
|
||||
@@ -392,7 +399,7 @@
|
||||
if (this.tickCount == 0) {
|
||||
this.resetPosition();
|
||||
}
|
||||
@@ -997,7 +1195,15 @@
|
||||
@@ -997,7 +1197,15 @@
|
||||
if (this.player.isPassenger()) {
|
||||
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
@@ -408,7 +415,7 @@
|
||||
double d3 = this.player.getX();
|
||||
double d4 = this.player.getY();
|
||||
double d5 = this.player.getZ();
|
||||
@@ -1019,15 +1225,33 @@
|
||||
@@ -1019,15 +1227,33 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
@@ -444,7 +451,7 @@
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||
return;
|
||||
@@ -1049,6 +1273,7 @@
|
||||
@@ -1049,6 +1275,7 @@
|
||||
boolean flag2 = this.player.verticalCollisionBelow;
|
||||
|
||||
this.player.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
|
||||
@@ -452,7 +459,7 @@
|
||||
double d11 = d7;
|
||||
|
||||
d6 = d0 - this.player.getX();
|
||||
@@ -1067,9 +1292,75 @@
|
||||
@@ -1067,9 +1294,75 @@
|
||||
}
|
||||
|
||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
||||
@@ -529,7 +536,7 @@
|
||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
boolean flag4 = this.player.isAutoSpinAttack();
|
||||
|
||||
@@ -1119,6 +1410,7 @@
|
||||
@@ -1119,6 +1412,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
@@ -537,7 +544,7 @@
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@@ -1147,23 +1439,83 @@
|
||||
@@ -1147,23 +1441,83 @@
|
||||
}
|
||||
|
||||
public void teleport(double x, double y, double z, float yaw, float pitch) {
|
||||
@@ -624,7 +631,7 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
BlockPos blockposition = packet.getPos();
|
||||
|
||||
@@ -1175,14 +1527,46 @@
|
||||
@@ -1175,14 +1529,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND);
|
||||
|
||||
@@ -673,7 +680,7 @@
|
||||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1221,6 +1605,7 @@
|
||||
@@ -1221,6 +1607,7 @@
|
||||
@Override
|
||||
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -681,7 +688,7 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1244,6 +1629,7 @@
|
||||
@@ -1244,6 +1631,7 @@
|
||||
|
||||
if (blockposition.getY() <= i) {
|
||||
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
|
||||
@@ -689,7 +696,7 @@
|
||||
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1281,6 +1667,7 @@
|
||||
@@ -1281,6 +1669,7 @@
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -697,7 +704,7 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.ackBlockChangesUpTo(packet.getSequence());
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
@@ -1296,6 +1683,47 @@
|
||||
@@ -1296,6 +1685,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
|
||||
@@ -745,7 +752,7 @@
|
||||
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult instanceof InteractionResult.Success) {
|
||||
@@ -1321,7 +1749,7 @@
|
||||
@@ -1321,7 +1751,7 @@
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
@@ -754,7 +761,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1342,6 +1770,13 @@
|
||||
@@ -1342,6 +1772,13 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails info) {
|
||||
@@ -768,7 +775,7 @@
|
||||
ServerGamePacketListenerImpl.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), info.reason().getString());
|
||||
this.removePlayerFromWorld();
|
||||
super.onDisconnect(info);
|
||||
@@ -1349,10 +1784,18 @@
|
||||
@@ -1349,10 +1786,18 @@
|
||||
|
||||
private void removePlayerFromWorld() {
|
||||
this.chatMessageChain.close();
|
||||
@@ -789,7 +796,7 @@
|
||||
this.player.getTextFilter().leave();
|
||||
}
|
||||
|
||||
@@ -1367,7 +1810,16 @@
|
||||
@@ -1367,7 +1812,16 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -806,7 +813,7 @@
|
||||
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1376,11 +1828,18 @@
|
||||
@@ -1376,11 +1830,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
@@ -825,7 +832,7 @@
|
||||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1394,7 +1853,7 @@
|
||||
@@ -1394,7 +1855,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -834,7 +841,7 @@
|
||||
Component ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent());
|
||||
|
||||
this.chatMessageChain.append(completablefuture, (filteredtext) -> {
|
||||
@@ -1402,19 +1861,36 @@
|
||||
@@ -1402,19 +1863,36 @@
|
||||
|
||||
this.broadcastChatMessage(playerchatmessage1);
|
||||
});
|
||||
@@ -873,7 +880,7 @@
|
||||
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1431,19 +1907,37 @@
|
||||
@@ -1431,19 +1909,37 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
@@ -914,7 +921,7 @@
|
||||
} catch (SignedMessageChain.DecodeException signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1451,10 +1945,10 @@
|
||||
@@ -1451,10 +1947,10 @@
|
||||
|
||||
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
|
||||
|
||||
@@ -927,7 +934,7 @@
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||
@@ -1530,14 +2024,20 @@
|
||||
@@ -1530,14 +2026,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
@@ -952,7 +959,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1564,8 +2064,118 @@
|
||||
@@ -1564,8 +2066,122 @@
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1045,6 +1052,7 @@
|
||||
}
|
||||
|
||||
+ private void handleCommand(String s) {
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
|
||||
+ this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
|
||||
+
|
||||
+ CraftPlayer player = this.getCraftPlayer();
|
||||
@@ -1053,6 +1061,7 @@
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -1064,6 +1073,8 @@
|
||||
+ player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
+ java.util.logging.Logger.getLogger(ServerGamePacketListenerImpl.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
+ return;
|
||||
+ } finally {
|
||||
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -1071,7 +1082,7 @@
|
||||
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
|
||||
|
||||
@@ -1573,13 +2183,33 @@
|
||||
@@ -1573,13 +2189,33 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage message) {
|
||||
@@ -1108,7 +1119,7 @@
|
||||
this.disconnect((Component) Component.translatable("disconnect.spam"));
|
||||
}
|
||||
|
||||
@@ -1601,7 +2231,33 @@
|
||||
@@ -1601,7 +2237,33 @@
|
||||
@Override
|
||||
public void handleAnimate(ServerboundSwingPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1142,7 +1153,7 @@
|
||||
this.player.swing(packet.getHand());
|
||||
}
|
||||
|
||||
@@ -1609,6 +2265,29 @@
|
||||
@@ -1609,6 +2271,29 @@
|
||||
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.hasClientLoaded()) {
|
||||
@@ -1172,7 +1183,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
PlayerRideableJumping ijumpable;
|
||||
@@ -1691,6 +2370,12 @@
|
||||
@@ -1691,6 +2376,12 @@
|
||||
}
|
||||
|
||||
public void sendPlayerChatMessage(PlayerChatMessage message, ChatType.Bound params) {
|
||||
@@ -1185,7 +1196,7 @@
|
||||
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params));
|
||||
this.addPendingMessage(message);
|
||||
}
|
||||
@@ -1718,6 +2403,7 @@
|
||||
@@ -1718,6 +2409,7 @@
|
||||
@Override
|
||||
public void handleInteract(ServerboundInteractPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1193,7 +1204,7 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
final ServerLevel worldserver = this.player.serverLevel();
|
||||
final Entity entity = packet.getTarget(worldserver);
|
||||
@@ -1733,20 +2419,58 @@
|
||||
@@ -1733,20 +2425,58 @@
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packet.dispatch(new ServerboundInteractPacket.Handler() {
|
||||
@@ -1256,7 +1267,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1755,19 +2479,20 @@
|
||||
@@ -1755,19 +2485,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(InteractionHand hand) {
|
||||
@@ -1280,7 +1291,7 @@
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof AbstractArrow) {
|
||||
@@ -1785,6 +2510,11 @@
|
||||
@@ -1785,6 +2516,11 @@
|
||||
}
|
||||
|
||||
ServerGamePacketListenerImpl.this.player.attack(entity);
|
||||
@@ -1292,7 +1303,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1809,7 +2539,7 @@
|
||||
@@ -1809,7 +2545,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
@@ -1301,7 +1312,7 @@
|
||||
this.resetPosition();
|
||||
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
|
||||
} else {
|
||||
@@ -1817,11 +2547,11 @@
|
||||
@@ -1817,11 +2553,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1315,7 +1326,7 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1834,15 +2564,21 @@
|
||||
@@ -1834,15 +2570,21 @@
|
||||
@Override
|
||||
public void handleContainerClose(ServerboundContainerClosePacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1339,7 +1350,7 @@
|
||||
this.player.containerMenu.sendAllDataToRemote();
|
||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
@@ -1855,7 +2591,284 @@
|
||||
@@ -1855,7 +2597,284 @@
|
||||
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@@ -1625,7 +1636,7 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1901,8 +2914,22 @@
|
||||
@@ -1901,8 +2920,22 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1649,7 +1660,7 @@
|
||||
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
|
||||
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
|
||||
}
|
||||
@@ -1917,6 +2944,7 @@
|
||||
@@ -1917,6 +2950,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1657,7 +1668,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1945,7 +2973,44 @@
|
||||
@@ -1945,7 +2979,44 @@
|
||||
|
||||
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
@@ -1702,7 +1713,7 @@
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
|
||||
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemstack);
|
||||
@@ -1972,6 +3037,7 @@
|
||||
@@ -1972,6 +3043,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
|
||||
@@ -1710,7 +1721,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
ServerLevel worldserver = this.player.serverLevel();
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1993,7 +3059,17 @@
|
||||
@@ -1993,7 +3065,17 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
@@ -1729,7 +1740,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2058,7 +3134,7 @@
|
||||
@@ -2058,7 +3140,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
@@ -1738,7 +1749,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2083,8 +3159,10 @@
|
||||
@@ -2083,8 +3165,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user