Java Code Examples for org.bukkit.scheduler.BukkitScheduler#runTaskTimerAsynchronously()
The following examples show how to use
org.bukkit.scheduler.BukkitScheduler#runTaskTimerAsynchronously() .
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: LagMonitor.java From LagMonitor with MIT License | 6 votes |
private void setupMonitoringDatabase() { try { String host = getConfig().getString("host"); int port = getConfig().getInt("port"); String database = getConfig().getString("database"); boolean usessl = getConfig().getBoolean("usessl"); String username = getConfig().getString("username"); String password = getConfig().getString("password"); String tablePrefix = getConfig().getString("tablePrefix"); Storage storage = new Storage(getLogger(), host, port, database, usessl, username, password, tablePrefix); storage.createTables(); BukkitScheduler scheduler = getServer().getScheduler(); scheduler.runTaskTimerAsynchronously(this, new TPSSaveTask(tpsHistoryTask, storage), 20L, getConfig().getInt("tps-save-interval") * 20L); //this can run async because it runs independently from the main thread scheduler.runTaskTimerAsynchronously(this, new MonitorSaveTask(this, storage), 20L,getConfig().getInt("monitor-save-interval") * 20L); scheduler.runTaskTimerAsynchronously(this, new NativeSaveTask(this, storage), 20L,getConfig().getInt("native-save-interval") * 20L); } catch (SQLException sqlEx) { getLogger().log(Level.SEVERE, "Failed to setup monitoring database", sqlEx); } }
Example 2
Source File: LagMonitor.java From LagMonitor with MIT License | 6 votes |
private void setupMonitoringDatabase() { try { String host = getConfig().getString("host"); int port = getConfig().getInt("port"); String database = getConfig().getString("database"); boolean usessl = getConfig().getBoolean("usessl"); String username = getConfig().getString("username"); String password = getConfig().getString("password"); String tablePrefix = getConfig().getString("tablePrefix"); Storage storage = new Storage(getLogger(), host, port, database, usessl, username, password, tablePrefix); storage.createTables(); BukkitScheduler scheduler = getServer().getScheduler(); scheduler.runTaskTimerAsynchronously(this, new TPSSaveTask(tpsHistoryTask, storage), 20L, getConfig().getInt("tps-save-interval") * 20L); //this can run async because it runs independently from the main thread scheduler.runTaskTimerAsynchronously(this, new MonitorSaveTask(this, storage), 20L,getConfig().getInt("monitor-save-interval") * 20L); scheduler.runTaskTimerAsynchronously(this, new NativeSaveTask(this, storage), 20L,getConfig().getInt("native-save-interval") * 20L); } catch (SQLException sqlEx) { getLogger().log(Level.SEVERE, "Failed to setup monitoring database", sqlEx); } }
Example 3
Source File: ExploitFixer.java From ExploitFixer with GNU General Public License v3.0 | 5 votes |
@Override public void onEnable() { final Server server = this.getServer(); final BukkitScheduler scheduler = server.getScheduler(); this.configurationUtil = new ConfigurationUtil(this); createConfigurations(); final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml"); final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml"); VersionUtil.initialize(server); exploitFixer = this; this.moduleManager = new ModuleManager(this, configYml, messagesYml); this.listenerInitializer = new ListenerInitializer(this, moduleManager); registerListeners(); registerCommands(); if (checkHamsterAPI()) { server.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); this.hamsterAPIListenerInitializer = new HamsterAPIListenerInitializer(this, moduleManager); registerHamsterApi(); } else { scheduler.runTaskTimer(this, () -> this.getLogger().severe( "ExploitFixer requires HamsterAPI 0.0.8 or newer to work! Download: https://www.spigotmc.org/resources/78831/"), 20L, 20L); } scheduler.runTaskTimerAsynchronously(this, () -> { final ExploitPlayerManager exploitPlayerManager = moduleManager.getExploitPlayerManager(); exploitPlayerManager.clear(); }, 9000L, 9000L); }
Example 4
Source File: EffectManager.java From EffectLib with MIT License | 4 votes |
public void start(Effect effect) { if (disposed) { throw new IllegalStateException("EffectManager is disposed and not able to accept any effects."); } if (disposeOnTermination) { throw new IllegalStateException("EffectManager is awaiting termination to dispose and not able to accept any effects."); } if (effects.containsKey(effect)) { effect.cancel(false); } if (!owningPlugin.isEnabled()) return; BukkitScheduler s = Bukkit.getScheduler(); BukkitTask task = null; switch (effect.getType()) { case INSTANT: if(effect.isAsynchronous()) { task = s.runTaskAsynchronously(owningPlugin, effect); } else { task = s.runTask(owningPlugin, effect); } break; case DELAYED: if (effect.isAsynchronous()) { task = s.runTaskLaterAsynchronously(owningPlugin, effect, effect.getDelay()); } else { task = s.runTaskLater(owningPlugin, effect, effect.getDelay()); } break; case REPEATING: if (effect.isAsynchronous()) { task = s.runTaskTimerAsynchronously(owningPlugin, effect, effect.getDelay(), effect.getPeriod()); } else { task = s.runTaskTimer(owningPlugin, effect, effect.getDelay(), effect.getPeriod()); } break; } synchronized (this) { effects.put(effect, task); } }