2012-01-29 11:22:11 +01:00
|
|
|
package org.bukkit;
|
|
|
|
|
2012-12-14 02:02:02 -06:00
|
|
|
import static org.hamcrest.Matchers.*;
|
2019-04-23 14:54:36 +10:00
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import com.google.common.collect.Maps;
|
2012-12-14 02:02:02 -06:00
|
|
|
import java.util.Collections;
|
2019-04-23 14:54:36 +10:00
|
|
|
import java.util.Iterator;
|
2012-01-29 11:22:11 +01:00
|
|
|
import java.util.Map;
|
2018-08-26 12:00:00 +10:00
|
|
|
import net.minecraft.server.IRegistry;
|
2012-01-29 11:22:11 +01:00
|
|
|
import net.minecraft.server.Item;
|
2018-07-15 10:00:00 +10:00
|
|
|
import net.minecraft.server.MinecraftKey;
|
2019-04-23 14:54:36 +10:00
|
|
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
2012-01-29 11:22:11 +01:00
|
|
|
import org.bukkit.support.AbstractTestingBase;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
public class MaterialTest extends AbstractTestingBase {
|
2012-12-14 02:02:02 -06:00
|
|
|
|
2012-01-29 11:22:11 +01:00
|
|
|
@Test
|
|
|
|
public void verifyMapping() {
|
2018-07-15 10:00:00 +10:00
|
|
|
Map<MinecraftKey, Material> materials = Maps.newHashMap();
|
2012-01-29 11:22:11 +01:00
|
|
|
for (Material material : Material.values()) {
|
2013-11-04 07:07:38 -06:00
|
|
|
if (INVALIDATED_MATERIALS.contains(material)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-07-15 10:00:00 +10:00
|
|
|
materials.put(CraftMagicNumbers.key(material), material);
|
2012-01-29 11:22:11 +01:00
|
|
|
}
|
|
|
|
|
2018-08-26 12:00:00 +10:00
|
|
|
Iterator<Item> items = IRegistry.ITEM.iterator();
|
2013-11-04 07:07:38 -06:00
|
|
|
|
|
|
|
while (items.hasNext()) {
|
|
|
|
Item item = items.next();
|
2012-01-29 11:22:11 +01:00
|
|
|
if (item == null) continue;
|
|
|
|
|
2018-08-26 12:00:00 +10:00
|
|
|
MinecraftKey id = IRegistry.ITEM.getKey(item);
|
2012-01-29 11:22:11 +01:00
|
|
|
String name = item.getName();
|
|
|
|
|
|
|
|
Material material = materials.remove(id);
|
|
|
|
|
2012-12-14 02:02:02 -06:00
|
|
|
assertThat("Missing " + name + "(" + id + ")", material, is(not(nullValue())));
|
2018-07-15 10:00:00 +10:00
|
|
|
assertNotNull("No item mapping for " + name, CraftMagicNumbers.getMaterial(item));
|
2012-01-29 11:22:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-14 02:02:02 -06:00
|
|
|
assertThat(materials, is(Collections.EMPTY_MAP));
|
2012-01-29 11:22:11 +01:00
|
|
|
}
|
|
|
|
}
|