mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-21 16:09:19 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@1c3c47a Correctly check enchants for ItemStack#damage (#11240) PaperMC/Paper@1187544 Fix teleport event getTo returning null (#11239) PaperMC/Paper@dd941cc Re-add patches for can-place/can-destroy API (#11238) PaperMC/Paper@ab0d24a Configuration for horizontal-only item merging (#11219) PaperMC/Paper@098bd39 Remove arbitrary book page limit (#11228) PaperMC/Paper@f97aff7 [ci skip] Fix Effect javadocs (#11182) PaperMC/Paper@4a97ba3 Fix `setSendViewDistance`'s return (#11247) PaperMC/Paper@1798e94 Fix BasicCommand suggestion arg count (#11241) PaperMC/Paper@7c9240f Improve standard messenger logging PaperMC/Paper@9ab644e Fix `TooltipContext.create` being wrong(#11254) PaperMC/Paper@11b4ac7 Fix disableEndCredits world config (#11261) PaperMC/Paper@bf5852a Fix NPE for PlayerPostRespawnEvent#getRespawnedLocation (#11268) PaperMC/Paper@fb53074 Apply optimise collision checking in move packet handling patch PaperMC/Paper@81bfda8 [ci skip] Specify rebase location in CONTRIBUTING (#11255) PaperMC/Paper@9571983 Fix scanForLegacyEnderDragon world config (#11262) PaperMC/Paper@ec55c11 Fix indestructable light blocks (#11275) PaperMC/Paper@1b8ab11 Add Configuration for vertical Despawn Ranges (#10440) PaperMC/Paper@534ab86 [ci-skip] Revert "Add Configuration for vertical Despawn Ranges (#10440)" (#11278) PaperMC/Paper@e619744 Allow skipping of world symlink validation (#11250) PaperMC/Paper@78216fe Re-implement portalCreateRadius world config (#11267) PaperMC/Paper@4829fbf Handle custom registry elements properly (#11230) PaperMC/Paper@d5ffc57 Implement more methods for horse inventories (#11147) PaperMC/Paper@52ae4ad Migrate ArmorStand meta to using entity tag (#11107) PaperMC/Paper@75655ec Add Configuration for vertical Despawn Ranges (#11279) PaperMC/Paper@0e73617 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11284) PaperMC/Paper@66a97cc Update item data sanitization (#11227) PaperMC/Paper@2e82fd2 Add even more Enchantment API (#11115) PaperMC/Paper@57dd822 Leashable API (#10961) PaperMC/Paper@8c3018a Fix Selector Arguments not working with permission (#11286) PaperMC/Paper@4401748 Fix CraftBukkit drag system (#10703) PaperMC/Paper@64c9ee6 Allow getting/setting the sign's editor uuid (#10637) Gale Changes: Dreeam-qwq/Gale@dc228bb Updated Upstream (Paper) Dreeam-qwq/Gale@ecbaa9c Updated Upstream (Paper) Dreeam-qwq/Gale@7e2df5b Updated Upstream (Paper) Dreeam-qwq/Gale@ea59414 Updated Upstream (Paper) Dreeam-qwq/Gale@e373e97 Updated Upstream (Paper) Purpur Changes: PurpurMC/Purpur@366af80 Updated Upstream (Paper) PurpurMC/Purpur@07979c3 Updated Upstream (Paper) PurpurMC/Purpur@3f790ac Updated Upstream (Paper) PurpurMC/Purpur@201e928 Updated Upstream (Pufferfish) (#1575) PurpurMC/Purpur@f2307b8 Updated Upstream (Paper) PurpurMC/Purpur@bba87bf Updated Upstream (Paper) PurpurMC/Purpur@f530395 Fix no exp drops from spawners using silk touch pickaxe without option enabled (#1582)
105 lines
7.2 KiB
Diff
105 lines
7.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Date: Sun, 2 Jun 2024 01:21:36 +0800
|
|
Subject: [PATCH] Configurable connection message
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index 3482c172685990f696797a954ef765fe2d0f6261..9d2faacd5c9c6e5439c6b8b2e2f7cb2bab4ad8f8 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -354,7 +354,7 @@ public abstract class PlayerList {
|
|
// Ensure that player inventory is populated with its viewer
|
|
player.containerMenu.transferTo(player.containerMenu, bukkitPlayer);
|
|
|
|
- PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(bukkitPlayer, io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure
|
|
+ PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(bukkitPlayer, getJoinMsg(io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent), bukkitPlayer)); // Paper - Adventure // Leaf - Configurable connection message - join message
|
|
this.cserver.getPluginManager().callEvent(playerJoinEvent);
|
|
|
|
if (!player.connection.isAcceptingMessages()) {
|
|
@@ -367,7 +367,7 @@ public abstract class PlayerList {
|
|
|
|
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
|
|
|
- if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
|
|
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinEnabled && jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure // Leaf - Configurable connection message - join message
|
|
joinMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(jm); // Paper - Adventure
|
|
this.server.getPlayerList().broadcastSystemMessage(joinMessage, false); // Paper - Adventure
|
|
}
|
|
@@ -626,7 +626,7 @@ public abstract class PlayerList {
|
|
entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
|
|
}
|
|
|
|
- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName())), entityplayer.quitReason); // Paper - Adventure & Add API for quit reason
|
|
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), getQuitMsg(net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName())), entityplayer.getBukkitEntity()), entityplayer.quitReason); // Paper - Adventure & Add API for quit reason // Leaf - Configurable connection message - quit message
|
|
this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
|
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
|
|
|
@@ -1663,4 +1663,29 @@ public abstract class PlayerList {
|
|
public boolean isAllowCommandsForAllPlayers() {
|
|
return this.allowCommandsForAllPlayers;
|
|
}
|
|
+
|
|
+ // Leaf start - Configurable connection message
|
|
+ private net.kyori.adventure.text.Component getJoinMsg(net.kyori.adventure.text.Component defaultJoinMsg, Player player) {
|
|
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinEnabled) {
|
|
+ return "default".equals(org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinMessage)
|
|
+ ? defaultJoinMsg
|
|
+ : net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinMessage)
|
|
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("%player_name%").replacement(player.getName()).build())
|
|
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("%player_displayname%").replacement(player.displayName()).build());
|
|
+ }
|
|
+
|
|
+ return net.kyori.adventure.text.Component.empty();
|
|
+ }
|
|
+ private net.kyori.adventure.text.Component getQuitMsg(net.kyori.adventure.text.Component defaultQuitMsg, Player player) {
|
|
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitEnabled) {
|
|
+ return "default".equals(org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitMessage)
|
|
+ ? defaultQuitMsg
|
|
+ : net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitMessage)
|
|
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("%player_name%").replacement(player.getName()).build())
|
|
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("%player_displayname%").replacement(player.displayName()).build());
|
|
+ }
|
|
+
|
|
+ return net.kyori.adventure.text.Component.empty();
|
|
+ }
|
|
+ // Leaf end - Configurable connection message
|
|
}
|
|
diff --git a/src/main/java/org/dreeam/leaf/config/modules/misc/ConnectionMessage.java b/src/main/java/org/dreeam/leaf/config/modules/misc/ConnectionMessage.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..d05c123143ff623ce45c351a487e10ba52c92a61
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/misc/ConnectionMessage.java
|
|
@@ -0,0 +1,31 @@
|
|
+package org.dreeam.leaf.config.modules.misc;
|
|
+
|
|
+import org.dreeam.leaf.config.ConfigModules;
|
|
+import org.dreeam.leaf.config.EnumConfigCategory;
|
|
+
|
|
+public class ConnectionMessage extends ConfigModules {
|
|
+
|
|
+ public String getBasePath() {
|
|
+ return EnumConfigCategory.MISC.getBaseKeyName() + ".connection-message";
|
|
+ }
|
|
+
|
|
+ public static boolean joinEnabled = true;
|
|
+ public static String joinMessage = "default";
|
|
+ public static boolean quitEnabled = true;
|
|
+ public static String quitMessage = "default";
|
|
+
|
|
+ @Override
|
|
+ public void onLoaded() {
|
|
+ config.addComment(getBasePath(), """
|
|
+ Connection message, using MiniMessage format, set to "default" to use vanilla join message.
|
|
+ available placeholders:
|
|
+ %player_name% - player name
|
|
+ %player_displayname% - player display name""");
|
|
+
|
|
+ joinEnabled = config.getBoolean(getBasePath() + ".join.enabled", joinEnabled);
|
|
+ joinMessage = config.getString(getBasePath() + ".join.message", joinMessage, "Join message of player");
|
|
+
|
|
+ quitEnabled = config.getBoolean(getBasePath() + ".quit.enabled", quitEnabled);
|
|
+ quitMessage = config.getString(getBasePath() + ".quit.message", quitMessage, "Quit message of player");
|
|
+ }
|
|
+}
|