本文整理汇总了Java中org.bukkit.scheduler.BukkitWorker类的典型用法代码示例。如果您正苦于以下问题:Java BukkitWorker类的具体用法?Java BukkitWorker怎么用?Java BukkitWorker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BukkitWorker类属于org.bukkit.scheduler包,在下文中一共展示了BukkitWorker类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reload
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
@Override
public void reload() {
pluginManager.clearPlugins();
commandMap.clearCommands();
resetRecipes();
List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
for (BukkitWorker worker : overdueWorkers) {
Plugin plugin = worker.getOwner();
String author = "<NoAuthorGiven>";
if (plugin.getDescription().getAuthors().size() > 0) {
author = plugin.getDescription().getAuthors().get(0);
}
getLogger().log(Level.SEVERE, String.format(
"Nag author: '%s' of '%s' about the following: %s",
author,
plugin.getDescription().getName(),
"This plugin is not properly shutting down its async tasks when it is being reloaded. This may cause conflicts with the newly loaded version of the plugin"
));
}
loadPlugins();
enablePlugins();
}
示例2: getActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
public List<BukkitWorker> getActiveWorkers() {
final ArrayList<BukkitWorker> workers = new ArrayList<BukkitWorker>();
for (final CraftTask taskObj : runners.values()) {
// Iterator will be a best-effort (may fail to grab very new values) if called from an async thread
if (taskObj.isSync()) {
continue;
}
final CraftAsyncTask task = (CraftAsyncTask) taskObj;
synchronized (task.getWorkers()) {
// This will never have an issue with stale threads; it's state-safe
workers.addAll(task.getWorkers());
}
}
return workers;
}
示例3: getActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
public List<BukkitWorker> getActiveWorkers() {
final ArrayList<BukkitWorker> workers = new ArrayList<BukkitWorker>();
for (final NukkitTask taskObj : runners.values()) {
// Iterator will be a best-effort (may fail to grab very new values) if called from an async thread
if (taskObj.isSync()) {
continue;
}
final NukkitAsyncTask task = (NukkitAsyncTask) taskObj;
synchronized (task.getWorkers()) {
// This will never have an issue with stale threads; it's state-safe
workers.addAll(task.getWorkers());
}
}
return workers;
}
示例4: reload
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
/**
* Reloads TimeIsMoney.
*/
void reload() {
// cancelling current tasks
for (BukkitWorker bw: Bukkit.getScheduler().getActiveWorkers()) {
if (bw.getOwner() == this) {
Bukkit.getScheduler().cancelTask(bw.getTaskId());
}
}
Bukkit.getPluginManager().disablePlugin(this);
Bukkit.getPluginManager().enablePlugin(this);
}
示例5: getPendingTasks
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
private List<Integer> getPendingTasks() {
List<Integer> pendingTasks = new ArrayList<>();
//returns only the async tasks
for (BukkitWorker pendingTask : scheduler.getActiveWorkers()) {
if (pendingTask.getOwner().equals(plugin)
//it's not a periodic task
&& !scheduler.isQueued(pendingTask.getTaskId())) {
pendingTasks.add(pendingTask.getTaskId());
}
}
return pendingTasks;
}
示例6: mockActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
private void mockActiveWorkers() {
Plugin otherOwner = mock(Plugin.class);
List<BukkitWorker> tasks = Arrays.asList(
mockBukkitWorker(authMe, ACTIVE_WORKERS_ID[0], false),
mockBukkitWorker(otherOwner, 3, false),
mockBukkitWorker(authMe, ACTIVE_WORKERS_ID[1], false),
mockBukkitWorker(authMe, 7, true),
mockBukkitWorker(otherOwner, 11, true));
given(bukkitScheduler.getActiveWorkers()).willReturn(tasks);
}
示例7: mockBukkitWorker
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
private BukkitWorker mockBukkitWorker(Plugin owner, int taskId, boolean isQueued) {
BukkitWorker worker = mock(BukkitWorker.class);
given(worker.getOwner()).willReturn(owner);
given(worker.getTaskId()).willReturn(taskId);
given(bukkitScheduler.isQueued(taskId)).willReturn(isQueued);
return worker;
}
示例8: getWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
LinkedList<BukkitWorker> getWorkers() {
return workers;
}
示例9: getActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
@Override
public List<BukkitWorker> getActiveWorkers()
{
// TODO Auto-generated method stub
throw new UnimplementedOperationException();
}
示例10: getActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
@Override
public List<BukkitWorker> getActiveWorkers() {
return delegate.getActiveWorkers();
}
示例11: getActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
@Override
public List<BukkitWorker> getActiveWorkers() {
return Collections.emptyList();
}
示例12: getActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
@Override
public List<BukkitWorker> getActiveWorkers() {
// TODO Auto-generated method stub
return null;
}
示例13: getActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
@Override
public List<BukkitWorker> getActiveWorkers() {
throw Pokkit.unsupported();
}
示例14: getActiveWorkers
import org.bukkit.scheduler.BukkitWorker; //导入依赖的package包/类
public List<BukkitWorker> getActiveWorkers() {
// TODO talk to dark about maybe adding Async task handling to ServerTaskManager
// For now return a empty array list
return new ArrayList<BukkitWorker>();
}