From a84348b6c9a8142135478cd07d76903fbe88a3b4 Mon Sep 17 00:00:00 2001 From: Trigary Date: Tue, 14 Apr 2020 12:11:25 +0200 Subject: [PATCH] Add player elytra boost API --- .../0230-Player-elytra-boost-API.patch | 30 ++++++++++++++++++ .../0592-Player-elytra-boost-API.patch | 31 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 Spigot-API-Patches/0230-Player-elytra-boost-API.patch create mode 100644 Spigot-Server-Patches/0592-Player-elytra-boost-API.patch diff --git a/Spigot-API-Patches/0230-Player-elytra-boost-API.patch b/Spigot-API-Patches/0230-Player-elytra-boost-API.patch new file mode 100644 index 0000000000..b44c5f589f --- /dev/null +++ b/Spigot-API-Patches/0230-Player-elytra-boost-API.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Trigary +Date: Tue, 14 Apr 2020 12:06:14 +0200 +Subject: [PATCH] Player elytra boost API + + +diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java +index 991f757a89d2e917186bb152a2f92bad8b6c2897..16bdb4b717368d121e84121f85bbf3de5fb642f1 100644 +--- a/src/main/java/org/bukkit/entity/Player.java ++++ b/src/main/java/org/bukkit/entity/Player.java +@@ -1777,6 +1777,19 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + */ + @NotNull + T getClientOption(@NotNull ClientOption option); ++ ++ /** ++ * Boost a Player that's {@link #isGliding()} using a {@link Firework}. ++ * If the creation of the entity is cancelled, no boosting is done. ++ * This method does not fire {@link com.destroystokyo.paper.event.player.PlayerElytraBoostEvent}. ++ * ++ * @param firework The {@link Material#FIREWORK_ROCKET} to boost the player with ++ * @return The {@link Firework} boosting the Player or null if the spawning of the entity was cancelled ++ * @throws IllegalArgumentException if {@link #isGliding()} is false ++ * or if the {@code firework} isn't a {@link Material#FIREWORK_ROCKET} ++ */ ++ @Nullable ++ Firework boostElytra(@NotNull ItemStack firework); + // Paper end + + // Spigot start diff --git a/Spigot-Server-Patches/0592-Player-elytra-boost-API.patch b/Spigot-Server-Patches/0592-Player-elytra-boost-API.patch new file mode 100644 index 0000000000..1206f76d88 --- /dev/null +++ b/Spigot-Server-Patches/0592-Player-elytra-boost-API.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Trigary +Date: Tue, 14 Apr 2020 12:05:22 +0200 +Subject: [PATCH] Player elytra boost API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index fb1852ea6bf6997771a3522079bf3a32ebca357c..9f04172fb28b89f57515191204c62148d14e0034 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -2086,6 +2086,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + throw new RuntimeException("Unknown settings type"); + } ++ ++ @Override ++ public org.bukkit.entity.Firework boostElytra(ItemStack firework) { ++ Validate.isTrue(isGliding(), "Player must be gliding"); ++ Validate.isTrue(firework != null, "firework == null"); ++ Validate.isTrue(firework.getType() == Material.FIREWORK_ROCKET, "Firework must be Material.FIREWORK_ROCKET"); ++ ++ net.minecraft.server.ItemStack item = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(firework); ++ net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle(); ++ net.minecraft.server.EntityFireworks entity = new net.minecraft.server.EntityFireworks(world, item, getHandle()); ++ return world.addEntity(entity) ++ ? (org.bukkit.entity.Firework) entity.getBukkitEntity() ++ : null; ++ } + // Paper end + + // Spigot start