当前位置: 首页>>代码示例>>Java>>正文


Java BukkitTask.isSync方法代码示例

本文整理汇总了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;
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:24,代码来源:MonitorUtils.java

示例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();
				}
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:21,代码来源:SchedulerTaskInjector.java

示例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();
				}
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:18,代码来源:SchedulerTaskInjector.java

示例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;
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:23,代码来源:MonitorUtils.java

示例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();
				}
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:15,代码来源:SchedulerTaskInjector.java

示例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);
        }
    }
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:15,代码来源:TaskInjector.java

示例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);
            }
        }
    }
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:16,代码来源:TaskInjector.java

示例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;
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:43,代码来源:TasksCommand.java


注:本文中的org.bukkit.scheduler.BukkitTask.isSync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。