Java 类net.minecraft.server.MinecraftKey 实例源码

项目:Craftbukkit    文件:CraftStatistic.java   
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) {
    String statisticString = statistic.name;
    String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
    Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
    if (item != null) {
        return Material.getMaterial(Item.getId(item));
    }
    Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
    if (block != null) {
        return Material.getMaterial(Block.getId(block));
    }
    try {
        return Material.getMaterial(Integer.parseInt(val));
    } catch (NumberFormatException e) {
        return null;
    }
}
项目:SpigotSource    文件:CraftStatistic.java   
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) {
    String statisticString = statistic.name;
    String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
    Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
    if (item != null) {
        return Material.getMaterial(Item.getId(item));
    }
    Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
    if (block != null) {
        return Material.getMaterial(Block.getId(block));
    }
    try {
        return Material.getMaterial(Integer.parseInt(val));
    } catch (NumberFormatException e) {
        return null;
    }
}
项目:Craftbukkit    文件:CraftMagicNumbers.java   
@Override
public List<String> tabCompleteInternalMaterialName(String token, List<String> completions) {
    ArrayList<String> results = Lists.newArrayList();
    for (MinecraftKey key : (Set<MinecraftKey>)Item.REGISTRY.keySet()) {
        results.add(key.toString());
    }
    return StringUtil.copyPartialMatches(token, results, completions);
}
项目:SpigotSource    文件:CraftMagicNumbers.java   
@Override
public List<String> tabCompleteInternalMaterialName(String token, List<String> completions) {
    ArrayList<String> results = Lists.newArrayList();
    for (MinecraftKey key : (Set<MinecraftKey>)Item.REGISTRY.keySet()) {
        results.add(key.toString());
    }
    return StringUtil.copyPartialMatches(token, results, completions);
}
项目:ProjectAres    文件:NMSHacks.java   
public static String getKey(Material material) {
    MinecraftKey key = Item.REGISTRY.b(CraftMagicNumbers.getItem(material));
    return key == null ? null : key.toString();
}
项目:ProjectAres    文件:NMSHacks.java   
public static @Nullable Material materialByKey(String key) {
    final Item item = Item.REGISTRY.get(new MinecraftKey(key));
    return item == null ? null : CraftMagicNumbers.getMaterial(item);
}
项目:Craftbukkit    文件:CraftMagicNumbers.java   
@Override
public Material getMaterialFromInternalName(String name) {
    return getMaterial((Item) Item.REGISTRY.get(new MinecraftKey(name)));
}
项目:SpigotSource    文件:CraftMagicNumbers.java   
@Override
public Material getMaterialFromInternalName(String name) {
    return getMaterial((Item) Item.REGISTRY.get(new MinecraftKey(name)));
}
项目:SpigotSource    文件:SoundTest.java   
@Test
public void testReverse() {
    for (MinecraftKey effect : SoundEffect.a.keySet()) {
        assertNotNull(effect + "", Sound.valueOf(effect.a().replace('.', '_').toUpperCase()));
    }
}