Changed the fix for PacketPlayOutRecipeUpdateFix

This commit is contained in:
Auxilor
2021-01-21 08:38:28 +00:00
parent f0cd9ae16d
commit 876343facb
7 changed files with 106 additions and 71 deletions

View File

@@ -1,6 +1,5 @@
package com.willfp.eco.spigot;
import com.comphenix.protocol.ProtocolLibrary;
import com.willfp.eco.spigot.display.packets.PacketAutoRecipe;
import com.willfp.eco.spigot.display.packets.PacketChat;
import com.willfp.eco.spigot.display.packets.PacketOpenWindowMerchant;
@@ -58,7 +57,7 @@ public class EcoPlugin extends AbstractEcoPlugin {
this.getEventManager().registerListener(new DispenserArmorListener());
this.getEventManager().registerListener(new EntityDeathByEntityListeners(this));
this.getEventManager().registerListener(new RecipeListener(this));
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketPlayOutRecipeUpdateFix(this));
//ProtocolLibrary.getProtocolManager().addPacketListener(new PacketPlayOutRecipeUpdateFix(this));
}
@Override

View File

@@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class PacketPlayOutRecipeUpdateFix extends PacketAdapter {
/**
@@ -28,16 +27,14 @@ public class PacketPlayOutRecipeUpdateFix extends PacketAdapter {
PacketContainer packet = event.getPacket();
Player player = event.getPlayer();
List<Object> packets = InternalProxyUtils.getProxy(PacketPlayOutRecipeUpdateFixProxy.class).splitPackets(packet.getHandle(), player);
if (packets.size() > 1) {
Object otherPacket = InternalProxyUtils.getProxy(PacketPlayOutRecipeUpdateFixProxy.class).splitAndModifyPacket(packet.getHandle());
if (otherPacket != null) {
event.setCancelled(true);
for (Object o : packets) {
PacketContainer container = PacketContainer.fromPacket(o);
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, container);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
PacketContainer container = PacketContainer.fromPacket(otherPacket);
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, container);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}