From 88f74d1bac173e6cac1b873c096a50f754d931ef Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 7 Jun 2022 13:23:16 -0700 Subject: [PATCH] Fix some api compilation errors --- patches/api/0007-Timings-v2.patch | 69 +++++++++---------- .../0020-Add-exception-reporting-event.patch | 8 +-- ...ent-to-allow-plugins-to-handle-clien.patch | 9 +-- patches/api/0040-Add-EntityZapEvent.patch | 11 ++- 4 files changed, 46 insertions(+), 51 deletions(-) diff --git a/patches/api/0007-Timings-v2.patch b/patches/api/0007-Timings-v2.patch index befff4d9b0..c74aa51de8 100644 --- a/patches/api/0007-Timings-v2.patch +++ b/patches/api/0007-Timings-v2.patch @@ -1257,10 +1257,10 @@ index 0000000000000000000000000000000000000000..df142a89b8c43acb81eb383eac0ef048 +} diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java new file mode 100644 -index 0000000000000000000000000000000000000000..da76e1aaee1dee794e38ddd4e0a28e0071e90bbf +index 0000000000000000000000000000000000000000..dd72a34eaa4bedd9ea0b92eaa79091b00eb4dd09 --- /dev/null +++ b/src/main/java/co/aikar/timings/Timings.java -@@ -0,0 +1,296 @@ +@@ -0,0 +1,295 @@ +/* + * This file is licensed under the MIT License (MIT). + * @@ -1289,7 +1289,6 @@ index 0000000000000000000000000000000000000000..da76e1aaee1dee794e38ddd4e0a28e00 +import com.google.common.base.Preconditions; +import com.google.common.collect.EvictingQueue; +import com.google.common.collect.Lists; -+import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; @@ -1523,7 +1522,7 @@ index 0000000000000000000000000000000000000000..da76e1aaee1dee794e38ddd4e0a28e00 + * @param sender The listener to send responses too. + */ + public static void generateReport(@NotNull TimingsReportListener sender) { -+ Validate.notNull(sender); ++ Preconditions.checkNotNull(sender); + requestingReport.add(sender); + } + @@ -1559,7 +1558,7 @@ index 0000000000000000000000000000000000000000..da76e1aaee1dee794e38ddd4e0a28e00 +} diff --git a/src/main/java/co/aikar/timings/TimingsCommand.java b/src/main/java/co/aikar/timings/TimingsCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..c01606bddbcf123ca322d14cbccfc3095777dd4c +index 0000000000000000000000000000000000000000..3132dc98d26c54c5e46162e53aaed195d7335c8d --- /dev/null +++ b/src/main/java/co/aikar/timings/TimingsCommand.java @@ -0,0 +1,120 @@ @@ -1588,9 +1587,9 @@ index 0000000000000000000000000000000000000000..c01606bddbcf123ca322d14cbccfc309 + */ +package co.aikar.timings; + ++import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import net.kyori.adventure.text.format.NamedTextColor; -+import org.apache.commons.lang.Validate; +import org.bukkit.command.CommandSender; +import org.bukkit.command.defaults.BukkitCommand; +import org.bukkit.util.StringUtil; @@ -1672,9 +1671,9 @@ index 0000000000000000000000000000000000000000..c01606bddbcf123ca322d14cbccfc309 + @NotNull + @Override + public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) { -+ Validate.notNull(sender, "Sender cannot be null"); -+ Validate.notNull(args, "Arguments cannot be null"); -+ Validate.notNull(alias, "Alias cannot be null"); ++ Preconditions.checkNotNull(sender, "Sender cannot be null"); ++ Preconditions.checkNotNull(args, "Arguments cannot be null"); ++ Preconditions.checkNotNull(alias, "Alias cannot be null"); + + if (args.length == 1) { + return StringUtil.copyPartialMatches(args[0], TIMINGS_SUBCOMMANDS, @@ -1879,25 +1878,24 @@ index 0000000000000000000000000000000000000000..a92925d41110226f7fda055b71ce7be6 +} diff --git a/src/main/java/co/aikar/timings/TimingsReportListener.java b/src/main/java/co/aikar/timings/TimingsReportListener.java new file mode 100644 -index 0000000000000000000000000000000000000000..73452e53afc68061245a915c863067f47a1d99f9 +index 0000000000000000000000000000000000000000..34f4c02c3bdbe571a7efb1f8c61d8924b0c81268 --- /dev/null +++ b/src/main/java/co/aikar/timings/TimingsReportListener.java -@@ -0,0 +1,87 @@ +@@ -0,0 +1,86 @@ +package co.aikar.timings; + ++import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; -+import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.command.MessageCommandSender; +import org.bukkit.command.RemoteConsoleCommandSender; -+ -+import java.util.List; -+ +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + ++import java.util.List; ++ +@SuppressWarnings("WeakerAccess") +public class TimingsReportListener implements net.kyori.adventure.audience.ForwardingAudience, MessageCommandSender { + private final List senders; @@ -1914,8 +1912,8 @@ index 0000000000000000000000000000000000000000..73452e53afc68061245a915c863067f4 + this(senders, null); + } + public TimingsReportListener(@NotNull List senders, @Nullable Runnable onDone) { -+ Validate.notNull(senders); -+ Validate.notEmpty(senders); ++ Preconditions.checkNotNull(senders); ++ Preconditions.checkArgument(!senders.isEmpty(), "senders is empty"); + + this.senders = Lists.newArrayList(senders); + this.onDone = onDone; @@ -2941,13 +2939,12 @@ index d6c8938b1e13b63116b7b0e074ea8ef5997f8dc3..a6ad94ef98a1df1d2842635d850bc990 } diff --git a/src/main/java/org/bukkit/command/MessageCommandSender.java b/src/main/java/org/bukkit/command/MessageCommandSender.java new file mode 100644 -index 0000000000000000000000000000000000000000..f8f0aa688e337222f305fb07f57eec474e3a3a2b +index 0000000000000000000000000000000000000000..9d263ab3afb938c215c0b64d9171345fca6ceb2c --- /dev/null +++ b/src/main/java/org/bukkit/command/MessageCommandSender.java -@@ -0,0 +1,136 @@ +@@ -0,0 +1,135 @@ +package org.bukkit.command; + -+import org.apache.commons.lang.NotImplementedException; +import org.bukkit.Bukkit; +import org.bukkit.Server; +import org.bukkit.permissions.Permission; @@ -2994,90 +2991,90 @@ index 0000000000000000000000000000000000000000..f8f0aa688e337222f305fb07f57eec47 + // Paper start + @Override + default net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + // Paper end + + @NotNull + @Override + default String getName() { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @Override + default boolean isOp() { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @Override + default void setOp(boolean value) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @Override + default boolean isPermissionSet(@NotNull String name) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @Override + default boolean isPermissionSet(@NotNull Permission perm) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @Override + default boolean hasPermission(@NotNull String name) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @Override + default boolean hasPermission(@NotNull Permission perm) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @NotNull + @Override + default PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @NotNull + @Override + default PermissionAttachment addAttachment(@NotNull Plugin plugin) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @NotNull + @Override + default PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @NotNull + @Override + default PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @Override + default void removeAttachment(@NotNull PermissionAttachment attachment) { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @Override + default void recalculatePermissions() { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @NotNull + @Override + default Set getEffectivePermissions() { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + + @NotNull + @Override + default Spigot spigot() { -+ throw new NotImplementedException(); ++ throw new UnsupportedOperationException(); + } + +} diff --git a/patches/api/0020-Add-exception-reporting-event.patch b/patches/api/0020-Add-exception-reporting-event.patch index e094da52ca..bfb88b8fae 100644 --- a/patches/api/0020-Add-exception-reporting-event.patch +++ b/patches/api/0020-Add-exception-reporting-event.patch @@ -280,17 +280,15 @@ index 0000000000000000000000000000000000000000..f016ba3b1b62e554a9bacbb9635f2dbe \ No newline at end of file diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerPluginException.java b/src/main/java/com/destroystokyo/paper/exception/ServerPluginException.java new file mode 100644 -index 0000000000000000000000000000000000000000..6defac287d0214fdf99418d979144050cc1e53bc +index 0000000000000000000000000000000000000000..be3f92e3c6bcefe8b78da701b75121275001882e --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/exception/ServerPluginException.java -@@ -0,0 +1,38 @@ +@@ -0,0 +1,36 @@ +package com.destroystokyo.paper.exception; + -+import com.google.common.base.Preconditions; -+import org.apache.commons.lang.Validate; +import org.bukkit.plugin.Plugin; + -+import static com.google.common.base.Preconditions.*; ++import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Wrapper exception for all cases to which a plugin can be immediately blamed for diff --git a/patches/api/0036-Add-handshake-event-to-allow-plugins-to-handle-clien.patch b/patches/api/0036-Add-handshake-event-to-allow-plugins-to-handle-clien.patch index 1c8ac8b08e..39371691cf 100644 --- a/patches/api/0036-Add-handshake-event-to-allow-plugins-to-handle-clien.patch +++ b/patches/api/0036-Add-handshake-event-to-allow-plugins-to-handle-clien.patch @@ -7,16 +7,17 @@ Subject: [PATCH] Add handshake event to allow plugins to handle client diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..a79aa4834e700f845a625e9ab15760690726e81c +index 0000000000000000000000000000000000000000..0f533119af49f77b5e84a68c24b9d4e1b28663f1 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java -@@ -0,0 +1,277 @@ +@@ -0,0 +1,278 @@ +package com.destroystokyo.paper.event.player; + ++import com.google.common.base.Preconditions; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -+import org.apache.commons.lang.Validate; ++import org.apache.commons.lang3.Validate; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; @@ -273,7 +274,7 @@ index 0000000000000000000000000000000000000000..a79aa4834e700f845a625e9ab1576069 + */ + @Deprecated + public void setFailMessage(@NotNull String failMessage) { -+ Validate.notEmpty(failMessage, "fail message cannot be null or empty"); ++ Preconditions.checkArgument(failMessage != null && failMessage.isEmpty(), "fail message cannot be null or empty"); + this.failMessage(LegacyComponentSerializer.legacySection().deserialize(failMessage)); + } + diff --git a/patches/api/0040-Add-EntityZapEvent.patch b/patches/api/0040-Add-EntityZapEvent.patch index 41d603f073..cb9acafef2 100644 --- a/patches/api/0040-Add-EntityZapEvent.patch +++ b/patches/api/0040-Add-EntityZapEvent.patch @@ -6,18 +6,17 @@ Subject: [PATCH] Add EntityZapEvent diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..3b725a489008d333630af166d2be5fc48168a6b9 +index 0000000000000000000000000000000000000000..1c5fa066c9e5e1b1a06df30842a4c7acc4742df8 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java -@@ -0,0 +1,65 @@ +@@ -0,0 +1,64 @@ +package com.destroystokyo.paper.event.entity; + -+import org.apache.commons.lang.Validate; ++import com.google.common.base.Preconditions; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LightningStrike; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; -+import org.bukkit.event.entity.EntityEvent; +import org.bukkit.event.entity.EntityTransformEvent; + +import java.util.Collections; @@ -33,8 +32,8 @@ index 0000000000000000000000000000000000000000..3b725a489008d333630af166d2be5fc4 + + public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) { + super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING); -+ Validate.notNull(bolt); -+ Validate.notNull(replacementEntity); ++ Preconditions.checkNotNull(bolt); ++ Preconditions.checkNotNull(replacementEntity); + this.bolt = bolt; + } +