Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Fix #3260
Dieser Commit ist enthalten in:
Ursprung
7f7c6241de
Commit
d4894ca4b5
@ -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)) {
|
||||
|
@ -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) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren