Java Code Examples for org.bukkit.Material#ELYTRA
The following examples show how to use
org.bukkit.Material#ELYTRA .
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: ArmorListener.java From MineTinker with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onElytraDamage(PlayerItemDamageEvent event) { if (!event.getPlayer().isGliding()) { return; } if (event.getItem().getType() != Material.ELYTRA) { return; } if (!modManager.isArmorViable(event.getItem())) { return; } Random rand = new Random(); int chance = rand.nextInt(100); if (chance < ConfigurationManager.getConfig("Elytra.yml").getInt("ExpChanceWhileFlying")) { modManager.addExp(event.getPlayer(), event.getItem(), MineTinker.getPlugin().getConfig().getInt("ExpPerEntityHit")); } }
Example 2
Source File: CommandHandler.java From NyaaUtils with MIT License | 4 votes |
@SubCommand(value = "launch", permission = "nu.launch") public void commandLaunch(CommandSender sender, Arguments args) { if (args.top() == null) { sender.sendMessage(I18n.format("user.launch.usage")); } else { double yaw = args.nextDouble(); double pitch = args.nextDouble(); double speed = args.nextDouble(); int delay = args.nextInt(); int launchSpeed = args.nextInt(); Player p = args.nextPlayerOrSender(); ItemStack chestPlate = p.getInventory().getChestplate(); if (chestPlate == null || chestPlate.getType() != Material.ELYTRA) { sender.sendMessage(I18n.format("user.launch.not_ready_to_fly_sender")); p.sendMessage(I18n.format("user.launch.not_ready_to_fly")); return; } new BukkitRunnable() { private final static int ELYTRA_DELAY = 3; final int d = delay; final Vector v = toVector(yaw, pitch, speed); final Player player = p; int current = 0; boolean stopped = false; @Override public void run() { if (player.isOnline() && !stopped) { if (current < d) { current++; player.setVelocity(v); if (current == ELYTRA_DELAY) { player.setGliding(true); } } else { if (!player.isGliding()) { player.setGliding(true); } player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(launchSpeed)); cancel(); stopped = true; } } else { cancel(); stopped = true; } } }.runTaskTimer(plugin, 1, 1); } }
Example 3
Source File: ElytraEnhanceListener.java From NyaaUtils with MIT License | 4 votes |
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void playerMove(PlayerMoveEvent e) { Player player = e.getPlayer(); if (player.isGliding() && plugin.cfg.elytra_enhance_enabled && !plugin.cfg.disabled_world.contains(player.getWorld().getName()) && player.getLocation().getBlock().isEmpty() && player.getEyeLocation().getBlock().isEmpty() && !disableFuelMode.contains(player.getUniqueId()) && !player.isSneaking()) { if (!FuelMode.contains(player.getUniqueId()) && player.getVelocity().length() >= 0.75 && plugin.fuelManager.getFuelAmount(player, false) > 0) { FuelMode.add(player.getUniqueId()); } if (duration.containsKey(player.getUniqueId()) && duration.get(player.getUniqueId()) >= System.currentTimeMillis()) { player.setVelocity(player.getEyeLocation().getDirection().multiply(plugin.cfg.elytra_max_velocity)); } if (FuelMode.contains(player.getUniqueId()) && player.getVelocity().length() <= plugin.cfg.elytra_min_velocity && player.getLocation().getBlockY() <= plugin.cfg.elytra_boost_max_height && player.getLocation().getPitch() < 50) { if (player.getInventory().getChestplate() != null && player.getInventory().getChestplate().getType() == Material.ELYTRA) { int durability = player.getInventory().getChestplate().getType().getMaxDurability() - ((Damageable)player.getInventory().getChestplate().getItemMeta()).getDamage(); if (durability <= plugin.cfg.elytra_durability_notify) { player.sendMessage(I18n.format("user.elytra_enhance.durability_notify", durability)); } } if (!plugin.fuelManager.useFuel(player)) { FuelMode.remove(player.getUniqueId()); if (duration.containsKey(player.getUniqueId())) { duration.remove(player.getUniqueId()); } return; } else { duration.put(player.getUniqueId(), System.currentTimeMillis() + (plugin.cfg.elytra_power_duration * 1000)); player.setVelocity(player.getEyeLocation().getDirection().multiply(plugin.cfg.elytra_max_velocity)); } int fuelAmount = plugin.fuelManager.getFuelAmount(player, false); if (fuelAmount <= plugin.cfg.elytra_fuel_notify) { player.sendMessage(I18n.format("user.elytra_enhance.fuel_notify", fuelAmount)); } } return; } else if (FuelMode.contains(player.getUniqueId())) { FuelMode.remove(player.getUniqueId()); } }
Example 4
Source File: GUIManager.java From Statz with GNU General Public License v3.0 | 4 votes |
private Material getIconMaterialForSpecificStatistic(Query query, PlayerStat stat) { if (stat == PlayerStat.BLOCKS_BROKEN || stat == PlayerStat.BLOCKS_PLACED) { Material material = Material.getMaterial(query.getValue("block").toString()); if (material != null && material.isItem()) { return material; } } if (stat == PlayerStat.VILLAGER_TRADES) { return Material.getMaterial(query.getValue("trade").toString()); } if (stat == PlayerStat.KILLS_MOBS) { return Material.getMaterial(query.getValue("weapon").toString()); } if (stat == PlayerStat.ITEMS_PICKED_UP || stat == PlayerStat.ITEMS_DROPPED || stat == PlayerStat.ITEMS_CRAFTED || stat == PlayerStat.TOOLS_BROKEN) { return Material.getMaterial(query.getValue("item").toString()); } if (stat == PlayerStat.ITEMS_CAUGHT) { return Material.getMaterial(query.getValue("caught").toString()); } if (stat == PlayerStat.FOOD_EATEN) { return Material.getMaterial(query.getValue("foodEaten").toString()); } if (stat == PlayerStat.DISTANCE_TRAVELLED) { String movementType = query.getValue("moveType").toString(); switch (movementType) { case "SWIM": return Material.TROPICAL_FISH; case "FLY": return Material.BLAZE_POWDER; case "BOAT": return Material.OAK_BOAT; case "MINECART": case "HORSE IN MINECART": return Material.MINECART; case "PIG IN MINECART": case "PIG": return Material.COOKED_PORKCHOP; case "HORSE": return Material.DIAMOND_HORSE_ARMOR; case "FLY WITH ELYTRA": return Material.ELYTRA; case "WALK": return Material.GOLDEN_BOOTS; } } return plugin.getStatisticDescriptionConfig().getIconMaterial(stat); }