Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
Add armor toggle patch for Bukkit (#3210)
Dieser Commit ist enthalten in:
Ursprung
93654b8eaf
Commit
734bc9e88c
@ -458,4 +458,6 @@ public interface ViaVersionConfig {
|
||||
boolean cache1_17Light();
|
||||
|
||||
@Nullable String chatTypeFormat(String translationKey);
|
||||
|
||||
boolean isArmorToggleFix();
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viaversion.bukkit.listeners.protocol1_19_4To1_19_3;
|
||||
|
||||
import com.viaversion.viaversion.ViaVersionPlugin;
|
||||
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.Protocol1_19_4To1_19_3;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public final class ArmorToggleListener extends ViaBukkitListener {
|
||||
|
||||
public ArmorToggleListener(ViaVersionPlugin plugin) {
|
||||
super(plugin, Protocol1_19_4To1_19_3.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void itemUse(final PlayerInteractEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
final ItemStack item = event.getItem();
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
final EquipmentSlot equipmentSlot = item.getType().getEquipmentSlot();
|
||||
// Name comparison for OFF_HAND so 1.8 doesn't complain
|
||||
if (equipmentSlot != EquipmentSlot.HAND && !equipmentSlot.name().equals("OFF_HAND")) {
|
||||
final ItemStack armor = player.getInventory().getItem(equipmentSlot);
|
||||
// If two pieces of armor are equal, the client will do nothing.
|
||||
if (armor != null && armor.getType() != Material.AIR && !armor.equals(item)) {
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ public class BukkitViaConfig extends AbstractViaConfig {
|
||||
private boolean hitboxFix1_9;
|
||||
private boolean hitboxFix1_14;
|
||||
private String blockConnectionMethod;
|
||||
private boolean armorToggleFix;
|
||||
|
||||
public BukkitViaConfig() {
|
||||
super(new File(((Plugin) Via.getPlatform()).getDataFolder(), "config.yml"));
|
||||
@ -47,6 +48,7 @@ public class BukkitViaConfig extends AbstractViaConfig {
|
||||
hitboxFix1_9 = getBoolean("change-1_9-hitbox", false);
|
||||
hitboxFix1_14 = getBoolean("change-1_14-hitbox", false);
|
||||
blockConnectionMethod = getString("blockconnection-method", "packet");
|
||||
armorToggleFix = getBoolean("armor-toggle-fix", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,6 +80,11 @@ public class BukkitViaConfig extends AbstractViaConfig {
|
||||
return blockConnectionMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArmorToggleFix() {
|
||||
return armorToggleFix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUnsupportedOptions() {
|
||||
return UNSUPPORTED;
|
||||
|
@ -28,6 +28,7 @@ import com.viaversion.viaversion.bukkit.listeners.JoinListener;
|
||||
import com.viaversion.viaversion.bukkit.listeners.UpdateListener;
|
||||
import com.viaversion.viaversion.bukkit.listeners.multiversion.PlayerSneakListener;
|
||||
import com.viaversion.viaversion.bukkit.listeners.protocol1_15to1_14_4.EntityToggleGlideListener;
|
||||
import com.viaversion.viaversion.bukkit.listeners.protocol1_19_4To1_19_3.ArmorToggleListener;
|
||||
import com.viaversion.viaversion.bukkit.listeners.protocol1_19to1_18_2.BlockBreakListener;
|
||||
import com.viaversion.viaversion.bukkit.listeners.protocol1_9to1_8.ArmorListener;
|
||||
import com.viaversion.viaversion.bukkit.listeners.protocol1_9to1_8.BlockListener;
|
||||
@ -142,6 +143,10 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
||||
}
|
||||
}
|
||||
|
||||
if (serverProtocolVersion < ProtocolVersion.v1_19_4.getVersion() && plugin.getConf().isArmorToggleFix()) {
|
||||
storeListener(new ArmorToggleListener(plugin)).register();
|
||||
}
|
||||
|
||||
/* Providers */
|
||||
if (serverProtocolVersion < ProtocolVersion.v1_9.getVersion()) {
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BukkitViaMovementTransmitter());
|
||||
|
@ -533,4 +533,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
||||
public @Nullable String chatTypeFormat(final String translationKey) {
|
||||
return chatTypeFormats.get(translationKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArmorToggleFix() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -172,6 +172,9 @@ chat-types-1_19:
|
||||
chat.type.team.text: "%s <%s> %s"
|
||||
chat.type.emote: "* %s %s"
|
||||
#
|
||||
# Force-update 1.19.4+ player's inventory when they try to swap armor in a pre-occupied slot.
|
||||
armor-toggle-fix: true
|
||||
#
|
||||
#----------------------------------------------------------#
|
||||
# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #
|
||||
#----------------------------------------------------------#
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren