Java Code Examples for org.bukkit.Material#DIAMOND
The following examples show how to use
org.bukkit.Material#DIAMOND .
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: TestRecipeService.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@Test public void testRecipe() { MinecraftRecipeService service = new MinecraftRecipeService(plugin); NamespacedKey key = new NamespacedKey(plugin, "furnace_recipe_test"); ItemStack result = new ItemStack(Material.EMERALD_BLOCK); FurnaceRecipe recipe = new FurnaceRecipe(key, result, new MaterialChoice(Material.DIAMOND), 1, 2); server.addRecipe(recipe); // The Snapshot has not been taken, so it should fallback to an empty array Assertions.assertEquals(0, service.getRecipesFor(result).length); service.refresh(); Recipe[] recipes = service.getRecipesFor(result); Assertions.assertEquals(1, recipes.length); Assertions.assertEquals(recipe, recipes[0]); }
Example 4
Source File: TextCustomTextureService.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@Test public void testSetTexture() { Config config = new Config("plugins/temporary"); CustomTextureService service = new CustomTextureService(config); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "TEXTURE_TEST", new ItemStack(Material.LANTERN)); String version = "Unit Test v1.0"; config.setValue(item.getID(), 300); config.setValue("version", version); service.register(Arrays.asList(item), false); Assertions.assertTrue(service.isActive()); Assertions.assertEquals(version, service.getVersion()); Assertions.assertEquals(300, service.getModelData(item.getID())); ItemStack stack = new ItemStack(Material.DIAMOND); service.setTexture(stack, item.getID()); Assertions.assertTrue(stack.getItemMeta().hasCustomModelData()); Assertions.assertEquals(300, stack.getItemMeta().getCustomModelData()); }
Example 5
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 6
Source File: UHPluginListener.java From KTP with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onInventoryClick(InventoryClickEvent ev) { if (ev.getInventory().getName().equals("- Teams -")) { Player pl = (Player) ev.getWhoClicked(); ev.setCancelled(true); if (ev.getCurrentItem().getType() == Material.DIAMOND) { pl.closeInventory(); p.getConversationFactory("teamPrompt").buildConversation(pl).begin(); } else if (ev.getCurrentItem().getType() == Material.BEACON) { pl.closeInventory(); Conversation c = p.getConversationFactory("playerPrompt").buildConversation(pl); c.getContext().setSessionData("nomTeam", ChatColor.stripColor(ev.getCurrentItem().getItemMeta().getDisplayName())); c.getContext().setSessionData("color", p.getTeam(ChatColor.stripColor(ev.getCurrentItem().getItemMeta().getDisplayName())).getChatColor()); c.begin(); } } }
Example 7
Source File: Gizmos.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void click(final InventoryClickEvent event) { if(event.getCurrentItem() == null) return; Player player = (Player) event.getWhoClicked(); if(!purchasingMap.containsKey(player)) return; Material clicked = event.getCurrentItem().getType(); for(Gizmo gizmo : gizmos) { if(clicked == gizmo.getIcon()) { player.closeInventory(); if(gizmo.ownsGizmo(player)) { GizmoUtils.setGizmo(player, gizmo, false); } else if(purchasingMap.containsKey(player)) { player.sendMessage(ChatColor.GOLD + LobbyTranslations.get().t("gizmo.currentlyPurchasing", player)); } else if(gizmo.canPurchase(player)) { GizmoUtils.openShop(player, gizmo); purchasingMap.put(player, gizmo); } else { player.sendMessage(gizmo.getNoPurchaseMessage(player)); } break; } } if(clicked == Material.DIAMOND) { GizmoUtils.purchaseGizmo(player, purchasingMap.get(player)); } else if(clicked == Material.REDSTONE_BLOCK) { GizmoUtils.cancelPurchase(player); } event.setCancelled(true); }
Example 8
Source File: GizmoUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static void openShop(Player player, Gizmo gizmo) { Inventory inventory = Bukkit.createInventory(player, 54, StringUtils.truncate(ChatColor.GOLD + LobbyTranslations.get().t("gizmos.shopFor", player, gizmo.getColoredName(player)), 32)); inventory.setItem(4, Utils.getGhastTear(player, RaindropsListener.raindrops.get(player))); inventory.setItem(22, gizmo.getItemStack(player)); ItemStack accept = new ItemStack(Material.DIAMOND); ItemMeta acceptMeta = accept.getItemMeta(); acceptMeta.setDisplayName(ChatColor.GREEN + LobbyTranslations.get().t("purchase.purchase", player, gizmo.getColoredName(player))); acceptMeta.setLore(Lists.newArrayList(gizmo.getCostText(player))); accept.setItemMeta(acceptMeta); ItemStack exit = new ItemStack(Material.REDSTONE_BLOCK); ItemMeta exitMeta = exit.getItemMeta(); exitMeta.setDisplayName(ChatColor.RED + LobbyTranslations.get().t("purchase.cancel", player)); exit.setItemMeta(exitMeta); for(int i = 3; i < 6; i++) { for(int x = 0; x < 3; x++) { inventory.setItem(i * 9 + x, accept); } for(int y = 6; y < 9; y++) { inventory.setItem(i * 9 + y, exit); } } player.openInventory(inventory); }
Example 9
Source File: PlayerStorage.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public void addGameStartItem() { ItemStack startGame = new ItemStack(Material.DIAMOND, 1); ItemMeta im = startGame.getItemMeta(); im.setDisplayName(BedwarsRel._l(player, "lobby.startgame")); startGame.setItemMeta(im); this.player.getInventory().addItem(startGame); }
Example 10
Source File: TestSoulboundItem.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Test public void testSetSoulbound() { ItemStack item = new CustomItem(Material.DIAMOND, "&cI wanna be soulbound!"); Assertions.assertFalse(SlimefunUtils.isSoulbound(item)); SlimefunUtils.setSoulbound(item, true); Assertions.assertTrue(SlimefunUtils.isSoulbound(item)); Assertions.assertEquals(1, item.getItemMeta().getLore().size()); SlimefunUtils.setSoulbound(item, false); Assertions.assertFalse(SlimefunUtils.isSoulbound(item)); Assertions.assertEquals(0, item.getItemMeta().getLore().size()); }
Example 11
Source File: TestSoulboundItem.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Test public void testDoubleCalls() { ItemStack item = new CustomItem(Material.DIAMOND, "&cI wanna be soulbound!"); SlimefunUtils.setSoulbound(item, true); SlimefunUtils.setSoulbound(item, true); Assertions.assertTrue(SlimefunUtils.isSoulbound(item)); Assertions.assertEquals(1, item.getItemMeta().getLore().size()); SlimefunUtils.setSoulbound(item, false); SlimefunUtils.setSoulbound(item, false); Assertions.assertFalse(SlimefunUtils.isSoulbound(item)); Assertions.assertEquals(0, item.getItemMeta().getLore().size()); }
Example 12
Source File: TestSlimefunItemRegistration.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Test public void testRecipe() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RECIPE_TEST", new CustomItem(Material.DIAMOND, "&dAnother one bites the test")); ItemStack[] recipe = { null, new ItemStack(Material.DIAMOND), null, null, new ItemStack(Material.DIAMOND), null, null, new ItemStack(Material.DIAMOND), null }; item.setRecipe(recipe); item.register(plugin); Assertions.assertArrayEquals(recipe, item.getRecipe()); Assertions.assertThrows(IllegalArgumentException.class, () -> item.setRecipe(null)); Assertions.assertThrows(IllegalArgumentException.class, () -> item.setRecipe(new ItemStack[3])); Assertions.assertThrows(IllegalArgumentException.class, () -> item.setRecipe(new ItemStack[20])); }
Example 13
Source File: VeinMinerListener.java From UhcCore with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onBlockBreak(BlockBreakEvent e){ Player player = e.getPlayer(); if (!player.isSneaking()){ return; } Block block = e.getBlock(); ItemStack tool = player.getItemInHand(); if (block.getType() == UniversalMaterial.GLOWING_REDSTONE_ORE.getType()){ block.setType(Material.REDSTONE_ORE); } if (!UniversalMaterial.isCorrectTool(block.getType(), player.getItemInHand().getType())){ return; } // find all surrounding blocks Vein vein = new Vein(block); vein.process(); player.getWorld().dropItem(player.getLocation().getBlock().getLocation().add(.5,.5,.5), vein.getDrops(getVeinMultiplier(vein.getDropType()))); if (vein.getTotalXp() != 0){ UhcItems.spawnExtraXp(player.getLocation(), vein.getTotalXp()); } // Process blood diamonds. if (isActivated(Scenario.BLOODDIAMONDS) && vein.getDropType() == Material.DIAMOND){ player.getWorld().playSound(player.getLocation(), UniversalSound.PLAYER_HURT.getSound(), 1, 1); if (player.getHealth() < vein.getOres()){ player.setHealth(0); }else { player.setHealth(player.getHealth() - vein.getOres()); } } int newDurability = tool.getDurability()-vein.getOres(); if (newDurability<1) newDurability = 1; tool.setDurability((short) newDurability); player.setItemInHand(tool); }