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:
parent
f70c5fcd4c
commit
d2e8c21941
2 changed files with 27 additions and 32 deletions
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue