當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。