org.bukkit.Sound Java Examples

The following examples show how to use org.bukkit.Sound. 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: IntruderEffect.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
private void broadcastMessageToAllTownMembers(Town town, boolean entering, String playerName) {
    if (lastMessage.containsKey(playerName)) {
        if (lastMessage.get(playerName) + 60000 > System.currentTimeMillis()) {
            return;
        }
    }
    lastMessage.put(playerName, System.currentTimeMillis());

    for (Player p : Bukkit.getOnlinePlayers()) {
        if (town.getPeople().containsKey(p.getUniqueId())) {
            Civilian civilian = CivilianManager.getInstance().getCivilian(p.getUniqueId());
            String message;
            if (entering) {
                message = LocaleManager.getInstance().getTranslation(civilian.getLocale(),
                        "intruder-enter").replace("$1", playerName).replace("$2", town.getName());
            } else {
                message = LocaleManager.getInstance().getTranslation(civilian.getLocale(),
                        "intruder-exit").replace("$1", playerName).replace("$2", town.getName());
            }
            p.sendMessage(Civs.getPrefix() + ChatColor.RED + message);
            p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 1, 1);
        }
    }
}
 
Example #2
Source File: TinkerListener.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onModifierFail(ModifierFailEvent event) {
	Player player = event.getPlayer();
	ItemStack tool = event.getTool();
	Modifier mod = event.getMod();

	if (MineTinker.getPlugin().getConfig().getBoolean("Sound.OnFail")) {
		player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_BREAK, 1.0F, 0.5F);
	}

	if (!event.isCommand()) {
		ChatWriter.sendActionBar(player,
				LanguageManager.getString("TinkerListener.ModifierFail", player)
						.replace("%mod", mod.getColor() + mod.getName() + ChatColor.WHITE)
						.replace("%tool", ChatWriter.getDisplayName(tool) + ChatColor.WHITE)
						.replace("%cause", event.getFailCause().toString(player)));
		ChatWriter.log(false, player.getDisplayName() + " failed to apply " + mod.getColor()
				+ mod.getName() + ChatColor.GRAY + " " + (modManager.getModLevel(tool, mod) + 1) + " on "
				+ ChatWriter.getDisplayName(tool) + ChatColor.GRAY + " (" + tool.getType().toString() + ") ("
				+ event.getFailCause().toString() + ")");
	}
}
 
Example #3
Source File: DoubleJumpMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) {
  Player player = event.getPlayer();
  Jumper jumper = this.jumpers.get(player);
  if (jumper == null) return;

  if (event.isFlying()) {
    event.setCancelled(true);

    this.setCharge(jumper, 0f);
    this.refreshJump(player);

    // calculate jump
    Vector impulse = player.getLocation().getDirection();

    impulse.setY(0.75 + Math.abs(impulse.getY()) * 0.5);
    impulse.multiply(jumper.kit.power / 3f);
    event.getPlayer().setVelocity(impulse);

    player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_INFECT, 0.5f, 1.8f);
  }
}
 
Example #4
Source File: MagicWorkbench.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void startAnimation(Player p, Block b, Inventory inv, ItemStack output) {
    for (int j = 0; j < 4; j++) {
        int current = j;
        Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
            p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
            p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);

            if (current < 3) {
                p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F);
            }
            else {
                p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
                inv.addItem(output);
            }
        }, j * 20L);
    }
}
 
Example #5
Source File: TimeFirework.java    From NBTEditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public final void onExplode(FireworkPlayerDetails details) {
	final Location loc = details.getFirework().getLocation();
	if (!_changing && loc.getY() > 255) {
		_changing = true;
		final World world = loc.getWorld();
		world.setStorm(false);
		world.playSound(loc, Sound.ENTITY_LIGHTNING_BOLT_THUNDER, 100, 0);
		final BukkitTask[] task = new BukkitTask[1];
		task[0] = Bukkit.getScheduler().runTaskTimer(getPlugin(), new Runnable() {
			@Override
			public void run() {
				long time = world.getFullTime() + 250;
				world.setFullTime(time);
				if (Math.abs(_finalTime - Math.abs(time%24000)) < 500) {
					world.playSound(loc, Sound.ENTITY_LIGHTNING_BOLT_THUNDER, 100, 0);
					task[0].cancel();
					_changing = false;
				}
			}
		}, 0, 5);
	}
}
 
