blob: 8eba0b5dadf1e7c3c61b832019783559aa62c07a [file] [log] [blame] [raw]
package itemstack;
import org.bukkit.enchantments.Enchantment;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import protocolsupport.api.ProtocolVersion;
import protocolsupport.protocol.typeremapper.basic.GenericIdSkipper;
import protocolsupport.protocol.typeremapper.legacy.LegacyEnchantmentId;
import protocolsupport.protocol.typeremapper.utils.SkippingTable.GenericSkippingTable;
import protocolsupport.protocol.utils.CommonNBT;
class NetworkItemStackEnchantTests {
@Test
void testFakeEnchantmentRegistered() {
int id = Assertions.assertDoesNotThrow(() -> LegacyEnchantmentId.getId(CommonNBT.FAKE_ENCHANTMENT_KEY_STR));
Assertions.assertEquals(CommonNBT.FAKE_ENCHANTMENT_KEY_STR, LegacyEnchantmentId.getById(id));
}
@Test
void testLegacyId() {
GenericSkippingTable<String> enchSkipTable = GenericIdSkipper.ENCHANT.getTable(ProtocolVersion.MINECRAFT_1_12_2);
for (Enchantment ench : Enchantment.values()) {
String key = ench.getKey().toString();
if (!enchSkipTable.isSet(key)) {
Assertions.assertDoesNotThrow(() -> LegacyEnchantmentId.getId(key));
}
}
}
}