@EventHandler public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { if (!this.allowed.contains(event.getPlayer().getUniqueId())) return; this.allowed.remove(event.getPlayer().getUniqueId()); if (this.hub.getPlayerManager().isBusy(event.getPlayer())) return; event.setCancelled(true); event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().multiply(1.6D).setY(1.0D)); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 1.0F, 1.0F); for (int i = 0; i < 20; i++) ParticleEffect.CLOUD.display(0.5F, 0.15F, 0.5F, 0.25F, 20, event.getPlayer().getLocation().subtract(0.0F, 0.20F, 0.0F)); event.getPlayer().setAllowFlight(false); }
public static void divingBellThread(final Location loc) { new Thread() { @Override public void run() { setPriority(Thread.MIN_PRIORITY); // taskNum = -1; try { World cw = loc.getWorld(); for (int i = 0; i < 8; i++) { sleep(200); if ((i % 2) == 0) { cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 1.0f, 1.2f); } else { cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 1.0f, 1); } } } catch (InterruptedException e) { e.printStackTrace(); } } }.start(); // , 20L); }
@EventHandler public void onInventoryClick1(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); ItemStack is = event.getCurrentItem(); if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) { if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) { event.setCancelled(true); for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) { Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i]; Location location = player.getLocation(); if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) { player.closeInventory(); player.teleport(targetPlayer); player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!"); player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1); player.playEffect(location, Effect.ENDER_SIGNAL, 1); targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1); } } } } }
public static void sonarPingThread(final Location loc) { new Thread() { @Override public void run() { setPriority(Thread.MIN_PRIORITY); // taskNum = -1; try { World cw = loc.getWorld(); for (int i = 0; i < 2; i++) { sleep(400); if( i==0 ) cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 2.0f, 1.6f); else cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 2.0f, 2.0f); } } catch (InterruptedException e) { e.printStackTrace(); } } }.start(); // , 20L); }
public void execute(MatchPlayer player) { checkNotNull(player, "player"); this.sendMessage(player.getBukkit()); if(this.teleportPoint != null) { Location teleport = this.getSafeTeleport(player); if(teleport != null) { player.getBukkit().teleport(teleport); player.getBukkit().setFlying(true); } else { player.sendMessage(" " + ChatColor.YELLOW + ChatColor.BOLD + PGMTranslations.t("tutorial.teleport.unsafe", player)); } player.playSound(Sound.ENTITY_ENDERMEN_TELEPORT, 0.5f, 1.0f); } else { player.playSound(Sound.BLOCK_PISTON_EXTEND, 0.5f, 2.0f); } }
public static void surfaceBellThread(final Location loc) { new Thread() { @Override public void run() { setPriority(Thread.MIN_PRIORITY); // taskNum = -1; try { World cw = loc.getWorld(); for (int i = 0; i < 2; i++) { sleep(300); cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 1.0f, 2); } } catch (InterruptedException e) { e.printStackTrace(); } } }.start(); }
@Override public void notify(Player player, Object extra) { Location eye = player.getEyeLocation(); Vector direction = eye.getDirection().multiply(2); Block source = (Block) extra; Projectile projectile = player.getWorld().spawn(source.getRelative(BlockFace.UP).getLocation().setDirection(direction), LargeFireball.class); projectile.setShooter(player); projectile.setVelocity(direction); Inventory inv = player.getInventory(); if (inv.contains(Material.TNT)) { int slot = inv.first(Material.TNT); ItemStack ammo = inv.getItem(slot); int amount = ammo.getAmount(); if (amount > 1) { ammo.setAmount(amount - 1); inv.setItem(slot, ammo); } else { inv.setItem(slot, null); } projectile.setCustomName("recreator.structure.turret.tnt"); } AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true); }
/** * Give old player enchants on head eating * * @param event Event */ @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM || event.getItem().getDurability() != 3 || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)) return; SkullMeta skullMeta = (SkullMeta)event.getItem().getItemMeta(); List<PotionEffect> effectList = this.effects.get(skullMeta.getOwner()); if (effectList != null) { effectList.forEach(event.getPlayer()::addPotionEffect); this.effects.remove(skullMeta.getOwner()); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 1F, 1F); } }
private void enforce(Punishment punishment, Player punished) { final Audience audience = audiences.get(punished); switch(punishment.type()) { case WARN: audience.playSound(new BukkitSound(Sound.ENTITY_ENDERDRAGON_GROWL, 1f, 1f)); punishmentFormatter.warning(punishment) .feed((title, subtitle) -> audience.showTitle(title, subtitle, 5, 200, 10)); break; case KICK: case BAN: playerServerChanger.kickPlayer(punished, punishmentFormatter.screen(punishment, punished)); break; } punishmentService.update(punishment._id(), (PunishmentDoc.Enforce) () -> true); }
public static void playSound(InventoryClickEvent event) { if (event.getSlot() == -999) { return; } HumanEntity human = event.getWhoClicked(); if (!(human instanceof Player)) { return; } ItemStack clicked = event.getCurrentItem(); if (clicked == null || clicked.getType() == Material.AIR) { return; } if (clicked.getType() == Material.BARRIER) { ((Player) human).playSound(human.getLocation(), Sound.BLOCK_ANVIL_PLACE, 1, 1); } else if (clicked != null && !clicked.equals(PLACEHOLDER)) { ((Player) human).playSound(human.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1); } }
@Override public void playSound(Player p) { RScheduler.schedule(plugin, new Runnable() { int counter = 0; public void run() { if (p == null || !p.isOnline()) return; if (Math.random() < 0.5) RSound.playSound(p, Sound.ENTITY_ZOMBIE_AMBIENT); else RSound.playSound(p, Sound.ENTITY_ZOMBIE_STEP); counter++; if (counter < 10) RScheduler.schedule(plugin, this, RTicks.seconds(0.5)); } }); }
@Override public void playSound(Player p) { RScheduler.schedule(plugin, new Runnable() { int counter = 0; public void run() { if (p == null || !p.isOnline()) return; if (Math.random() < 0.5) RSound.playSound(p, Sound.ENTITY_LIGHTNING_THUNDER); else RSound.playSound(p, Sound.ENTITY_SKELETON_AMBIENT); counter++; if (counter < 10) RScheduler.schedule(plugin, this, RTicks.seconds(0.5)); } }); }
@Override public void playSound(Player p) { RScheduler.schedule(plugin, new Runnable() { int counter = 0; public void run() { if (p == null || !p.isOnline()) return; RSound.playSound(p, Sound.ENTITY_SKELETON_STEP); RSound.playSound(p, Sound.ENTITY_SKELETON_AMBIENT); counter++; if (counter < 10) RScheduler.schedule(plugin, this, RTicks.seconds(0.5)); } }); }
@Override public void handleDeath(Player player, Location location, String deathMessage) { if (location != null) { player.teleport(location.clone().add(0, 3, 0)); } this.startSpectating(player); this.sendMessage(deathMessage); if (!deathMessage.contains("left the match")) { playSound(Sound.AMBIENCE_THUNDER, 10.0f); ManagerHandler.getEntityHider().hideEntity(this.player1, this.player2); ManagerHandler.getEntityHider().hideEntity(this.player2, this.player1); } Cache.storeInventory(player, true); if (player == this.player1) { this.endMatch(this.player2, this.player1); } if (player == this.player2) { this.endMatch(this.player1, this.player2); } }
protected boolean priorityKick(MatchPlayer joining) { if(!jmm.canPriorityKick(joining)) return false; List<MatchPlayer> kickable = new ArrayList<>(); for(MatchPlayer player : getMatch().getParticipatingPlayers()) { if(!jmm.canPriorityKick(player)) kickable.add(player); } if(kickable.isEmpty()) return false; MatchPlayer kickMe = kickable.get(getMatch().getRandom().nextInt(kickable.size())); kickMe.sendWarning(new TranslatableComponent("gameplay.ffa.kickedForPremium"), false); kickMe.sendMessage(Links.shopPlug("shop.plug.ffa.neverKicked")); kickMe.playSound(Sound.ENTITY_VILLAGER_HURT, kickMe.getBukkit().getLocation(), 1, 1); getMatch().setPlayerParty(kickMe, getMatch().getDefaultParty()); return true; }
@EventHandler public void onMove(PlayerMoveEvent e){ Player p = e.getPlayer(); WCUser user = WCSurvival.getPlayer(p); Block launch = p.getWorld().getBlockAt(p.getLocation()).getRelative(BlockFace.DOWN); Block base = launch.getRelative(BlockFace.DOWN); if (!e.getFrom().equals(e.getTo())){ if (WCServer.afkMode.contains(user)) user.toggleAFK(); } if(launch.getType() == Material.SPONGE && base.getType() == Material.DIAMOND_BLOCK){ p.setVelocity(p.getLocation().getDirection().multiply(3)); p.setVelocity(new Vector(p.getVelocity().getX(), 1.0D, p.getVelocity().getZ())); WCServer.getUser(p).sendSound(Sound.ENTITY_IRONGOLEM_ATTACK); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onAttack(EntityDamageByEntityEvent event) { if(event.isCancelled()) return; if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK) { Player player = (Player)event.getDamager(); ItemStack mainItem = player.getInventory().getItemInMainHand(); LivingEntity enemy = (LivingEntity)event.getEntity(); Random rand = new Random(); if(mainItem.getType() == Material.GOLD_AXE) { enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false)); enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false)); enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F); } } }
private void handleFreeze(Player player, Rune rune) { Player target = Utility.getTargetPlayer(player, 10); if(target == null || !Utility.canAttack(player, target)) { return; } LineEffect eff = new LineEffect(plugin.getEffectManager()); eff.setEntity(player); eff.setTargetEntity(target); eff.particle = ParticleEffect.SNOW_SHOVEL; eff.start(); target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 6)); target.playSound(target.getLocation(), Sound.ENTITY_SNOWMAN_DEATH, 1F, 1F); player.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_APPLY.toString() .replaceAll("%s", rune.getName())); target.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_FROZEN.toString() .replaceAll("%s", player.getName())); finish(player, false); }
@EventHandler(priority = EventPriority.HIGH) public void upElevator(PlayerMoveEvent e) { Player p = e.getPlayer(); Block b = e.getTo().getBlock().getRelative(BlockFace.DOWN); if (p.hasPermission("ironelevators.use") && e.getFrom().getY() < e.getTo().getY() && b.getType() == elevatorMaterial) { b = b.getRelative(BlockFace.UP, minElevation); int i = maxElevation; while (i > 0 && !( b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent() ) ) { i--; b = b.getRelative(BlockFace.UP); } if (i > 0) { Location l = p.getLocation(); l.setY(l.getY() + maxElevation + 3 - i); p.teleport(l); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1); } } }
/** * Gives players the resources necessary to enchant when they start playing in the game. * * @param event The event */ @EventHandler public void onPlayerInit(PlayerInitEvent event) { Player player = event.getPlayer(); Inventory inventory = player.getInventory(); inventory.addItem( new ItemStack(Material.ENCHANTMENT_TABLE, 64), new ItemStack(Material.BOOKSHELF, 64), new ItemStack(Material.BOOKSHELF, 64), new ItemStack(Material.LAPIS_BLOCK, 64) ); if (anvils) { inventory.addItem(new ItemStack(Material.ANVIL, 64)); } player.setLevel(30); player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1); }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender instanceof ConsoleCommandSender) { return true; } Player player = (Player) sender; Location location = player.getLocation(); if (label.equalsIgnoreCase("tphere")) { if (!(args.length == 0)) { if (args.length == 0) { player.sendMessage(ChatColor.RED + "Please specify the player you want to teleport to or use /teleport help for more info."); TeleportHereMenu.newInventory(sender); return true; } if (!sender.hasPermission("core.tp")) { player.sendMessage(ChatColor.RED + "Sorry, you need core.tp permission to execute /tphere."); return true; } if (args[0].equals(player.getName())) { player.sendMessage(ChatColor.RED + "Lol, you cannot teleport to yourself dummy."); return true; } Player target1 = Bukkit.getServer().getPlayer(args[1]); if (target1 == null) { player.sendMessage(ChatColor.RED + "Can't find user specified."); return true; } target1.teleport(player); player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + target1.getDisplayName() + ChatColor.YELLOW + " to you!"); player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1); player.playEffect(location, Effect.ENDER_SIGNAL, 1); target1.playEffect(location, Effect.ENDER_SIGNAL, 1); return true; } } return false; }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void handleInstantActivation(BlockPlaceEvent event) { if(this.properties.instantIgnite && event.getBlock().getType() == Material.TNT) { World world = event.getBlock().getWorld(); TNTPrimed tnt = world.spawn(BlockUtils.base(event.getBlock()), TNTPrimed.class); if(this.properties.fuse != null) { tnt.setFuseTicks(this.getFuseTicks()); } if(this.properties.power != null) { tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield } if(callPrimeEvent(tnt, event.getPlayer(), true)) { // Only cancel the block placement if the prime event is NOT cancelled. // If priming is cancelled, the block is allowed to stay (unless some // other handler has already cancelled the place event). event.setCancelled(true); world.playSound(tnt.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); ItemStack inHand = event.getItemInHand(); if(inHand.getAmount() == 1) { inHand = null; } else { inHand.setAmount(inHand.getAmount() - 1); } event.getPlayer().getInventory().setItem(event.getHand(), inHand); } } }
@GameEvent public void onStep(@Nonnull PlayerInteractEvent event) { if (event.getAction() == Action.PHYSICAL) { if (event.getClickedBlock().getType() != Material.WOOD_PLATE && event.getClickedBlock().getType() != Material.STONE_PLATE) { return; } if (event.isCancelled()) { return; } double strength = 1.5; double up = 1; if (event.getClickedBlock().getRelative(BlockFace.DOWN, 2).getState() instanceof Sign) { Sign sign = (Sign) event.getClickedBlock().getRelative(BlockFace.DOWN, 2).getState(); if (sign.getLine(0).contains("[Boom]")) { try { strength = Double.parseDouble(sign.getLine(1)); up = Double.parseDouble(sign.getLine(2)); } catch (final Exception ex) { log.warning("Invalid boom sign at " + sign.getLocation()); } } } event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERDRAGON_SHOOT, 10.0F, 1.0F); event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.SMOKE, 10); Vector v = event.getPlayer().getLocation().getDirection().multiply(strength / 2).setY(up / 2); event.getPlayer().setVelocity(v); event.setCancelled(true); } }
public void playerSpeaksOnCellPhone(Player p, String message) { PlayerObject pObject = main.getPlayerManager().getPlayer(p); if (pObject == null) return; if (pObject.getContacts().size() == 0) { p.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&7You have no contacts. Add some with &e/mtr add contact <name>")); return; } if (pObject.getCurrentCellPhoneRecipient().equalsIgnoreCase(p.getName())) { p.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&7You can't call yourself, what are you doing?")); return; } Player recipient = main.getServer().getPlayer(pObject.getCurrentCellPhoneRecipient()); // Recipient not online, send as text message if (recipient == null) { main.getTextMessageManager().addTextMessage(p.getName(), pObject.getCurrentCellPhoneRecipient(), message); p.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&7Contact is not online. Message sent as text.")); } else { if (main.getPlayerManager().getPlayer(recipient).receiveNotificationSound()) recipient.playSound(recipient.getLocation(), Sound.BLOCK_NOTE_CHIME, 5, 1); recipient.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&8&l[&e" + p.getName() + "&8&l] &7" + message)); p.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&7Called &e" + pObject.getCurrentCellPhoneRecipient() + "&7: " + message)); } }
@EventHandler public void onWalkieTalkieChat(AsyncPlayerChatEvent e) { // Comparator as temporary walkie talkie if (e.getPlayer().getInventory().getItemInMainHand().getType() != Material.REDSTONE_COMPARATOR) return; e.setCancelled(true); Player sender = e.getPlayer(); Frequency senderFreq = main.getPlayerManager().getPlayer(sender).getCurrentWalkieTalkieFrequency(); // Search for players with walkie talkie in their inv. for (Player p : sender.getWorld().getPlayers()) { if (p.getInventory().contains(Material.REDSTONE_COMPARATOR)) { // Are walkie talkies on the same frequency. Player recipient = p; Frequency recipientFreq = main.getPlayerManager().getPlayer(recipient) .getCurrentWalkieTalkieFrequency(); if (recipientFreq.getChannel() == senderFreq.getChannel()) { if (p != recipient) { if (main.getPlayerManager().getPlayer(recipient).receiveNotificationSound()) p.playSound(recipient.getLocation(), Sound.BLOCK_NOTE_CHIME, 5, 1); } p.sendMessage(MortuusTerraChat.WALKIETALKIE_PREFIX + color("&8&l[&e" + sender.getName() + "&8&l] &eCh." + senderFreq.getChannel() + ">&7 " + e.getMessage())); } } } }
@Override public Object parse(Class<?> type, List<String> args) throws ParseException { Sound sound = CompatibleSound.get(args.get(0)); if (sound != null) return sound; else throw new ParseException(args.get(0), "Sound"); }
/** * Make all loaded slime balls bounce if they're in a slime chunk. */ private void bounceSlimes() { Core.getMainWorld().getEntities().stream().filter(entity -> entity instanceof Item) .map(e -> (Item)e).filter(i -> isSlimeChunk(i.getLocation().getChunk())).filter(Entity::isValid) .filter(i -> i.getItemStack().getType() == Material.SLIME_BALL).forEach(slime -> { slime.getWorld().playSound(slime.getLocation(), Sound.ENTITY_SLIME_JUMP, .5F, 1F); slime.setVelocity(new Vector(0, .33F, 0)); }); }
@Override public PlaySoundAction create(Plugin plugin, Map<String, Object> pars) { return new PlaySoundAction( plugin, (Sound) pars.get("sound"), PlaceholderUtil.parseFloat(pars.get("volume")), PlaceholderUtil.parseFloat(pars.get("pitch")) ); }
@EventHandler public void onPlayerLevelUp(PlayerLevelUpEvent event) { Player player = event.getPlayerContext().getPlayer(); player.sendMessage(ChatColor.AQUA + "" + ChatColor.STRIKETHROUGH + "----------------------------------------"); player.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + " Level up!" + ChatColor.GREEN + " You are now level " + ChatColor.RED + event.getToLevel()); player.sendMessage(ChatColor.AQUA + "" + ChatColor.STRIKETHROUGH + "----------------------------------------"); player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1); }
@Override public void run(PlayerInteractEvent evt) { Player player = evt.getPlayer(); if (CooldownTicker.can(this, player) || evt.getItem().getItemMeta().getLore().contains("§6高速射击")) { Inventory inv = player.getInventory(); if (!inv.contains(Material.SULPHUR)) { AzureAPI.log(player, "你没有弹药! 需要 " + ChatColor.RED + "火药" + ChatColor.GOLD + " 作为弹药"); AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK); return; } int slot = inv.first(Material.SULPHUR); ItemStack ammo = inv.getItem(slot); int amount = ammo.getAmount(); if (amount > 1) { ammo.setAmount(amount - 1); inv.setItem(slot, ammo); } else { inv.setItem(slot, null); } Location eye = player.getEyeLocation(); Vector direction = eye.getDirection().multiply(2); Projectile projectile = player.getWorld().spawn(eye.add(direction), Fireball.class); projectile.setShooter(player); projectile.setVelocity(direction); AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true); CooldownTicker.cooldown(this, player, TimeUnit.SECONDS, 3); } else { AzureAPI.playSound(player, Sound.UI_BUTTON_CLICK); AzureAPI.log(player, "冷却时间还没有结束呢!"); } }
@Override protected void onTick() { if(isCancelled()) return; int amountParticipating = teamManagerModule.getAmountParticipating(); if (amountParticipating < REQUIRED_PLAYERS) { int needed = REQUIRED_PLAYERS - amountParticipating; getBossBar().setProgress(1); getBossBar().setTitle(ChatColor.RED + "Waiting for " + ChatColor.AQUA + needed + ChatColor.RED + " more player" + (needed == 1 ? "" : "s") + " to join"); getBossBar().setColor(BarColor.RED); setTimeLeft(getTimeMax()); return; } getBossBar().setProgress((getTimeMax() - getTimeLeft()) / getTimeMax()); if (getTimeLeft() % 20 == 0) { getBossBar().setColor(BarColor.GREEN); getBossBar().setTitle(ChatColor.GREEN + "Match starting in " + ChatColor.DARK_RED + getTimeLeftSeconds() + ChatColor.GREEN + " second" + (getTimeLeftSeconds() > 1 ? "s" : "")); if (getTimeLeftSeconds() <= 3) { for (Player player : Bukkit.getOnlinePlayers()) { player.playSound(player.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1); if (!TGM.get().getModule(TeamManagerModule.class).getSpectators().containsPlayer(player)) { player.sendTitle(ChatColor.YELLOW.toString() + getTimeLeftSeconds(), "", 0, 5, 15); } } } } }
@EventHandler public void onPetFeed(PlayerInteractEntityEvent event) { Player player = event.getPlayer(); ItemStack itemInHand = player.getEquipment().getItemInMainHand(); if (!InventoryManager.playerIsLoaded(player)) { return; } PlayerWrapper playerWrapper = InventoryManager.get(player); if (PetFood.isFoodItem(itemInHand) && playerWrapper.hasPet() && event.getRightClicked() == playerWrapper.getPet()) { event.setCancelled(true); LivingEntity pet = (LivingEntity) event.getRightClicked(); PetFood petFood = PetManager.getFoodFromItem(itemInHand); if (pet.getHealth() == pet.getMaxHealth() || petFood == null || !petFood.canBeEaten(playerWrapper.getPet())) { return; } double health = pet.getHealth() + petFood.getValue(); pet.setHealth(health < pet.getMaxHealth() ? health : pet.getMaxHealth()); itemInHand.setAmount(itemInHand.getAmount() - 1); player.getEquipment().setItemInMainHand(itemInHand); pet.getWorld().playSound(pet.getLocation(), Sound.ENTITY_GENERIC_EAT, 1.0f, (float) (1.0 + Math.random() * 0.4)); } }
public Grenade(int id){ super(id, Material.FIREWORK_CHARGE, "Granada", lore); setParticle(ParticleEffect.SMOKE_NORMAL); setSound(Sound.BLOCK_REDSTONE_TORCH_BURNOUT); setAmmo(new Grenades()); setShootCooldown(1000); }
public Bazooka(int id) { super(id, Material.GOLD_SPADE, "Bazooka", lore); setSound(Sound.BLOCK_ANVIL_BREAK); setAmmo(new Grenades()); setShootCooldown(1750); }
private void claimPoint(Player player, Location location) { if(!this.currentLocations.containsKey(location)) return; final PointType pointType = (PointType) this.currentLocations.get(location)[0]; final FallingBlock entity = (FallingBlock) this.currentLocations.get(location)[1]; this.currentLocations.remove(location); entity.getWorld().playSound(entity.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1f, 1f); player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1.1f); entity.remove(); ScoreSidebar scoreSidebar = ((ScoreSidebar) this.getSidebar()); scoreSidebar.setScore(player, (scoreSidebar.getScore(player) + pointType.getPoints())); if(pointType == PointType.SUPER_BOOST) { player.setVelocity(new org.bukkit.util.Vector(0, 1.7D, 0)); } this.spawnPoint(); }
@Override public void tick() { final Duration timeout = config.timeout(); final Duration warning = config.warning(); Instant now = Instant.now(); Instant kickTime = now.minus(timeout); Instant warnTime = warning == null ? null : now.minus(warning); Instant lastWarnTime = warning == null || lastCheck == null ? null : lastCheck.minus(warning); // Iterate over a copy, because kicking players while iterating the original // OnlinePlayerMapAdapter throws a ConcurrentModificationException for(Map.Entry<Player, Instant> entry : lastActivity.entrySetCopy()) { Player player = entry.getKey(); Instant time = entry.getValue(); if(time.isBefore(kickTime)) { playerServerChanger.kickPlayer(player, CommonsTranslations.get().t("afk.kick", player)); } else if(warnTime != null && time.isAfter(lastWarnTime) && !time.isAfter(warnTime)) { player.playSound(player.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1); player.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD + CommonsTranslations.get().t( "afk.warn", player, ChatColor.AQUA.toString() + ChatColor.BOLD + timeout.minus(warning).getSeconds() + ChatColor.RED + ChatColor.BOLD )); } } lastCheck = now; }
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (!this.isParkouring(event.getPlayer().getUniqueId())) return; event.setCancelled(true); if (event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == Material.IRON_PLATE && event.getClickedBlock().getLocation().equals(this.minusFloor)) { event.getPlayer().teleport(this.fail); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_PISTON_CONTRACT, 1.0F, 1.0F); } }
public static String getSoundsText() { String s = ""; for (final Sound sound : Sound.values()) { if (s.isEmpty()) s += sound.name().toLowerCase(); else s += ", " + sound.name().toLowerCase(); } return s; }
@Override public void run() { if (plugin.getGm().getPlaying().size() < plugin.getAm().getMinPlayers()) { plugin.getGm().setCheckStart(true); plugin.getServer().getOnlinePlayers().forEach(pl -> pl.setLevel(0)); GameState.setState(GameState.LOBBY); cancel(); return; } plugin.getGm().getPlaying().forEach(p -> { NexusSiege.getPlayer(p).sendActionBar("&a&lEl juego empieza en: " + count); }); switch (count) { case 30: Utils.broadcastMsg("&7El juego empezará en &c30 &7segundos"); break; case 5: case 4: case 3: case 2: case 1: Utils.broadcastMsg("&7El juego empezará en &c" + count + " &7segundos"); plugin.getGm().getPlaying().forEach(p -> p.playSound(p.getLocation(), Sound.NOTE_PLING, 1F, 1F)); break; case 0: new GameTask(plugin).runTaskTimer(plugin, 0, 20); cancel(); break; } --count; }