// <Index = 2> @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { Player p = event.getPlayer(); final String pName = p.getName(); event.setQuitMessage(ChatMessages.WHITE + pName + ChatMessages.quitMessage); Bukkit.getScheduler() .scheduleSyncDelayedTask( plugin, new Runnable() { @Override public void run() { if (Main.lobbyBoolean == false && Bukkit.getOnlinePlayers().size() < 2) { Main.gameTimer = 5; } } }, 100); Bukkit.getScheduler() .scheduleSyncDelayedTask( Main.getInstance(), new Runnable() { @Override public void run() { if (!Bukkit.getOfflinePlayer(pName).isOnline()) ScoreboardHandler.removePlayer(pName); } }, 300L); }
private void next() { if (currentTask != -1) Bukkit.getScheduler().cancelTask(currentTask); if (onTask != null) inFlight.add(onTask); onTask = inFlight.poll(); if (onTask == null) return; if (onTask.timeToEnd() <= 0) { onTask.cancel(); currentTask = -1; onTask = null; next(); return; } currentTask = Bukkit.getScheduler() .scheduleSyncDelayedTask( Bastion.getPlugin(), new BukkitRunnable() { @Override public void run() { onTask.cancel(); onTask = null; currentTask = -1; next(); } }, onTask.timeToEnd()); }
public void onEnd(final Player player, final boolean quit) { if (quit) { Bukkit.getScheduler() .runTaskLater( MarioKart.plugin, new Runnable() { @Override public void run() { FullServerManager.get().sendToLobby(player); return; } }, 10l); return; } Bukkit.getScheduler() .runTaskLater( MarioKart.plugin, new Runnable() { @Override public void run() { spectators.add(player); return; } }, 5l); }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!sender.hasPermission(GoldRushPerms.SCHEDULE)) { deny(sender); return true; } int taskID = Departure.getTaskID(); BukkitScheduler s = Bukkit.getScheduler(); if (args[0].equalsIgnoreCase("Start") && taskID == -1) { sender.sendMessage("Starting Train Cycle..."); Departure.setTaskID( Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Departure(plugin), 100, 400)); return true; } else if (taskID != 0) { sender.sendMessage("Train Cycle already started!"); return true; } else if (args[0].equalsIgnoreCase("Stop") && (s.isCurrentlyRunning(taskID) || s.isQueued(taskID))) { sender.sendMessage("Stopping Train Cycle..."); Bukkit.getScheduler().cancelTask(taskID); Departure.resetTaskID(); return true; } else if (taskID == -1) { sender.sendMessage("Train Cycle is not running."); return true; } return false; }
@Override public void process(CommandSender sender, String[] args) { if (args[0] != null) { Bukkit.getScheduler() .runTaskAsynchronously(Main.getInstance(), new LookupTask(args[0], sender)); } else { Bukkit.getScheduler() .runTaskAsynchronously(Main.getInstance(), new LookupTask(sender.getName(), sender)); } }
@Override public void run() { if (Bukkit.getPlayer(uuid) == null) Bukkit.getScheduler().cancelTask(id); else if (Bukkit.getPlayer(uuid).isDead()) Bukkit.getScheduler().cancelTask(id); else if (!Bukkit.getPlayer(uuid).isSneaking()) Bukkit.getScheduler().cancelTask(id); else { Player p = Bukkit.getPlayer(uuid); Vector vector = new Vector(0, 1, 0); vector.multiply(-0.1); p.setVelocity(vector); p.setFallDistance(0.0f); if (!p.isSneaking()) Bukkit.getScheduler().cancelTask(id); } }
public void execute(final Player p, Entity unused, float f) { if (isCooldown(p)) { return; } else { SkillMgr.addCooldown(p, getName(), cooldown); } if (!isLevel(p)) { return; } if (RaceMgr.getRace(p.getName()).hasData("invis")) { return; } for (Player other : Bukkit.getOnlinePlayers()) { other.hidePlayer(p); } Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCraft.plugin, new Runnable() { public void run() { RaceMgr.getRace(p.getName()).setData("invis", null); for (final Player other : Bukkit.getOnlinePlayers()) { Player hide = EntityMgr.getOnlinePlayer(other.getName()); Player look = EntityMgr.getOnlinePlayer(p.getName()); if (hide != null && look != null) { if (look.equals(hide)) { continue; } if (look.getWorld() == hide.getWorld()) { if (HookVanish.canSee(other, p)) { other.showPlayer(p); } } } } } }, lasts); //XXX: Config - Notify when they go invisible and visible //if () { //invis p.sendMessage(MMOCraft.prefix + I18n._("skillinvison", new Object[] {})); SoundEffects.PORTAL_TRAVEL.play(p, p.getLocation(), 0.3f, 2.0f); //} //if () { //vis int tid = Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCraft.plugin, new Runnable() { public void run() { if (p != null) { p.sendMessage(MMOCraft.prefix + I18n._("skillinvisoff", new Object[] {})); SoundEffects.PORTAL_TRIGGER.play(p, p.getLocation(), 25f, 2.5f); } } }, lasts); RaceMgr.getRace(p.getName()).setData("invis", tid); //} //XXX }
@Override public void onInteractItem(PlayerInteractEvent event) { final Player player = event.getPlayer(); if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { Block b = event.getClickedBlock(); if (STBUtil.isCrop(b.getType())) { b = b.getRelative(BlockFace.DOWN); } final List<Location> l = new ArrayList<Location>(); for (int i = -getRadius(); i <= getRadius(); i++) { for (int j = -getRadius(); j <= getRadius(); j++) { Block b1 = b.getRelative(i, 0, j); if (b1.getType() == Material.SOIL) { l.add(b1.getLocation()); } } } if (!l.isEmpty()) { Bukkit.getScheduler() .runTask( getProviderPlugin(), new Runnable() { @SuppressWarnings("deprecation") @Override public void run() { for (Location loc : l) { player.sendBlockChange(loc, Material.WOOL, getSaturationData(loc.getBlock())); } } }); Bukkit.getScheduler() .runTaskLater( getProviderPlugin(), new Runnable() { @SuppressWarnings("deprecation") @Override public void run() { for (Location loc : l) { player.sendBlockChange( loc, loc.getBlock().getType(), loc.getBlock().getData()); } } }, 30L); event.setCancelled(true); } } }
@Override public void onEnable() { PluginManager pm = Bukkit.getPluginManager(); AccountsConfig config; try { config = getLoader().loadOrCreate("config.json", AccountsConfig.class); } catch (GsonLoadException exc) { getLogger().log(Level.SEVERE, "Unable to load config.json", exc); config = new AccountsConfig(); } Accounts accounts = new EVAccounts(this, config); EthilVan.registerAccounts(accounts); Listener accountsListener = new AccountsListener(this); pm.registerEvents(accountsListener, this); ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); protocolManager.addPacketListener(new NamePlatePacketListener(this)); CommandsRegistration registration = new CommandsRegistration(this, Locale.FRANCE); registration.register(new AccountsCommands()); Bukkit.getScheduler().runTaskTimer(this, this, 6000, 6000); }
public GameTimer(GameManager game, int time) { gameManager = game; timeLeft = time; timeState = Bukkit.getScheduler().scheduleSyncRepeatingTask(HotPotato.getPlugin(), this, 20L, 20L); }
@EventHandler public void asyncChatTrigger(final AsyncPlayerChatEvent event) { if (event.isCancelled()) return; // Return if "Use asynchronous event" is false in config file if (!Settings.ChatAsynchronous()) return; Callable<Boolean> call = new Callable<Boolean>() { public Boolean call() { return process(event.getPlayer(), event.getMessage()); } }; Boolean cancelled = false; try { cancelled = event.isAsynchronous() ? Bukkit.getScheduler().callSyncMethod(DenizenAPI.getCurrentInstance(), call).get() : call.call(); } catch (InterruptedException e) { // dB.echoError(e); } catch (ExecutionException e) { dB.echoError(e); } catch (Exception e) { dB.echoError(e); } event.setCancelled(cancelled); }
public void createDuel(Player p1, Player p2, String mode) { Duel duel = new Duel(this.plugin, p1.getName(), p2.getName(), mode); this.invites.removeAll(p1.getName()); this.invites.removeAll(p2.getName()); p1.getInventory().clear(); p2.getInventory().clear(); p1.updateInventory(); p2.updateInventory(); p1.setHealth(20.0D); p2.setHealth(20.0D); this.duels.add(duel); duel.setTaskID(Bukkit.getScheduler().scheduleSyncRepeatingTask(this.plugin, duel, 0L, 10L)); for (String s : ovo) { Player p = Bukkit.getPlayerExact(s); if ((!p.getName().equals(p1.getName())) && (!p.getName().equals(p2.getName()))) { p1.hidePlayer(p); p2.hidePlayer(p); } } }
static void startTask(Player player) { chairTimer.put(player, 0); int taskId = Bukkit.getScheduler() .scheduleSyncRepeatingTask( Main.getPlugin(), new Runnable() { @Override public void run() { int x = Integer.parseInt(occupiedChairs.get(player).split(",")[0]); int y = Integer.parseInt(occupiedChairs.get(player).split(",")[1]); int z = Integer.parseInt(occupiedChairs.get(player).split(",")[2]); Block sitBlock = player.getWorld().getBlockAt(x, y, z); if (!isSitting(player)) { unsitPlayer(player, sitBlock); return; } if (chairTimer.get(player) == 600) { resitPlayer(player, sitBlock); chairTimer.replace(player, 0); } chairTimer.replace(player, chairTimer.get(player) + 1); } }, 0L, 1L); chairTask.put(player, taskId); }
private boolean needFirstspawn() { if (player.hasPlayedBefore()) return false; if (Spawn.getInstance().getFirstSpawn() == null || Spawn.getInstance().getFirstSpawn().getWorld() == null) return false; FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent( player, player.getLocation(), Spawn.getInstance().getFirstSpawn()); plugin.getServer().getPluginManager().callEvent(tpEvent); if (!tpEvent.isCancelled()) { if (player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) { final Location fLoc = tpEvent.getTo(); Bukkit.getScheduler() .scheduleSyncDelayedTask( plugin, new Runnable() { @Override public void run() { player.teleport(fLoc); } }); } } return true; }
@Override void onUpdate() { final Item ITEM = ent.getWorld() .dropItem( ((Sheep) ent).getEyeLocation(), ItemFactory.create( Material.WOOL, (byte) r.nextInt(017), UUID.randomUUID().toString())); ITEM.setPickupDelay(30000); ITEM.setVelocity( new Vector(r.nextDouble() - 0.5, r.nextDouble() / 2.0 + 0.3, r.nextDouble() - 0.5) .multiply(0.4)); items.add(ITEM); Bukkit.getScheduler() .runTaskLater( Core.getPlugin(), new Runnable() { @Override public void run() { ITEM.remove(); items.remove(ITEM); } }, 5); }
public BattleResumeCountdown(int startCountdownDuration) { this.startCountdownDuration = startCountdownDuration; this.counter = 0; this.handle = Bukkit.getScheduler().scheduleSyncRepeatingTask(BattlePlugin.instance(), this, 0, 20); }
public void run() { id = Bukkit.getScheduler() .scheduleSyncRepeatingTask( storm, new Runnable() { @Override public void run() { if (rand.nextInt(100) <= glob.Natural__Disasters_Meteor_Chance__To__Spawn) { Chunk chunk = Storm.util.pickChunk(spawnWorld); if (chunk == null) { return; } final int x = rand.nextInt(16); final int z = rand.nextInt(16); final Block b = chunk.getBlock(x, 4, z); spawnMeteorNaturallyAndRandomly(chunk.getWorld(), b.getX(), b.getZ()); } } }, glob.Natural__Disasters_Meteor_Scheduler__Recalculation__Intervals__In__Ticks, glob.Natural__Disasters_Meteor_Scheduler__Recalculation__Intervals__In__Ticks); }
private void placePlayerSafely(final Player player, final Location spawnLoc) { if (spawnLoc == null) return; if (!Settings.noTeleport) return; if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) return; if (!player.hasPlayedBefore()) return; Bukkit.getScheduler() .scheduleSyncDelayedTask( plugin, new Runnable() { @Override public void run() { Location loc = null; Block b = player.getLocation().getBlock(); if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL) { m.send(player, "unsafe_spawn"); if (spawnLoc.getWorld() != null) loc = spawnLoc; } else { Block c = player.getLocation().add(0D, 1D, 0D).getBlock(); if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL) { m.send(player, "unsafe_spawn"); if (spawnLoc.getWorld() != null) loc = spawnLoc; } } if (loc != null) player.teleport(loc); } }); }
@Override public void onDisable() { HandlerList.unregisterAll(); // log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), // getDescription().getVersion())); Bukkit.getScheduler().cancelTasks(this); }
public void startAttacking(final LivingEntity e) { if (this.attackingID != -1) this.stopAttacking(); this.attackingID = Bukkit.getScheduler() .scheduleSyncRepeatingTask( DragonsLairMain.getInstance(), new NPCAttackTask(this, e), 0, 10L); }
public ZoneUserManager(Plugin plugin, ZoneConfig usersConfig) { this.usersConfigReference = usersConfig; this.usersConfigFilePath = usersConfig.getFile().getPath(); this.plugin = plugin; if (plugin instanceof ZonePlugin) { this.isZonePlugin = true; } else { this.isZonePlugin = false; } loadUsers(usersConfig); if (preventOnlineUserGC) { for (Player player : Bukkit.getOnlinePlayers()) { holdUserFromGC(getUser(player)); } } Bukkit.getPluginManager().registerEvents(this, plugin); Bukkit.getScheduler() .runTaskTimerAsynchronously( plugin, new Runnable() { @Override public void run() { getUsersConfig().schedualSave(); } }, saveInterval, saveInterval); }
@Override public void run() { basetime = new Date().getTime(); worldbasetime = getWorld().getFullTime(); worldevent = 0; event = 0; sortEvents(); schedule = Bukkit.getScheduler() .scheduleSyncRepeatingTask( ManhuntPlugin.getInstance(), new Runnable() { public void run() { while (event < events.size() && new Date().getTime() >= basetime + events.get(event).getTriggerTime()) { events.get(event).execute(); event++; } while (worldevent < worldevents.size() && worldevents.get(worldevent).getWorld().getFullTime() >= worldbasetime + worldevents.get(worldevent).getTriggerTime()) { worldevents.get(worldevent).execute(); worldevent++; } } }, 0, 0); }
@Override public void onEnable() { Bukkit.getScheduler() .runTaskTimerAsynchronously( this, new Runnable() { @Override public void run() { if (isProcessing) return; isProcessing = true; Iterator<AtomicInteger> iterator = scores.values().iterator(); int threshold = getConfig().getInt("threshold"); while (iterator.hasNext()) { AtomicInteger score = iterator.next(); int newScore = score.decrementAndGet(); if (newScore <= 0) { iterator.remove(); } else if (newScore > threshold) { score.compareAndSet(newScore, threshold); } } isProcessing = false; } }, 60, 60); saveDefaultConfig(); Bukkit.getPluginManager().registerEvents(this, this); }
// This gets called from /mcmmo command public static void anniversaryCheck(final CommandSender sender) { if (sender instanceof Player) { GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3); GregorianCalendar anniversaryEnd = new GregorianCalendar(2013, Calendar.FEBRUARY, 6); GregorianCalendar day = new GregorianCalendar(); if (hasCelebrated.contains(sender.getName())) { return; } if (getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) { sender.sendMessage(ChatColor.BLUE + "Happy 2 Year Anniversary! In honor of all of"); sender.sendMessage( ChatColor.BLUE + "nossr50's work and all the devs, here's a firework show!"); final int firework_amount = 10; for (int i = 0; i < firework_amount; i++) { int delay = (int) (Math.random() * 3) + 4; Bukkit.getScheduler() .scheduleSyncDelayedTask( mcMMO.p, new Runnable() { @Override public void run() { spawnFireworks((Player) sender); } }, 20 * delay); } } hasCelebrated.add(sender.getName()); } }
@Override public void turnOn(final String channelName) { WirelessRedstone.getWRLogger().debug("Clock started by: " + channelName); BukkitTask task = Bukkit.getScheduler() .runTaskTimer( WirelessRedstone.getInstance(), new Runnable() { boolean b = false; @Override public void run() { // WirelessRedstone.getWRLogger().debug("Clock " + channelName + // ", state is " // + b); if (b) { superTurnOff(channelName); } else { superTurnOn(channelName); } b = !b; } }, 0L, this.delay / 50); WirelessRedstone.config.getWirelessChannel(channelName).startClock(task); }
@EventHandler(priority = EventPriority.HIGHEST) private void onPlayerJoin(PlayerJoinEvent evt) { final Player p = evt.getPlayer(); Bukkit.getScheduler() .scheduleSyncDelayedTask( plugin, new Runnable() { public void run() { p.sendMessage( "Welcome to jayserp's Minekoth. Type" + " /red <class> or /blue <class> to join a team."); UsersDataClass userData = plugin.getSqlDb().getUser(p.getDisplayName()); if (userData != null) { plugin.getPlayerHandler().addSpecPlayer(p.getDisplayName(), userData.getRank()); if (userData.getRank() > 90) { p.sendMessage("Welcome, admin."); } } else { plugin.getPlayerHandler().addSpecPlayer(p.getDisplayName()); } plugin.getCustomTab().updateTab(); } }, 3); }
public void bOOM() { Vector v = p.getVelocity(); v.setY(2.3); p.teleport(p.getLocation().add(0, 0.5, 0)); p.setVelocity(v); p.setFallDistance(0F); TempData.sonicRainBoomMap.put(p.getUniqueId(), System.currentTimeMillis()); p.sendMessage(ChatColor.LIGHT_PURPLE + "SONIC RAINBOOM!"); TempData.fallMap.add(p.getUniqueId()); // Particles final World world = p.getWorld(); for (int i = 0; i < 20 * 4; i++) { Bukkit.getScheduler() .scheduleSyncDelayedTask( Main.PLUGIN, new Runnable() { @Override public void run() { world .spigot() .playEffect(p.getLocation(), Effect.COLOURED_DUST, 1, 1, 1, 1, 1, 1, 48, 30); } }, i); } }
@Override public void onDisable() { DataManager.saveAllData(); HandlerList.unregisterAll(this); Bukkit.getScheduler().cancelTasks(this); message("disabled"); }
@EventHandler public void onInteract(PlayerInteractEvent pie) { if (pie.getAction().equals(Action.RIGHT_CLICK_BLOCK) || pie.getAction().equals(Action.RIGHT_CLICK_AIR)) { Player player = pie.getPlayer(); World world = player.getWorld(); if (player.getInventory().getItemInHand() != null) { ItemStack item = player.getInventory().getItemInHand(); if (item.getType().equals(Material.DOUBLE_PLANT)) { pie.setCancelled(true); Item bomb = world.dropItem(player.getEyeLocation(), new ItemStack(Material.GOLD_BLOCK)); bomb.setPickupDelay(Integer.MAX_VALUE); bomb.setVelocity(player.getLocation().getDirection().multiply(0.5)); double radius = 1.5; for (double i = 0; i <= 20D; i += 0.1) { Item coin = world.dropItem(bomb.getLocation(), new ItemStack(Material.DOUBLE_PLANT)); double x = Math.sin(radius * i); double z = Math.cos(radius * i); Bukkit.getScheduler() .scheduleSyncDelayedTask( Factions.instance, new Runnable() { public void run() {} }, 1); } } } } }
@EventHandler public void arrowParticles(MapLoadEvent event) { if (event.getWorld().getName().equals(getName())) { particles = Bukkit.getScheduler() .scheduleSyncRepeatingTask( plugin, new Runnable() { public void run() { World world = Bukkit.getWorld(getName()); if (getArena().equals(getName())) { for (Entity arrow : world.getEntities()) { if (arrow != null) { if (arrow instanceof Arrow) { world.playEffect(arrow.getLocation(), Effect.SMOKE, 10); } } } } } }, 5L, 5L); } }