Skip to content

Commit

Permalink
Add option for Do not place player if the server is full
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Jul 21, 2024
1 parent 5ee73b6 commit 0c0c456
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions patches/server/0083-Do-not-place-player-if-the-server-is-full.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,15 @@ Subject: [PATCH] Do not place player if the server is full
Fix https://github.com/PaperMC/Paper/issues/10668

diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index eaf81d2fdebae94c3ba5eead84a3ebf1c09fa7ad..dca6ca722c2ce8ab320c2e36eb12fa75b78758ec 100644
index eaf81d2fdebae94c3ba5eead84a3ebf1c09fa7ad..1f17ce0dbbc82ea7fe14e7c3bff784432919b437 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -78,6 +78,7 @@ import net.minecraft.server.level.ClientInformation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.CommonListenerCookie;
+import net.minecraft.server.network.ServerCommonPacketListenerImpl;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
import net.minecraft.sounds.SoundEvents;
@@ -281,6 +282,13 @@ public abstract class PlayerList {
@@ -281,6 +281,13 @@ public abstract class PlayerList {
return;
}
// Gale end - MultiPaper - do not place player in world if kicked before being spawned in
+ // Leaf start - Do not place player if the server is full - copied from canPlayerLogin
+ if (this.players.size() >= this.maxPlayers && !(player.getBukkitEntity().hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameprofile))) { // Purpur
+ if (org.dreeam.leaf.config.modules.fixes.DontPlacePlayerIfFull.enabled && this.players.size() >= this.maxPlayers && !(player.getBukkitEntity().hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameprofile))) { // Purpur
+ connection.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)));
+ //playerconnection.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
+ return;
Expand All @@ -31,3 +23,30 @@ index eaf81d2fdebae94c3ba5eead84a3ebf1c09fa7ad..dca6ca722c2ce8ab320c2e36eb12fa75

Location loc = ev.getSpawnLocation();
worldserver1 = ((CraftWorld) loc.getWorld()).getHandle();
diff --git a/src/main/java/org/dreeam/leaf/config/modules/fixes/DontPlacePlayerIfFull.java b/src/main/java/org/dreeam/leaf/config/modules/fixes/DontPlacePlayerIfFull.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ca0c6ef982fa45891e67430c729eb1c92235853
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/config/modules/fixes/DontPlacePlayerIfFull.java
@@ -0,0 +1,21 @@
+package org.dreeam.leaf.config.modules.fixes;
+
+import org.dreeam.leaf.config.ConfigModules;
+import org.dreeam.leaf.config.EnumConfigCategory;
+
+public class DontPlacePlayerIfFull extends ConfigModules {
+
+ public String getBasePath() {
+ return EnumConfigCategory.FIXES.getBaseKeyName();
+ }
+
+ public static boolean enabled = false;
+
+ @Override
+ public void onLoaded() {
+ enabled = config.getBoolean(getBasePath() + ".dont-place-player-if-server-full", enabled, """
+ Don't let player join server if the server is full.
+ If enable this, you should use 'purpur.joinfullserver' permission instead of
+ PlayerLoginEvent#allow to let player join full server.""");
+ }
+}

0 comments on commit 0c0c456

Please sign in to comment.