Example #6
Source File: Compat19.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent e) {
    Player p = e.getPlayer();

    // Glide options
    if (!p.hasPermission("redprotect.bypass.glide")) {
        if (!RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).player_glide.allow_elytra) {
            ItemStack item = p.getInventory().getChestplate();
            if (item != null && item.getType().equals(Material.ELYTRA)) {
                PlayerInventory inv = p.getInventory();
                inv.setChestplate(new ItemStack(Material.AIR));
                if (inv.firstEmpty() == -1) {
                    p.getWorld().dropItem(p.getLocation(), item);
                } else {
                    inv.setItem(inv.firstEmpty(), item);
                }
                p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 10, 1);
                RedProtect.get().lang.sendMessage(p, "globallistener.elytra.cantequip");
            }
        }
    }
}
 
Example #7
Source File: AncientAltarListener.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void insertItem(Player p, Block b) {
    ItemStack hand = p.getInventory().getItemInMainHand();
    ItemStack stack = new CustomItem(hand, 1);

    if (p.getGameMode() != GameMode.CREATIVE) {
        ItemUtils.consumeItem(hand, false);
    }

    String nametag = ItemUtils.getItemName(stack);
    Item entity = b.getWorld().dropItem(b.getLocation().add(0.5, 1.2, 0.5), new CustomItem(stack, "&5&dALTAR &3Probe - &e" + System.nanoTime()));
    entity.setVelocity(new Vector(0, 0.1, 0));
    SlimefunUtils.markAsNoPickup(entity, "altar_item");
    entity.setCustomNameVisible(true);
    entity.setCustomName(nametag);
    p.playSound(b.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.3F, 0.3F);
}
 
Example #8
Source File: EffectManager.java    From ce with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void playSound(Location loc, String sound, float volume, float pitch) {
    Sound s;

    try {
        s = Sound.valueOf(sound);
    } catch (IllegalArgumentException ex) {
        try {
            //Try to resolve the 1.8 Sounds
            s = Sound.valueOf(sound.substring(sound.indexOf("_") + 1, sound.length()).replace("_AMBIENT", "").replace("GENERIC_", "").replace("EXPERIENCE_", "").replace("PLAYER_", ""));
        } catch (IllegalArgumentException ex2) {
            return;
        }
    }

    loc.getWorld().playSound(loc, s, volume, pitch);
}
 
Example #9
Source File: PlayerInteractListener.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler 
  public void onInventoryClose(InventoryCloseEvent e) {
  	Inventory inv = e.getInventory();
InventoryView inView = e.getPlayer().getOpenInventory();
  	if (inView.getTitle().equals(new Messaging.MessageFormatter().format("event.crateInv"))) {
  		for (GameMap gMap: GameMap.getPlayableArenas(GameType.ALL)) {
  			for (Crate crate: gMap.getCrates()) {
  				if(crate.getInventory().equals(inv) && inv.getViewers().size() <= 1) {
				if (SkyWarsReloaded.getNMS().getVersion() < 9) {
					e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.valueOf("CHEST_CLOSE"), 1, 1);
				} else {
					e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.BLOCK_CHEST_CLOSE, 1, 1);
				}
  					SkyWarsReloaded.getNMS().playEnderChestAction(e.getPlayer().getWorld().getBlockAt(crate.getLocation()), false);
  					return;
  				}
  			}
  		}
  	} else if (inView.getTitle().contains("chest.yml")) {
  		SkyWarsReloaded.getCM().save(inView.getTitle());
}
  	
  }
 
Example #10
Source File: FreeForAllMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: Crucible.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void runPostTask(Block block, Sound sound, int times) {
    if (!(block.getBlockData() instanceof Levelled)) {
        block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F);
        return;
    }

    block.getWorld().playSound(block.getLocation(), sound, 1F, 1F);
    int level = 8 - times;
    Levelled le = (Levelled) block.getBlockData();
    le.setLevel(level);
    block.setBlockData(le, false);

    if (times < 8) {
        Slimefun.runSync(() -> runPostTask(block, sound, times + 1), 50L);
    }
    else {
        block.getWorld().playSound(block.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
    }
}
 
Example #12
Source File: DoubleJumpMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) {
    Player player = event.getPlayer();
    Jumper jumper = this.jumpers.get(player);
    if(jumper == null) return;

    if(event.isFlying()) {
        event.setCancelled(true);

        this.setCharge(jumper, 0f);
        this.refreshJump(player);

        // calculate jump
        Vector impulse = player.getLocation().getDirection();

        impulse.setY(0.75 + Math.abs(impulse.getY()) * 0.5);
        impulse.multiply(jumper.kit.power / 3f);
        event.getPlayer().applyImpulse(impulse, true);

        player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f);
    }
}
 
Example #13
Source File: NoGUIOpener.java    From CratesPlus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void doOpen(Player player, Crate crate, Location location) {
    if (chestSound) {
        Sound sound = null;
        try {
            sound = Sound.valueOf("CHEST_OPEN");
        } catch (Exception e) {
            try {
                sound = Sound.valueOf("BLOCK_CHEST_OPEN");
            } catch (Exception ee) {
                // This should never happen!
            }
        }
        if (sound != null)
            player.playSound(player.getLocation(), sound, (float) 0.5, 1);
    }
    crate.handleWin(player);
    finish(player);
}
 
Example #14
Source File: PressureChamber.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void craft(Player p, Block b, ItemStack output, Inventory outputInv) {
    for (int i = 0; i < 4; i++) {
        int j = i;

        Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
            p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
            p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
            p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);
            p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4);

            if (j < 3) {
                p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1F, 1F);
            }
            else {
                p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
                outputInv.addItem(output);
            }
        }, i * 20L);
    }
}
 
Example #15
Source File: DeathTracker.java    From CardinalPGM with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerDeath(CardinalDeathEvent event) {
    TrackerDamageEvent tracker = DamageTracker.getEvent(event.getPlayer());
    boolean time = tracker != null && System.currentTimeMillis() - tracker.getTime() <= 7500;
    if (time) {
        if (event.getTrackerDamageEvent() == null) {
            event.setTrackerDamageEvent(tracker);
        }
        if (event.getKiller() == null && tracker.getDamager() != null) {
            event.setKiller(tracker.getDamager().getPlayer());
        }
    }

    for (Player player : Bukkit.getOnlinePlayers()) {
        if (player == event.getPlayer()) {
            player.playSound(player.getLocation(), Sound.ENTITY_IRONGOLEM_DEATH, 1, 1);
        } else if (event.getKiller() != null && player == event.getKiller()) {
            player.playSound(player.getLocation(), Sound.ENTITY_IRONGOLEM_DEATH, 1, 1.35F);
        } else {
            player.playSound(event.getPlayer().getLocation(), Sound.ENTITY_IRONGOLEM_HURT, 1, 1.35F);
        }
    }
}
 
Example #16
Source File: ToolRepair.java    From CardinalPGM with MIT License 6 votes vote down vote up
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    if (!event.isCancelled()) {
        ItemStack item1 = event.getItem().getItemStack();
        if (materials.contains(item1.getType()) && event.getPlayer().getInventory().contains(item1.getType())) {
            for (ItemStack item2 : event.getPlayer().getInventory().getContents()) {
                if (item2 != null && Items.toMaxDurability(item1).equals(Items.toMaxDurability(item2))) {
                    event.setCancelled(true);
                    event.getItem().remove();
                    event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.1F, 1);
                    int result = item2.getDurability() - (item1.getType().getMaxDurability() - item1.getDurability());
                    item2.setDurability((short) (result < 0 ? 0 : result));
                    break;
                }
            }
        }
    }
}
 
Example #17
Source File: InactivePlayerListener.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #18
Source File: RaindropUtil.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void showRaindrops(Player player, int delta, int multiplier, @Nullable BaseComponent reason, boolean show) {
    eventBus.callEvent(new PlayerRecieveRaindropsEvent(player, delta, multiplier, reason));
    if (show) {
        final Audience audience = audiences.get(player);
        audience.sendMessage(raindropsMessage(delta, multiplier, reason));
        player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1.5f);
        raindropDisplay(player, delta);
    }
}
 
Example #19
Source File: Util.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
public void playSound(Player player, Location location, String sound, float volume, float pitch) {
	if (SkyWarsReloaded.getCfg().soundsEnabled()) {
		try {
			if (player != null) {
				player.playSound(location, Sound.valueOf(sound), volume, pitch);
			}
		} catch (IllegalArgumentException | NullPointerException e) {
			SkyWarsReloaded.get().getLogger().info("ERROR: " + sound + " is not a valid bukkit sound. Please check your configs");
		}
	}
}
 
Example #20
Source File: ShieldPlayerModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Recharge the shield to its maximum health. If the player has more absorption than the current
 * shield strength, the excess is preserved.
 */
void recharge() {
  if (shieldHealth < parameters.maxHealth) {
    double delta = parameters.maxHealth - shieldHealth;
    logger.fine("Recharging shield: shield=" + shieldHealth + " delta=" + delta);
    shieldHealth = parameters.maxHealth;
    addAbsorption(delta);
    bukkit.playSound(bukkit.getLocation(), Sound.ORB_PICKUP, 1, 2);
  }
}
 
Example #21
Source File: ChickenGizmo.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
boolean add(Player viewer) {
    if(viewers.add(viewer)) {
        viewer.hidePlayer(player);
        entity.spawn(viewer, player.getLocation());
        viewer.playSound(viewer.getLocation(), Sound.ENTITY_CHICKEN_AMBIENT, 1f, 1f);
        viewer.playSound(viewer.getLocation(), Sound.ENTITY_CHICKEN_HURT, 1f, 1f);
        return true;
    }

    return false;
}
 
Example #22
Source File: Research.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private void playResearchAnimation(Player p) {
    for (int i = 1; i < RESEARCH_PROGRESS.length + 1; i++) {
        int j = i;

        Slimefun.runSync(() -> {
            p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F);
            SlimefunPlugin.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, getName(p)).replace("%progress%", RESEARCH_PROGRESS[j - 1] + "%"));
        }, i * 20L);
    }
}
 
Example #23
Source File: DebugCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void sound_cmd() throws CivException {
	Player player = getPlayer();
	
	if (args.length < 3) {
		throw new CivException("Enter sound enum name and pitch.");
	}
	
	player.getWorld().playSound(player.getLocation(), Sound.valueOf(args[1].toUpperCase()), 1.0f, Float.valueOf(args[2]));
}
 
Example #24
Source File: ItemTransferListener.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    // When this event is fired, the ItemStack in the Item being picked up is temporarily
    // set to the amount that will actually be picked up, while the difference from the
    // actual amount in the stack is available from getRemaining(). When the event returns,
    // the original amount is restored to the stack, meaning that we can't change the amount
    // from inside the event, so instead we replace the entire stack.

    int initialQuantity = event.getItem().getItemStack().getAmount();
    PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(
        event, ItemTransferEvent.Type.PICKUP, event.getPlayer(),
        Optional.empty(),
        Optional.of(new InventorySlot<>(event.getPlayer().getInventory())),
        event.getItem().getItemStack(), event.getItem(),
        initialQuantity, event.getPlayer().getOpenInventory().getCursor()
    );

    this.callEvent(transferEvent);

    int quantity = Math.min(transferEvent.getQuantity(), initialQuantity);

    if(!event.isCancelled() && quantity < initialQuantity) {
        event.setCancelled(true);
        if(quantity > 0) {
            ItemStack stack = event.getItem().getItemStack().clone();
            stack.setAmount(stack.getAmount() - quantity);
            event.getItem().setItemStack(stack);

            stack = stack.clone();
            stack.setAmount(quantity);
            event.getPlayer().getInventory().addItem(stack);
            event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 1);
        }
    }
}
 
Example #25
Source File: TNTMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example #26
Source File: MiddleCollectEffect.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void handleReadData() {
	//TODO: send needed collect packets from middle packet itself after implementing serverside entity position cache
	if (
		(collectorId == cache.getEntityCache().getSelfId()) &&
		(version.getProtocolType() == ProtocolType.PC) &&
		version.isBefore(ProtocolVersion.MINECRAFT_1_9)
	) {
		Player player = connection.getPlayer();
		NetworkEntity entity = cache.getEntityCache().getEntity(entityId);
		if ((entity != null) && (player != null)) {
			switch (entity.getType()) {
				case ITEM: {
					player.playSound(
						player.getLocation(), Sound.ENTITY_ITEM_PICKUP,
						0.2F, (((ThreadLocalRandom.current().nextFloat() - ThreadLocalRandom.current().nextFloat()) * 0.7F) + 1.0F) * 2.0F
					);
					break;
				}
				case EXP_ORB: {
					player.playSound(
						player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP,
						0.2F, (((ThreadLocalRandom.current().nextFloat() - ThreadLocalRandom.current().nextFloat()) * 0.7F) + 1.0F) * 2.0F
					);
					break;
				}
				default: {
					break;
				}
			}
		}
	}
}
 
Example #27
Source File: Camp.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void onControlBlockHit(ControlPoint cp, World world, Player player) {
	world.playSound(cp.getCoord().getLocation(), Sound.ANVIL_USE, 0.2f, 1);
	world.playEffect(cp.getCoord().getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
	
	CivMessage.send(player, CivColor.LightGray+"Damaged Control Block ("+cp.getHitpoints()+" / "+cp.getMaxHitpoints()+")");
	CivMessage.sendCamp(this, CivColor.Yellow+"One of our camp's Control Points is under attack!");
}
 
Example #28
Source File: SoundModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onObjectiveUncomplete(ObjectiveUncompleteEvent event) {
    for (Player player : Bukkit.getOnlinePlayers()) {
        if (Settings.getSettingByName("Sounds") != null && Settings.getSettingByName("Sounds").getValueByPlayer(player).getValue().equalsIgnoreCase("on")) {
            TeamModule team = Teams.getTeamByPlayer(player).get();
            if (team.isObserver() || !team.equals(event.getOldTeam())) {
                player.playSound(player.getLocation(), Sound.BLOCK_PORTAL_TRAVEL, 0.7f, 2f);
            } else {
                player.playSound(player.getLocation(), Sound.ENTITY_BLAZE_DEATH, 0.8f, 0.8f);
            }
        }
    }
}
 
Example #29
Source File: AcidTask.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
public void runAcidItemRemovalTask() {
    if (task != null)
        task.cancel();
    // If items must be removed when dropped in acid
    if (Settings.acidItemDestroyTime > 0) {
        task = new BukkitRunnable() {
            public void run() {
                //plugin.getLogger().info("DEBUG: running task every " + Settings.acidItemDestroyTime);
                List<Entity> entList = ASkyBlock.getIslandWorld().getEntities();
                // Clean up the itemsInWater list
                Set<UUID> newItemsInWater = new HashSet<>();
                for (Entity current: entList) {
                    if (current.getType() != null && current.getType().equals(EntityType.DROPPED_ITEM)) {
                        if ((current.getLocation().getBlock().getType() == Material.WATER)
                                || (current.getLocation().getBlock().getType() == Material.STATIONARY_WATER)) {
                            //plugin.getLogger().info("DEBUG: Item in water " + current.toString());
                            // Check if this item was in the list last time
                            if (itemsInWater.contains(current.getUniqueId())) {
                                // Remove item
                                if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
                                    current.getWorld().playSound(current.getLocation(), Sound.valueOf("FIZZ"), 3F, 3F);
                                } else {
                                    current.getWorld().playSound(current.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 3F, 3F);
                                }
                                current.remove();
                            } else {
                                // Add to list
                                newItemsInWater.add(current.getUniqueId());
                            }
                        }
                    }
                }
                // Clean up any items from the list that do not exist anymore
                itemsInWater = newItemsInWater;
                //plugin.getLogger().info("DEBUG: items in water size = " + itemsInWater.size());
            }
        }.runTaskTimer(plugin, Settings.acidItemDestroyTime, Settings.acidItemDestroyTime);
    }
}
 
Example #30
Source File: AncientAltarTask.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private void abort() {
    running = false;

    for (Block b : pedestals) {
        listener.getAltarsInUse().remove(b.getLocation());
    }

    // This should re-enable altar blocks on craft failure.
    listener.getAltarsInUse().remove(altar.getLocation());
    dropLocation.getWorld().playSound(dropLocation, Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1F, 1F);
    itemLock.clear();
    listener.getAltars().remove(altar);
}