3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2023-03-17 13:15:56 +01:00
Ursprung 7f7c6241de
Commit d4894ca4b5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 11 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -31,28 +31,12 @@ import org.bukkit.inventory.PlayerInventory;
public final class ArmorToggleListener extends ViaBukkitListener {
private static final boolean ENABLED = hasEquipmentSlot();
public ArmorToggleListener(final ViaVersionPlugin plugin) {
super(plugin, Protocol1_19_4To1_19_3.class);
}
private static boolean hasEquipmentSlot() {
// Doesn't exist on 1.8
try {
Material.class.getMethod("getEquipmentSlot");
return true;
} catch (final NoSuchMethodException e) {
return false;
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void itemUse(final PlayerInteractEvent event) {
if (!ENABLED) {
return;
}
final Player player = event.getPlayer();
final ItemStack item = event.getItem();
if (item == null || event.getHand() == null || !isOnPipe(player)) {

Datei anzeigen

@ -52,6 +52,7 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scheduler.BukkitTask;
public class BukkitViaLoader implements ViaPlatformLoader {
@ -144,7 +145,7 @@ public class BukkitViaLoader implements ViaPlatformLoader {
}
}
if (serverProtocolVersion < ProtocolVersion.v1_19_4.getVersion() && plugin.getConf().isArmorToggleFix()) {
if (serverProtocolVersion < ProtocolVersion.v1_19_4.getVersion() && plugin.getConf().isArmorToggleFix() && hasGetHandMethod()) {
new ArmorToggleListener(plugin).register();
}
@ -195,6 +196,15 @@ public class BukkitViaLoader implements ViaPlatformLoader {
}
}
private boolean hasGetHandMethod() {
try {
PlayerInteractEvent.class.getDeclaredMethod("getHand");
return true;
} catch (NoSuchMethodException e) {
return false;
}
}
@Override
public void unload() {
for (BukkitTask task : tasks) {