mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-20 23:49:31 +00:00
* uwu * reorder * Change author * Sync upstream * Lithium: equipment tracking * Faster CraftServer#getworlds list creation Co-Authored-By: Kobe ⑧ <102713261+HaHaWTH@users.noreply.github.com>
66 lines
4.4 KiB
Diff
66 lines
4.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Date: Mon, 24 Jun 2024 10:49:04 +0800
|
|
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 8e3bbc7a0cf2a3e5999738c0f764544f5e64ef4a..a7fadf66ff2935c6a3751f2121b0e1a8860cc3f9 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -377,6 +377,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 (org.dreeam.leaf.config.modules.fixes.DontPlacePlayerIfFull.enabled && this.realPlayers.size() >= this.maxPlayers && !(player.getBukkitEntity().hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameprofile))) { // Purpur // Leaves - skip
|
|
+ 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;
|
|
+ }
|
|
+ // Leaf end - Do not place player if the server is full - copied from canPlayerLogin
|
|
|
|
Location loc = ev.getSpawnLocation();
|
|
worldserver1 = ((CraftWorld) loc.getWorld()).getHandle();
|
|
@@ -914,7 +921,7 @@ public abstract class PlayerList {
|
|
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure
|
|
} else {
|
|
// return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null;
|
|
- if (this.realPlayers.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameprofile))) { // Purpur // Leaves - skip
|
|
+ if (this.realPlayers.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameprofile))) { // Purpur // Leaves - skip // Leaf - Do not place player if the server is full - diff on change
|
|
event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
|
|
}
|
|
}
|
|
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..ae21bcac9d57b760d751d25f2bdb746e4bd636f1
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/fixes/DontPlacePlayerIfFull.java
|
|
@@ -0,0 +1,25 @@
|
|
+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, config.pickStringRegionBased("""
|
|
+ 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.""",
|
|
+ """
|
|
+ 服务器已满时禁止玩家加入.
|
|
+ 开启后需使用权限 'purpur.joinfullserver' 而不是
|
|
+ PlayerLoginEvent#allow 让玩家进入已满的服务器."""));
|
|
+ }
|
|
+}
|