diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 541c92cc..8dd8a96d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '16' + java-version: '17' - name: Run maven build lifecycle run: mvn --batch-mode clean test package diff --git a/jitpack.yml b/jitpack.yml index 376245fb..f5195ef9 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,5 +1,5 @@ before_install: - source "$HOME/.sdkman/bin/sdkman-init.sh" - sdk update - - sdk install java 16.0.1.hs-adpt - - sdk use java 16.0.1.hs-adpt + - sdk install java 17.0.1-tem + - sdk use java 17.0.1-tem diff --git a/pom.xml b/pom.xml index a9a79389..ae8cff1d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.comphenix.protocol ProtocolLib ProtocolLib - 4.7.1-SNAPSHOT + 4.7.2-SNAPSHOT Provides read/write access to the Minecraft protocol. https://github.com/dmulloy2/ProtocolLib @@ -16,8 +16,8 @@ ${project.version} - 2.0.7 - 1.17.1-R0.1-SNAPSHOT + 2.0.9 + 1.18-R0.1-SNAPSHOT @@ -110,13 +110,13 @@ - --illegal-access=permit + --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED maven-javadoc-plugin - 3.2.0 + 3.3.1 false ISO-8859-1 @@ -284,6 +284,19 @@ 4.0.23.Final provided + + + io.netty + netty-common + 4.1.70.Final + test + + + io.netty + netty-transport + 4.1.70.Final + test + org.spigotmc spigot-api @@ -299,27 +312,27 @@ net.kyori adventure-text-serializer-gson - 4.5.1 + 4.9.3 provided net.bytebuddy byte-buddy - 1.11.0 + 1.12.1 junit junit - 4.13.1 + 4.13.2 test org.mockito mockito-core - 3.5.10 + 3.12.4 test diff --git a/src/main/java/com/comphenix/protocol/PacketLogging.java b/src/main/java/com/comphenix/protocol/PacketLogging.java index 1958616f..a7d0c363 100644 --- a/src/main/java/com/comphenix/protocol/PacketLogging.java +++ b/src/main/java/com/comphenix/protocol/PacketLogging.java @@ -19,6 +19,7 @@ package com.comphenix.protocol; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.io.OutputStream; import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -31,13 +32,16 @@ import com.comphenix.protocol.events.ListeningWhitelist; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketListener; import com.comphenix.protocol.injector.netty.WirePacket; +import com.comphenix.protocol.reflect.FuzzyReflection; +import com.comphenix.protocol.reflect.accessors.Accessors; +import com.comphenix.protocol.reflect.accessors.MethodAccessor; +import com.comphenix.protocol.utility.MinecraftReflection; import com.google.common.base.Charsets; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.libs.org.apache.commons.io.HexDump; import org.bukkit.plugin.Plugin; /** @@ -47,6 +51,8 @@ import org.bukkit.plugin.Plugin; public class PacketLogging implements CommandExecutor, PacketListener { public static final String NAME = "packetlog"; + private static MethodAccessor HEX_DUMP; + private List sendingTypes = new ArrayList<>(); private List receivingTypes = new ArrayList<>(); @@ -199,7 +205,13 @@ public class PacketLogging implements CommandExecutor, PacketListener { private static String hexDump(byte[] bytes) throws IOException { try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { - HexDump.dump(bytes, 0, output, 0); + if (HEX_DUMP == null) { + Class hexDumpClass = MinecraftReflection.getLibraryClass("org.apache.commons.io.HexDump"); + HEX_DUMP = Accessors.getMethodAccessor(FuzzyReflection.fromClass(hexDumpClass) + .getMethodByParameters("dump", byte[].class, long.class, OutputStream.class, int.class)); + } + + HEX_DUMP.invoke(null, bytes, 0, output, 0); return new String(output.toByteArray(), Charsets.UTF_8); } } diff --git a/src/main/java/com/comphenix/protocol/PacketType.java b/src/main/java/com/comphenix/protocol/PacketType.java index f5ea08a6..9d822481 100644 --- a/src/main/java/com/comphenix/protocol/PacketType.java +++ b/src/main/java/com/comphenix/protocol/PacketType.java @@ -137,7 +137,7 @@ public class PacketType implements Serializable, Cloneable, Comparable unsafeClass = Class.forName("sun.misc.Unsafe"); + // get the unsafe instance + Field theUnsafe = unsafeClass.getDeclaredField("theUnsafe"); + theUnsafe.setAccessible(true); + sun.misc.Unsafe unsafe = (sun.misc.Unsafe) theUnsafe.get(null); + // get the trusted lookup field + Field trustedLookup = Lookup.class.getDeclaredField("IMPL_LOOKUP"); + // get access to the base and offset value of it + long offset = unsafe.staticFieldOffset(trustedLookup); + Object baseValue = unsafe.staticFieldBase(trustedLookup); + // get the trusted lookup instance + trusted = (Lookup) unsafe.getObject(baseValue, offset); + } catch (Exception exception) { + ProtocolLogger.log(Level.SEVERE, "Unable to retrieve trusted lookup", exception); + } + + TRUSTED_LOOKUP = trusted; + } + + public static boolean hasTrustedLookup() { + return TRUSTED_LOOKUP != null; + } + + public static MethodHandle findSetter(Field field) throws ReflectiveOperationException { + if (Modifier.isStatic(field.getModifiers())) { + return TRUSTED_LOOKUP.findStaticSetter(field.getDeclaringClass(), field.getName(), field.getType()); + } else { + return TRUSTED_LOOKUP.findSetter(field.getDeclaringClass(), field.getName(), field.getType()); + } + } +} diff --git a/src/main/java/com/comphenix/protocol/utility/Constants.java b/src/main/java/com/comphenix/protocol/utility/Constants.java index 78772048..96f9985d 100644 --- a/src/main/java/com/comphenix/protocol/utility/Constants.java +++ b/src/main/java/com/comphenix/protocol/utility/Constants.java @@ -21,10 +21,10 @@ package com.comphenix.protocol.utility; */ public final class Constants { - public static final String PACKAGE_VERSION = "v1_17_R1"; + public static final String PACKAGE_VERSION = "v1_18_R1"; public static final String NMS = "net.minecraft"; public static final String OBC = "org.bukkit.craftbukkit." + PACKAGE_VERSION; - public static final MinecraftVersion CURRENT_VERSION = MinecraftVersion.CAVES_CLIFFS_1; + public static final MinecraftVersion CURRENT_VERSION = MinecraftVersion.CAVES_CLIFFS_2; public static void init() { MinecraftReflection.setMinecraftPackage(NMS, OBC); diff --git a/src/main/java/com/comphenix/protocol/utility/MinecraftProtocolVersion.java b/src/main/java/com/comphenix/protocol/utility/MinecraftProtocolVersion.java index 88575d5e..9d3730c1 100644 --- a/src/main/java/com/comphenix/protocol/utility/MinecraftProtocolVersion.java +++ b/src/main/java/com/comphenix/protocol/utility/MinecraftProtocolVersion.java @@ -76,6 +76,8 @@ public class MinecraftProtocolVersion { map.put(new MinecraftVersion(1, 17, 0), 755); map.put(new MinecraftVersion(1, 17, 1), 756); + + map.put(new MinecraftVersion(1, 18, 0), 757); return map; } diff --git a/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java b/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java index 94c92bf2..861c7a80 100644 --- a/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java +++ b/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java @@ -2267,13 +2267,7 @@ public class MinecraftReflection { } public static Class getFastUtilClass(String className) { - try { - return getMinecraftLibraryClass("it.unimi.dsi.fastutil." + className); - } catch (RuntimeException ex) { - Class clazz = getMinecraftLibraryClass("org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil." + className); - setMinecraftLibraryClass("it.unimi.dsi.fastutil." + className, clazz); - return clazz; - } + return getLibraryClass("it.unimi.dsi.fastutil." + className); } public static Class getInt2ObjectMapClass() { @@ -2283,4 +2277,14 @@ public class MinecraftReflection { public static Class getIntArrayListClass() { return getFastUtilClass("ints.IntArrayList"); } + + public static Class getLibraryClass(String classname) { + try { + return getMinecraftLibraryClass(classname); + } catch (RuntimeException ex) { + Class clazz = getMinecraftLibraryClass("org.bukkit.craftbukkit.libs." + classname); + setMinecraftLibraryClass(classname, clazz); + return clazz; + } + } } diff --git a/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java b/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java index cb48d36e..308d6e03 100644 --- a/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java +++ b/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java @@ -44,6 +44,11 @@ public class MinecraftVersion implements Comparable, Serializa */ private static final Pattern VERSION_PATTERN = Pattern.compile(".*\\(.*MC.\\s*([a-zA-z0-9\\-.]+).*"); + /** + * Version 1.18 - caves and cliffs part 2 + */ + public static final MinecraftVersion CAVES_CLIFFS_2 = new MinecraftVersion("1.18"); + /** * Version 1.17 - caves and cliffs part 1 */ diff --git a/src/main/java/com/comphenix/protocol/utility/ZeroBuffer.java b/src/main/java/com/comphenix/protocol/utility/ZeroBuffer.java index 99e0e398..a813cba0 100644 --- a/src/main/java/com/comphenix/protocol/utility/ZeroBuffer.java +++ b/src/main/java/com/comphenix/protocol/utility/ZeroBuffer.java @@ -738,4 +738,4 @@ public class ZeroBuffer extends ByteBuf { public ByteBuf retain() { return null; } -} +} \ No newline at end of file diff --git a/src/main/java/com/comphenix/protocol/wrappers/WrappedDataWatcher.java b/src/main/java/com/comphenix/protocol/wrappers/WrappedDataWatcher.java index b9217918..0a5b0b3b 100644 --- a/src/main/java/com/comphenix/protocol/wrappers/WrappedDataWatcher.java +++ b/src/main/java/com/comphenix/protocol/wrappers/WrappedDataWatcher.java @@ -495,7 +495,7 @@ public class WrappedDataWatcher extends AbstractWrapper implements Iterable methods = fuzzy.getMethodList(contract); for (Method method : methods) { - if (method.getName().equals("set") || method.getName().equals("watch")) { + if (method.getName().equals("set") || method.getName().equals("watch") || method.getName().equals("b")) { SETTER = Accessors.getMethodAccessor(method); } else { REGISTER = Accessors.getMethodAccessor(method); diff --git a/src/main/java/com/comphenix/protocol/wrappers/WrappedRegistry.java b/src/main/java/com/comphenix/protocol/wrappers/WrappedRegistry.java index 4b129761..b5b5276b 100644 --- a/src/main/java/com/comphenix/protocol/wrappers/WrappedRegistry.java +++ b/src/main/java/com/comphenix/protocol/wrappers/WrappedRegistry.java @@ -5,10 +5,10 @@ import com.comphenix.protocol.reflect.accessors.Accessors; import com.comphenix.protocol.reflect.accessors.MethodAccessor; import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract; import com.comphenix.protocol.utility.MinecraftReflection; -import com.comphenix.protocol.utility.MinecraftVersion; import com.google.common.collect.ImmutableMap; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.HashMap; @@ -46,9 +46,14 @@ public class WrappedRegistry { REGISTRY = ImmutableMap.copyOf(regMap); - GET = Accessors.getMethodAccessor(regClass, "get", MinecraftReflection.getMinecraftKeyClass()); - FuzzyReflection fuzzy = FuzzyReflection.fromClass(regClass, false); + GET = Accessors.getMethodAccessor(fuzzy.getMethod(FuzzyMethodContract + .newBuilder() + .parameterCount(1) + .returnDerivedOf(Object.class) + .requireModifier(Modifier.ABSTRACT) + .parameterExactType(MinecraftReflection.getMinecraftKeyClass()) + .build())); GET_KEY = Accessors.getMethodAccessor(fuzzy.getMethod(FuzzyMethodContract .newBuilder() .parameterCount(1) diff --git a/src/test/java/com/comphenix/integration/protocol/SimpleCraftBukkitITCase.java b/src/test/java/com/comphenix/integration/protocol/SimpleCraftBukkitITCase.java index 39b95a14..d7ab0f83 100644 --- a/src/test/java/com/comphenix/integration/protocol/SimpleCraftBukkitITCase.java +++ b/src/test/java/com/comphenix/integration/protocol/SimpleCraftBukkitITCase.java @@ -33,7 +33,7 @@ import com.google.common.io.Files; // TODO Migrate this to Gradle if necessary // Damn final classes ... @RunWith(org.powermock.modules.junit4.PowerMockRunner.class) -@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" }) +@PowerMockIgnore({ "org.apache.logging.log4j.core.config.xml.*", "javax.management.*" }) @PrepareForTest(PluginDescriptionFile.class) public class SimpleCraftBukkitITCase { // The fake plugin diff --git a/src/test/java/com/comphenix/protocol/BukkitInitialization.java b/src/test/java/com/comphenix/protocol/BukkitInitialization.java index 0fa575a8..9a25e1df 100644 --- a/src/test/java/com/comphenix/protocol/BukkitInitialization.java +++ b/src/test/java/com/comphenix/protocol/BukkitInitialization.java @@ -5,7 +5,6 @@ import java.util.List; import com.comphenix.protocol.reflect.FieldUtils; import com.comphenix.protocol.utility.Constants; -import com.mojang.bridge.game.GameVersion; import net.minecraft.SharedConstants; import net.minecraft.core.IRegistry; @@ -16,10 +15,10 @@ import org.apache.logging.log4j.LogManager; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemFactory; -import org.bukkit.craftbukkit.v1_17_R1.util.Versioning; +import org.bukkit.craftbukkit.v1_18_R1.CraftServer; +import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemFactory; +import org.bukkit.craftbukkit.v1_18_R1.util.Versioning; import org.spigotmc.SpigotWorldConfig; import static org.mockito.Mockito.mock; @@ -81,7 +80,7 @@ public class BukkitInitialization { instance.setPackage(); SharedConstants.a(); - DispenserRegistry.init(); + DispenserRegistry.a(); try { IRegistry.class.getName(); @@ -89,12 +88,15 @@ public class BukkitInitialization { ex.printStackTrace(); } + String releaseTarget = SharedConstants.b().getReleaseTarget(); + String serverVersion = CraftServer.class.getPackage().getImplementationVersion(); + // Mock the server object Server mockedServer = mock(Server.class); when(mockedServer.getLogger()).thenReturn(java.util.logging.Logger.getLogger("Minecraft")); when(mockedServer.getName()).thenReturn("Mock Server"); - when(mockedServer.getVersion()).thenReturn(CraftServer.class.getPackage().getImplementationVersion()); + when(mockedServer.getVersion()).thenReturn(serverVersion + " (MC: " + releaseTarget + ")"); when(mockedServer.getBukkitVersion()).thenReturn(Versioning.getBukkitVersion()); when(mockedServer.getItemFactory()).thenReturn(CraftItemFactory.instance()); diff --git a/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java b/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java index cf184f4c..91ab697b 100644 --- a/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java +++ b/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java @@ -76,7 +76,7 @@ import static org.junit.Assert.*; // Ensure that the CraftItemFactory is mockable @RunWith(org.powermock.modules.junit4.PowerMockRunner.class) -@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*", "javax.management.*", "javax.xml.parsers.*", "com.sun.org.apache.xerces.internal.jaxp.*" }) +@PowerMockIgnore({ "org.apache.logging.log4j.core.config.xml.*", "javax.management.*" }) //@PrepareForTest(CraftItemFactory.class) public class PacketContainerTest { // Helper converters @@ -191,7 +191,7 @@ public class PacketContainerTest { @Test public void testGetIntegerArrays() { // Contains a byte array we will test - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MAP_CHUNK); + PacketContainer packet = new PacketContainer(PacketType.Play.Server.MOUNT); StructureModifier integers = packet.getIntegerArrays(); int[] testArray = new int[] { 1, 2, 3 }; @@ -411,7 +411,7 @@ public class PacketContainerTest { // are inner classes (which is ultimately pointless because AttributeSnapshots don't access any // members of the packet itself) PacketPlayOutUpdateAttributes packet = (PacketPlayOutUpdateAttributes) attribute.getHandle(); - AttributeBase base = IRegistry.al.get(MinecraftKey.a("generic.max_health")); + AttributeBase base = IRegistry.am.a(MinecraftKey.a("generic.max_health")); AttributeSnapshot snapshot = new AttributeSnapshot(base, 20.0D, modifiers); attribute.getSpecificModifier(List.class).write(0, Lists.newArrayList(snapshot)); @@ -461,7 +461,7 @@ public class PacketContainerTest { @SuppressWarnings("deprecation") public void testPotionEffect() { PotionEffect effect = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * 60, 1); - MobEffect mobEffect = new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), + MobEffect mobEffect = new MobEffect(MobEffectList.a(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()); int entityId = 42; @@ -663,12 +663,20 @@ public class PacketContainerTest { assertEquals(position, clone.getPosition()); } + @Test + public void testSetSimulationDistance() { + // first packet which is a record - set will fail if we missed something during patching + PacketContainer container = new PacketContainer(PacketType.Play.Server.UPDATE_SIMULATION_DISTANCE); + container.getIntegers().write(0, 1234); + assertEquals(1234, (int) container.getIntegers().read(0)); + } + @Test public void testMapChunk() { // this is a special case as we are generating a data serializer class (we only need to construct the packet) PacketContainer container = new PacketContainer(PacketType.Play.Server.MAP_CHUNK); // check if we can read an nbt compound from the class - assertTrue(container.getNbtModifier().optionRead(0).isPresent()); + assertTrue(container.getStructures().read(0).getNbtModifier().optionRead(0).isPresent()); } /** diff --git a/src/test/java/com/comphenix/protocol/injector/EntityUtilitiesTest.java b/src/test/java/com/comphenix/protocol/injector/EntityUtilitiesTest.java index 2ca81315..495f4995 100644 --- a/src/test/java/com/comphenix/protocol/injector/EntityUtilitiesTest.java +++ b/src/test/java/com/comphenix/protocol/injector/EntityUtilitiesTest.java @@ -9,6 +9,8 @@ import com.comphenix.protocol.reflect.accessors.Accessors; import com.comphenix.protocol.reflect.accessors.FieldAccessor; import com.comphenix.protocol.reflect.fuzzy.FuzzyFieldContract; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.server.level.ChunkProviderServer; import net.minecraft.server.level.EntityTrackerEntry; import net.minecraft.server.level.PlayerChunkMap; @@ -16,10 +18,8 @@ import net.minecraft.server.level.PlayerChunkMap.EntityTracker; import net.minecraft.server.level.WorldServer; import net.minecraft.world.entity.Entity; -import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity; import org.junit.BeforeClass; import org.junit.Test; @@ -45,7 +45,7 @@ public class EntityUtilitiesTest { when(bukkit.getHandle()).thenReturn(world); ChunkProviderServer provider = mock(ChunkProviderServer.class); - when(world.getChunkProvider()).thenReturn(provider); + when(world.k()).thenReturn(provider); PlayerChunkMap chunkMap = mock(PlayerChunkMap.class); Field chunkMapField = FuzzyReflection.fromClass(ChunkProviderServer.class, true) diff --git a/src/test/java/com/comphenix/protocol/injector/PluginVerifierTest.java b/src/test/java/com/comphenix/protocol/injector/PluginVerifierTest.java index 15febf7f..b730cb8e 100644 --- a/src/test/java/com/comphenix/protocol/injector/PluginVerifierTest.java +++ b/src/test/java/com/comphenix/protocol/injector/PluginVerifierTest.java @@ -1,7 +1,7 @@ package com.comphenix.protocol.injector; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -26,7 +26,7 @@ import com.google.common.collect.Lists; // Damn final classes @RunWith(org.powermock.modules.junit4.PowerMockRunner.class) -@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" }) +@PowerMockIgnore({ "org.apache.logging.log4j.core.config.xml.*", "javax.management.*" }) @PrepareForTest(PluginDescriptionFile.class) public class PluginVerifierTest { @Test diff --git a/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java b/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java index 62b72e74..81dcf41e 100644 --- a/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java +++ b/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java @@ -8,7 +8,7 @@ import static org.mockito.Mockito.verify; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; import org.junit.AfterClass; @@ -31,7 +31,7 @@ import net.minecraft.world.level.ChunkCoordIntPair; import net.minecraft.world.level.block.state.IBlockData; @RunWith(org.powermock.modules.junit4.PowerMockRunner.class) -@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" }) +@PowerMockIgnore({ "org.apache.logging.log4j.core.config.xml.*", "javax.management.*" }) public class MinecraftReflectionTest { @BeforeClass diff --git a/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java b/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java index fc1ad6a4..9ff6eb86 100644 --- a/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java +++ b/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java @@ -19,7 +19,7 @@ import static com.comphenix.protocol.utility.TestUtils.assertItemsEqual; import static org.junit.Assert.assertEquals; @RunWith(org.powermock.modules.junit4.PowerMockRunner.class) -@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" }) +@PowerMockIgnore({ "org.apache.logging.log4j.core.config.xml.*", "org.bukkit.craftbukkit.libs.jline.*" }) //@PrepareForTest(CraftItemFactory.class) public class StreamSerializerTest { diff --git a/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java b/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java index 1c73e805..39d25feb 100644 --- a/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java +++ b/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java @@ -26,7 +26,7 @@ public class ChunkCoordIntPairTest { (net.minecraft.world.level.ChunkCoordIntPair) ChunkCoordIntPair.getConverter(). getGeneric(specific); - assertEquals(1, roundtrip.b); - assertEquals(2, roundtrip.c); + assertEquals(1, roundtrip.c); + assertEquals(2, roundtrip.d); } } diff --git a/src/test/java/com/comphenix/protocol/wrappers/MultiBlockChangeTest.java b/src/test/java/com/comphenix/protocol/wrappers/MultiBlockChangeTest.java index a34123b1..92e74d82 100644 --- a/src/test/java/com/comphenix/protocol/wrappers/MultiBlockChangeTest.java +++ b/src/test/java/com/comphenix/protocol/wrappers/MultiBlockChangeTest.java @@ -33,7 +33,7 @@ import com.comphenix.protocol.utility.MinecraftReflection; * @author dmulloy2 */ @RunWith(org.powermock.modules.junit4.PowerMockRunner.class) -@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" }) +@PowerMockIgnore({ "org.apache.logging.log4j.core.config.xml.*", "javax.management.*" }) public class MultiBlockChangeTest { // @BeforeClass diff --git a/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java b/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java index d6921465..7ae44a98 100644 --- a/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java +++ b/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java @@ -92,7 +92,7 @@ public class WrappedAttributeTest { modifiers.add((AttributeModifier) wrapper.getHandle()); } - AttributeBase base = IRegistry.al.get(MinecraftKey.a(attribute.getAttributeKey())); + AttributeBase base = IRegistry.am.a(MinecraftKey.a(attribute.getAttributeKey())); return new AttributeSnapshot(base, attribute.getBaseValue(), modifiers); } diff --git a/src/test/java/com/comphenix/protocol/wrappers/WrappedBlockDataTest.java b/src/test/java/com/comphenix/protocol/wrappers/WrappedBlockDataTest.java index 4ee165d6..2a5265da 100644 --- a/src/test/java/com/comphenix/protocol/wrappers/WrappedBlockDataTest.java +++ b/src/test/java/com/comphenix/protocol/wrappers/WrappedBlockDataTest.java @@ -23,9 +23,9 @@ import net.minecraft.world.level.block.state.IBlockData; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.GlassPane; -import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_17_R1.block.impl.CraftStainedGlassPane; -import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData; +import org.bukkit.craftbukkit.v1_18_R1.block.impl.CraftStainedGlassPane; +import org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers; import org.junit.BeforeClass; import org.junit.Test; @@ -60,7 +60,7 @@ public class WrappedBlockDataTest { @Test public void testDataCreation() { - IBlockData nmsData = CraftMagicNumbers.getBlock(Material.CYAN_STAINED_GLASS_PANE).getBlockData(); + IBlockData nmsData = CraftMagicNumbers.getBlock(Material.CYAN_STAINED_GLASS_PANE).n(); GlassPane data = (GlassPane) CraftBlockData.fromData(nmsData); data.setFace(BlockFace.EAST, true); diff --git a/src/test/java/com/comphenix/protocol/wrappers/WrappedDataWatcherTest.java b/src/test/java/com/comphenix/protocol/wrappers/WrappedDataWatcherTest.java index 14841c97..43289042 100644 --- a/src/test/java/com/comphenix/protocol/wrappers/WrappedDataWatcherTest.java +++ b/src/test/java/com/comphenix/protocol/wrappers/WrappedDataWatcherTest.java @@ -25,8 +25,8 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObje import net.minecraft.world.entity.projectile.EntityEgg; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEgg; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEgg; +import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity; import org.junit.BeforeClass; import org.junit.Test; diff --git a/src/test/java/com/comphenix/protocol/wrappers/nbt/NbtFactoryTest.java b/src/test/java/com/comphenix/protocol/wrappers/nbt/NbtFactoryTest.java index abf718f5..d96e3c0f 100644 --- a/src/test/java/com/comphenix/protocol/wrappers/nbt/NbtFactoryTest.java +++ b/src/test/java/com/comphenix/protocol/wrappers/nbt/NbtFactoryTest.java @@ -48,7 +48,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @RunWith(org.powermock.modules.junit4.PowerMockRunner.class) -@PowerMockIgnore({ "org.apache.log4j.*", "org.apache.logging.*", "org.bukkit.craftbukkit.libs.jline.*" }) +@PowerMockIgnore({ "org.apache.logging.log4j.core.config.xml.*", "javax.management.*" }) //@PrepareForTest(CraftItemFactory.class) public class NbtFactoryTest { @BeforeClass