use of org.bukkit.scheduler.BukkitScheduler in project MagicPlugin by elBukkit.
the class Mage method showHoloText.
@Override
public void showHoloText(Location location, String text, int duration) {
// TODO: Broadcast
if (!isPlayer())
return;
final Player player = getPlayer();
if (hologram == null) {
hologram = HoloUtils.createHoloText(location, text);
} else {
if (hologramIsVisible) {
hologram.hide(player);
}
hologram.teleport(location);
hologram.setLabel(text);
}
hologram.show(player);
BukkitScheduler scheduler = Bukkit.getScheduler();
if (duration > 0) {
scheduler.scheduleSyncDelayedTask(controller.getPlugin(), new Runnable() {
@Override
public void run() {
hologram.hide(player);
hologramIsVisible = false;
}
}, duration);
}
}
use of org.bukkit.scheduler.BukkitScheduler in project TokenManager by RealizedMC.
the class DataManager method handleUnload.
@Override
public void handleUnload() throws Exception {
if (task != null) {
final BukkitScheduler scheduler = Bukkit.getScheduler();
if (scheduler.isCurrentlyRunning(task) || scheduler.isQueued(task)) {
scheduler.cancelTask(task);
}
}
database.save();
database = null;
}
use of org.bukkit.scheduler.BukkitScheduler in project NoCheatPlus by NoCheatPlus.
the class NoCheatPlus method scheduleConsistencyCheckers.
private void scheduleConsistencyCheckers() {
BukkitScheduler sched = getServer().getScheduler();
if (consistencyCheckerTaskId != -1) {
sched.cancelTask(consistencyCheckerTaskId);
}
ConfigFile config = ConfigManager.getConfigFile();
if (!config.getBoolean(ConfPaths.DATA_CONSISTENCYCHECKS_CHECK, true)) {
return;
}
// Schedule task in seconds.
final long delay = 20L * config.getInt(ConfPaths.DATA_CONSISTENCYCHECKS_INTERVAL, 1, 3600, 10);
consistencyCheckerTaskId = sched.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
runConsistencyChecks();
}
}, delay, delay);
}
use of org.bukkit.scheduler.BukkitScheduler in project AuthMeReloaded by AuthMe.
the class AuthMeInitializationTest method shouldHandlePrematureShutdownGracefully.
@Test
public void shouldHandlePrematureShutdownGracefully() {
// given
BukkitScheduler scheduler = mock(BukkitScheduler.class);
given(server.getScheduler()).willReturn(scheduler);
// Make sure ConsoleLogger has no logger reference since that may happen on unexpected stops
ReflectionTestUtils.setField(ConsoleLogger.class, null, "logger", null);
// when
authMe.onDisable();
// then - no exceptions
// via TaskCloser
verify(scheduler).getActiveWorkers();
}
use of org.bukkit.scheduler.BukkitScheduler in project Prism-Bukkit by prism.
the class InternalAffairs method run.
@Override
public void run() {
if (plugin.recordingTask != null) {
final int taskId = plugin.recordingTask.getTaskId();
final BukkitScheduler scheduler = Bukkit.getScheduler();
// is recording task running?
if (scheduler.isCurrentlyRunning(taskId) || scheduler.isQueued(taskId)) {
Prism.debug("[InternalAffairs] Recorder is currently active. All is good.");
return;
}
}
Prism.log("[InternalAffairs] Recorder is NOT active... checking database");
// is db connection valid?
try (Connection conn = Prism.getPrismDataSource().getConnection()) {
if (conn == null) {
Prism.log("[InternalAffairs] Pool returned NULL instead of a valid connection.");
} else if (conn.isClosed()) {
Prism.log("[InternalAffairs] Pool returned an already closed connection.");
} else if (conn.isValid(5)) {
Prism.log("[InternalAffairs] Pool returned valid connection!");
Prism.log("[InternalAffairs] Restarting scheduled recorder tasks");
plugin.actionRecorderTask();
}
} catch (final SQLException e) {
Prism.debug("[InternalAffairs] Error: " + e.getMessage());
e.printStackTrace();
}
}
Aggregations