• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClassInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@Override
protected Object[] get(Event e) {
  Object t = type.getSingle(e);
  if (t == null) {
    return null;
  }

  Class convertTo;
  if (t instanceof ClassInfo) {
    convertTo = ((ClassInfo) t).getC();
  } else if (t instanceof JavaType) {
    convertTo = ((JavaType) t).getJavaClass();
  } else {
    throw new IllegalStateException();
  }

  return convertArray(source.getArray(e), convertTo);
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:19,代码来源:ExprCast.java


示例2: init

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Literal<?>[] args, int matchedPattern,
                    SkriptParser.ParseResult parseResult) {
  isChanger = (parseResult.mark & 1) == 1;

  String what = parseResult.regexes.get(0).group();
  switch (matchedPattern) {
    case 0:
      whiches.add(createSyntaxInfo(what, (parseResult.mark & 2) == 2, false));
      break;
    case 1:
      String fromType = ((Literal<ClassInfo>) args[0]).getSingle().getCodeName();
      whiches.add(createSyntaxInfo("[the] " + what + " of %$" + fromType + "s%", false, true));
      whiches.add(createSyntaxInfo("%$" + fromType + "s%'[s] " + what, false, false));
      break;
  }

  return true;
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:21,代码来源:CustomExpression.java


示例3: init

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Literal<?>[] args, int matchedPattern,
                    SkriptParser.ParseResult parseResult) {
  String c = parseResult.regexes.get(0).group();
  switch (matchedPattern) {
    case 0:
      whiches.add(createSyntaxInfo(c, false));
      break;
    case 1:
      String type = ((Literal<ClassInfo>) args[0]).getSingle().getCodeName();
      whiches.add(createSyntaxInfo("%" + type + "% (is|are) " + c, false));
      whiches.add(createSyntaxInfo("%" + type + "% (isn't|is not|aren't|are not) " + c, true));
      break;
  }

  return true;
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:19,代码来源:CustomCondition.java


示例4: build

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
public DocumentationElement.Changer build(DocumentationElement parent) {
    ClassInfo classInfo;
    boolean single;
    if (type == null) {
        classInfo = null;
        single = false;
    } else if (type.getComponentType() != null) {
        classInfo = Classes.getExactClassInfo(type.getComponentType());
        single = false;
    } else {
        classInfo = Classes.getExactClassInfo(type);
        single = true;
    }
    Optional<Pair<ClassInfo, Boolean>> typeDoc = classInfo == null ? Optional.empty() : Optional.of(new Pair<>(classInfo, single));
    return new DocumentationElement.Changer(parent, mode, typeDoc, description, originVersion);
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:17,代码来源:DocumentationBuilder.java


示例5: getSuperClassInfo

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
/**
 * Gets the class info of the given class or its closest registered superclass. This method will never return null unless <tt>c</tt> is null.
 * 
 * @param c
 * @return The closest superclass's info
 */
@SuppressWarnings({"unchecked", "null"})
public static <T> ClassInfo<? super T> getSuperClassInfo(final Class<T> c) {
	assert c != null;
	checkAllowClassInfoInteraction();
	final ClassInfo<?> i = superClassInfos.get(c);
	if (i != null)
		return (ClassInfo<? super T>) i;
	for (final ClassInfo<?> ci : getClassInfos()) {
		if (ci.getC().isAssignableFrom(c)) {
			if (!Skript.isAcceptRegistrations())
				superClassInfos.put(c, ci);
			return (ClassInfo<? super T>) ci;
		}
	}
	assert false;
	return null;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:24,代码来源:Classes.java


示例6: getClassInfoFromUserInput

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
/**
 * As the name implies
 * 
 * @param name
 * @return the class info or null if the name was not recognised
 */
@Nullable
public static ClassInfo<?> getClassInfoFromUserInput(String name) {
	checkAllowClassInfoInteraction();
	name = "" + name.toLowerCase();
	for (final ClassInfo<?> ci : getClassInfos()) {
		final Pattern[] uip = ci.getUserInputPatterns();
		if (uip == null)
			continue;
		for (final Pattern pattern : uip) {
			if (pattern.matcher(name).matches())
				return ci;
		}
	}
	return null;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:22,代码来源:Classes.java


示例7: parseSimple

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
/**
 * Parses without trying to convert anything.
 * <p>
 * Can log an error xor other log messages.
 * 
 * @param s
 * @param c
 * @return The parsed object
 */
@Nullable
public static <T> T parseSimple(final String s, final Class<T> c, final ParseContext context) {
	final ParseLogHandler log = SkriptLogger.startParseLogHandler();
	try {
		for (final ClassInfo<?> info : getClassInfos()) {
			final Parser<?> parser = info.getParser();
			if (parser == null || !parser.canParse(context) || !c.isAssignableFrom(info.getC()))
				continue;
			log.clear();
			@SuppressWarnings("unchecked")
			final T t = (T) parser.parse(s, context);
			if (t != null) {
				log.printLog();
				return t;
			}
		}
		log.printError();
	} finally {
		log.stop();
	}
	return null;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:32,代码来源:Classes.java


示例8: getYggdrasilStart

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
private final static byte[] getYggdrasilStart(final ClassInfo<?> c) throws NotSerializableException {
	assert Enum.class.isAssignableFrom(Kleenean.class) && Tag.getType(Kleenean.class) == Tag.T_ENUM : Tag.getType(Kleenean.class); // TODO why is this check here?
	final Tag t = Tag.getType(c.getC());
	assert t.isWrapper() || t == Tag.T_STRING || t == Tag.T_OBJECT || t == Tag.T_ENUM;
	final byte[] cn = t == Tag.T_OBJECT || t == Tag.T_ENUM ? Variables.yggdrasil.getID(c.getC()).getBytes(UTF_8) : null;
	final byte[] r = new byte[YGGDRASIL_START.length + 1 + (cn == null ? 0 : 1 + cn.length)];
	int i = 0;
	for (; i < YGGDRASIL_START.length; i++)
		r[i] = YGGDRASIL_START[i];
	r[i++] = t.tag;
	if (cn != null) {
		r[i++] = (byte) cn.length;
		for (int j = 0; j < cn.length; j++)
			r[i++] = cn[j];
	}
	assert i == r.length;
	return r;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:19,代码来源:Classes.java


示例9: deserialize

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@Nullable
public final static Object deserialize(final ClassInfo<?> type, InputStream value) {
	Serializer<?> s;
	assert (s = type.getSerializer()) != null && (s.mustSyncDeserialization() ? Bukkit.isPrimaryThread() : true) : type + "; " + s + "; " + Bukkit.isPrimaryThread();
	YggdrasilInputStream in = null;
	try {
		value = new SequenceInputStream(new ByteArrayInputStream(getYggdrasilStart(type)), value);
		in = Variables.yggdrasil.newInputStream(value);
		return in.readObject();
	} catch (final IOException e) { // i.e. invalid save
		if (Skript.testing())
			e.printStackTrace();
		return null;
	} finally {
		if (in != null) {
			try {
				in.close();
			} catch (final IOException e) {}
		}
		try {
			value.close();
		} catch (final IOException e) {}
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:25,代码来源:Classes.java


示例10: notOfType

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
public final static String notOfType(final ClassInfo<?>... cs) {
	if (cs.length == 1) {
		return Language.get("not") + " " + cs[0].getName().withIndefiniteArticle();
	} else {
		final StringBuilder b = new StringBuilder(Language.get("neither") + " ");
		for (int k = 0; k < cs.length; k++) {
			if (k != 0) {
				if (k != cs.length - 1)
					b.append(", ");
				else
					b.append(" " + Language.get("nor") + " ");
			}
			b.append(cs[k].getName().withIndefiniteArticle());
		}
		return "" + b.toString();
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:18,代码来源:SkriptParser.java


示例11: insertClass

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
private final static void insertClass(final PrintWriter pw, final ClassInfo<?> info) {
	if (info.getDocName() == ClassInfo.NO_DOC)
		return;
	if (info.getDocName() == null || info.getDescription() == null || info.getUsage() == null || info.getExamples() == null || info.getSince() == null) {
		Skript.warning("Class " + info.getCodeName() + " is missing information");
		return;
	}
	final String desc = validateHTML(StringUtils.join(info.getDescription(), "<br/>"), "classes");
	final String usage = validateHTML(StringUtils.join(info.getUsage(), "<br/>"), "classes");
	final String since = info.getSince() == null ? "" : validateHTML(info.getSince(), "classes");
	if (desc == null || usage == null || since == null) {
		Skript.warning("Class " + info.getCodeName() + "'s description, usage or 'since' is invalid");
		return;
	}
	final String patterns = info.getUserInputPatterns() == null ? "" : convertRegex(StringUtils.join(info.getUserInputPatterns(), "\n"));
	insertOnDuplicateKeyUpdate(pw, "classes",
			"id, name, description, patterns, `usage`, examples, since",
			"patterns = TRIM(LEADING '\n' FROM CONCAT(patterns, '\n', '" + escapeSQL(patterns) + "'))",
			escapeHTML(info.getCodeName()),
			escapeHTML(info.getDocName()),
			desc,
			patterns,
			usage,
			escapeHTML(StringUtils.join(info.getExamples(), "\n")),
			since);
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:27,代码来源:Documentation.java


示例12: Changer

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
public Changer(DocumentationElement parent, ch.njol.skript.classes.Changer.ChangeMode mode, Optional<Pair<ClassInfo, Boolean>> type, String description, String originVersion) {
    this.parent = parent;
    this.mode = mode;
    this.type = type;
    this.description = description;
    this.originVersion = originVersion;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:8,代码来源:DocumentationElement.java


示例13: load

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
public static void load() {
    Registration.registerEffect(EffCallCustomEvent.class, "(0¦call|1¦async call|1¦call async) custom event %strings% [to] [det[ail]s %-objects%] [arg[ument]s %-objects%]")
            .document("Call Custom Event", "1.6.7", "Calls a custom event with the specified id and optionally the specified details and/or arguments. "
                    + "Details are used in events as event-type. For example, if you had a detail 3426, event-number would equal 3426. "
                    + "Details may be of any type that is in Skript by default (number, string, player, world, etc.) as well as of any type added in MundoSK (creator, achievement, difficulty, etc.), and possibly other addons, depending on what loads in what order. "
                    + "You can't have two or more details of the same type. If you try to do this, only the detail that comes last of that type will be used. "
                    + "Arguments are like details, except that you may have multiple arguments of the same type, and they can be of any type from any addon. "
                    + "Arguments are accessed from within the event using the Args of Custom Event expression. "
                    + "For both details and arguments, you have to put them in a list variable and then call the custom event using the list variable in the syntax, otherwise you'll get an internal error. "
                    + "In MundoSK 1.8, two new features have been introduced (these will not work in previous versions):"
                    + "First, you can specify that the custom event is being called asynchronously. When code running in async is calling a custom event, this should be specified in order to prevent errors and corruption. "
                    + "Second, you can specify multiple custom event ids. This allows users of your custom events to choose from a variety of possible ids to list for custom events. "
                    + "Note that you must specify at least one id, otherwise no event will be called.");
    Registration.registerEvent("Custom Event", EvtCustomEvent.class, SkriptCustomEvent.class, "ev[en]t %strings%")
            .document("Custom Event", "1.6.7", "Called when the Call Custom Event effect is used with the specified id or one of the specified ids. "
                    + "This is used as a way for Skripters to create their own \"events\". See the Call Custom Event effect for more info.");
    Registration.registerExpression(ExprIDOfCustomEvent.class, String.class, ExpressionType.SIMPLE, "(0¦id|1¦ids) of custom event", "custom event's (0¦id|1¦ids)")
            .document("ID of Custom Event", "1.6.7", "An expression, used in the Custom Event event, for either the primary id, or all ids (MundoSK 1.8+), of the custom event that was called. "
                    + "The primary id means the one that was listed first when calling the custom event. See the Call Custom Event effect for more info.");
    Registration.registerExpression(ExprArgsOfCustomEvent.class, Object.class, ExpressionType.SIMPLE,"args of custom event", "custom event's args")
            .document("Args of Custom Event", "1.6.7", "An expression, used in the Custom Event event, for a list of the arguments, if any, "
                    + "that were specified for this particular custom event call. See the Call Custom Event effect for more info.");
    Registration.registerExpressionCondition(CondLastCustomEventCancelled.class, ExpressionType.SIMPLE, "last [called] custom event (0¦was|1¦wasn't) cancelled")
            .document("Last Called Custom Event was Cancelled", "1.8", "Checks whether the last custom event that was called in this trigger was or wasn't cancelled. "
                    + "This expression/condition is unaffected by whether another section of code calls a custom event. See the Call Custom Event effect for more info about custom events.");

    try {
        List<ClassInfo<?>> classes = (List<ClassInfo<?>>) Reflection.getStaticField(Classes.class, "tempClassInfos");
        for (int i = 0; i < classes.size(); i++) {
            registerCustomEventValue(classes.get(i));
        }
    } catch (Exception e1) {
        Logging.reportException(CustomEventMundo.class, e1);
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:36,代码来源:CustomEventMundo.java


示例14: acceptChange

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
    ClassInfo<?> rti = returnTypeInfo;
    if (rti == null)
        returnTypeInfo = rti = Classes.getSuperClassInfo(getReturnType());
    final Changer<?> c = rti.getChanger();
    if (c == null)
        return null;
    return c.acceptChange(mode);
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:12,代码来源:BaseExpression.java


示例15: change

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
    final ClassInfo<?> rti = returnTypeInfo;
    if (rti == null)
        throw new UnsupportedOperationException();
    final Changer<?> c = rti.getChanger();
    if (c == null)
        throw new UnsupportedOperationException();
    ((Changer<T>) c).change(getArray(e), delta, mode);
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:12,代码来源:BaseExpression.java


示例16: init

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	final Expression<?> expr = exprs[1].getConvertedExpression((((Literal<ClassInfo<?>>) exprs[0]).getSingle()).getC());
	if (expr == null)
		return false;
	this.expr = expr;
	return true;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:10,代码来源:ExprRandom.java


示例17: init

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
	@SuppressWarnings("unchecked")
	final ClassInfo<?> ci = ((Literal<ClassInfo<?>>) exprs[0]).getSingle();
	final EventValueExpression<?> e = new EventValueExpression<Object>(ci.getC());
	setExpr(e);
	return e.init();
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:ExprEventExpression.java


示例18: registerClass

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
/**
 * @param info info about the class to register
 */
public static <T> void registerClass(final ClassInfo<T> info) {
	Skript.checkAcceptRegistrations();
	if (classInfosByCodeName.containsKey(info.getCodeName()))
		throw new IllegalArgumentException("Can't register " + info.getC().getName() + " with the code name " + info.getCodeName() + " because that name is already used by " + classInfosByCodeName.get(info.getCodeName()));
	if (exactClassInfos.containsKey(info.getC()))
		throw new IllegalArgumentException("Can't register the class info " + info.getCodeName() + " because the class " + info.getC().getName() + " is already registered");
	if (info.getCodeName().length() > DatabaseStorage.MAX_CLASS_CODENAME_LENGTH)
		throw new IllegalArgumentException("The codename '" + info.getCodeName() + "' is too long to be saved in a database, the maximum length allowed is " + DatabaseStorage.MAX_CLASS_CODENAME_LENGTH);
	exactClassInfos.put(info.getC(), info);
	classInfosByCodeName.put(info.getCodeName(), info);
	tempClassInfos.add(info);
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:16,代码来源:Classes.java


示例19: getClassInfos

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
@SuppressWarnings("null")
public static List<ClassInfo<?>> getClassInfos() {
	checkAllowClassInfoInteraction();
	final ClassInfo<?>[] ci = classInfos;
	if (ci == null)
		return Collections.emptyList();
	return Collections.unmodifiableList(Arrays.asList(ci));
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:Classes.java


示例20: getClassFromUserInput

import ch.njol.skript.classes.ClassInfo; //导入依赖的package包/类
/**
 * As the name implies
 * 
 * @param name
 * @return the class or null if the name was not recognized
 */
@Nullable
public static Class<?> getClassFromUserInput(final String name) {
	checkAllowClassInfoInteraction();
	final ClassInfo<?> ci = getClassInfoFromUserInput(name);
	return ci == null ? null : ci.getC();
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:13,代码来源:Classes.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NumberRenderer类代码示例发布时间:2022-05-23
下一篇:
Java PerfCounterPack类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap