mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-28 05:35:28 +01:00
Compile PL for 1.4.7 - though earlier versions will still work.
This commit is contained in:
parent
5c098339a9
commit
b138332608
@ -11,12 +11,12 @@
|
|||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>net.sourceforge.metrics.builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>net.sourceforge.metrics.builder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
@ -203,7 +203,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.4.6-R0.1</version>
|
<version>1.4.7-R0.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -56,7 +56,7 @@ public class ProtocolLibrary extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* The maximum version ProtocolLib has been tested with,
|
* The maximum version ProtocolLib has been tested with,
|
||||||
*/
|
*/
|
||||||
private static final String MAXIMUM_MINECRAFT_VERSION = "1.4.6";
|
private static final String MAXIMUM_MINECRAFT_VERSION = "1.4.7";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of milliseconds per second.
|
* The number of milliseconds per second.
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.comphenix.protocol;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
// Will have to be updated for every version though
|
||||||
|
import org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemFactory;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.inventory.ItemFactory;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import com.comphenix.protocol.reflect.FieldUtils;
|
||||||
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to ensure that ProtocolLib and Bukkit is prepared to be tested.
|
||||||
|
*
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
public class BukkitInitialization {
|
||||||
|
private static boolean initialized;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Bukkit and ProtocolLib such that we can perfrom unit testing.
|
||||||
|
* @throws IllegalAccessException If we are unable to initialize Bukkit.
|
||||||
|
*/
|
||||||
|
public static void initializeItemMeta() throws IllegalAccessException {
|
||||||
|
if (!initialized) {
|
||||||
|
// Denote that we're done
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
initializePackage();
|
||||||
|
|
||||||
|
// Mock the server object
|
||||||
|
Server mockedServer = mock(Server.class);
|
||||||
|
ItemFactory mockedFactory = mock(CraftItemFactory.class);
|
||||||
|
ItemMeta mockedMeta = mock(ItemMeta.class);
|
||||||
|
|
||||||
|
when(mockedServer.getItemFactory()).thenReturn(mockedFactory);
|
||||||
|
when(mockedFactory.getItemMeta(any(Material.class))).thenReturn(mockedMeta);
|
||||||
|
|
||||||
|
// Inject this fake server
|
||||||
|
FieldUtils.writeStaticField(Bukkit.class, "server", mockedServer, true);
|
||||||
|
|
||||||
|
// And the fake item factory
|
||||||
|
FieldUtils.writeStaticField(CraftItemFactory.class, "instance", mockedFactory, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that package names are correctly set up.
|
||||||
|
*/
|
||||||
|
public static void initializePackage() {
|
||||||
|
// Initialize reflection
|
||||||
|
MinecraftReflection.setMinecraftPackage("net.minecraft.server.v1_4_R1", "org.bukkit.craftbukkit.v1_4_R1");
|
||||||
|
}
|
||||||
|
}
|
@ -18,31 +18,23 @@
|
|||||||
package com.comphenix.protocol.events;
|
package com.comphenix.protocol.events;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// Will have to be updated for every version though
|
// Will have to be updated for every version though
|
||||||
import org.bukkit.craftbukkit.v1_4_6.inventory.CraftItemFactory;
|
import org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemFactory;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.WorldType;
|
import org.bukkit.WorldType;
|
||||||
import org.bukkit.inventory.ItemFactory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
import com.comphenix.protocol.Packets;
|
import com.comphenix.protocol.Packets;
|
||||||
import com.comphenix.protocol.reflect.EquivalentConverter;
|
import com.comphenix.protocol.reflect.EquivalentConverter;
|
||||||
import com.comphenix.protocol.reflect.FieldUtils;
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.comphenix.protocol.wrappers.BukkitConverters;
|
import com.comphenix.protocol.wrappers.BukkitConverters;
|
||||||
@ -65,22 +57,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initializeBukkit() throws IllegalAccessException {
|
public static void initializeBukkit() throws IllegalAccessException {
|
||||||
// Initialize reflection
|
BukkitInitialization.initializeItemMeta();
|
||||||
MinecraftReflection.setMinecraftPackage("net.minecraft.server.v1_4_6", "org.bukkit.craftbukkit.v1_4_6");
|
|
||||||
|
|
||||||
// Mock the server object
|
|
||||||
Server mockedServer = mock(Server.class);
|
|
||||||
ItemFactory mockedFactory = mock(CraftItemFactory.class);
|
|
||||||
ItemMeta mockedMeta = mock(ItemMeta.class);
|
|
||||||
|
|
||||||
when(mockedServer.getItemFactory()).thenReturn(mockedFactory);
|
|
||||||
when(mockedFactory.getItemMeta(any(Material.class))).thenReturn(mockedMeta);
|
|
||||||
|
|
||||||
// Inject this fake server
|
|
||||||
FieldUtils.writeStaticField(Bukkit.class, "server", mockedServer, true);
|
|
||||||
|
|
||||||
// And the fake item factory
|
|
||||||
FieldUtils.writeStaticField(CraftItemFactory.class, "instance", mockedFactory, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void testPrimitive(StructureModifier<T> modifier, int index, T initialValue, T testValue) {
|
private <T> void testPrimitive(StructureModifier<T> modifier, int index, T initialValue, T testValue) {
|
||||||
|
@ -30,7 +30,6 @@ import com.comphenix.protocol.events.ListenerPriority;
|
|||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
public class SortedCopyOnWriteArrayTest {
|
public class SortedCopyOnWriteArrayTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertion() {
|
public void testInsertion() {
|
||||||
|
|
||||||
|
@ -21,13 +21,12 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
|
||||||
|
|
||||||
public class NbtCompoundTest {
|
public class NbtCompoundTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupBukkit() {
|
public static void initializeBukkit() throws IllegalAccessException {
|
||||||
MinecraftReflection.setMinecraftPackage("net.minecraft.server.v1_4_6", "org.bukkit.craftbukkit.v1_4_6");
|
BukkitInitialization.initializePackage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -28,15 +28,13 @@ import java.io.DataOutputStream;
|
|||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.io.NbtBinarySerializer;
|
import com.comphenix.protocol.wrappers.nbt.io.NbtBinarySerializer;
|
||||||
|
|
||||||
public class NbtFactoryTest {
|
public class NbtFactoryTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initializeBukkit() {
|
public static void initializeBukkit() throws IllegalAccessException {
|
||||||
// Initialize reflection
|
BukkitInitialization.initializePackage();
|
||||||
MinecraftReflection.setMinecraftPackage("net.minecraft.server.v1_4_6", "org.bukkit.craftbukkit.v1_4_6");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -6,15 +6,14 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||||
|
|
||||||
public class NbtConfigurationSerializerTest {
|
public class NbtConfigurationSerializerTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initializeBukkit() {
|
public static void initializeBukkit() throws IllegalAccessException {
|
||||||
// Initialize reflection
|
BukkitInitialization.initializePackage();
|
||||||
MinecraftReflection.setMinecraftPackage("net.minecraft.server.v1_4_6", "org.bukkit.craftbukkit.v1_4_6");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
Loading…
Reference in New Issue
Block a user