diff --git a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/PacketPlayOutRecipeUpdateFix.java b/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/PacketPlayOutRecipeUpdateFix.java deleted file mode 100644 index 68fa30ad..00000000 --- a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/PacketPlayOutRecipeUpdateFix.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.willfp.eco.proxy.v1_15_R1; - -import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy; -import com.willfp.eco.util.plugin.AbstractEcoPlugin; -import net.minecraft.server.v1_15_R1.IRecipe; -import net.minecraft.server.v1_15_R1.PacketPlayOutRecipeUpdate; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -@SuppressWarnings("unchecked") -public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy { - @Override - public Object splitAndModifyPacket(@NotNull final Object object) { - if (!(object instanceof PacketPlayOutRecipeUpdate)) { - throw new IllegalArgumentException("Parameter not packet!"); - } - - PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object; - List> recipes = new ArrayList<>(); - Field f = null; - try { - f = oldPacket.getClass().getDeclaredField("a"); - f.setAccessible(true); - recipes.addAll((Collection>) f.get(oldPacket)); - } catch (IllegalAccessException | NoSuchFieldException e) { - e.printStackTrace(); - } - - if (f == null) { - return null; - } - - List> externRecipes = new ArrayList<>(); - for (IRecipe recipe : new ArrayList<>(recipes)) { - if (AbstractEcoPlugin.LOADED_ECO_PLUGINS.contains(recipe.getKey().getNamespace())) { - externRecipes.add(recipe); - recipes.remove(recipe); - } - } - - if (recipes.isEmpty()) { - return null; - } - - try { - f.set(object, recipes); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - return new PacketPlayOutRecipeUpdate(externRecipes); - } -} diff --git a/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/eco/proxy/v1_16_R1/PacketPlayOutRecipeUpdateFix.java b/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/eco/proxy/v1_16_R1/PacketPlayOutRecipeUpdateFix.java deleted file mode 100644 index ae1d8084..00000000 --- a/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/eco/proxy/v1_16_R1/PacketPlayOutRecipeUpdateFix.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.willfp.eco.proxy.v1_16_R1; - -import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy; -import com.willfp.eco.util.plugin.AbstractEcoPlugin; -import net.minecraft.server.v1_16_R1.IRecipe; -import net.minecraft.server.v1_16_R1.PacketPlayOutRecipeUpdate; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -@SuppressWarnings("unchecked") -public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy { - @Override - public Object splitAndModifyPacket(@NotNull final Object object) { - if (!(object instanceof PacketPlayOutRecipeUpdate)) { - throw new IllegalArgumentException("Parameter not packet!"); - } - - PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object; - List> recipes = new ArrayList<>(); - Field f = null; - try { - f = oldPacket.getClass().getDeclaredField("a"); - f.setAccessible(true); - recipes.addAll((Collection>) f.get(oldPacket)); - } catch (IllegalAccessException | NoSuchFieldException e) { - e.printStackTrace(); - } - - if (f == null) { - return null; - } - - List> externRecipes = new ArrayList<>(); - for (IRecipe recipe : new ArrayList<>(recipes)) { - if (AbstractEcoPlugin.LOADED_ECO_PLUGINS.contains(recipe.getKey().getNamespace())) { - externRecipes.add(recipe); - recipes.remove(recipe); - } - } - - if (recipes.isEmpty()) { - return null; - } - - try { - f.set(object, recipes); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - return new PacketPlayOutRecipeUpdate(externRecipes); - } -} diff --git a/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/eco/proxy/v1_16_R2/PacketPlayOutRecipeUpdateFix.java b/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/eco/proxy/v1_16_R2/PacketPlayOutRecipeUpdateFix.java deleted file mode 100644 index 2fb3139f..00000000 --- a/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/eco/proxy/v1_16_R2/PacketPlayOutRecipeUpdateFix.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.willfp.eco.proxy.v1_16_R2; - -import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy; -import com.willfp.eco.util.plugin.AbstractEcoPlugin; -import net.minecraft.server.v1_16_R2.IRecipe; -import net.minecraft.server.v1_16_R2.PacketPlayOutRecipeUpdate; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -@SuppressWarnings("unchecked") -public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy { - @Override - public Object splitAndModifyPacket(@NotNull final Object object) { - if (!(object instanceof PacketPlayOutRecipeUpdate)) { - throw new IllegalArgumentException("Parameter not packet!"); - } - - PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object; - List> recipes = new ArrayList<>(); - Field f = null; - try { - f = oldPacket.getClass().getDeclaredField("a"); - f.setAccessible(true); - recipes.addAll((Collection>) f.get(oldPacket)); - } catch (IllegalAccessException | NoSuchFieldException e) { - e.printStackTrace(); - } - - if (f == null) { - return null; - } - - List> externRecipes = new ArrayList<>(); - for (IRecipe recipe : new ArrayList<>(recipes)) { - if (AbstractEcoPlugin.LOADED_ECO_PLUGINS.contains(recipe.getKey().getNamespace())) { - externRecipes.add(recipe); - recipes.remove(recipe); - } - } - - if (recipes.isEmpty()) { - return null; - } - - try { - f.set(object, recipes); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - return new PacketPlayOutRecipeUpdate(externRecipes); - } -} diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/PacketPlayOutRecipeUpdateFix.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/PacketPlayOutRecipeUpdateFix.java deleted file mode 100644 index f77a65c9..00000000 --- a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/PacketPlayOutRecipeUpdateFix.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.willfp.eco.proxy.v1_16_R3; - -import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy; -import com.willfp.eco.util.plugin.AbstractEcoPlugin; -import net.minecraft.server.v1_16_R3.IRecipe; -import net.minecraft.server.v1_16_R3.PacketPlayOutRecipeUpdate; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -@SuppressWarnings("unchecked") -public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy { - @Override - public Object splitAndModifyPacket(@NotNull final Object object) { - if (!(object instanceof PacketPlayOutRecipeUpdate)) { - throw new IllegalArgumentException("Parameter not packet!"); - } - - PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object; - List> recipes = new ArrayList<>(); - Field f = null; - try { - f = oldPacket.getClass().getDeclaredField("a"); - f.setAccessible(true); - recipes.addAll((Collection>) f.get(oldPacket)); - } catch (IllegalAccessException | NoSuchFieldException e) { - e.printStackTrace(); - } - - if (f == null) { - return null; - } - - List> externRecipes = new ArrayList<>(); - for (IRecipe recipe : new ArrayList<>(recipes)) { - if (AbstractEcoPlugin.LOADED_ECO_PLUGINS.contains(recipe.getKey().getNamespace())) { - externRecipes.add(recipe); - recipes.remove(recipe); - } - } - - if (recipes.isEmpty()) { - return null; - } - - try { - f.set(object, recipes); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - return new PacketPlayOutRecipeUpdate(externRecipes); - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoPlugin.java index 87464ce3..5f715740 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoPlugin.java @@ -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; @@ -56,7 +55,7 @@ public class EcoPlugin extends AbstractEcoPlugin { this.getEventManager().registerListener(new ArmorListener()); this.getEventManager().registerListener(new DispenserArmorListener()); this.getEventManager().registerListener(new EntityDeathByEntityListeners(this)); - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketPlayOutRecipeUpdateFix(this)); + //ProtocolLibrary.getProtocolManager().addPacketListener(new PacketPlayOutRecipeUpdateFix(this)); } @Override diff --git a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/PacketPlayOutRecipeUpdateFix.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/PacketPlayOutRecipeUpdateFix.java deleted file mode 100644 index 4f5aa0fb..00000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/PacketPlayOutRecipeUpdateFix.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.willfp.eco.spigot; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy; -import com.willfp.eco.util.plugin.AbstractEcoPlugin; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.InvocationTargetException; - -public class PacketPlayOutRecipeUpdateFix extends PacketAdapter { - /** - * Create new fixer for PacketPlayOutRecipeUpdate. - * - * @param plugin Plugin. - */ - public PacketPlayOutRecipeUpdateFix(@NotNull final AbstractEcoPlugin plugin) { - super(plugin, PacketType.Play.Server.RECIPE_UPDATE); - } - - @Override - public void onPacketSending(@NotNull final PacketEvent event) { - PacketContainer packet = event.getPacket(); - Player player = event.getPlayer(); - - Object otherPacket = InternalProxyUtils.getProxy(PacketPlayOutRecipeUpdateFixProxy.class).splitAndModifyPacket(packet.getHandle()); - if (otherPacket != null) { - event.setCancelled(true); - PacketContainer container = PacketContainer.fromPacket(otherPacket); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(player, container); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - } -} diff --git a/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/PacketPlayOutRecipeUpdateFixProxy.java b/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/PacketPlayOutRecipeUpdateFixProxy.java deleted file mode 100644 index 8f844f00..00000000 --- a/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/PacketPlayOutRecipeUpdateFixProxy.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.willfp.eco.proxy.proxies; - - -import com.willfp.eco.util.proxy.AbstractProxy; -import org.jetbrains.annotations.NotNull; - -public interface PacketPlayOutRecipeUpdateFixProxy extends AbstractProxy { - /** - * Split recipe update packet into smaller packets. - * - * @param object The packet. - * @return The extra packet for eco recipes. - */ - Object splitAndModifyPacket(@NotNull Object object); -}