Revert "Changed the fix for PacketPlayOutRecipeUpdateFix"
This reverts commit 876343fa
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
package com.willfp.eco.proxy.v1_15_R1;
|
package com.willfp.eco.proxy.v1_15_R1;
|
||||||
|
|
||||||
import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy;
|
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.IRecipe;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutRecipeUpdate;
|
import net.minecraft.server.v1_15_R1.PacketPlayOutRecipeUpdate;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -14,44 +14,33 @@ import java.util.List;
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy {
|
public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy {
|
||||||
@Override
|
@Override
|
||||||
public Object splitAndModifyPacket(@NotNull final Object object) {
|
public List<Object> splitPackets(@NotNull final Object object,
|
||||||
|
@NotNull final Player player) {
|
||||||
if (!(object instanceof PacketPlayOutRecipeUpdate)) {
|
if (!(object instanceof PacketPlayOutRecipeUpdate)) {
|
||||||
throw new IllegalArgumentException("Parameter not packet!");
|
throw new IllegalArgumentException("Parameter not packet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object;
|
PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object;
|
||||||
List<IRecipe<?>> recipes = new ArrayList<>();
|
List<IRecipe<?>> recipes = new ArrayList<>();
|
||||||
Field f = null;
|
|
||||||
try {
|
try {
|
||||||
f = oldPacket.getClass().getDeclaredField("a");
|
Field f = oldPacket.getClass().getDeclaredField("a");
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
recipes.addAll((Collection<? extends IRecipe<?>>) f.get(oldPacket));
|
recipes.addAll((Collection<? extends IRecipe<?>>) f.get(oldPacket));
|
||||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f == null) {
|
List<Object> splitPackets = new ArrayList<>();
|
||||||
return null;
|
List<IRecipe<?>> splitRecipes = new ArrayList<>();
|
||||||
}
|
for (int i = 0; i < recipes.size(); i++) {
|
||||||
|
splitRecipes.add(recipes.get(i));
|
||||||
List<IRecipe<?>> externRecipes = new ArrayList<>();
|
if (i % 100 == 0) {
|
||||||
for (IRecipe<?> recipe : new ArrayList<>(recipes)) {
|
PacketPlayOutRecipeUpdate newPacket = new PacketPlayOutRecipeUpdate(splitRecipes);
|
||||||
if (AbstractEcoPlugin.LOADED_ECO_PLUGINS.contains(recipe.getKey().getNamespace())) {
|
splitPackets.add(newPacket);
|
||||||
externRecipes.add(recipe);
|
splitRecipes.clear();
|
||||||
recipes.remove(recipe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recipes.isEmpty()) {
|
return splitPackets;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
f.set(object, recipes);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PacketPlayOutRecipeUpdate(externRecipes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.willfp.eco.proxy.v1_16_R1;
|
package com.willfp.eco.proxy.v1_16_R1;
|
||||||
|
|
||||||
import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy;
|
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.IRecipe;
|
||||||
import net.minecraft.server.v1_16_R1.PacketPlayOutRecipeUpdate;
|
import net.minecraft.server.v1_16_R1.PacketPlayOutRecipeUpdate;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -14,44 +14,33 @@ import java.util.List;
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy {
|
public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy {
|
||||||
@Override
|
@Override
|
||||||
public Object splitAndModifyPacket(@NotNull final Object object) {
|
public List<Object> splitPackets(@NotNull final Object object,
|
||||||
|
@NotNull final Player player) {
|
||||||
if (!(object instanceof PacketPlayOutRecipeUpdate)) {
|
if (!(object instanceof PacketPlayOutRecipeUpdate)) {
|
||||||
throw new IllegalArgumentException("Parameter not packet!");
|
throw new IllegalArgumentException("Parameter not packet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object;
|
PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object;
|
||||||
List<IRecipe<?>> recipes = new ArrayList<>();
|
List<IRecipe<?>> recipes = new ArrayList<>();
|
||||||
Field f = null;
|
|
||||||
try {
|
try {
|
||||||
f = oldPacket.getClass().getDeclaredField("a");
|
Field f = oldPacket.getClass().getDeclaredField("a");
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
recipes.addAll((Collection<? extends IRecipe<?>>) f.get(oldPacket));
|
recipes.addAll((Collection<? extends IRecipe<?>>) f.get(oldPacket));
|
||||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f == null) {
|
List<Object> splitPackets = new ArrayList<>();
|
||||||
return null;
|
List<IRecipe<?>> splitRecipes = new ArrayList<>();
|
||||||
}
|
for (int i = 0; i < recipes.size(); i++) {
|
||||||
|
splitRecipes.add(recipes.get(i));
|
||||||
List<IRecipe<?>> externRecipes = new ArrayList<>();
|
if (i % 100 == 0) {
|
||||||
for (IRecipe<?> recipe : new ArrayList<>(recipes)) {
|
PacketPlayOutRecipeUpdate newPacket = new PacketPlayOutRecipeUpdate(splitRecipes);
|
||||||
if (AbstractEcoPlugin.LOADED_ECO_PLUGINS.contains(recipe.getKey().getNamespace())) {
|
splitPackets.add(newPacket);
|
||||||
externRecipes.add(recipe);
|
splitRecipes.clear();
|
||||||
recipes.remove(recipe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recipes.isEmpty()) {
|
return splitPackets;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
f.set(object, recipes);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PacketPlayOutRecipeUpdate(externRecipes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.willfp.eco.proxy.v1_16_R2;
|
package com.willfp.eco.proxy.v1_16_R2;
|
||||||
|
|
||||||
import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy;
|
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.IRecipe;
|
||||||
import net.minecraft.server.v1_16_R2.PacketPlayOutRecipeUpdate;
|
import net.minecraft.server.v1_16_R2.PacketPlayOutRecipeUpdate;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -14,44 +14,33 @@ import java.util.List;
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy {
|
public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy {
|
||||||
@Override
|
@Override
|
||||||
public Object splitAndModifyPacket(@NotNull final Object object) {
|
public List<Object> splitPackets(@NotNull final Object object,
|
||||||
|
@NotNull final Player player) {
|
||||||
if (!(object instanceof PacketPlayOutRecipeUpdate)) {
|
if (!(object instanceof PacketPlayOutRecipeUpdate)) {
|
||||||
throw new IllegalArgumentException("Parameter not packet!");
|
throw new IllegalArgumentException("Parameter not packet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object;
|
PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object;
|
||||||
List<IRecipe<?>> recipes = new ArrayList<>();
|
List<IRecipe<?>> recipes = new ArrayList<>();
|
||||||
Field f = null;
|
|
||||||
try {
|
try {
|
||||||
f = oldPacket.getClass().getDeclaredField("a");
|
Field f = oldPacket.getClass().getDeclaredField("a");
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
recipes.addAll((Collection<? extends IRecipe<?>>) f.get(oldPacket));
|
recipes.addAll((Collection<? extends IRecipe<?>>) f.get(oldPacket));
|
||||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f == null) {
|
List<Object> splitPackets = new ArrayList<>();
|
||||||
return null;
|
List<IRecipe<?>> splitRecipes = new ArrayList<>();
|
||||||
}
|
for (int i = 0; i < recipes.size(); i++) {
|
||||||
|
splitRecipes.add(recipes.get(i));
|
||||||
List<IRecipe<?>> externRecipes = new ArrayList<>();
|
if (i % 100 == 0) {
|
||||||
for (IRecipe<?> recipe : new ArrayList<>(recipes)) {
|
PacketPlayOutRecipeUpdate newPacket = new PacketPlayOutRecipeUpdate(splitRecipes);
|
||||||
if (AbstractEcoPlugin.LOADED_ECO_PLUGINS.contains(recipe.getKey().getNamespace())) {
|
splitPackets.add(newPacket);
|
||||||
externRecipes.add(recipe);
|
splitRecipes.clear();
|
||||||
recipes.remove(recipe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recipes.isEmpty()) {
|
return splitPackets;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
f.set(object, recipes);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PacketPlayOutRecipeUpdate(externRecipes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.willfp.eco.proxy.v1_16_R3;
|
package com.willfp.eco.proxy.v1_16_R3;
|
||||||
|
|
||||||
import com.willfp.eco.proxy.proxies.PacketPlayOutRecipeUpdateFixProxy;
|
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.IRecipe;
|
||||||
import net.minecraft.server.v1_16_R3.PacketPlayOutRecipeUpdate;
|
import net.minecraft.server.v1_16_R3.PacketPlayOutRecipeUpdate;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -14,44 +14,33 @@ import java.util.List;
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy {
|
public final class PacketPlayOutRecipeUpdateFix implements PacketPlayOutRecipeUpdateFixProxy {
|
||||||
@Override
|
@Override
|
||||||
public Object splitAndModifyPacket(@NotNull final Object object) {
|
public List<Object> splitPackets(@NotNull final Object object,
|
||||||
|
@NotNull final Player player) {
|
||||||
if (!(object instanceof PacketPlayOutRecipeUpdate)) {
|
if (!(object instanceof PacketPlayOutRecipeUpdate)) {
|
||||||
throw new IllegalArgumentException("Parameter not packet!");
|
throw new IllegalArgumentException("Parameter not packet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object;
|
PacketPlayOutRecipeUpdate oldPacket = (PacketPlayOutRecipeUpdate) object;
|
||||||
List<IRecipe<?>> recipes = new ArrayList<>();
|
List<IRecipe<?>> recipes = new ArrayList<>();
|
||||||
Field f = null;
|
|
||||||
try {
|
try {
|
||||||
f = oldPacket.getClass().getDeclaredField("a");
|
Field f = oldPacket.getClass().getDeclaredField("a");
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
recipes.addAll((Collection<? extends IRecipe<?>>) f.get(oldPacket));
|
recipes.addAll((Collection<? extends IRecipe<?>>) f.get(oldPacket));
|
||||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f == null) {
|
List<Object> splitPackets = new ArrayList<>();
|
||||||
return null;
|
List<IRecipe<?>> splitRecipes = new ArrayList<>();
|
||||||
}
|
for (int i = 0; i < recipes.size(); i++) {
|
||||||
|
splitRecipes.add(recipes.get(i));
|
||||||
List<IRecipe<?>> externRecipes = new ArrayList<>();
|
if (i % 100 == 0) {
|
||||||
for (IRecipe<?> recipe : new ArrayList<>(recipes)) {
|
PacketPlayOutRecipeUpdate newPacket = new PacketPlayOutRecipeUpdate(splitRecipes);
|
||||||
if (AbstractEcoPlugin.LOADED_ECO_PLUGINS.contains(recipe.getKey().getNamespace())) {
|
splitPackets.add(newPacket);
|
||||||
externRecipes.add(recipe);
|
splitRecipes.clear();
|
||||||
recipes.remove(recipe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recipes.isEmpty()) {
|
return splitPackets;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
f.set(object, recipes);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PacketPlayOutRecipeUpdate(externRecipes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PacketPlayOutRecipeUpdateFix extends PacketAdapter {
|
public class PacketPlayOutRecipeUpdateFix extends PacketAdapter {
|
||||||
/**
|
/**
|
||||||
@@ -27,10 +28,11 @@ public class PacketPlayOutRecipeUpdateFix extends PacketAdapter {
|
|||||||
PacketContainer packet = event.getPacket();
|
PacketContainer packet = event.getPacket();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
Object otherPacket = InternalProxyUtils.getProxy(PacketPlayOutRecipeUpdateFixProxy.class).splitAndModifyPacket(packet.getHandle());
|
List<Object> packets = InternalProxyUtils.getProxy(PacketPlayOutRecipeUpdateFixProxy.class).splitPackets(packet.getHandle(), player);
|
||||||
if (otherPacket != null) {
|
if (packets.size() > 1) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
PacketContainer container = PacketContainer.fromPacket(otherPacket);
|
for (Object o : packets) {
|
||||||
|
PacketContainer container = PacketContainer.fromPacket(o);
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, container);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, container);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
@@ -38,4 +40,5 @@ public class PacketPlayOutRecipeUpdateFix extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,19 @@ package com.willfp.eco.proxy.proxies;
|
|||||||
|
|
||||||
|
|
||||||
import com.willfp.eco.util.proxy.AbstractProxy;
|
import com.willfp.eco.util.proxy.AbstractProxy;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface PacketPlayOutRecipeUpdateFixProxy extends AbstractProxy {
|
public interface PacketPlayOutRecipeUpdateFixProxy extends AbstractProxy {
|
||||||
/**
|
/**
|
||||||
* Split recipe update packet into smaller packets.
|
* Split recipe update packet into smaller packets.
|
||||||
*
|
*
|
||||||
* @param object The packet.
|
* @param object The packet.
|
||||||
* @return The extra packet for eco recipes.
|
* @param player The player.
|
||||||
|
* @return The packets, split up.
|
||||||
*/
|
*/
|
||||||
Object splitAndModifyPacket(@NotNull Object object);
|
List<Object> splitPackets(@NotNull Object object,
|
||||||
|
@NotNull Player player);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user