org.bukkit.scheduler.BukkitRunnable Java Examples
The following examples show how to use
org.bukkit.scheduler.BukkitRunnable.
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: SitListener.java From NyaaUtils with MIT License | 6 votes |
@EventHandler public void onDismount(EntityDismountEvent event) { if (event.getDismounted() instanceof ArmorStand) { ArmorStand armorStand = (ArmorStand) event.getDismounted(); if (armorStand.hasMetadata(metadata_key)) { for (Entity p : armorStand.getPassengers()) { if (p.isValid()) { Location loc = safeLocations.get(p.getUniqueId()); safeLocations.remove(p.getUniqueId()); new BukkitRunnable() { @Override public void run() { if (p.isValid() && loc != null) { p.teleport(loc); } } }.runTask(plugin); } } } armorStand.remove(); } }
Example #2
Source File: GunUtil.java From QualityArmory with GNU General Public License v3.0 | 6 votes |
public static void addRecoil(final Player player, final Gun g) { if (g.getRecoil() == 0) return; if (g.getFireRate() >= 4) { if (highRecoilCounter.containsKey(player.getUniqueId())) { highRecoilCounter.put(player.getUniqueId(), highRecoilCounter.get(player.getUniqueId()) + g.getRecoil()); } else { highRecoilCounter.put(player.getUniqueId(), g.getRecoil()); new BukkitRunnable() { @Override public void run() { if (QAMain.hasProtocolLib && QAMain.isVersionHigherThan(1, 13) && !QAMain.hasViaVersion) { addRecoilWithProtocolLib(player, g, true); } else addRecoilWithTeleport(player, g, true); } }.runTaskLater(QAMain.getInstance(), 3); } } else { if (QAMain.hasProtocolLib && QAMain.isVersionHigherThan(1, 13)) { addRecoilWithProtocolLib(player, g, false); } else addRecoilWithTeleport(player, g, false); } }
Example #3
Source File: SimpleImageLoader.java From HoloAPI with GNU General Public License v3.0 | 6 votes |
private ImageGenerator prepareUrlGenerator(final CommandSender sender, final String key) { UnloadedImageStorage data = this.URL_UNLOADED.get(key); HoloAPI.LOG.info("Loading custom URL image of key " + key); this.URL_UNLOADED.remove(key); final ImageGenerator g = new ImageGenerator(key, data.getImagePath(), data.getImageHeight(), data.getCharType(), false, data.requiresBorder()); new BukkitRunnable() { @Override public void run() { g.loadUrlImage(); if (sender != null) { Lang.IMAGE_LOADED.send(sender, "key", key); } HoloAPI.LOG.info("Custom URL image '" + key + "' loaded."); KEY_TO_IMAGE_MAP.put(key, g); } }.runTaskAsynchronously(HoloAPI.getCore()); return g; }
Example #4
Source File: Door.java From ZombieEscape with GNU General Public License v2.0 | 6 votes |
/** * Opens the Door Open at a given sign. The * door will stay open for 10 seconds, then * will close once more. * * @param plugin the plugin instance * @param sign the sign that was interacted with */ public void open(Plugin plugin, final Sign sign) { section.clear(); sign.setLine(2, Utils.color("&4&lRUN!")); sign.update(); if (nukeroom) { Messages.NUKEROOM_OPEN_FOR.broadcast(); } else { Messages.DOOR_OPENED.broadcast(); } new BukkitRunnable() { @Override public void run() { activated = false; section.restore(); sign.setLine(1, "Timer: " + seconds + "s"); sign.setLine(2, "CLICK TO"); sign.setLine(3, "ACTIVATE"); sign.update(); } }.runTaskLater(plugin, 20 * 10); }
Example #5
Source File: THologramHandler.java From TabooLib with MIT License | 6 votes |
public static void learn(Player player) { NMS.handle().spawn(player.getLocation(), ArmorStand.class, c -> { learnTarget = c; learnTarget.setMarker(true); learnTarget.setVisible(false); learnTarget.setCustomName(" "); learnTarget.setCustomNameVisible(true); learnTarget.setBasePlate(false); }); reset(); new BukkitRunnable() { @Override public void run() { THologramSchedule schedule = queueSchedule.peek(); if (schedule == null) { cancel(); learnTarget.remove(); } else if (schedule.check()) { currentSchedule = queueSchedule.poll(); currentSchedule.before(); } } }.runTaskTimer(TabooLib.getPlugin(), 1, 1); }
Example #6
Source File: EventExecutor.java From PlayerSQL with GNU General Public License v2.0 | 6 votes |
private void receiveContents(Player player, PlayerSqlProtocol packet) { main.debug("recv data_buf"); DataSupply dataSupply = (DataSupply) packet; if (dataSupply.getBuf() == null || dataSupply.getBuf().length == 0 || !group.equals(dataSupply.getGroup())) { return; } PlayerData data = PlayerDataHelper.decode(dataSupply.getBuf()); BukkitRunnable pend = (BukkitRunnable) pending.remove(dataSupply.getId()); if (pend == null) { main.debug("pending received data_buf"); pending.put(dataSupply.getId(), data); } else { main.debug("process received data_buf"); pend.cancel(); main.run(() -> { manager.pend(player, data); runAsync(() -> manager.updateDataLock(dataSupply.getId(), true)); }); } }
Example #7
Source File: Main.java From Crazy-Crates with MIT License | 6 votes |
@EventHandler public void onJoin(PlayerJoinEvent e) { Player player = e.getPlayer(); cc.setNewPlayerKeys(player); cc.loadOfflinePlayersKeys(player); new BukkitRunnable() { @Override public void run() { if (player.getName().equals("BadBones69")) { player.sendMessage(Methods.getPrefix() + Methods.color("&7This server is running your Crazy Crates Plugin. " + "&7It is running version &av" + Methods.plugin.getDescription().getVersion() + "&7.")); } if (player.isOp() && updateChecker) { Methods.hasUpdate(player); } } }.runTaskLaterAsynchronously(this, 40); }
Example #8
Source File: DoubleDamageEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
@Override public void doEvent() { if (gMap.getMatchState() == MatchState.PLAYING) { this.fired = true; sendTitle(); gMap.setDoubleDamageEnabled(true); if (length != -1) { br = new BukkitRunnable() { @Override public void run() { endEvent(false); } }.runTaskLater(SkyWarsReloaded.get(), length * 20L); } } }
Example #9
Source File: DatabaseManager.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
/** * Queued database manager. Use queue to solve run SQL make server lagg issue. * * @param plugin plugin main class * @param db database */ public DatabaseManager(@NotNull QuickShop plugin, @NotNull Database db) { this.plugin = plugin; this.warningSender = new WarningSender(plugin, 600000); this.database = db; this.useQueue = plugin.getConfig().getBoolean("database.queue"); if (!useQueue) { return; } try { task = new BukkitRunnable() { @Override public void run() { plugin.getDatabaseManager().runTask(); } }.runTaskTimerAsynchronously(plugin, 1, plugin.getConfig().getLong("database.queue-commit-interval") * 20); } catch (IllegalPluginAccessException e) { Util.debugLog("Plugin is disabled but trying create database task, move to Main Thread..."); plugin.getDatabaseManager().runTask(); } }
Example #10
Source File: Tools.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
public static void applyBleed(final Player target, final int bleedDuration) { target.sendMessage(ChatColor.RED + "You are Bleeding!"); target.setMetadata("ce.bleed", new FixedMetadataValue(Main.plugin, null)); new BukkitRunnable() { int seconds = bleedDuration; @Override public void run() { if (seconds >= 0) { if (!target.isDead() && target.hasMetadata("ce.bleed")) { target.damage(1 + (((Damageable) target).getHealth() / 15)); seconds--; } else { target.removeMetadata("ce.bleed", Main.plugin); this.cancel(); } } else { target.removeMetadata("ce.bleed", Main.plugin); target.sendMessage(ChatColor.GREEN + "You have stopped Bleeding!"); this.cancel(); } } }.runTaskTimer(Main.plugin, 0l, 20l); }
Example #11
Source File: XParticle.java From XSeries with MIT License | 6 votes |
/** * A sin/cos based smoothly animated explosion wave. * Source: https://www.youtube.com/watch?v=n8W7RxW5KB4 * * @param rate the distance between each cos/sin lines. * @since 1.0.0 */ public static void explosionWave(JavaPlugin plugin, double rate, ParticleDisplay display, ParticleDisplay secDisplay) { new BukkitRunnable() { final double addition = Math.PI * 0.1; final double rateDiv = Math.PI / rate; double times = Math.PI / 4; public void run() { times += addition; for (double theta = 0; theta <= PII; theta += rateDiv) { double x = times * Math.cos(theta); double y = 2 * Math.exp(-0.1 * times) * Math.sin(times) + 1.5; double z = times * Math.sin(theta); display.spawn(x, y, z); theta = theta + Math.PI / 64; x = times * Math.cos(theta); //y = 2 * Math.exp(-0.1 * times) * Math.sin(times) + 1.5; z = times * Math.sin(theta); secDisplay.spawn(x, y, z); } if (times > 20) cancel(); } }.runTaskTimerAsynchronously(plugin, 0L, 1L); }
Example #12
Source File: PluginMessageMessenger.java From LuckPerms with MIT License | 6 votes |
@Override public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(outgoingMessage.asEncodedString()); byte[] data = out.toByteArray(); new BukkitRunnable() { @Override public void run() { Collection<? extends Player> players = PluginMessageMessenger.this.plugin.getBootstrap().getServer().getOnlinePlayers(); Player p = Iterables.getFirst(players, null); if (p == null) { return; } p.sendPluginMessage(PluginMessageMessenger.this.plugin.getBootstrap(), CHANNEL, data); cancel(); } }.runTaskTimer(this.plugin.getBootstrap(), 1L, 100L); }
Example #13
Source File: AttackWeb.java From EliteMobs with GNU General Public License v3.0 | 6 votes |
@EventHandler public void attackWeb(EntityDamageByEntityEvent event) { EliteMobEntity eliteMobEntity = EventValidator.getEventEliteMob(this, event); if (eliteMobEntity == null) return; Player player = EntityFinder.findPlayer(event); if (PowerCooldown.isInCooldown(eliteMobEntity, cooldownList)) return; Block block = player.getLocation().getBlock(); Material originalMaterial = block.getType(); if (!originalMaterial.equals(Material.AIR)) return; block.setType(Material.WEB); new BukkitRunnable() { @Override public void run() { block.setType(originalMaterial); } }.runTaskLater(MetadataHandler.PLUGIN, 20 * 3); PowerCooldown.startCooldownTimer(eliteMobEntity, cooldownList, 3 * 20); }
Example #14
Source File: ShopUpdateListener.java From ShopChest with MIT License | 6 votes |
@EventHandler public void onPlayerLeave(PlayerQuitEvent e) { // If done without delay, Bukkit#getOnlinePlayers() would still // contain the player even though he left, so the shop updater // would show the shop again. new BukkitRunnable(){ @Override public void run() { for (Shop shop : plugin.getShopUtils().getShops()) { if (shop.hasItem()) { shop.getItem().resetVisible(e.getPlayer()); } if (shop.hasHologram()) { shop.getHologram().resetVisible(e.getPlayer()); } } plugin.getShopUtils().resetPlayerLocation(e.getPlayer()); } }.runTaskLater(plugin, 1L); }
Example #15
Source File: TeamSpectateMenu.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public TeamSpectateMenu(GameMap gMap) { String menuName = new Messaging.MessageFormatter().setVariable("mapname", gMap.getDisplayName()).format("menu.teamspectate-menu-title"); int menuSize = 27; Inventory menu = Bukkit.createInventory(null, menuSize + 9, menuName); ArrayList<Inventory> invs = new ArrayList<>(); invs.add(menu); SkyWarsReloaded.getIC().create(gMap.getName() + "teamspectate", invs, event -> { Player player = event.getPlayer(); String name = event.getName(); if (name.equalsIgnoreCase(SkyWarsReloaded.getNMS().getItemName(SkyWarsReloaded.getIM().getItem("exitMenuItem")))) { if (!SkyWarsReloaded.getIC().hasViewers("spectateteammenu")) { new BukkitRunnable() { @Override public void run() { SkyWarsReloaded.getIC().getMenu("jointeammenu").update(); } }.runTaskLater(SkyWarsReloaded.get(), 5); } SkyWarsReloaded.getIC().show(player, "spectateteammenu"); return; } if (player.hasPermission("sw.spectate")) { player.closeInventory(); if (gMap.getMatchState() != MatchState.OFFLINE && gMap.getMatchState() != MatchState.ENDING) { MatchManager.get().addSpectator(gMap, player); } } }); }
Example #16
Source File: TinyDB.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Async Saving of the DB */ public void asyncSaveDB() { if (!savingFlag) { new BukkitRunnable() { @Override public void run() { saveDB(); }}.runTaskAsynchronously(plugin); } }
Example #17
Source File: ShopUpdateListener.java From ShopChest with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerTeleport(PlayerTeleportEvent e) { Location from = e.getFrom(); Location to = e.getTo(); final Player p = e.getPlayer(); // Wait till the chunk should have loaded on the client if (!from.getWorld().getName().equals(to.getWorld().getName()) || from.getChunk().getX() != to.getChunk().getX() || from.getChunk().getZ() != to.getChunk().getZ()) { new BukkitRunnable() { @Override public void run() { plugin.getUpdater().queue(() -> { if (p.isOnline()) { for (Shop shop : plugin.getShopUtils().getShops()) { if (shop.hasItem()) { shop.getItem().hidePlayer(p); } if (shop.hasHologram()) { shop.getHologram().hidePlayer(p); } } plugin.getShopUtils().resetPlayerLocation(p); } }); plugin.getUpdater().updateShops(p); } }.runTaskLater(plugin, 15L); } }
Example #18
Source File: AdminCmd.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Purges the unowned islands upon direction from sender * @param sender */ private void purgeUnownedIslands(final CommandSender sender) { purgeFlag = true; final int total = unowned.size(); new BukkitRunnable() { @Override public void run() { if (unowned.isEmpty()) { purgeFlag = false; Util.sendMessage(sender, ChatColor.YELLOW + plugin.myLocale().purgefinished); this.cancel(); plugin.getGrid().saveGrid(); } if (unowned.size() > 0) { Iterator<Entry<String, Island>> it = unowned.entrySet().iterator(); Entry<String,Island> entry = it.next(); if (entry.getValue().getOwner() == null) { Util.sendMessage(sender, ChatColor.YELLOW + "[" + (total - unowned.size() + 1) + "/" + total + "] " + plugin.myLocale().purgeRemovingAt.replace("[location]", entry.getValue().getCenter().getWorld().getName() + " " + entry.getValue().getCenter().getBlockX() + "," + entry.getValue().getCenter().getBlockZ())); deleteIslands(entry.getValue(),sender); } // Remove from the list it.remove(); } Util.sendMessage(sender, plugin.myLocale().purgeNowWaiting); } }.runTaskTimer(plugin, 0L, 20L); }
Example #19
Source File: ShrinkingBorderEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@Override public void doEvent() { if (gMap.getMatchState() == MatchState.PLAYING) { this.fired = true; sendTitle(); WorldBorder wb = getGameMap().getCurrentWorld().getWorldBorder(); wb.setCenter(getGameMap().getSpectateSpawn().getX(), getGameMap().getSpectateSpawn().getZ()); wb.setSize(borderSize); br = new BukkitRunnable() { @Override public void run() { if (length != -1) { if (count >= length) { endEvent(false); } } if (gMap.getMatchState().equals(MatchState.PLAYING)) { if (gMap.getAlivePlayers().size() > 1) { wb.setSize(wb.getSize() - 1); } count++; } else { endEvent(false); } } }.runTaskTimer(SkyWarsReloaded.get(), delay * 20, 20); } }
Example #20
Source File: EntitySkeletonPet.java From EchoPet with GNU General Public License v3.0 | 5 votes |
public EntitySkeletonPet(World world, final IPet pet) { super(world, pet); new BukkitRunnable() { @Override public void run() { if (((ISkeletonPet) pet).isWither()) { setEquipment(0, new ItemStack(Items.STONE_SWORD)); } else { setEquipment(0, new ItemStack(Items.BOW)); } } }.runTaskLater(EchoPet.getPlugin(), 5L); }
Example #21
Source File: AbstractEntityZombiePet.java From SonarPet with GNU General Public License v3.0 | 5 votes |
@Override public void initiateEntityPet() { super.initiateEntityPet(); new BukkitRunnable() { @Override public void run() { //noinspection deprecation - 1.8.8 compatibility getBukkitEntity().getEquipment().setItemInHand(new ItemStack(getInitialItemInHand())); } }.runTaskLater(EchoPet.getPlugin(), 5L); }
Example #22
Source File: BungeeUtils.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
public static void sendPlayerBungeeMessage(Player player, String string) { new BukkitRunnable() { public void run() { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Message"); out.writeUTF(player.getName()); out.writeUTF(string); Bukkit.getServer().sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray()); } }.runTaskLater(Main.getInstance(), 30L); }
Example #23
Source File: MainListener.java From ArmorStandTools with MIT License | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerTeleport(PlayerTeleportEvent event) { final Player p = event.getPlayer(); boolean sameWorld = event.getFrom().getWorld() == event.getTo().getWorld(); if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) { UUID uuid = event.getPlayer().getUniqueId(); final ArmorStand as = plugin.carryingArmorStand.get(uuid); if (as == null || as.isDead()) { plugin.carryingArmorStand.remove(p.getUniqueId()); Utils.actionBarMsg(p, Config.asDropped); return; } if(sameWorld || Config.allowMoveWorld) { new BukkitRunnable() { @Override public void run() { as.teleport(Utils.getLocationFacing(p.getLocation())); Utils.actionBarMsg(p, Config.carrying); } }.runTaskLater(plugin, 1L); } else { plugin.returnArmorStand(plugin.carryingArmorStand.get(uuid)); plugin.carryingArmorStand.remove(uuid); if (plugin.savedInventories.containsKey(uuid)) { plugin.restoreInventory(p); } } } if(Config.deactivateOnWorldChange && !sameWorld && plugin.savedInventories.containsKey(p.getUniqueId())) { plugin.restoreInventory(p); } }
Example #24
Source File: LoggedScheduler.java From VoxelGamesLibv2 with MIT License | 5 votes |
public int scheduleAsyncRepeatingTask(Plugin plugin, BukkitRunnable task, long delay, long period) { TaskedRunnable wrapped = new TaskedRunnable(task); wrapped.setTaskID(delegate.scheduleAsyncRepeatingTask(plugin, wrapped, delay, period)); return wrapped.getTaskID(); }
Example #25
Source File: PlayerQuitListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerQuit(final PlayerQuitEvent a1) { final String id = a1.getPlayer().getUniqueId().toString(); Party party = Party.getParty(a1.getPlayer()); if (party != null) { party.removeMember(a1.getPlayer()); } final GameMap gameMap = MatchManager.get().getPlayerMap(a1.getPlayer()); if (gameMap == null) { new BukkitRunnable() { @Override public void run() { PlayerStat.removePlayer(id); } }.runTaskLater(SkyWarsReloaded.get(), 5); return; } MatchManager.get().playerLeave(a1.getPlayer(), DamageCause.CUSTOM, true, true, true); if (PlayerStat.getPlayerStats(id) != null) { new BukkitRunnable() { @Override public void run() { PlayerStat.removePlayer(id); } }.runTaskLater(SkyWarsReloaded.get(), 20); } }
Example #26
Source File: ChatListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler public void signPlaced(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); UUID uuid = event.getPlayer().getUniqueId(); if (chatList.containsKey(uuid)) { if (Math.abs((System.currentTimeMillis() - chatList.get(uuid))) < 20000) { ChatListener.chatList.remove(uuid); event.setCancelled(true); String[] settings = toChange.get(uuid).split(":"); GameMap gMap = GameMap.getMap(settings[0]); String setting = settings[1]; String variable = event.getMessage(); if (gMap != null && setting.equals("display")) { gMap.setDisplayName(variable); player.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", gMap.getName()).setVariable("displayname", variable).format("maps.name")); new BukkitRunnable() { @Override public void run() { gMap.update(); } }.runTask(SkyWarsReloaded.get()); SkyWarsReloaded.getIC().show(player, gMap.getArenaKey()); } else if (gMap != null && setting.equalsIgnoreCase("creator")) { gMap.setCreator(variable); player.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", gMap.getName()).setVariable("creator", variable).format("maps.creator")); new BukkitRunnable() { @Override public void run() { gMap.update(); } }.runTask(SkyWarsReloaded.get()); SkyWarsReloaded.getIC().show(player, gMap.getArenaKey()); } ChatListener.toChange.remove(uuid); } else { ChatListener.chatList.remove(uuid); ChatListener.toChange.remove(uuid); } } }
Example #27
Source File: Database.java From ShopChest with MIT License | 5 votes |
/** * Get shop amounts for each player * * @param callback Callback that returns a map of each player's shop amount */ public void getShopAmounts(final Callback<Map<UUID, Integer>> callback) { new BukkitRunnable(){ @Override public void run() { try (Connection con = dataSource.getConnection(); Statement s = con.createStatement()) { ResultSet rs = s.executeQuery("SELECT vendor, COUNT(*) AS count FROM " + tableShops + " WHERE shoptype = 'NORMAL' GROUP BY vendor"); plugin.debug("Getting shop amounts from database"); Map<UUID, Integer> result = new HashMap<>(); while (rs.next()) { UUID uuid = UUID.fromString(rs.getString("vendor")); result.put(uuid, rs.getInt("count")); } if (callback != null) { callback.callSyncResult(result); } } catch (SQLException ex) { if (callback != null) { callback.callSyncError(ex); } plugin.getLogger().severe("Failed to get shop amounts from database"); plugin.debug("Failed to get shop amounts from database"); plugin.debug(ex); } } }.runTaskAsynchronously(plugin); }
Example #28
Source File: Database.java From ShopChest with MIT License | 5 votes |
/** * Get the last logout of a player * * @param player Player who logged out * @param callback Callback that - if succeeded - returns the time in * milliseconds the player logged out (as {@code long}) * or {@code -1} if the player has not logged out yet. */ public void getLastLogout(final Player player, final Callback<Long> callback) { new BukkitRunnable() { @Override public void run() { try (Connection con = dataSource.getConnection(); PreparedStatement ps = con.prepareStatement("SELECT * FROM " + tableLogouts + " WHERE player = ?")) { ps.setString(1, player.getUniqueId().toString()); ResultSet rs = ps.executeQuery(); if (rs.next()) { if (callback != null) { callback.callSyncResult(rs.getLong("time")); } } if (callback != null) { callback.callSyncResult(-1L); } } catch (SQLException ex) { if (callback != null) { callback.callSyncError(ex); } plugin.getLogger().severe("Failed to get last logout from database"); plugin.debug("Failed to get last logout from player \"" + player.getName() + "\""); plugin.debug(ex); } } }.runTaskAsynchronously(plugin); }
Example #29
Source File: MobKillNotifier.java From BetonQuest with GNU General Public License v3.0 | 5 votes |
public MobKillNotifier() { instance = this; cleaner = new BukkitRunnable() { @Override public void run() { entities.clear(); } }; cleaner.runTaskTimer(BetonQuest.getInstance(), 1, 1); }
Example #30
Source File: GunUtil.java From QualityArmory with GNU General Public License v3.0 | 5 votes |
public static void playShoot(final Gun g, final Player player) { g.damageDurability(player); new BukkitRunnable() { @SuppressWarnings("deprecation") @Override public void run() { try { String soundname = null; if (g.getWeaponSounds().size() > 1) { soundname = g.getWeaponSounds() .get(ThreadLocalRandom.current().nextInt(g.getWeaponSounds().size())); } else { soundname = g.getWeaponSound(); } player.getWorld().playSound(player.getLocation(), soundname, (float) g.getVolume(), 1); if (!QAMain.isVersionHigherThan(1, 9)) { try { player.getWorld().playSound(player.getLocation(), Sound.valueOf("CLICK"), 5, 1); player.getWorld().playSound(player.getLocation(), Sound.valueOf("WITHER_SHOOT"), 8, 2); player.getWorld().playSound(player.getLocation(), Sound.valueOf("EXPLODE"), 8, 2f); } catch (Error | Exception e3) { player.getWorld().playSound(player.getLocation(), Sound.valueOf("BLOCK_LEVER_CLICK"), 5, 1); } } } catch (Error e2) { player.getWorld().playSound(player.getLocation(), Sound.valueOf("CLICK"), 5, 1); player.getWorld().playSound(player.getLocation(), Sound.valueOf("WITHER_SHOOT"), 8, 2); player.getWorld().playSound(player.getLocation(), Sound.valueOf("EXPLODE"), 8, 2f); } } }.runTaskLater(QAMain.getInstance(), 1); // Simply delaying the sound by 1/20th of a second makes shooting so much more // immersive }