minimessage conversion

This commit is contained in:
Jake Potrebic 2022-06-09 14:11:43 -07:00
parent c34a306393
commit c946526ab1
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5
27 changed files with 167 additions and 82 deletions

View file

@ -25,19 +25,29 @@ index 653fe32bd134945e1cb1cf40f2623ffffdf5d762..9bd83fc81ae5a196a7254a4fd68f8848
* Creates a PlayerProfile for the specified uuid, with name as null.
*
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 2042f4963c53d5a903f0de1fec6a9af3a7b2bba4..b8ed8d5d48cb4f1b2f598e2c48e4423ab2d899f4 100644
index 2042f4963c53d5a903f0de1fec6a9af3a7b2bba4..475fe51ff7a9f1c1ed5048ea59d6d8ba73f2903c 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1854,6 +1854,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1854,6 +1854,23 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
boolean suggestPlayerNamesWhenNullTabCompletions();
+ /**
+ * Gets the default no permission message used on the server
+ *
+ * @return the default no permission message used on the server
+ * @return the default message
+ * @deprecated use {@link #permissionMessage()}
+ */
+ @NotNull
+ @Deprecated
+ String getPermissionMessage();
+
+ /**
+ * Gets the default no permission message used on the server
+ *
+ * @return the default message
+ */
+ @NotNull net.kyori.adventure.text.Component permissionMessage();
+
/**
* Creates a PlayerProfile for the specified uuid, with name as null.

View file

@ -20,10 +20,10 @@ index 3a011b6fe654da9710aa81c4e13e9b135fbecfc3..5880fe78b52cab2e9c2e4f2639570e03
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 102ce4e488d5b6fd4a19766e9fa02d29075b2c33..ad1d73940908f4f20a4944e81b186739fded20ab 100644
index 911b26247b3cd5e80c1f0a904ad3f88761091551..97149dc0142bd910681b8f013803fb3ea9f72dbb 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1927,5 +1927,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1937,5 +1937,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name);

View file

@ -26,10 +26,10 @@ index 3b60fa65686572fdd8fab22cd131ca5cfe5274c8..3455de478517a91285bb9d1b306ce1c4
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 6fe653a2a0fd4f07d39ed584bc11688d4926d54e..d59a7e0c9ec50040fb0b2cc3239cae46760aba04 100644
index b549cb954e4fb4e37277303911d174bedd0ee27d..8895de971276bc8027c9f02dee41f002dfcb8770 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1949,5 +1949,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1959,5 +1959,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return Current tick
*/
int getCurrentTick();

View file

@ -544,10 +544,10 @@ index 706e42172b938840c6ec06f0f7b686eee17a4a93..3faefc48a2dca51f19d4289547f0ce87
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 9b2c1eb7e215a9227c60bc85906fed33ec1dd60a..c11d802408c793c6410118bd281a21e59394066f 100644
index 81b6368189809808d2d42a21a5437b7b215f2ee2..aa621e00d48aafcbc6f9baeff55082248ad487f1 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1966,5 +1966,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1976,5 +1976,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return true if server is in the process of being shutdown
*/
boolean isStopping();

View file

@ -89,10 +89,10 @@ index 4c6780dd1375f5d2c6e60229cc05c4af9d480b8a..3e3e48f467eef561eeada98c6b99388e
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 181493def187f72b6ff89c3849598428f35d31f3..2409c0023f90689399c8ceba179b800156d16eea 100644
index c22fdde77b3d1b00577f45027dd5799bbb1cd3a3..09d72432cd854b929b262112921370138344e39c 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2013,5 +2013,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2023,5 +2023,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
com.destroystokyo.paper.entity.ai.MobGoals getMobGoals();

View file

@ -122,10 +122,10 @@ index 7fcb2d84e707576531ddb9a7dd85cf0481ae58ce..a87399fa4838d4b2c1ff9cc35d433ae7
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 5aa14f6c2f5be4d72689d764ad4d0ce5a3d704a8..79b26045a68ebb9b01e5bd06abbccaaef5489777 100644
index 99821da965069d54820bbbe349ab5dc09226f450..30b49aed62fa67276e8964922ea3f84458d854bb 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2047,5 +2047,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2057,5 +2057,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
io.papermc.paper.datapack.DatapackManager getDatapackManager();

View file

@ -404,17 +404,18 @@ index 0000000000000000000000000000000000000000..844275e8671c62633e370ae3d4e0738e
+}
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..30633591ecd078997e7bb0dc937f8c5ddedaa3ab
index 0000000000000000000000000000000000000000..5a808a09291da691cbee75a55f6aa1b70ac9f018
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
@@ -0,0 +1,263 @@
@@ -0,0 +1,264 @@
+package io.papermc.paper.configuration;
+
+import co.aikar.timings.MinecraftTimings;
+import co.aikar.timings.TimingsManager;
+import com.destroystokyo.paper.io.chunk.ChunkTaskManager;
+import io.papermc.paper.configuration.constraint.Constraint;
+import io.papermc.paper.configuration.constraint.Constraints;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.minecraft.network.protocol.Packet;
+import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket;
+import org.checkerframework.checker.nullness.qual.Nullable;
@ -447,13 +448,13 @@ index 0000000000000000000000000000000000000000..30633591ecd078997e7bb0dc937f8c5d
+ public Kick kick;
+
+ public class Kick extends ConfigurationPart {
+ public String authenticationServersDown = ""; // TODO empty is fallback to translatable msg
+ public String connectionThrottle = "Connection throttled! Please wait before reconnecting.";
+ public String flyingPlayer = "Flying is not enabled on this server";
+ public String flyingVehicle = "Flying is not enabled on this server";
+ public Component authenticationServersDown = Component.translatable("multiplayer.disconnect.authservers_down");
+ public Component connectionThrottle = Component.text("Connection throttled! Please wait before reconnecting.");
+ public Component flyingPlayer = Component.translatable("multiplayer.disconnect.flying");
+ public Component flyingVehicle = Component.translatable("multiplayer.disconnect.flying");
+ }
+
+ public String noPermission = "&cI'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.";
+ public Component noPermission = Component.text("I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.", NamedTextColor.RED);
+ public boolean useDisplayNameInQuitMessage = false;
+ }
+
@ -613,7 +614,7 @@ index 0000000000000000000000000000000000000000..30633591ecd078997e7bb0dc937f8c5d
+ public PacketLimiter packetLimiter;
+
+ public class PacketLimiter extends ConfigurationPart {
+ public String kickMessage = "&cSent too many packets"; // todo: minimessage
+ public Component kickMessage = Component.translatable("disconnect.exceeded_packet_rate", NamedTextColor.RED);
+ public PacketLimit allPackets = new PacketLimit(7.0, 500.0, PacketLimit.ViolateAction.KICK);
+ public Map<Class<? extends Packet<?>>, PacketLimit> overrides = Map.of(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP));
+
@ -835,10 +836,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1
+}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
new file mode 100644
index 0000000000000000000000000000000000000000..d25393aa10a02a74f500c520bfb2979428693177
index 0000000000000000000000000000000000000000..214bc66788d1736d40202b794ab5f820e0ebe611
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -0,0 +1,392 @@
@@ -0,0 +1,394 @@
+package io.papermc.paper.configuration;
+
+import com.google.common.base.Suppliers;
@ -846,6 +847,7 @@ index 0000000000000000000000000000000000000000..d25393aa10a02a74f500c520bfb29794
+import com.mojang.logging.LogUtils;
+import io.leangen.geantyref.TypeToken;
+import io.papermc.paper.configuration.legacy.RequiresSpigotInitialization;
+import io.papermc.paper.configuration.serializer.ComponentSerializer;
+import io.papermc.paper.configuration.serializer.EnumValueSerializer;
+import io.papermc.paper.configuration.serializer.FastutilMapSerializer;
+import io.papermc.paper.configuration.serializer.PacketClassSerializer;
@ -971,6 +973,7 @@ index 0000000000000000000000000000000000000000..d25393aa10a02a74f500c520bfb29794
+ return options.serializers(builder -> builder
+ .register(MapSerializer.TYPE, new MapSerializer(false))
+ .register(new EnumValueSerializer())
+ .register(new ComponentSerializer())
+ );
+ }
+
@ -2006,6 +2009,38 @@ index 0000000000000000000000000000000000000000..4e3bcd7c478096384fcc643d48771ab9
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
\ No newline at end of file
diff --git a/src/main/java/io/papermc/paper/configuration/serializer/ComponentSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/ComponentSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..9c339ef178ebc3b0251095f320e4a7a3656d3521
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/serializer/ComponentSerializer.java
@@ -0,0 +1,26 @@
+package io.papermc.paper.configuration.serializer;
+
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import org.spongepowered.configurate.serialize.ScalarSerializer;
+import org.spongepowered.configurate.serialize.SerializationException;
+
+import java.lang.reflect.Type;
+import java.util.function.Predicate;
+
+public class ComponentSerializer extends ScalarSerializer<Component> {
+
+ public ComponentSerializer() {
+ super(Component.class);
+ }
+
+ @Override
+ public Component deserialize(Type type, Object obj) throws SerializationException {
+ return MiniMessage.miniMessage().deserialize(obj.toString());
+ }
+
+ @Override
+ protected Object serialize(Component component, Predicate<Class<?>> typeSupported) {
+ return MiniMessage.miniMessage().serialize(component);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/serializer/EnumValueSerializer.java b/src/main/java/io/papermc/paper/configuration/serializer/EnumValueSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..2afb9268447792e3cdb46172b2050dbce066c59a
@ -2693,18 +2728,23 @@ index 0000000000000000000000000000000000000000..0300fb1e09d41465e4a50bfdc987b957
+}
diff --git a/src/main/java/io/papermc/paper/configuration/transformation/global/LegacyPaperConfig.java b/src/main/java/io/papermc/paper/configuration/transformation/global/LegacyPaperConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..9866cffcec3fdff4f9abc616d4374591d8d13860
index 0000000000000000000000000000000000000000..55886e548d3b140c4fb14495f7265ea3e1c26fd0
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/transformation/global/LegacyPaperConfig.java
@@ -0,0 +1,190 @@
@@ -0,0 +1,236 @@
+package io.papermc.paper.configuration.transformation.global;
+
+import com.mojang.logging.LogUtils;
+import io.papermc.paper.configuration.Configuration;
+import io.papermc.paper.configuration.serializer.PacketClassSerializer;
+import io.papermc.paper.util.ObfHelper;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import net.minecraft.network.protocol.Packet;
+import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket;
+import org.bukkit.ChatColor;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.slf4j.Logger;
@ -2713,6 +2753,8 @@ index 0000000000000000000000000000000000000000..9866cffcec3fdff4f9abc616d4374591
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
+import org.spongepowered.configurate.transformation.TransformAction;
+
+import java.util.function.Predicate;
+
+import static org.spongepowered.configurate.NodePath.path;
+
+public final class LegacyPaperConfig {
@ -2867,10 +2909,49 @@ index 0000000000000000000000000000000000000000..9866cffcec3fdff4f9abc616d4374591
+
+ moveFromRoot(builder, "proxy-protocol", "proxies");
+
+ miniMessageWithTranslatable(builder, String::isBlank, "multiplayer.disconnect.authservers_down", "messages", "kick", "authentication-servers-down");
+ miniMessageWithTranslatable(builder, Predicate.isEqual("Flying is not enabled on this server"), "multiplayer.disconnect.flying", "messages", "kick", "flying-player");
+ miniMessageWithTranslatable(builder, Predicate.isEqual("Flying is not enabled on this server"), "multiplayer.disconnect.flying", "messages", "kick", "flying-vehicle");
+ miniMessage(builder, "messages", "kick", "connection-throttle");
+ miniMessage(builder, "messages", "no-permission");
+ miniMessageWithTranslatable(builder, Predicate.isEqual("&cSent too many packets"), Component.translatable("disconnect.exceeded_packet_rate", NamedTextColor.RED), "packet-limiter", "kick-message");
+
+ return builder.build();
+ }
+
+ private static void moveFromRootToMisc(final ConfigurationTransformation.Builder builder, String key) {
+ private static void miniMessageWithTranslatable(final ConfigurationTransformation.Builder builder, final Predicate<String> englishCheck, final String i18nKey, final String... strPath) {
+ miniMessageWithTranslatable(builder, englishCheck, Component.translatable(i18nKey), strPath);
+ }
+ private static void miniMessageWithTranslatable(final ConfigurationTransformation.Builder builder, final Predicate<String> englishCheck, final Component component, final String... strPath) {
+ builder.addAction(path((Object[]) strPath), (path, value) -> {
+ final @Nullable Object val = value.raw();
+ if (val != null) {
+ final String strVal = val.toString();
+ if (!englishCheck.test(strVal)) {
+ value.set(miniMessage(strVal));
+ return null;
+ }
+ }
+ value.set(MiniMessage.miniMessage().serialize(component));
+ return null;
+ });
+ }
+
+ private static void miniMessage(final ConfigurationTransformation.Builder builder, final String... strPath) {
+ builder.addAction(path((Object[]) strPath), (path, value) -> {
+ final @Nullable Object val = value.raw();
+ if (val != null) {
+ value.set(miniMessage(val.toString()));
+ }
+ return null;
+ });
+ }
+
+ private static String miniMessage(final String input) {
+ return MiniMessage.miniMessage().serialize(LegacyComponentSerializer.legacySection().deserialize(ChatColor.translateAlternateColorCodes('&', input)));
+ }
+
+ private static void moveFromRootToMisc(final ConfigurationTransformation.Builder builder, final String key) {
+ moveFromRoot(builder, key, "misc");
+ }
+

View file

@ -307,7 +307,7 @@ index d25393aa10a02a74f500c520bfb2979428693177..2e8da92c09fca465b754e45e0bf9984b
import com.google.common.base.Suppliers;
import com.google.common.collect.Table;
import com.mojang.logging.LogUtils;
@@ -350,6 +351,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
@@ -352,6 +353,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
private static final Map<String, Command> COMMANDS = new HashMap<>();
static {

View file

@ -700,7 +700,7 @@ index 2e8da92c09fca465b754e45e0bf9984b978557e9..b1845b20091b2a28a988f729c18415bb
import com.destroystokyo.paper.PaperCommand;
import com.google.common.base.Suppliers;
import com.google.common.collect.Table;
@@ -350,6 +351,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
@@ -352,6 +353,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
}
private static final Map<String, Command> COMMANDS = new HashMap<>();
@ -708,7 +708,7 @@ index 2e8da92c09fca465b754e45e0bf9984b978557e9..b1845b20091b2a28a988f729c18415bb
static {
COMMANDS.put("paper", new PaperCommand("paper"));
}
@@ -358,6 +360,11 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
@@ -360,6 +362,11 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
COMMANDS.forEach((s, command) -> {
server.server.getCommandMap().register(s, "Paper", command);
});

View file

@ -6,17 +6,15 @@ Subject: [PATCH] Allow specifying a custom "authentication servers down" kick
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index dc932515bada7f84a386827f3b7e1e8f69bd7159..9fe3ec7e6bd194b825a1b29bcff9fcd5e21f22ad 100644
index dc932515bada7f84a386827f3b7e1e8f69bd7159..d2f0450c6bae722bfa9162b027e723eb10b22c78 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -358,6 +358,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
@@ -358,7 +358,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
ServerLoginPacketListenerImpl.this.gameProfile = ServerLoginPacketListenerImpl.this.createFakeProfile(gameprofile);
ServerLoginPacketListenerImpl.this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT;
} else {
+ // Paper start
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.authenticationServersDown.isEmpty()) {
+ ServerLoginPacketListenerImpl.this.disconnect(Component.literal(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.authenticationServersDown));
+ } else // Paper end
ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.authservers_down"));
- ServerLoginPacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.authservers_down"));
+ ServerLoginPacketListenerImpl.this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.authenticationServersDown)); // Paper
ServerLoginPacketListenerImpl.LOGGER.error("Couldn't verify username because servers are unavailable");
}
// CraftBukkit start - catch all exceptions

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Ability to change PlayerProfile in AsyncPreLoginEvent
This will allow you to change the players name or skin on login.
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 5bf48f4fb0794a1eaea3783add9e5852997434f6..27a90187a615734fb86d0325dae0c7af2768375a 100644
index 145f3eae6622453d47769e10fb30ce8d31d5f847..53e8804b8ee35acdc2c4b3cbe2bc409242840726 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -397,8 +397,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
@@ -393,8 +393,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId();
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Player.setPlayerProfile API
This can be useful for changing name or skins after a player has logged in.
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 27a90187a615734fb86d0325dae0c7af2768375a..e27ce986dab7b249f8a69e1d94cfbd91bab5c4b9 100644
index 53e8804b8ee35acdc2c4b3cbe2bc409242840726..1b075033f0640433341957f6e26ebe25f18928ee 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -398,11 +398,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
@@ -394,11 +394,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server;
// Paper start
@ -24,7 +24,7 @@ index 27a90187a615734fb86d0325dae0c7af2768375a..e27ce986dab7b249f8a69e1d94cfbd91
playerName = gameProfile.getName();
uniqueId = gameProfile.getId();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index e6ca45329c5f102ebf4abc729837108cad63a59f..380bdc7cfa8980d5db29a15b29613fc62d75de2a 100644
index 153b5602f1c5f6ef7a184fc8c9cb72523fa3fccb..fd3304d1e58f0976cd048d4a265181a0f1251c2f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -75,6 +75,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes;

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Configurable connection throttle kick message
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
index 4170bda451df3db43e7d57d87d1abb81934d7dad..14fa831c9984e72ae2185c4f9e07f65b0c2ed67c 100644
index 4170bda451df3db43e7d57d87d1abb81934d7dad..43759cdf3da0796d7969c6504ac9a6986c0f0518 100644
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
@@ -49,7 +49,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
@ -13,7 +13,7 @@ index 4170bda451df3db43e7d57d87d1abb81934d7dad..14fa831c9984e72ae2185c4f9e07f65b
if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
- MutableComponent chatmessage = Component.literal("Connection throttled! Please wait before reconnecting.");
+ MutableComponent chatmessage = Component.literal(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message
+ Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
this.connection.disconnect(chatmessage);
return;

View file

@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..74b3265bba78491f462c15709a31bc44
+ }
+}
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index e27ce986dab7b249f8a69e1d94cfbd91bab5c4b9..1e4c306569fa96327dc99bb5dd6b3a749e60813e 100644
index 1b075033f0640433341957f6e26ebe25f18928ee..b070624c7ee85b6692f1f44ded6c78139925b669 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -69,6 +69,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
@ -112,7 +112,7 @@ index e27ce986dab7b249f8a69e1d94cfbd91bab5c4b9..1e4c306569fa96327dc99bb5dd6b3a74
// Spigot start
// Paper start - Cache authenticator threads
authenticatorPool.execute(new Runnable() {
@@ -392,6 +401,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
@@ -388,6 +397,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
public class LoginHandler {
public void fireEvents() throws Exception {
@ -125,7 +125,7 @@ index e27ce986dab7b249f8a69e1d94cfbd91bab5c4b9..1e4c306569fa96327dc99bb5dd6b3a74
String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName();
java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();
java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId();
@@ -439,6 +454,40 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
@@ -435,6 +450,40 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
// Spigot end
public void handleCustomQueryPacket(ServerboundCustomQueryPacket packet) {

View file

@ -18,15 +18,20 @@ index e75134a6aa92c86aa86430c7603e111280077d16..c5b005e7a803c848dca31dc76d1ec83f
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 9a9b6ceab49e78a6b5523825e571186f6f610212..fe5a676abb5c47045f6ca1a6dde78d9859b43abe 100644
index 9a9b6ceab49e78a6b5523825e571186f6f610212..80e508aa9fc9cf41ecfc528086cc9eebde7b5728 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2586,6 +2586,11 @@ public final class CraftServer implements Server {
@@ -2586,6 +2586,16 @@ public final class CraftServer implements Server {
return io.papermc.paper.configuration.GlobalConfiguration.get().commands.suggestPlayerNamesWhenNullTabCompletions;
}
+ @Override
+ public String getPermissionMessage() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand().serialize(io.papermc.paper.configuration.GlobalConfiguration.get().messages.noPermission);
+ }
+
+ @Override
+ public net.kyori.adventure.text.Component permissionMessage() {
+ return io.papermc.paper.configuration.GlobalConfiguration.get().messages.noPermission;
+ }
+

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Expose the internal current tick
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 403f4166b9e27a9037920195996e7f13c2fb31a2..4c8ca8625860c7a19c73da633b236e2b255bd6de 100644
index b554f7f3ae57a2cca69a10ec3e8314180cf73d32..45d923dafdc7dad8b35b8bfd97ce7934abf7efde 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2622,5 +2622,10 @@ public final class CraftServer implements Server {
@@ -2627,5 +2627,10 @@ public final class CraftServer implements Server {
profile.getProperties().putAll(((CraftPlayer)player).getHandle().getGameProfile().getProperties());
return new com.destroystokyo.paper.profile.CraftPlayerProfile(profile);
}

View file

@ -1017,7 +1017,7 @@ index 0000000000000000000000000000000000000000..80a2dfb266ae1221680a7b24fee2f7e2
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
index ab145a47bef1d356e28c719e5c25552ff4bc6555..e4845a818b3a9dc3b06a67b3a461ce506bb37cba 100644
index bc0922d959816c990b16233689192b46371a73e4..5626a772908f7956a30a82ca73929b05c19f7268 100644
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -2,6 +2,7 @@ package io.papermc.paper.configuration;
@ -1028,7 +1028,7 @@ index ab145a47bef1d356e28c719e5c25552ff4bc6555..e4845a818b3a9dc3b06a67b3a461ce50
import com.google.common.base.Suppliers;
import com.google.common.collect.Table;
import com.mojang.logging.LogUtils;
@@ -191,6 +192,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
@@ -193,6 +194,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
.register(DoubleOrDefault.SERIALIZER)
.register(BooleanOrDefault.SERIALIZER)
.register(Duration.SERIALIZER)
@ -1607,7 +1607,7 @@ index cf48c93d89da53e0ec771e5c2c8582e30b35e3f5..518dfbb7dbd4221937636cf46d27109d
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 4c8ca8625860c7a19c73da633b236e2b255bd6de..cf7b6b0c4b682baefcb080b4a971c388667533e5 100644
index 45d923dafdc7dad8b35b8bfd97ce7934abf7efde..2dfcb0fcae636043fa3aeeb20aaa0091a73b578c 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2204,7 +2204,7 @@ public final class CraftServer implements Server {

View file

@ -120,7 +120,7 @@ index 2e5718d720744967c5f2ba13805aad53a1dec593..61a26e9312b1a2d0b582778a178f73db
import com.destroystokyo.paper.Metrics;
import com.destroystokyo.paper.PaperCommand;
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray;
@@ -356,6 +357,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
@@ -358,6 +359,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
private static boolean metricsStarted = false;
static {
COMMANDS.put("paper", new PaperCommand("paper"));
@ -189,7 +189,7 @@ index bf97a9be49a8a187004ceb302db59c31f12e3e1b..7de1368bcde500ba133282537270fbdf
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index cf7b6b0c4b682baefcb080b4a971c388667533e5..d06855176c8e7a99527f9ae0862440a8f74cf7bd 100644
index 2dfcb0fcae636043fa3aeeb20aaa0091a73b578c..2f74bdd0ce45486b19314cf17aa312b56fe7c2b7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2449,6 +2449,16 @@ public final class CraftServer implements Server {

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Expose MinecraftServer#isRunning
This allows for plugins to detect if the server is actually turning off in onDisable rather than just plugins reloading.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d06855176c8e7a99527f9ae0862440a8f74cf7bd..a67e99a53f35c2d0142193ac75f47ba8bd7d9784 100644
index 2f74bdd0ce45486b19314cf17aa312b56fe7c2b7..f83d09866176f6d8fd9549f82cf743312b3df000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2637,5 +2637,10 @@ public final class CraftServer implements Server {
@@ -2642,5 +2642,10 @@ public final class CraftServer implements Server {
public int getCurrentTick() {
return net.minecraft.server.MinecraftServer.currentTick;
}

View file

@ -789,10 +789,10 @@ index 4379b9948f1eecfe6fd7dea98e298ad5f761019a..3f081183521603824430709886a9cc31
LOOK,
JUMP,
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 29cedf6164e00779fd47f98ad8febb0627df2b9f..fc4a7e9bb246a2bd1075cf180949878e8b58cfa4 100644
index 1a60c91bd1cf171645370a24c3bc3f081b3ecbea..3e6598bcf442b6623df10cc3caaef98f789d4ea9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2650,5 +2650,11 @@ public final class CraftServer implements Server {
@@ -2655,5 +2655,11 @@ public final class CraftServer implements Server {
public boolean isStopping() {
return net.minecraft.server.MinecraftServer.getServer().hasStopped();
}

View file

@ -5,18 +5,9 @@ Subject: [PATCH] Fix hex colors not working in some kick messages
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
index 14fa831c9984e72ae2185c4f9e07f65b0c2ed67c..9ece2ceac6c5095469b080f08bf7af8f7b31f003 100644
index 43759cdf3da0796d7969c6504ac9a6986c0f0518..750fef0f5b908b776a7306e54653eba497b7c50b 100644
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
@@ -49,7 +49,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
synchronized (ServerHandshakePacketListenerImpl.throttleTracker) {
if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
- MutableComponent chatmessage = Component.literal(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message
+ Component chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle, true)[0]; // Paper - Configurable connection throttle kick message // Paper - Fix hex colors not working in some kick messages
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
this.connection.disconnect(chatmessage);
return;
@@ -75,12 +75,12 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
}
// CraftBukkit end
@ -34,7 +25,7 @@ index 14fa831c9984e72ae2185c4f9e07f65b0c2ed67c..9ece2ceac6c5095469b080f08bf7af8f
this.connection.send(new ClientboundLoginDisconnectPacket(ichatmutablecomponent));
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index a0d694ad78576fe77f0d99269d15a0fc0cdda035..ed9c4a8e377867771d8376c485f56c6bd234192b 100644
index ae93ca7bcc7347ee165cbb0e9fd20aa3da54616c..25d96d74a656765c92e8df0bb8563947f5587f3b 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -111,7 +111,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add raw address to AsyncPlayerPreLoginEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index ed9c4a8e377867771d8376c485f56c6bd234192b..71614fb07ba771ec9a00772074b031b77210d425 100644
index 25d96d74a656765c92e8df0bb8563947f5587f3b..3f3210fa043bee7e3a0f794e58dcba6c317e2de7 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -414,12 +414,13 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
@@ -410,12 +410,13 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
// Paper end
String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName();
java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress();

View file

@ -92,7 +92,7 @@ index 0000000000000000000000000000000000000000..cf4374493c11057451a62a655514415c
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 288d6625c30e7d36c6c4ce372bccf3d42536be35..3752cd9e3ac1b1a82b79006ca09a873c9adbd7a4 100644
index 648d37ecde4b890cfb93ca94b2b9f8fe08283981..50fb92c87fbaabdbac1e08979132619d71b8b0c6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -276,6 +276,7 @@ public final class CraftServer implements Server {
@ -111,7 +111,7 @@ index 288d6625c30e7d36c6c4ce372bccf3d42536be35..3752cd9e3ac1b1a82b79006ca09a873c
}
public boolean getCommandBlockOverride(String command) {
@@ -2729,5 +2731,11 @@ public final class CraftServer implements Server {
@@ -2734,5 +2736,11 @@ public final class CraftServer implements Server {
public com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
return mobGoals;
}

View file

@ -24,7 +24,7 @@ and an action can be defined: DROP or KICK
If interval or rate are less-than 0, the limit is ignored
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 05a15b2da76a6d246b705e682b61a7c40c5dade7..f13c93764d6026b7e53123a8f6f123d986ded3a5 100644
index 05a15b2da76a6d246b705e682b61a7c40c5dade7..8c6e2aa1a5e98456684f74d677ac0af24aa90246 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -135,6 +135,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -40,8 +40,8 @@ index 05a15b2da76a6d246b705e682b61a7c40c5dade7..f13c93764d6026b7e53123a8f6f123d9
+
+ private boolean stopReadingPackets;
+ private void killForPacketSpam() {
+ this.sendPacket(new ClientboundDisconnectPacket(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.kickMessage, true)[0]), (future) -> {
+ this.disconnect(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.kickMessage, true)[0]);
+ this.sendPacket(new ClientboundDisconnectPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.kickMessage)), (future) -> {
+ this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.kickMessage));
+ });
+ this.setReadOnly();
+ this.stopReadingPackets = true;

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Added getHostname to AsyncPlayerPreLoginEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index e581656c4450be708f1a91a42b5b1da9105df6f3..5f46bdcb109ec4af7e1241a278737b3dc41299f5 100644
index f18c24266eecdc3d108c6523da6b75985bba291a..89f8690848db712f382d1a1e5b75053262d991ac 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -454,7 +454,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
@@ -450,7 +450,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
// Paper start
com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile);

View file

@ -164,7 +164,7 @@ index 3d688e334c7287f41460bd866bfd1155e8bb55d2..55006724ccec9f3de828ec18693728e9
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c62af511153b104ae3fdf45c899cec5de5c0de53..bf45b635cb5397dc30ac9cf2d7c37fa1cfc1b32b 100644
index 8d94fd23b85bf6bbe8486f3548dfd12360926f5d..781bc5ee94bdd33bfd31c3234c5a75132be5468a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -279,6 +279,7 @@ public final class CraftServer implements Server {
@ -184,7 +184,7 @@ index c62af511153b104ae3fdf45c899cec5de5c0de53..bf45b635cb5397dc30ac9cf2d7c37fa1
MobEffects.BLINDNESS.getClass();
PotionEffectType.stopAcceptingRegistrations();
// Ugly hack :(
@@ -2855,5 +2856,10 @@ public final class CraftServer implements Server {
@@ -2860,5 +2861,10 @@ public final class CraftServer implements Server {
return datapackManager;
}