本文整理匯總了Java中org.bukkit.scheduler.BukkitTask.isSync方法的典型用法代碼示例。如果您正苦於以下問題:Java BukkitTask.isSync方法的具體用法?Java BukkitTask.isSync怎麽用?Java BukkitTask.isSync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.scheduler.BukkitTask
的用法示例。
在下文中一共展示了BukkitTask.isSync方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTaskTimingsByPlugin
import org.bukkit.scheduler.BukkitTask; //導入方法依賴的package包/類
public static MonitorRecord getTaskTimingsByPlugin(Plugin plg) {
MonitorRecord monitorRecord = getMonitorRecord("Scheduler", 0L, 0L, 0L);
if (plg == null) {
return monitorRecord;
}
for (BukkitTask pendingTask : Bukkit.getScheduler().getPendingTasks()) {
if (pendingTask.isSync() && pendingTask.getOwner().equals(plg)) {
try {
FieldAccessor<Runnable> field = Reflection.getField(pendingTask.getClass(), "task", Runnable.class);
Runnable runnable = field.get(pendingTask);
if (runnable instanceof SchedulerTaskInjector) {
SchedulerTaskInjector schedulerTaskInjector = (SchedulerTaskInjector) runnable;
monitorRecord = monitorRecord.merge(getMonitorRecord("Scheduler",
schedulerTaskInjector.getTotalTime(), schedulerTaskInjector.getTotalCount(),
schedulerTaskInjector.getMaxExecuteTime()));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return monitorRecord;
}
示例2: inject
import org.bukkit.scheduler.BukkitTask; //導入方法依賴的package包/類
/**
*
* @author jiongjionger,Vlvxingze
*/
// 替換原本的Runnable為帶性能統計的版本
public static void inject(Plugin plg) {
if (plg != null) {
for (BukkitTask pendingTask : Bukkit.getScheduler().getPendingTasks()) {
if (pendingTask.isSync() && pendingTask.getOwner().equals(plg)) {
try {
FieldAccessor<Runnable> field = Reflection.getField(pendingTask.getClass(), "task", Runnable.class);
field.set(pendingTask, new SchedulerTaskInjector(plg, field.get(pendingTask)));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
示例3: uninject
import org.bukkit.scheduler.BukkitTask; //導入方法依賴的package包/類
public static void uninject(Plugin plg) {
if (plg != null) {
for (BukkitTask pendingTask : Bukkit.getScheduler().getPendingTasks()) {
if (pendingTask.isSync() && pendingTask.getOwner().equals(plg)) {
try {
FieldAccessor<Runnable> field = Reflection.getField(pendingTask.getClass(), "task", Runnable.class);
Runnable runnable = field.get(pendingTask);
if (runnable instanceof SchedulerTaskInjector) {
field.set(pendingTask, ((SchedulerTaskInjector) runnable).getRunnable());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
示例4: getTaskTimingsByPlugin
import org.bukkit.scheduler.BukkitTask; //導入方法依賴的package包/類
public static MonitorRecord getTaskTimingsByPlugin(Plugin plg) {
MonitorRecord monitorRecord = getMonitorRecord("Scheduler", 0L, 0L, 0L);
if (plg == null) {
return monitorRecord;
}
for (BukkitTask pendingTask : Bukkit.getScheduler().getPendingTasks()) {
if (pendingTask.isSync() && pendingTask.getOwner().equals(plg)) {
try {
FieldAccessor<Runnable> field = Reflection.getField(pendingTask.getClass(), "task", Runnable.class);
Runnable runnable = field.get(pendingTask);
if (runnable instanceof SchedulerTaskInjector) {
SchedulerTaskInjector schedulerTaskInjector = (SchedulerTaskInjector) runnable;
monitorRecord = monitorRecord
.merge(getMonitorRecord("Scheduler", schedulerTaskInjector.getTotalTime(), schedulerTaskInjector.getTotalCount(), schedulerTaskInjector.getMaxExecuteTime()));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return monitorRecord;
}
示例5: inject
import org.bukkit.scheduler.BukkitTask; //導入方法依賴的package包/類
public static void inject(Plugin plg) {
if (plg != null) {
for (BukkitTask pendingTask : Bukkit.getScheduler().getPendingTasks()) {
if (pendingTask.isSync() && pendingTask.getOwner().equals(plg)) {
try {
FieldAccessor<Runnable> field = Reflection.getField(pendingTask.getClass(), "task", Runnable.class);
field.set(pendingTask, new SchedulerTaskInjector(plg, field.get(pendingTask)));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
示例6: inject
import org.bukkit.scheduler.BukkitTask; //導入方法依賴的package包/類
public static void inject(Plugin plugin) {
BukkitScheduler scheduler = Bukkit.getScheduler();
List<BukkitTask> pendingTasks = scheduler.getPendingTasks();
for (BukkitTask pendingTask : pendingTasks) {
//we could ignore async tasks for now
if (pendingTask.isSync() && pendingTask.getOwner().equals(plugin)) {
FieldAccessor<Runnable> taskField = Reflection.getField(pendingTask.getClass(), "task", Runnable.class);
Runnable originalTask = taskField.get(pendingTask);
TaskInjector taskInjector = new TaskInjector(originalTask);
taskField.set(pendingTask, taskInjector);
}
}
}
示例7: uninject
import org.bukkit.scheduler.BukkitTask; //導入方法依賴的package包/類
public static void uninject(Plugin plugin) {
BukkitScheduler scheduler = Bukkit.getScheduler();
List<BukkitTask> pendingTasks = scheduler.getPendingTasks();
for (BukkitTask pendingTask : pendingTasks) {
//we could ignore async tasks for now
if (pendingTask.isSync() && pendingTask.getOwner().equals(plugin)) {
FieldAccessor<Runnable> taskField = Reflection.getField(pendingTask.getClass(), "task", Runnable.class);
Runnable task = taskField.get(pendingTask);
if (task instanceof TaskInjector) {
taskField.set(pendingTask, ((TaskInjector) task).originalTask);
}
}
}
}
示例8: onCommand
import org.bukkit.scheduler.BukkitTask; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!isAllowed(sender, command)) {
sender.sendMessage(org.bukkit.ChatColor.DARK_RED + "Not whitelisted");
return true;
}
List<BaseComponent[]> lines = Lists.newArrayList();
List<BukkitTask> pendingTasks = Bukkit.getScheduler().getPendingTasks();
for (BukkitTask pendingTask : pendingTasks) {
Plugin owner = pendingTask.getOwner();
int taskId = pendingTask.getTaskId();
boolean sync = pendingTask.isSync();
String id = Integer.toString(taskId);
if (sync) {
id += "-Sync";
} else if (Bukkit.getScheduler().isCurrentlyRunning(taskId)) {
id += "-Running";
}
lines.add(new ComponentBuilder(owner.getName())
.color(PRIMARY_COLOR)
.append('-' + id)
.color(SECONDARY_COLOR)
.create());
Class<?> runnableClass = getRunnableClass(pendingTask);
if (runnableClass != null) {
lines.add(new ComponentBuilder(" Task: ")
.color(PRIMARY_COLOR)
.append(runnableClass.getSimpleName())
.color(SECONDARY_COLOR)
.create());
}
}
Pagination pagination = new Pagination("Stacktrace", lines);
pagination.send(sender);
plugin.getPaginations().put(sender, pagination);
return true;
}