Java Code Examples for org.bukkit.Material#EMERALD
The following examples show how to use
org.bukkit.Material#EMERALD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VeinMinerListener.java From UhcCore with GNU General Public License v3.0 | 6 votes |
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; }
Example 2
Source File: IndustrialMiner.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
/** * 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); } }
Example 3
Source File: TestItemDataService.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@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()); }
Example 4
Source File: TestVanillaMachinesListener.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
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; }
Example 5
Source File: TestCategories.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@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)); }
Example 6
Source File: BountyHunter.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example 7
Source File: PlayerStorage.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
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); }
Example 8
Source File: TestItemDataService.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 9
Source File: TestVanillaMachinesListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
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; }
Example 10
Source File: TestSlimefunItemRegistration.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 11
Source File: TestCategories.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@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)); }
Example 12
Source File: Tutorial.java From CardinalPGM with MIT License | 5 votes |
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); }
Example 13
Source File: TestUtilities.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
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); }
Example 14
Source File: TestUtilities.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
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; }