diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 68297504..8107b456 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -8,5 +8,5 @@ repositories { dependencies { // version must be manually kept in sync with the one in root project settings.gradle.kts - implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.2") + implementation("gradle.plugin.com.github.johnrengelman", "shadow", "8.0.0") } diff --git a/bukkit/src/main/java/com/viaversion/viabackwards/BukkitPlugin.java b/bukkit/src/main/java/com/viaversion/viabackwards/BukkitPlugin.java index 8e6bfb9e..2c0509f0 100644 --- a/bukkit/src/main/java/com/viaversion/viabackwards/BukkitPlugin.java +++ b/bukkit/src/main/java/com/viaversion/viabackwards/BukkitPlugin.java @@ -19,6 +19,7 @@ package com.viaversion.viabackwards; import com.viaversion.viabackwards.api.ViaBackwardsPlatform; +import com.viaversion.viabackwards.listener.PlayerItemDropListener; import com.viaversion.viabackwards.listener.FireDamageListener; import com.viaversion.viabackwards.listener.FireExtinguishListener; import com.viaversion.viabackwards.listener.LecternInteractListener; @@ -58,6 +59,9 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform { private void onServerLoaded() { BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader(); int protocolVersion = Via.getAPI().getServerVersion().highestSupportedVersion(); + if (protocolVersion >= ProtocolVersion.v1_17.getVersion()) { + loader.storeListener(new PlayerItemDropListener(this)).register(); + } if (protocolVersion >= ProtocolVersion.v1_16.getVersion()) { loader.storeListener(new FireExtinguishListener(this)).register(); } diff --git a/bukkit/src/main/java/com/viaversion/viabackwards/listener/PlayerItemDropListener.java b/bukkit/src/main/java/com/viaversion/viabackwards/listener/PlayerItemDropListener.java new file mode 100644 index 00000000..032be6e1 --- /dev/null +++ b/bukkit/src/main/java/com/viaversion/viabackwards/listener/PlayerItemDropListener.java @@ -0,0 +1,48 @@ + +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2016-2023 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.viaversion.viabackwards.listener; + +import com.viaversion.viabackwards.BukkitPlugin; +import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1; +import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.inventory.ItemStack; + +public class PlayerItemDropListener extends ViaBukkitListener { + + public PlayerItemDropListener(final BukkitPlugin plugin) { + super(plugin, Protocol1_13To1_13_1.class); // Starts with 1.13 clients on 1.17 servers + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onItemDrop(final PlayerDropItemEvent event) { + final Player player = event.getPlayer(); + if (!isOnPipe(player)) { + return; + } + + // Resent the item in the hand + final int slot = player.getInventory().getHeldItemSlot(); + final ItemStack item = player.getInventory().getItem(slot); + player.getInventory().setItem(slot, item); + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 3efa520c..f64af541 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,7 +16,7 @@ dependencyResolutionManagement { pluginManagement { plugins { id("net.kyori.blossom") version "1.2.0" - id("com.github.johnrengelman.shadow") version "7.1.2" + id("com.github.johnrengelman.shadow") version "8.0.0" } }