Java Code Examples for ch.njol.skript.Skript#debug()

The following examples show how to use ch.njol.skript.Skript#debug() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerUtils.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
	try {
		for (final Player p : inviUpdate)
			p.updateInventory();
	} catch (final NullPointerException e) { // can happen on older CraftBukkit (Tekkit) builds
		if (Skript.debug())
			e.printStackTrace();
	}
	inviUpdate.clear();
}
 
Example 2
Source File: LogEntry.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
public LogEntry(final Level level, final int quality, final String message, final @Nullable Node node, final boolean tracked) {
	this.level = level;
	this.quality = quality;
	this.message = message;
	this.node = node;
	this.tracked = tracked;
	from = tracked || Skript.debug() ? findCaller() : "";
}
 
Example 3
Source File: IndeterminateDelay.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
protected TriggerItem walk(final Event e) {
	debug(e, true);
	final long start = Skript.debug() ? System.nanoTime() : 0;
	final TriggerItem next = getNext();
	if (next != null) {
		delayed.add(e);
		final Timespan d = duration.getSingle(e);
		if (d == null)
			return null;
		
		// Back up local variables
		Object localVars = Variables.removeLocals(e);
		
		Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
			@Override
			public void run() {
				if (Skript.debug())
					Skript.info(getIndentation() + "... continuing after " + (System.nanoTime() - start) / 1000000000. + "s");
				
				// Re-set local variables
				if (localVars != null)
					Variables.setLocalVariables(e, localVars);
				
				TriggerItem.walk(next, e);
			}
		}, d.getTicks_i());
	}
	return null;
}
 
Example 4
Source File: ParseLogger.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
default void debug(@Nullable String msg) {
	if (Skript.debug())
		info(msg);
}
 
Example 5
Source File: TriggerItem.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
protected final void debug(final Event e, final boolean run) {
	if (!Skript.debug())
		return;
	Skript.debug(getIndentation() + (run ? "" : "-") + toString(e, true));
}
 
Example 6
Source File: Delay.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
protected TriggerItem walk(final Event e) {
	debug(e, true);
	final long start = Skript.debug() ? System.nanoTime() : 0;
	final TriggerItem next = getNext();
	if (next != null) {
		delayed.add(e);
		final Timespan d = duration.getSingle(e);
		if (d == null)
			return null;
		
		// Back up local variables
		Object localVars = Variables.removeLocals(e);
		
		Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
			@Override
			public void run() {
				if (Skript.debug())
					Skript.info(getIndentation() + "... continuing after " + (System.nanoTime() - start) / 1000000000. + "s");
				
				// Re-set local variables
				if (localVars != null)
					Variables.setLocalVariables(e, localVars);
				
				Object timing = null;
				if (SkriptTimings.enabled()) { // getTrigger call is not free, do it only if we must
					Trigger trigger = getTrigger();
					if (trigger != null) {
						timing = SkriptTimings.start(trigger.getDebugLabel());
					}
				}
				
				TriggerItem.walk(next, e);
				Variables.removeLocals(e); // Clean up local vars, we may be exiting now
				
				SkriptTimings.stop(timing); // Stop timing if it was even started
			}
		}, d.getTicks_i() < 1 ? 1 : d.getTicks_i()); // Minimum delay is one tick, less than it is useless!
	}
	return null;
}