Java Code Examples for org.bukkit.Material#ROTTEN_FLESH

The following examples show how to use org.bukkit.Material#ROTTEN_FLESH . 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: TestMonsterJerky.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public MonsterJerky registerSlimefunItem(SlimefunPlugin plugin, String id) {
    SlimefunItemStack item = new SlimefunItemStack(id, Material.ROTTEN_FLESH, "&5Test Monster Jerky");
    MonsterJerky jerky = new MonsterJerky(TestUtilities.getCategory(plugin, "monster_jerky"), item, RecipeType.NULL, new ItemStack[9]);
    jerky.register(plugin);
    return jerky;
}
 
Example 2
Source File: UHPluginListener.java    From KTP with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerInteract(PlayerInteractEvent ev) {
	if ((ev.getAction() == Action.RIGHT_CLICK_AIR || ev.getAction() == Action.RIGHT_CLICK_BLOCK) && ev.getPlayer().getItemInHand().getType() == Material.COMPASS && p.getConfig().getBoolean("compass")) {
		Player pl = ev.getPlayer();
		Boolean foundRottenFlesh = false;
		for (ItemStack is : pl.getInventory().getContents()) {
			if (is != null && is.getType() == Material.ROTTEN_FLESH) {
				p.getLogger().info(""+is.getAmount());
				if (is.getAmount() != 1) is.setAmount(is.getAmount()-1);
				else { p.getLogger().info("lol"); pl.getInventory().removeItem(is); }
				pl.updateInventory();
				foundRottenFlesh = true;
				break;
			}
		}
		if (!foundRottenFlesh) {
			pl.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Vous n'avez pas de chair de zombie.");
			pl.playSound(pl.getLocation(), Sound.BLOCK_WOOD_STEP, 1F, 1F);
			return;
		}
		pl.playSound(pl.getLocation(), Sound.ENTITY_PLAYER_BURP, 1F, 1F);
		Player nearest = null;
		Double distance = 99999D;
		for (Player pl2 : p.getServer().getOnlinePlayers()) {
			try {	
				Double calc = pl.getLocation().distance(pl2.getLocation());
				if (calc > 1 && calc < distance) {
					distance = calc;
					if (pl2 != pl && !this.p.inSameTeam(pl, pl2)) nearest = pl2.getPlayer();
				}
			} catch (Exception e) {}
		}
		if (nearest == null) {
			pl.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Seul le silence comble votre requĂȘte.");
			return;
		}
		pl.sendMessage(ChatColor.GRAY+"La boussole pointe sur le joueur le plus proche.");
		pl.setCompassTarget(nearest.getLocation());
	}
}