mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-10 09:02:09 -07:00
Cache material data constructors. Fixes BUKKIT-2980
Reobtaining a constructor is not a trivial operation, this change makes the Material enum store the respective constructors for each MaterialData. Additionally 'fixed' the material tests to use proper generics. By: Darth Android <darthandroid@gmail.com>
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package org.bukkit;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.isA;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MaterialTest {
|
||||
@@ -42,14 +40,12 @@ public class MaterialTest {
|
||||
assertThat(Material.getMaterial(null), is(nullValue()));
|
||||
}
|
||||
|
||||
// [EB]: gawd we need better code >.>
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Test
|
||||
public void getData() {
|
||||
for (Material material : Material.values()) {
|
||||
Class clazz = material.getData();
|
||||
Class<? extends MaterialData> clazz = material.getData();
|
||||
|
||||
assertThat(material.getNewData((byte) 0), isA(clazz));
|
||||
assertThat(material.getNewData((byte) 0), is(instanceOf(clazz)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user