Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
c9dd6e2ba7
@ -158,7 +158,7 @@ public class WirePacket {
|
|||||||
* bytes from that packet
|
* bytes from that packet
|
||||||
*
|
*
|
||||||
* @param packet Existing packet
|
* @param packet Existing packet
|
||||||
* @return The ByteBuf
|
* @return the byte array
|
||||||
*/
|
*/
|
||||||
public static byte[] bytesFromPacket(PacketContainer packet) {
|
public static byte[] bytesFromPacket(PacketContainer packet) {
|
||||||
checkNotNull(packet, "packet cannot be null!");
|
checkNotNull(packet, "packet cannot be null!");
|
||||||
@ -177,6 +177,8 @@ public class WirePacket {
|
|||||||
|
|
||||||
byte[] bytes = getBytes(buffer);
|
byte[] bytes = getBytes(buffer);
|
||||||
|
|
||||||
|
buffer.release();
|
||||||
|
|
||||||
// Rewrite them to the packet to avoid issues with certain packets
|
// Rewrite them to the packet to avoid issues with certain packets
|
||||||
if (packet.getType() == PacketType.Play.Server.CUSTOM_PAYLOAD
|
if (packet.getType() == PacketType.Play.Server.CUSTOM_PAYLOAD
|
||||||
|| packet.getType() == PacketType.Play.Client.CUSTOM_PAYLOAD) {
|
|| packet.getType() == PacketType.Play.Client.CUSTOM_PAYLOAD) {
|
||||||
@ -195,6 +197,8 @@ public class WirePacket {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store.release();
|
||||||
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +224,11 @@ public class WirePacket {
|
|||||||
throw new RuntimeException("Failed to serialize packet contents.", ex);
|
throw new RuntimeException("Failed to serialize packet contents.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WirePacket(id, getBytes(buffer));
|
byte[] bytes = getBytes(buffer);
|
||||||
|
|
||||||
|
buffer.release();
|
||||||
|
|
||||||
|
return new WirePacket(id, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeVarInt(ByteBuf output, int i) {
|
public static void writeVarInt(ByteBuf output, int i) {
|
||||||
|
@ -1852,7 +1852,7 @@ public class MinecraftReflection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---- ItemStack conversions
|
// ---- ItemStack conversions
|
||||||
|
private static Object itemStackAir = null;
|
||||||
private static Method asNMSCopy = null;
|
private static Method asNMSCopy = null;
|
||||||
private static Method asCraftMirror = null;
|
private static Method asCraftMirror = null;
|
||||||
|
|
||||||
@ -1943,7 +1943,16 @@ public class MinecraftReflection {
|
|||||||
|
|
||||||
if (is(getCraftItemStackClass(), specific)) {
|
if (is(getCraftItemStackClass(), specific)) {
|
||||||
// If it's already a CraftItemStack, use its handle
|
// If it's already a CraftItemStack, use its handle
|
||||||
return new BukkitUnwrapper().unwrapItem(specific);
|
Object unwrapped = new BukkitUnwrapper().unwrapItem(specific);
|
||||||
|
if (unwrapped != null) {
|
||||||
|
return unwrapped;
|
||||||
|
} else {
|
||||||
|
if (itemStackAir == null) {
|
||||||
|
// Easiest way to get the Material.AIR ItemStack?
|
||||||
|
itemStackAir = getMinecraftItemStack(new ItemStack(Material.AIR));
|
||||||
|
}
|
||||||
|
return itemStackAir;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.comphenix.protocol.utility;
|
package com.comphenix.protocol.utility;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@ -20,6 +21,7 @@ import net.minecraft.server.v1_12_R1.ServerPing.ServerPingPlayerSample;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
@ -137,6 +139,9 @@ public class MinecraftReflectionTest {
|
|||||||
ItemStack stack = new ItemStack(Material.GOLD_SWORD);
|
ItemStack stack = new ItemStack(Material.GOLD_SWORD);
|
||||||
Object nmsStack = MinecraftReflection.getMinecraftItemStack(stack);
|
Object nmsStack = MinecraftReflection.getMinecraftItemStack(stack);
|
||||||
assertEquals(stack, MinecraftReflection.getBukkitItemStack(nmsStack));
|
assertEquals(stack, MinecraftReflection.getBukkitItemStack(nmsStack));
|
||||||
|
|
||||||
|
// The NMS handle for CraftItemStack is null with Material.AIR, make sure it is handled correctly
|
||||||
|
assertNotNull(MinecraftReflection.getMinecraftItemStack(CraftItemStack.asCraftCopy(new ItemStack(Material.AIR))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren