Java Code Examples for org.bukkit.scheduler.BukkitRunnable
The following examples show how to use
org.bukkit.scheduler.BukkitRunnable. These examples are extracted from open source projects.
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 Project: LuckPerms Source File: PluginMessageMessenger.java License: 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 2
Source Project: EliteMobs Source File: AttackWeb.java License: 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 3
Source Project: PlayerSQL Source File: EventExecutor.java License: 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 4
Source Project: XSeries Source File: XParticle.java License: 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 5
Source Project: ZombieEscape Source File: Door.java License: 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 6
Source Project: TabooLib Source File: THologramHandler.java License: 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 7
Source Project: SkyWarsReloaded Source File: DoubleDamageEvent.java License: 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 8
Source Project: QuickShop-Reremake Source File: DatabaseManager.java License: 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 9
Source Project: NyaaUtils Source File: SitListener.java License: 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 10
Source Project: ce Source File: Tools.java License: 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 Project: ShopChest Source File: ShopUpdateListener.java License: 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 12
Source Project: Crazy-Crates Source File: Main.java License: 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 13
Source Project: QualityArmory Source File: GunUtil.java License: 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 14
Source Project: HoloAPI Source File: SimpleImageLoader.java License: 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 15
Source Project: PlayerVaults Source File: VaultPreloadListener.java License: GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent event) { final UUID uuid = event.getPlayer().getUniqueId(); new BukkitRunnable() { @Override public void run() { vm.cachePlayerVaultFile(uuid.toString()); } }.runTaskAsynchronously(PlayerVaults.getInstance()); }
Example 16
Source Project: BedwarsRel Source File: Game.java License: GNU General Public License v3.0 | 5 votes |
private void startActionBarRunnable() { if (BedwarsRel.getInstance().getBooleanConfig("show-team-in-actionbar", false)) { try { Class<?> clazz = Class.forName("io.github.bedwarsrel.com." + BedwarsRel.getInstance().getCurrentVersion().toLowerCase() + ".ActionBar"); final Method sendActionBar = clazz.getDeclaredMethod("sendActionBar", Player.class, String.class); BukkitTask task = new BukkitRunnable() { @Override public void run() { for (Team team : Game.this.getTeams().values()) { for (Player player : team.getPlayers()) { try { sendActionBar.invoke(null, player, team.getChatColor() + BedwarsRel._l(player, "ingame.team") + " " + team .getDisplayName()); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { BedwarsRel.getInstance().getBugsnag().notify(e); e.printStackTrace(); } } } } }.runTaskTimer(BedwarsRel.getInstance(), 0L, 20L); this.addRunningTask(task); } catch (Exception ex) { BedwarsRel.getInstance().getBugsnag().notify(ex); ex.printStackTrace(); } } }
Example 17
Source Project: ce Source File: Bombardment.java License: GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public void effect(Event e, ItemStack item, final int level) { if(e instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; Entity target = event.getEntity(); final World world = target.getWorld(); Vector vec = new Vector(0, -5, 0); Location spawnLocation = new Location(world, target.getLocation().getX(), 255, target.getLocation().getZ()); final FallingBlock b = world.spawnFallingBlock(spawnLocation, 46, (byte) 0x0); b.setVelocity(vec); new BukkitRunnable() { Location l = b.getLocation(); @Override public void run() { l = b.getLocation(); if(b.isDead()) { l.getBlock().setType(Material.AIR); for(int i = 0; i <= TNTAmount + level; i++) { TNTPrimed tnt = world.spawn(l, TNTPrimed.class); tnt.setFuseTicks(0); if(!Main.createExplosions) tnt.setMetadata("ce.explosive", new FixedMetadataValue(getPlugin(), null)); } this.cancel(); } EffectManager.playSound(l, "ENTITY_ENDERDRAGON_GROWL", Volume, 2f); } }.runTaskTimer(getPlugin(), 0l, 5l); } }
Example 18
Source Project: SkyWarsReloaded Source File: GameMap.java License: GNU General Public License v3.0 | 5 votes |
public static void editMap(GameMap gMap, Player player) { if (gMap.isRegistered()) { gMap.unregister(true); new BukkitRunnable() { @Override public void run() { startEdit(gMap, player); } }.runTaskLater(SkyWarsReloaded.get(), 20); } else { startEdit(gMap, player); } }
Example 19
Source Project: BedWars Source File: BungeeUtils.java License: GNU Lesser General Public License v3.0 | 5 votes |
public static void movePlayerToBungeeServer(Player player, boolean serverRestart) { if (serverRestart) { internalMove(player); return; } new BukkitRunnable() { public void run() { internalMove(player); } }.runTask(Main.getInstance()); }
Example 20
Source Project: BedWars Source File: BungeeUtils.java License: 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 21
Source Project: SonarPet Source File: AbstractEntityZombiePet.java License: 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 Project: uSkyBlock Source File: uSkyBlock.java License: GNU General Public License v3.0 | 5 votes |
private void generateIsland(final Player player, final PlayerInfo pi, final Location next, final String cSchem) { if (!perkLogic.getSchemes(player).contains(cSchem)) { player.sendMessage(tr("\u00a7eYou do not have access to that island-schematic!")); orphanLogic.addOrphan(next); return; } final PlayerPerk playerPerk = new PlayerPerk(pi, perkLogic.getPerk(player)); player.sendMessage(tr("\u00a7eGetting your island ready, please be patient, it can take a while.")); BukkitRunnable createTask = new CreateIslandTask(this, player, playerPerk, next, cSchem); IslandInfo tempInfo = islandLogic.createIslandInfo(LocationUtil.getIslandName(next), pi.getPlayerName()); WorldGuardHandler.protectIsland(this, player, tempInfo); islandLogic.clearIsland(next, createTask); }
Example 23
Source Project: Quests Source File: PermissionTaskType.java License: MIT License | 5 votes |
@Override public void onReady() { this.poll = new BukkitRunnable() { @Override public void run() { for (Player player : Bukkit.getOnlinePlayers()) { QPlayer qPlayer = QuestsAPI.getPlayerManager().getPlayer(player.getUniqueId(), true); QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile(); for (Quest quest : PermissionTaskType.super.getRegisteredQuests()) { if (questProgressFile.hasStartedQuest(quest)) { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(PermissionTaskType.super.getType())) { TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { continue; } String permission = (String) task.getConfigValue("permission"); if (permission != null) { if (player.hasPermission(permission)) { taskProgress.setCompleted(true); } } } } } } } }.runTaskTimer(Quests.get(), 30L, 30L); }
Example 24
Source Project: BedWars Source File: RescuePlatform.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public void runTask() { new BukkitRunnable() { @Override public void run() { livingTime++; int time = breakingTime - livingTime; if (time < 6 && time > 0) { MiscUtils.sendActionBarMessage( player, i18nonly("specials_rescue_platform_destroy").replace("%time%", Integer.toString(time))); } if (livingTime == breakingTime) { for (Block block : platformBlocks) { block.getChunk().load(false); block.setType(Material.AIR); removeBlockFromList(block); game.getRegion().removeBlockBuiltDuringGame(block.getLocation()); } game.unregisterSpecialItem(RescuePlatform.this); this.cancel(); } } }.runTaskTimer(Main.getInstance(), 20L, 20L); }
Example 25
Source Project: EnchantmentsEnhance Source File: PlayerStreamListener.java License: GNU General Public License v3.0 | 5 votes |
/** * When a player gets kicked off the server, listener saves a player's data * from hashmap to file, but will not write to disk. * * @param e */ @EventHandler(priority = EventPriority.MONITOR) public void onKick(PlayerKickEvent e) { if (PlayerStatsManager.getPlayerStats(e.getPlayer().getName()) != null) { new BukkitRunnable() { @Override public void run() { PlayerStatsManager.removePlayerStats(e.getPlayer().getName()); } }.runTaskLater(Main.getMain(), 20); } }
Example 26
Source Project: BetonQuest Source File: InventoryConvIO.java License: GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onClose(InventoryCloseEvent event) { if (!(event.getPlayer() instanceof Player)) { return; } if (!event.getPlayer().equals(player)) { return; } // allow for closing previous option inventory if (switching) { return; } // allow closing when the conversation has finished if (allowClose) { HandlerList.unregisterAll(this); return; } if (conv.isMovementBlock()) { new BukkitRunnable() { public void run() { player.teleport(loc); player.openInventory(inv); } }.runTask(BetonQuest.getInstance()); } else { conv.endConversation(); HandlerList.unregisterAll(this); } }
Example 27
Source Project: EliteMobs Source File: Invisibility.java License: GNU General Public License v3.0 | 5 votes |
@Override public void applyPowers(Entity entity) { new BukkitRunnable() { @Override public void run() { ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1)); } }.runTaskLater(MetadataHandler.PLUGIN, 1); }
Example 28
Source Project: QualityArmory Source File: QualityArmory.java License: GNU General Public License v3.0 | 5 votes |
public static GunYML createAndLoadNewGun(String name, String displayname, Material material, int id, WeaponType type, WeaponSounds sound, boolean hasIronSights, String ammotype, int damage, int maxBullets, int cost) { File newGunsDir = new File(QAMain.getInstance().getDataFolder(), "newGuns"); final File gunFile = new File(newGunsDir, name); new BukkitRunnable() { public void run() { GunYMLLoader.loadGuns(QAMain.getInstance(), gunFile); } }.runTaskLater(QAMain.getInstance(), 1); return GunYMLCreator.createNewCustomGun(QAMain.getInstance().getDataFolder(), name, name, displayname, id, null, type, sound, hasIronSights, ammotype, damage, maxBullets, cost).setMaterial(material); }
Example 29
Source Project: SkyWarsReloaded Source File: PlayerQuitListener.java License: 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 30
Source Project: XSeries Source File: XParticle.java License: MIT License | 5 votes |
/** * Spawns a galaxy-like vortex. * Note that the speed of the particle is important. * Speed 0 will spawn static lines. * * @param plugin the timer handler. * @param points the points of the vortex. * @param rate the speed of the vortex. * @return the task handling the animation. * @since 2.0.0 */ public static BukkitTask vortex(JavaPlugin plugin, int points, double rate, ParticleDisplay display) { double rateDiv = Math.PI / rate; display.directional(); return new BukkitRunnable() { double theta = 0; @Override public void run() { theta += rateDiv; for (int i = 0; i < points; i++) { // Calculate our starting point in a circle radius. double multiplier = (PII * ((double) i / points)); double x = Math.cos(theta + multiplier); double z = Math.sin(theta + multiplier); // Calculate our direction of the spreading particles based on their angle. double angle = Math.atan2(z, x); double xDirection = Math.cos(angle); double zDirection = Math.sin(angle); display.offset(xDirection, 0, zDirection); display.spawn(x, 0, z); } } }.runTaskTimerAsynchronously(plugin, 0L, 1L); }