Add Material Tags
This adds a bunch of useful and missing Tags to be able to identify items that are related to each other by a trait. Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lena Kolb <lenakolb2204@gmail.com> Co-authored-by: Layla Silbernberg <livsilbernberg@gmail.com> Co-authored-by: Newwind <newwindserver@gmail.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
|
||||
*/
|
||||
|
||||
package com.destroystokyo.paper;
|
||||
|
||||
import io.papermc.paper.tag.BaseTag;
|
||||
import io.papermc.paper.tag.EntityTags;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class MaterialTagsTest extends AbstractTestingBase {
|
||||
|
||||
@Test
|
||||
public void testInitialize() {
|
||||
try {
|
||||
MaterialTags.SHULKER_BOXES.getValues();
|
||||
assert true;
|
||||
} catch (Throwable e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocked() {
|
||||
testLocked(MaterialTags.class);
|
||||
testLocked(EntityTags.class);
|
||||
}
|
||||
|
||||
private static void testLocked(Class<?> clazz) {
|
||||
for (BaseTag<?, ?> tag : collectTags(clazz)) {
|
||||
assertTrue(tag.isLocked(), "Tag " + tag.key() + " is not locked");
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<BaseTag<?, ?>> collectTags(Class<?> clazz) {
|
||||
Set<BaseTag<?, ?>> tags = new HashSet<>();
|
||||
try {
|
||||
for (Field field : clazz.getDeclaredFields()) {
|
||||
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && BaseTag.class.isAssignableFrom(field.getType())) {
|
||||
tags.add((BaseTag<?, ?>) field.get(null));
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
21
paper-api/src/test/java/io/papermc/paper/EntityTagsTest.java
Normal file
21
paper-api/src/test/java/io/papermc/paper/EntityTagsTest.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package io.papermc.paper;
|
||||
|
||||
import io.papermc.paper.tag.EntityTags;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class EntityTagsTest extends AbstractTestingBase {
|
||||
|
||||
@Test
|
||||
public void testInitialize() {
|
||||
try {
|
||||
EntityTags.HORSES.getValues();
|
||||
assert true;
|
||||
} catch (Throwable e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user