Fixed a VERY long standing bug discovered by libraryaddict.
Constructing a WrappedWatchableObject with a net.minecraft.server.ItemStack would cause ProtocolLib to throw an IllegalArgumentException, even though WrappedWatchableObject. setValue(Object) accepts ItemStacks without trouble. This is because WrappedWatchableObject.getUnwrappedType() didn't handle ItemStacks at all.
Dieser Commit ist enthalten in:
Ursprung
385bae8bda
Commit
5d7895d741
@ -346,6 +346,8 @@ public class WrappedWatchableObject extends AbstractWrapper {
|
|||||||
return MinecraftReflection.getChunkPositionClass();
|
return MinecraftReflection.getChunkPositionClass();
|
||||||
else if (wrapped.equals(WrappedChunkCoordinate.class))
|
else if (wrapped.equals(WrappedChunkCoordinate.class))
|
||||||
return MinecraftReflection.getChunkCoordinatesClass();
|
return MinecraftReflection.getChunkCoordinatesClass();
|
||||||
|
else if (ItemStack.class.isAssignableFrom(wrapped))
|
||||||
|
return MinecraftReflection.getItemStackClass();
|
||||||
else
|
else
|
||||||
return wrapped;
|
return wrapped;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemFactory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
|
|
||||||
|
@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
|
||||||
|
@PrepareForTest(CraftItemFactory.class)
|
||||||
|
public class WrappedWatchableObjectTest {
|
||||||
|
@BeforeClass
|
||||||
|
public static void initializeBukkit() throws IllegalAccessException {
|
||||||
|
BukkitInitialization.initializeItemMeta();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testItemStack() {
|
||||||
|
final ItemStack stack = new ItemStack(Material.GOLD_AXE);
|
||||||
|
final WrappedWatchableObject test = new WrappedWatchableObject(0, stack);
|
||||||
|
|
||||||
|
ItemStack value = (ItemStack) test.getValue();
|
||||||
|
assertEquals(value.getType(), stack.getType());
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren