org.bukkit.Material#EMERALD源码实例Demo

下面列出了org.bukkit.Material#EMERALD 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: UhcCore   文件: VeinMinerListener.java
private Material getDropType(){
    if (type == UniversalMaterial.NETHER_QUARTZ_ORE.getType()){
        return Material.QUARTZ;
    }

    switch (type){
        case DIAMOND_ORE:
            return Material.DIAMOND;
        case GOLD_ORE:
            return Material.GOLD_INGOT;
        case IRON_ORE:
            return Material.IRON_INGOT;
        case COAL_ORE:
            return Material.COAL;
        case LAPIS_ORE:
            return UniversalMaterial.LAPIS_LAZULI.getType();
        case EMERALD_ORE:
            return Material.EMERALD;
        case REDSTONE_ORE:
            return Material.REDSTONE;
        case GRAVEL:
            return Material.FLINT;
    }
    return null;
}
 
源代码2 项目: Slimefun4   文件: IndustrialMiner.java
/**
 * This method returns the outcome that mining certain ores yields.
 * 
 * @param ore
 *            The {@link Material} of the ore that was mined
 * 
 * @return The outcome when mining this ore
 */
public ItemStack getOutcome(Material ore) {
    if (hasSilkTouch()) {
        return new ItemStack(ore);
    }

    Random random = ThreadLocalRandom.current();

    switch (ore) {
    case COAL_ORE:
        return new ItemStack(Material.COAL);
    case DIAMOND_ORE:
        return new ItemStack(Material.DIAMOND);
    case EMERALD_ORE:
        return new ItemStack(Material.EMERALD);
    case NETHER_QUARTZ_ORE:
        return new ItemStack(Material.QUARTZ);
    case REDSTONE_ORE:
        return new ItemStack(Material.REDSTONE, 4 + random.nextInt(2));
    case LAPIS_ORE:
        return new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4));
    default:
        // This includes Iron and Gold ore
        return new ItemStack(ore);
    }
}
 
源代码3 项目: Slimefun4   文件: TestItemDataService.java
@Test
public void testSetDataItemMeta() {
    CustomItemDataService service = new CustomItemDataService(plugin, "test");
    ItemStack item = new ItemStack(Material.EMERALD);
    ItemMeta meta = item.getItemMeta();
    service.setItemData(meta, "Hello World");

    Optional<String> data = service.getItemData(meta);
    Assertions.assertTrue(data.isPresent());
    Assertions.assertEquals("Hello World", data.get());

    item.setItemMeta(meta);

    Optional<String> data2 = service.getItemData(item);
    Assertions.assertTrue(data2.isPresent());
    Assertions.assertEquals("Hello World", data2.get());
}
 
源代码4 项目: Slimefun4   文件: TestVanillaMachinesListener.java
private PrepareItemCraftEvent mockPreCraftingEvent(ItemStack item) {
    Player player = server.addPlayer();

    CraftingInventory inv = Mockito.mock(CraftingInventory.class);
    MutableObject result = new MutableObject(new ItemStack(Material.EMERALD));

    Mockito.doAnswer(invocation -> {
        ItemStack argument = invocation.getArgument(0);
        result.setValue(argument);
        return null;
    }).when(inv).setResult(Mockito.any());

    Mockito.when(inv.getResult()).thenAnswer(invocation -> result.getValue());
    Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { null, null, item, null, null, null, null, null, null });

    InventoryView view = player.openInventory(inv);
    PrepareItemCraftEvent event = new PrepareItemCraftEvent(inv, view, false);

    listener.onPrepareCraft(event);
    return event;
}
 
源代码5 项目: Slimefun4   文件: TestCategories.java
@Test
public void testLockedCategoriesParents() {
    Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));

    Category category = new Category(new NamespacedKey(plugin, "unlocked"), new CustomItem(Material.EMERALD, "&5I am SHERlocked"));
    category.register();

    Category unregistered = new Category(new NamespacedKey(plugin, "unregistered"), new CustomItem(Material.EMERALD, "&5I am unregistered"));

    LockedCategory locked = new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey(), unregistered.getKey());
    locked.register();

    Assertions.assertTrue(locked.getParents().contains(category));
    Assertions.assertFalse(locked.getParents().contains(unregistered));

    locked.removeParent(category);
    Assertions.assertFalse(locked.getParents().contains(category));

    Assertions.assertThrows(IllegalArgumentException.class, () -> locked.addParent(locked));
    Assertions.assertThrows(IllegalArgumentException.class, () -> locked.addParent(null));

    locked.addParent(category);
    Assertions.assertTrue(locked.getParents().contains(category));
}
 
源代码6 项目: ce   文件: BountyHunter.java
private Material getBounty() {
	double rand = Tools.random.nextDouble() *100;
	double currentChance = ChanceEmerald;
	
	if(rand < currentChance)
		return Material.EMERALD;
	currentChance += ChanceDiamond;
	
	if(rand < currentChance)
		return Material.DIAMOND;
	currentChance += ChanceGold;
	
	if(rand < currentChance)
		return Material.GOLD_INGOT;
	currentChance += ChanceIron;
	
	if(rand < currentChance)
		return Material.IRON_INGOT;
	return Material.COAL;
}
 
源代码7 项目: BedwarsRel   文件: PlayerStorage.java
public void addReduceCountdownItem() {
  ItemStack reduceCountdownItem = new ItemStack(Material.EMERALD, 1);
  ItemMeta im = reduceCountdownItem.getItemMeta();
  im.setDisplayName(BedwarsRel._l(player, "lobby.reduce_countdown"));
  reduceCountdownItem.setItemMeta(im);
  this.player.getInventory().addItem(reduceCountdownItem);
}
 
源代码8 项目: Slimefun4   文件: TestItemDataService.java
@Test
public void testSetDataItem() {
    CustomItemDataService service = new CustomItemDataService(plugin, "test");
    ItemStack item = new ItemStack(Material.EMERALD);

    service.setItemData(item, "Hello World");
    Optional<String> data = service.getItemData(item);

    Assertions.assertTrue(data.isPresent());
    Assertions.assertEquals("Hello World", data.get());
}
 
源代码9 项目: Slimefun4   文件: TestVanillaMachinesListener.java
private CraftItemEvent mockCraftingEvent(ItemStack item) {
    Recipe recipe = new ShapedRecipe(new NamespacedKey(plugin, "test_recipe"), new ItemStack(Material.EMERALD));
    Player player = server.addPlayer();

    CraftingInventory inv = Mockito.mock(CraftingInventory.class);
    Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { item, null, null, null, null, null, null, null, null });

    InventoryView view = player.openInventory(inv);
    CraftItemEvent event = new CraftItemEvent(recipe, view, SlotType.RESULT, 9, ClickType.LEFT, InventoryAction.PICKUP_ALL);

    listener.onCraft(event);
    return event;
}
 
源代码10 项目: Slimefun4   文件: TestSlimefunItemRegistration.java
@Test
public void testRecipeOutput() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RECIPE_OUTPUT_TEST", new CustomItem(Material.DIAMOND, "&cTest"));
    item.register(plugin);

    Assertions.assertEquals(item.getItem(), item.getRecipeOutput());

    ItemStack output = new ItemStack(Material.EMERALD, 64);
    item.setRecipeOutput(output);
    Assertions.assertEquals(output, item.getRecipeOutput());

    item.setRecipeOutput(item.getItem());
    Assertions.assertEquals(item.getItem(), item.getRecipeOutput());
}
 
源代码11 项目: Slimefun4   文件: TestCategories.java
@Test
public void testLockedCategoriesUnlocking() throws InterruptedException {
    Player player = server.addPlayer();
    PlayerProfile profile = TestUtilities.awaitProfile(player);

    Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));

    Category category = new Category(new NamespacedKey(plugin, "parent"), new CustomItem(Material.EMERALD, "&5I am SHERlocked"));
    category.register();

    LockedCategory locked = new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey());
    locked.register();

    // No Items, so it should be unlocked
    Assertions.assertTrue(locked.hasUnlocked(player, profile));

    SlimefunItem item = new SlimefunItem(category, new SlimefunItemStack("LOCKED_CATEGORY_TEST", new CustomItem(Material.LANTERN, "&6Test Item for locked categories")), RecipeType.NULL, new ItemStack[9]);
    item.register(plugin);
    item.load();

    SlimefunPlugin.getRegistry().setResearchingEnabled(true);
    Research research = new Research(new NamespacedKey(plugin, "cant_touch_this"), 432432, "MC Hammer", 90);
    research.addItems(item);
    research.register();

    Assertions.assertFalse(profile.hasUnlocked(research));
    Assertions.assertFalse(locked.hasUnlocked(player, profile));

    profile.setResearched(research, true);

    Assertions.assertTrue(locked.hasUnlocked(player, profile));
}
 
源代码12 项目: CardinalPGM   文件: Tutorial.java
public static ItemStack getEmerald(Player player) {
    if (GameHandler.getGameHandler().getMatch().getModules().getModules(Tutorial.class).size() > 0) {
        ItemStack emerald = new ItemStack(Material.EMERALD);
        ItemMeta meta = emerald.getItemMeta();
        meta.setDisplayName(ChatColor.GOLD + new LocalizedChatMessage(ChatConstant.UI_TUTORIAL_VIEW).getMessage(ChatUtil.getLocale(player)));
        emerald.setItemMeta(meta);
        return emerald;
    }
    return new ItemStack(Material.AIR);
}
 
源代码13 项目: Slimefun4   文件: TestUtilities.java
public static SlimefunItem mockSlimefunItem(Plugin plugin, String id, ItemStack item) {
    Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test Category"));

    return new MockSlimefunItem(category, item, id);
}
 
源代码14 项目: Slimefun4   文件: TestUtilities.java
public static VanillaItem mockVanillaItem(Plugin plugin, Material type, boolean enabled) {
    Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test Category"));
    VanillaItem item = new VanillaItem(category, new ItemStack(type), type.name(), RecipeType.NULL, new ItemStack[9]);
    SlimefunPlugin.getItemCfg().setValue(type.name() + ".enabled", enabled);
    return item;
}
 
 方法所在类
 同类方法