Java Code Examples for org.bukkit.Material#GOLD_NUGGET
The following examples show how to use
org.bukkit.Material#GOLD_NUGGET .
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: 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 2
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 3
Source File: TreasureGoblin.java From EliteMobs with GNU General Public License v3.0 | 2 votes |
private static void radialGoldExplosion(Zombie zombie) { int projectileCount = 200; List<Item> itemList = new ArrayList<>(); for (int i = 0; i < projectileCount; i++) { double x = ThreadLocalRandom.current().nextDouble() - 0.5; double y = ThreadLocalRandom.current().nextDouble() / 1.5; double z = ThreadLocalRandom.current().nextDouble() - 0.5; Vector locationAdjuster = new Vector(x, 0, z).normalize(); Location zombieLocation = zombie.getLocation().add(new Vector(0, 0.5, 0)); Location projectileLocation = zombieLocation.add(locationAdjuster); ItemStack visualProjectileItemStack = new ItemStack(Material.GOLD_NUGGET, 1); /* Set custom lore to prevent item stacking */ ItemMeta itemMeta = visualProjectileItemStack.getItemMeta(); List<String> lore = new ArrayList<>(); lore.add("" + ThreadLocalRandom.current().nextDouble() + "" + ThreadLocalRandom.current().nextDouble()); itemMeta.setLore(lore); visualProjectileItemStack.setItemMeta(itemMeta); Item visualProjectile = projectileLocation.getWorld().dropItem(projectileLocation, visualProjectileItemStack); Vector velocity = new Vector(x, y, z).multiply(2); visualProjectile.setVelocity(velocity); visualProjectile.setPickupDelay(Integer.MAX_VALUE); EntityTracker.registerCullableEntity(visualProjectile); itemList.add(visualProjectile); } new BukkitRunnable() { int counter = 0; @Override public void run() { if (itemList.size() == 0) cancel(); Iterator<Item> iterator = itemList.iterator(); while (iterator.hasNext()) { Item item = iterator.next(); if (counter > 20 * 5) { if (item != null && item.isValid()) iterator.remove(); if (item != null && item.isValid()) item.remove(); continue; } if (item == null || !item.isValid() || item.isDead()) iterator.remove(); else if (item.isOnGround()) { iterator.remove(); item.remove(); } else if (goldNuggetDamage(item.getNearbyEntities(0, 0, 0), zombie)) { iterator.remove(); item.remove(); } } if (counter > 20 * 5) cancel(); counter++; } }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1); }
Example 4
Source File: TreasureGoblin.java From EliteMobs with GNU General Public License v3.0 | 2 votes |
private static void goldShotgun(Zombie zombie, Location livingEntityLocation) { int projectileCount = 200; ItemStack visualProjectileItemStack = new ItemStack(Material.GOLD_NUGGET, 1); List<Item> itemList = new ArrayList<>(); for (int i = 0; i < projectileCount; i++) { double x = ThreadLocalRandom.current().nextDouble() * 2 - 1; double y = ThreadLocalRandom.current().nextDouble() * 2 - 1; double z = ThreadLocalRandom.current().nextDouble() * 2 - 1; Location tempLocation = livingEntityLocation.clone(); Location simulatedLocation = tempLocation.add(new Location(tempLocation.getWorld(), 0.0, 1.0, 0.0)) .add(new Location(tempLocation.getWorld(), x, y, z)); Vector toPlayer = simulatedLocation.subtract(zombie.getLocation()).toVector().normalize(); /* Set custom lore to prevent item stacking */ ItemMeta itemMeta = visualProjectileItemStack.getItemMeta(); List<String> lore = new ArrayList<>(); lore.add("" + ThreadLocalRandom.current().nextDouble() + "" + ThreadLocalRandom.current().nextDouble()); itemMeta.setLore(lore); visualProjectileItemStack.setItemMeta(itemMeta); Item visualProjectile = zombie.getLocation().add(new Location(livingEntityLocation.getWorld(), 0.0, 1.0, 0.0)).getWorld().dropItem(zombie.getLocation(), visualProjectileItemStack); visualProjectile.setGravity(false); visualProjectile.setVelocity(toPlayer.multiply(0.9)); visualProjectile.setPickupDelay(Integer.MAX_VALUE); EntityTracker.registerCullableEntity(visualProjectile); itemList.add(visualProjectile); } new BukkitRunnable() { int counter = 0; @Override public void run() { if (itemList.size() == 0) cancel(); Iterator<Item> iterator = itemList.iterator(); while (iterator.hasNext()) { Item item = iterator.next(); if (item == null || !item.isValid() || item.isDead()) iterator.remove(); else if (goldNuggetDamage(item.getNearbyEntities(0.5, 0.5, 0.5), zombie)) { iterator.remove(); item.remove(); } if (counter > 20 * 3) { iterator.remove(); if (item != null) item.remove(); } } if (counter > 20 * 3) cancel(); counter++; } }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1); }