This repository has been archived by the owner on Jul 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
3,578 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.bukkit; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.nullValue; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import com.google.common.collect.Lists; | ||
import java.util.Collections; | ||
import java.util.EnumMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import net.minecraft.entity.item.EntityPainting.EnumArt; | ||
import org.bukkit.craftbukkit.v1_12_R1.CraftArt; | ||
import org.junit.Test; | ||
|
||
public class ArtTest { | ||
|
||
private static final int UNIT_MULTIPLIER = 16; | ||
|
||
@Test | ||
public void verifyMapping() { | ||
List<Art> arts = Lists.newArrayList(Art.values()); | ||
|
||
for (EnumArt enumArt : EnumArt.values()) { | ||
int id = enumArt.ordinal(); | ||
String name = enumArt.title; | ||
int width = enumArt.sizeX / UNIT_MULTIPLIER; | ||
int height = enumArt.sizeY / UNIT_MULTIPLIER; | ||
|
||
Art subject = Art.getById(id); | ||
|
||
String message = String.format("org.bukkit.Art is missing id: %d named: '%s'", id, name); | ||
assertNotNull(message, subject); | ||
|
||
assertThat(Art.getByName(name), is(subject)); | ||
assertThat("Art." + subject + "'s width", subject.getBlockWidth(), is(width)); | ||
assertThat("Art." + subject + "'s height", subject.getBlockHeight(), is(height)); | ||
|
||
arts.remove(subject); | ||
} | ||
|
||
assertThat("org.bukkit.Art has too many arts", arts, is(Collections.EMPTY_LIST)); | ||
} | ||
|
||
@Test | ||
public void testCraftArtToNotch() { | ||
Map<EnumArt, Art> cache = new EnumMap(EnumArt.class); | ||
for (Art art : Art.values()) { | ||
EnumArt enumArt = CraftArt.BukkitToNotch(art); | ||
assertNotNull(art.name(), enumArt); | ||
assertThat(art.name(), cache.put(enumArt, art), is(nullValue())); | ||
} | ||
} | ||
|
||
@Test | ||
public void testCraftArtToBukkit() { | ||
Map<Art, EnumArt> cache = new EnumMap(Art.class); | ||
for (EnumArt enumArt : EnumArt.values()) { | ||
Art art = CraftArt.NotchToBukkit(enumArt); | ||
assertNotNull(enumArt.name(), art); | ||
assertThat(enumArt.name(), cache.put(art, enumArt), is(nullValue())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.bukkit; | ||
|
||
import org.bukkit.block.Biome; | ||
import org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock; | ||
import org.bukkit.support.AbstractTestingBase; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class BiomeTest extends AbstractTestingBase { | ||
|
||
@Test | ||
public void testBukkitToMinecraft() { | ||
for (Biome biome : Biome.values()) { | ||
Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(biome)); | ||
} | ||
} | ||
|
||
@Test | ||
public void testMinecraftToBukkit() { | ||
for (Object biome : net.minecraft.world.biome.Biome.REGISTRY) { | ||
Assert.assertNotNull("No Bukkit mapping for " + biome, CraftBlock.biomeBaseToBiome((net.minecraft.world.biome.Biome) biome)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.bukkit; | ||
|
||
import net.minecraft.util.text.TextFormatting; | ||
import org.bukkit.craftbukkit.v1_12_R1.util.CraftChatMessage; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class ChatTest { | ||
|
||
@Test | ||
public void testColors() { | ||
for (ChatColor color : ChatColor.values()) { | ||
Assert.assertNotNull(CraftChatMessage.getColor(color)); | ||
Assert.assertEquals(color, CraftChatMessage.getColor(CraftChatMessage.getColor(color))); | ||
} | ||
|
||
for (TextFormatting format : TextFormatting.values()) { | ||
Assert.assertNotNull(CraftChatMessage.getColor(format)); | ||
Assert.assertEquals(format, CraftChatMessage.getColor(CraftChatMessage.getColor(format))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.bukkit; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import net.minecraft.item.EnumDyeColor; | ||
import net.minecraft.item.ItemDye; | ||
import org.bukkit.support.AbstractTestingBase; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameter; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
@RunWith(Parameterized.class) | ||
public class DyeColorsTest extends AbstractTestingBase { | ||
|
||
@Parameter | ||
public DyeColor dye; | ||
|
||
@Parameters(name = "{index}: {0}") | ||
public static List<Object[]> data() { | ||
List<Object[]> list = new ArrayList<Object[]>(); | ||
for (DyeColor dye : DyeColor.values()) { | ||
list.add(new Object[]{dye}); | ||
} | ||
return list; | ||
} | ||
|
||
@Test | ||
public void checkColor() { | ||
Color color = dye.getColor(); | ||
float[] nmsColorArray = EnumDyeColor.byMetadata(dye.getWoolData()).getColorComponentValues(); | ||
Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255)); | ||
assertThat(color, is(nmsColor)); | ||
} | ||
|
||
@Test | ||
public void checkFireworkColor() { | ||
Color color = dye.getFireworkColor(); | ||
int nmsColor = ItemDye.DYE_COLORS[dye.getDyeData()]; | ||
assertThat(color, is(Color.fromRGB(nmsColor))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.bukkit; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.Matchers.nullValue; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import com.google.common.collect.Maps; | ||
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
import net.minecraft.item.Item; | ||
import org.bukkit.craftbukkit.v1_12_R1.util.CraftMagicNumbers; | ||
import org.bukkit.support.AbstractTestingBase; | ||
import org.junit.Test; | ||
|
||
public class MaterialTest extends AbstractTestingBase { | ||
|
||
@Test | ||
public void verifyMapping() { | ||
Map<Integer, Material> materials = Maps.newHashMap(); | ||
for (Material material : Material.values()) { | ||
if (INVALIDATED_MATERIALS.contains(material)) { | ||
continue; | ||
} | ||
|
||
materials.put(material.getId(), material); | ||
} | ||
|
||
Iterator<Item> items = Item.REGISTRY.iterator(); | ||
|
||
while (items.hasNext()) { | ||
Item item = items.next(); | ||
if (item == null) { | ||
continue; | ||
} | ||
|
||
int id = CraftMagicNumbers.getId(item); | ||
String name = item.getUnlocalizedName(); | ||
|
||
Material material = materials.remove(id); | ||
|
||
assertThat("Missing " + name + "(" + id + ")", material, is(not(nullValue()))); | ||
} | ||
|
||
assertThat(materials, is(Collections.EMPTY_MAP)); | ||
} | ||
} |
Oops, something went wrong.