本文整理匯總了Java中org.bukkit.scheduler.BukkitScheduler.runTaskTimer方法的典型用法代碼示例。如果您正苦於以下問題:Java BukkitScheduler.runTaskTimer方法的具體用法?Java BukkitScheduler.runTaskTimer怎麽用?Java BukkitScheduler.runTaskTimer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.scheduler.BukkitScheduler
的用法示例。
在下文中一共展示了BukkitScheduler.runTaskTimer方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerTasks
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
@Override
public void registerTasks() {
BukkitScheduler scheduler = getServer().getScheduler();
TicksPerSecondTask ticksTask = new TicksPerSecondTask();
scheduler.runTaskTimer(this, ticksTask, 60L, 1L);
TpsCollector tpsCollector = new TpsCollector(core.getConnector(), ticksTask::getLastTicks);
scheduler.runTaskTimer(this, tpsCollector, 20L, 20L);
PingCollector pingTask = new PingCollector(core.getConnector(), () -> Bukkit.getOnlinePlayers()
.stream()
.mapToInt(BukkitUtil::getReflectionPing)
.average()
.orElse(0));
scheduler.runTaskTimer(this, pingTask, 40L, 40L);
scheduler.runTaskTimer(this, new BukkitWorldCollector(core.getConnector()), 5 * 60 * 20L, 5 * 60 * 20L);
scheduler.runTaskTimer(this, playerCollector, 15 * 60 * 20L, 15 * 60 * 20L);
}
示例2: load
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
public void load() {
BukkitScheduler scheduler = plugin.getServer().getScheduler();
if (task != null) {
task.cancel();
task = null;
}
ConfigurationSection arenaConfiguration = loadDataFile("arenas");
load(arenaConfiguration);
ConfigurationSection arenaData = loadDataFile("data");
loadData(arenaData);
plugin.reloadConfig();
Configuration config = plugin.getConfig();
pathTemplate = config.getString("path_template", pathTemplate);
tickInterval = config.getInt("tick_interval", 40);
task = scheduler.runTaskTimer(plugin, this, 1, tickInterval);
}
示例3: runTask
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
@Override
public void runTask( RunnableData runnable ) {
runnable.check();
Collection<RunnableData.TaskType> types = runnable.getTaskTypes();
BukkitScheduler scheduler = getOriginObject().getServer().getScheduler();
if ( types.contains( RunnableData.TaskType.ASYNC ) ) {
if ( types.contains( RunnableData.TaskType.REPEATING ) ) {
scheduler.runTaskTimerAsynchronously( getOriginObject(), runnable, runnable.getStartTicks(), runnable.getRepeatTicks() );
} else if ( types.contains( RunnableData.TaskType.DELAYED ) ) {
scheduler.runTaskLaterAsynchronously( getOriginObject(), runnable, runnable.getStartTicks() );
} else {
scheduler.runTaskAsynchronously( getOriginObject(), runnable );
}
} else if ( types.contains( RunnableData.TaskType.SYNC ) ) {
if ( types.contains( RunnableData.TaskType.REPEATING ) ) {
scheduler.runTaskTimer( getOriginObject(), runnable, runnable.getStartTicks(), runnable.getRepeatTicks() );
} else if ( types.contains( RunnableData.TaskType.DELAYED ) ) {
scheduler.runTaskLater( getOriginObject(), runnable, runnable.getStartTicks() );
} else {
scheduler.runTask( getOriginObject(), runnable );
}
}
}
示例4: BukkitIntervalTrigger
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
public BukkitIntervalTrigger(Workspace workspace, Set<Trigger> parentTriggers, long timeout, long interval, boolean sync){
this.workspace = workspace;
this.parentTriggers = parentTriggers;
this.timeout = timeout;
this.interval = interval;
this.sync = sync;
VarScript plugin = this.workspace.getWorkspaceService().getVarScript();
BukkitScheduler scheduler = plugin.getServer().getScheduler();
parentTriggers.add(this);
if (sync) bukkitTask = scheduler.runTaskTimer(plugin, this, timeout, interval);
else bukkitTask = scheduler.runTaskTimerAsynchronously(plugin, this, timeout, interval);
}
示例5: initTask
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
@FlagInit
public static void initTask(HeavySpleef heavySpleef) {
BukkitScheduler scheduler = Bukkit.getScheduler();
task = new AntiCampingTask(heavySpleef);
bukkitTask = scheduler.runTaskTimer(heavySpleef.getPlugin(), task, ONE_SECOND_INTERVAL, ONE_SECOND_INTERVAL);
}
示例6: start
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
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);
}
}
示例7: start
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
public void start()
{
BukkitScheduler scheduler = player.getServer().getScheduler();
task = scheduler.runTaskTimer(player.getPlugin(), this, 0L, 1L);
}
示例8: onEnable
import org.bukkit.scheduler.BukkitScheduler; //導入方法依賴的package包/類
@Override
public void onEnable() {
if (!versionCheck()) {
getLogger().severe("This version of CraftBukkit is too old to run " + getDescription().getName() + ".");
getLogger().info(getDescription().getName() + " requires CB build >= " + minVersion + ".");
getLogger().info("Disabling plugin. This check can be turned off in the configuration.");
setEnabled(false);
return;
}
dataFolder = getDataFolder();
c = new Config(this);
final PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new SurvivorsListener(this), this);
pm.registerEvents(new ThirstListener(), this);
pm.registerEvents(new UHCListener(), this);
final BukkitScheduler bs = getServer().getScheduler();
bs.runTaskTimer(this, new BatteryRunner(this), Config.batteryDrainInterval * 60L * 20L, Config.batteryDrainInterval * 60L * 20L);
bs.runTaskTimer(this, new CompassUpdater(this), 0L, Config.gpsUpdateInterval * 20L);
bs.runTaskTimer(this, new ZombieSpray(this), 20L, Config.toxicInterval);
bs.runTaskTimer(this, new LootChestFiller(this), 20L, 200L);
bs.runTaskTimer(this, new RepairChestRunner(this), 20L, Config.repairChestRunInterval);
bs.runTaskTimer(this, new ColdRunner(this), 20L, Config.coldDrainInterval);
bs.runTaskTimerAsynchronously(this, new UserdataSaver(), 20L, Config.userdataSaveInterval * 60L * 20L);
if (Config.deathChestRemoveInterval > 0L)
bs.runTaskTimer(this, new DeathChestRemover(this), 0L, Config.deathChestRemoveInterval * 60L * 20L);
addAllRecipes();
registerCommand(new CmdRadio(this), "radio", this);
registerCommand(new CmdSurvivors(this), "survivors", this);
registerCommand(new CmdGPS(this), "gps", this);
try {
Metrics m = new Metrics(this);
Matcher matcher = versionPattern.matcher(getDescription().getVersion());
if (matcher.matches()) {
// 1 = base version
// 3 = -SNAPSHOT
// 6 = build #
String versionMinusBuild = (matcher.group(1) == null) ? "Unknown" : matcher.group(1);
String build = (matcher.group(6) == null) ? "local build" : matcher.group(6);
if (matcher.group(3) == null) build = "release";
Metrics.Graph g = m.createGraph("Version"); // get our custom version graph
g.addPlotter(
new Metrics.Plotter(versionMinusBuild + "~=~" + build) {
@Override
public int getValue() {
return 1; // this value doesn't matter
}
}
); // add the donut graph with major version inside and build outside
m.addGraph(g); // add the graph
}
if (!m.start())
getLogger().info("You have Metrics off! I like to keep accurate usage statistics, but okay. :(");
else getLogger().info("Metrics enabled. Thank you!");
} catch (Exception ignore) {
getLogger().warning("Could not start Metrics!");
}
}