Skip to content

Commit

Permalink
Update 0002-Feature-secure-seed.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
AltronMaxX authored Sep 27, 2023
1 parent e518840 commit 84799ef
Showing 1 changed file with 1 addition and 68 deletions.
69 changes: 1 addition & 68 deletions patches/server/0002-Feature-secure-seed.patch
Original file line number Diff line number Diff line change
Expand Up @@ -454,74 +454,7 @@ index 8b41da9d1f43340b6ba3812a93f681419d0d7cd8..7218200b140f658ae3009c1a423124cd
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 10ce902a1ce857db5376c8318ba0e67b53883873..ca2f411392a453ddd031dd755e163a8c2f4da03b 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -29,6 +29,8 @@ import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
+
+import net.edenor.foldenor.config.FoldenorConfig;
import net.minecraft.ChatFormatting;
import net.minecraft.SharedConstants;
import net.minecraft.Util;
@@ -251,6 +253,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
public final PlayerChunkSender chunkSender;
private int tickCount;
private int ackBlockChangesUpTo = -1;
+<<<<<<< HEAD
+=======
+ private long keepAliveTime = Util.getMillis();
+ private boolean keepAlivePending;
+ private long keepAliveChallenge;
+ private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList();
+>>>>>>> Add-alternative-keepalive
// CraftBukkit start - multithreaded fields
private final AtomicInteger chatSpamTickCount = new AtomicInteger();
private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
@@ -328,6 +337,40 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
private static final java.util.concurrent.atomic.AtomicLong DISCONNECT_TICKET_ID_GENERATOR = new java.util.concurrent.atomic.AtomicLong();
public static final net.minecraft.server.level.TicketType<Long> DISCONNECT_TICKET = net.minecraft.server.level.TicketType.create("disconnect_ticket", Long::compareTo);
public final Long disconnectTicketId = Long.valueOf(DISCONNECT_TICKET_ID_GENERATOR.getAndIncrement());
+<<<<<<< HEAD
+=======
+
+ private void checkKeepAlive() {
+ long currentTime = Util.getMillis();
+ long elapsedTime = currentTime - this.keepAliveTime;
+
+ if (FoldenorConfig.alternateKeepAlive) {
+ if (elapsedTime >= 1000L) { // 1 second
+ if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) {
+ LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName());
+ disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
+ } else {
+ keepAliveTime = currentTime; // hijack this field for 1 second intervals
+ keepAlives.add(currentTime); // currentTime is ID
+ send(new ClientboundKeepAlivePacket(currentTime));
+ }
+ }
+ } else
+ if (this.keepAlivePending) {
+ if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
+ ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
+ this.disconnect(Component.translatable("disconnect.timeout", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
+ }
+ } else {
+ if (elapsedTime >= 15000L) { // 15 seconds
+ this.keepAlivePending = true;
+ this.keepAliveTime = currentTime;
+ this.keepAliveChallenge = currentTime;
+ this.send(new ClientboundKeepAlivePacket(this.keepAliveChallenge));
+ }
+ }
+ }
+>>>>>>> Add-alternative-keepalive
// Folia end - region threading

@Override

diff --git a/src/main/java/net/minecraft/world/entity/monster/Slime.java b/src/main/java/net/minecraft/world/entity/monster/Slime.java
index b14979ab7bed34a37fceff5589ecb789bab31318..7463140f9d5afcfc02d02535c1d56ab750c45010 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Slime.java
Expand Down

0 comments on commit 84799ef

Please sign in to comment.