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


Java Trigger类代码示例

本文整理汇总了Java中ch.njol.skript.lang.Trigger的典型用法代码示例。如果您正苦于以下问题:Java Trigger类的具体用法?Java Trigger怎么用?Java Trigger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Trigger类属于ch.njol.skript.lang包,在下文中一共展示了Trigger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: register

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public void register(Trigger t) {
  whiches.forEach(which -> {
    String pattern = which.getPattern();
    if (!expressions.contains(pattern)) {
      expressions.add(pattern);
      expressionInfos.put(pattern, which);
    }

    Map<SyntaxInfo, Trigger> handlerMap = isChanger ? changerHandlers : expressionHandlers;
    if (handlerMap.containsKey(which)) {
      Skript.error(String.format("The custom expression '%s' already has a handler.", pattern));
    } else {
      handlerMap.put(which, t);
    }
  });
  updateExpressions();
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:19,代码来源:CustomExpression.java

示例2: getAll

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public T[] getAll(Event e) {
  Trigger trigger = expressionHandlers.get(which);
  ExpressionGetEvent expressionEvent = new ExpressionGetEvent(e, exprs, parseResult);

  if (trigger == null) {
    Skript.error(
        String.format("The custom expression '%s' no longer has a get handler.",
            which.getPattern())
    );
    return Util.newArray(superType, 0);
  } else {
    trigger.execute(expressionEvent);
  }

  if (expressionEvent.getOutput() == null) {
    Skript.error(
        String.format("The get handler for '%s' did not continue.", which.getPattern())
    );
    return Util.newArray(superType, 0);
  }

  return Converters.convertArray(expressionEvent.getOutput(), types, superType);
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:25,代码来源:CustomExpression.java

示例3: loadTrigger

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
/**
 * For unit testing
 * 
 * @param node
 * @return The loaded Trigger
 */
@Nullable
static Trigger loadTrigger(final SectionNode node) {
	String event = node.getKey();
	if (event == null) {
		assert false : node;
		return null;
	}
	if (event.toLowerCase().startsWith("on "))
		event = "" + event.substring("on ".length());
	
	final NonNullPair<SkriptEventInfo<?>, SkriptEvent> parsedEvent = SkriptParser.parseEvent(event, "can't understand this event: '" + node.getKey() + "'");
	if (parsedEvent == null) {
		assert false;
		return null;
	}
	
	setCurrentEvent("unit test", parsedEvent.getFirst().events);
	try {
		return new Trigger(null, event, parsedEvent.getSecond(), loadItems(node));
	} finally {
		deleteCurrentEvent();
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:30,代码来源:ScriptLoader.java

示例4: unregister

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public void unregister(final Trigger t) {
	assert t == this.t;
	this.t = null;
	final Iterator<EvtAtInfo> iter = triggers.values().iterator();
	while (iter.hasNext()) {
		final EvtAtInfo i = iter.next();
		i.list.remove(this);
		if (i.currentIndex >= i.list.size())
			i.currentIndex--;
		if (i.list.isEmpty())
			iter.remove();
	}
	if (triggers.isEmpty())
		unregisterAll();
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:17,代码来源:EvtAtTime.java

示例5: register

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
	public void register(final Trigger trigger) {
//		if (types == null) {
//			final BlockLocation l = new BlockLocation(world, x, y, z);
//			List<Trigger> ts = blockTriggers.get(l);
//			if (ts == null)
//				blockTriggers.put(l, ts = new ArrayList<Trigger>());
//			ts.add(trigger);
//		} else {
		for (final ItemType t : types) {
			for (final ItemData d : t) {
				if (d.getId() > Skript.MAXBLOCKID)
					continue;
				List<Trigger> ts = itemTypeTriggers.get(d.getId());
				if (ts == null)
					itemTypeTriggers.put(d.getId(), ts = new ArrayList<Trigger>());
				ts.add(trigger);
			}
		}
//		}
		if (!registeredExecutor) {
			Bukkit.getPluginManager().registerEvent(PlayerMoveEvent.class, new Listener() {}, SkriptConfig.defaultEventPriority.value(), executor, Skript.getInstance(), true);
			registeredExecutor = true;
		}
	}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:26,代码来源:EvtMoveOn.java

示例6: unregister

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
	public void unregister(final Trigger t) {
//		final Iterator<Entry<BlockLocation, List<Trigger>>> i = blockTriggers.entrySet().iterator();
//		while (i.hasNext()) {
//			final List<Trigger> ts = i.next().getValue();
//			ts.remove(t);
//			if (ts.isEmpty())
//				i.remove();
//		}
		final Iterator<Entry<Integer, List<Trigger>>> i2 = itemTypeTriggers.entrySet().iterator();
		while (i2.hasNext()) {
			final List<Trigger> ts = i2.next().getValue();
			ts.remove(t);
			if (ts.isEmpty())
				i2.remove();
		}
	}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:18,代码来源:EvtMoveOn.java

示例7: unregister

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public void unregister(Trigger t) {
  whiches.forEach(which -> {
    Map<SyntaxInfo, Trigger> handlerMap = isChanger ? changerHandlers : expressionHandlers;
    handlerMap.remove(which);

    if (!expressionHandlers.containsKey(which) && !changerHandlers.containsKey(which)) {
      expressions.remove(which.getPattern());
      expressionInfos.remove(which.getPattern());
    }
  });
  updateExpressions();
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:14,代码来源:CustomExpression.java

示例8: change

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
  Trigger trigger = changerHandlers.get(which);
  ExpressionChangeEvent expressionEvent =
      new ExpressionChangeEvent(e, exprs, parseResult, delta, mode);

  if (trigger == null) {
    Skript.error(
        String.format("The custom expression '%s' no longer has a change handler.",
            which.getPattern())
    );
  } else {
    trigger.execute(expressionEvent);
  }
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:16,代码来源:CustomExpression.java

示例9: register

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public void register(Trigger t) {
  if (effects.contains(which)) {
    Skript.error(String.format("The custom effect '%s' already has a handler.", which));
    return;
  }
  effects.add(which);
  effectHandlers.put(which, t);
  updateEffects();
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:11,代码来源:CustomEffect.java

示例10: invokeEffect

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
private EffectEvent invokeEffect(Event e) {
  Trigger trigger = effectHandlers.get(which);
  EffectEvent effectEvent = new EffectEvent(e, exprs, parseResult, which, getNext());
  if (trigger == null) {
    Skript.error(String.format("The custom effect '%s' no longer has a handler.", which));
  } else {
    trigger.execute(effectEvent);
  }
  return effectEvent;
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:11,代码来源:CustomEffect.java

示例11: register

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public void register(Trigger t) {
  whiches.forEach(which -> {
    String pattern = which.getPattern();
    if (!conditions.contains(pattern)) {
      conditions.add(pattern);
      conditionInfos.put(pattern, which);
      conditionHandlers.put(which, t);
    } else {
      Skript.error(String.format("The custom condition '%s' already has a handler.", pattern));
    }
  });
  updateConditions();
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:15,代码来源:CustomCondition.java

示例12: unregister

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public void unregister(Trigger t) {
  whiches.forEach(which -> {
    conditions.remove(which.getPattern());
    conditionInfos.remove(which.getPattern());
    conditionHandlers.remove(which);
  });
  updateConditions();
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:10,代码来源:CustomCondition.java

示例13: check

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public boolean check(Event e) {
  Trigger trigger = conditionHandlers.get(which);
  ConditionEvent conditionEvent = new ConditionEvent(e, exprs, parseResult);
  trigger.execute(conditionEvent);
  return conditionEvent.isMarkedContinue() == !which.isInverted();
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:8,代码来源:CustomCondition.java

示例14: register

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
@Override
public void register(Trigger trigger) {
    if (!afterInitRun) {
        afterInit();
        afterInitRun = true;
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:8,代码来源:MundoEventScope.java

示例15: getTriggers

import ch.njol.skript.lang.Trigger; //导入依赖的package包/类
private final static Iterator<Trigger> getTriggers(final Class<? extends Event> event) {
	return new Iterator<Trigger>() {
		@Nullable
		private Class<?> e = event;
		@Nullable
		private Iterator<Trigger> current = null;
		
		@Override
		public boolean hasNext() {
			Iterator<Trigger> current = this.current;
			Class<?> e = this.e;
			while (current == null || !current.hasNext()) {
				if (e == null || !Event.class.isAssignableFrom(e))
					return false;
				final List<Trigger> l = triggers.get(e);
				this.current = current = l == null ? null : l.iterator();
				this.e = e = e.getSuperclass();
			}
			return true;
		}
		
		@Override
		public Trigger next() {
			final Iterator<Trigger> current = this.current;
			if (current == null || !hasNext())
				throw new NoSuchElementException();
			final Trigger next = current.next();
			assert next != null;
			return next;
		}
		
		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
	};
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:38,代码来源:SkriptEventHandler.java


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