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

Java Classes类代码示例

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

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



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

示例1: build

import ch.njol.skript.registrations.Classes; //导入依赖的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


示例2: serializeJSONElement

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
public static Object serializeJSONElement(Object object) {
    if (object instanceof JSONArray) {
        JSONArray result = new JSONArray();
        for (Object elem : (JSONArray) object) {
            Object serializedElem = serializeJSONElement(elem);
            if (serializedElem != null) {
                result.add(serializedElem);
            }
        }
        return result;
    }
    SerializedVariable.Value value = Classes.serialize(object);
    if (value == null) {
        return null;
    }
    JSONObject valueJSON = new JSONObject();
    valueJSON.put("type", value.type);
    valueJSON.put("data", new String(value.data));
    return valueJSON;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:21,代码来源:MiscMundo.java


示例3: deserializeJSONElement

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
public static Object deserializeJSONElement(Object object) {
    if (object instanceof JSONArray) {
        JSONArray result = new JSONArray();
        for (Object serializedElem : (JSONArray) object) {
            Object deserializedElem = deserializeJSONElement(serializedElem);
            result.add(deserializedElem);
        }
        return result;
    }
    JSONObject jsonObject = (JSONObject) object;
    String type = (String) jsonObject.get("type");
    String dataString = (String) jsonObject.get("data");
    if (dataString == null) {
        dataString = (String) jsonObject.get("Data");
    }
    byte[] data = dataString.getBytes();
    return Classes.deserialize(type, data);
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:19,代码来源:MiscMundo.java


示例4: deserialize

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
@SuppressWarnings("null")
@Override
@Deprecated
protected boolean deserialize(final String s) {
	if (s.isEmpty())
		return true;
	final String[] split = s.split("(?<!,),(?!,)");
	hand = new ItemType[split.length];
	for (int i = 0; i < hand.length; i++) {
		final String[] t = split[i].split("(?<!:):(?::)");
		if (t.length != 2)
			return false;
		final Object o = Classes.deserialize(t[0], t[1].replace(",,", ",").replace("::", ":"));
		if (o == null || !(o instanceof ItemType))
			return false;
		hand[i] = (ItemType) o;
	}
	return false;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:20,代码来源:EndermanData.java


示例5: deserialize

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
/**
 * Loads an array of ItemTypes separated by '|'
 */
@Deprecated
@Nullable
public static ItemType[] deserialize(final String s) {
	if (s.isEmpty())
		return null;
	final String[] split = s.split("(?!<\\|)\\|(?!\\|)");
	final ItemType[] types = new ItemType[split.length];
	for (int i = 0; i < types.length; i++) {
		final ItemType t = (ItemType) Classes.deserialize("itemtype", "" + split[i].replace("||", "|"));
		if (t == null)
			return null;
		types[i] = t;
	}
	return types;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:19,代码来源:ItemType.java


示例6: getValue

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
@Nullable
protected <T> T getValue(final SectionNode n, final String key, final Class<T> type) {
	final String v = n.getValue(key);
	if (v == null) {
		Skript.error("The config is missing the entry for '" + key + "' in the database '" + databaseName + "'");
		return null;
	}
	final ParseLogHandler log = SkriptLogger.startParseLogHandler();
	try {
		final T r = Classes.parse(v, type, ParseContext.CONFIG);
		if (r == null)
			log.printError("The entry for '" + key + "' in the database '" + databaseName + "' must be " + Classes.getSuperClassInfo(type).getName().withIndefiniteArticle());
		else
			log.printLog();
		return r;
	} finally {
		log.stop();
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:20,代码来源:VariablesStorage.java


示例7: save

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
/**
 * Saves the variables.
 * <p>
 * This method uses the sorted variables map to save the variables in order.
 * 
 * @param pw
 * @param parent The parent's name with {@link Variable#SEPARATOR} at the end
 * @param map
 */
@SuppressWarnings("unchecked")
private final void save(final PrintWriter pw, final String parent, final TreeMap<String, Object> map) {
	outer: for (final Entry<String, Object> e : map.entrySet()) {
		final Object val = e.getValue();
		if (val == null)
			continue;
		if (val instanceof TreeMap) {
			save(pw, parent + e.getKey() + Variable.SEPARATOR, (TreeMap<String, Object>) val);
		} else {
			final String name = (e.getKey() == null ? parent.substring(0, parent.length() - Variable.SEPARATOR.length()) : parent + e.getKey());
			for (final VariablesStorage s : Variables.storages) {
				if (s != this && s.accept(name))
					continue outer;
			}
			final SerializedVariable.Value value = Classes.serialize(val);
			if (value != null)
				writeCSV(pw, name, value.type, encode(value.data));
		}
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:30,代码来源:FlatFileStorage.java


示例8: SkriptCustomEvent

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
public SkriptCustomEvent(String[] ids, Object[] details, Object[] args, boolean sync) {
 super(!sync);
 if (ids.length == 0) {
     throw new IllegalArgumentException("There must be at least one ID!");
    }
    this.ids = ImmutableList.copyOf(ids);
    for (int i = 0; i < details.length; i++) {
        Logging.debug(this, "DETAIL " + details[i]);
        Logging.debug(this, ".GETCLASS " + details[i].getClass());
        Logging.debug(this, "GETSUPERCLASSINFO " + Classes.getSuperClassInfo(details[i].getClass()));
        this.details.put(Classes.getSuperClassInfo(details[i].getClass()), details[i]);
    }
    this.args = args;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:15,代码来源:SkriptCustomEvent.java


示例9: load

import ch.njol.skript.registrations.Classes; //导入依赖的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


示例10: acceptChange

import ch.njol.skript.registrations.Classes; //导入依赖的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


示例11: toString

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
@Override
public String toString(final int flags) {
	final ItemType[] types = this.types;
	if (types == null)
		return super.toString(flags);
	final StringBuilder b = new StringBuilder();
	b.append(Noun.getArticleWithSpace(types[0].getTypes().get(0).getGender(), flags));
	b.append(m_adjective.toString(types[0].getTypes().get(0).getGender(), flags));
	b.append(" ");
	b.append(Classes.toString(types, flags & Language.NO_ARTICLE_MASK, false));
	return "" + b.toString();
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:13,代码来源:DroppedItemData.java


示例12: toString

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
@Override
public String toString(final int flags) {
	final ItemType[] hand = this.hand;
	if (hand == null)
		return super.toString(flags);
	return format.toString(super.toString(flags), Classes.toString(hand, false));
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:8,代码来源:EndermanData.java


示例13: acceptChange

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
@Nullable
public Class<?>[] acceptChange(final ChangeMode mode) {
	Changer<? super T> ch = changer;
	if (ch == null)
		changer = ch = (Changer<? super T>) Classes.getSuperClassInfo(c).getChanger();
	return ch == null ? null : ch.acceptChange(mode);
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:10,代码来源:EventValueExpression.java


示例14: toString

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
@Override
public String toString(final @Nullable Event e, final boolean debug) {
	if (e == null)
		return name;
	if (isVariableLoop) {
		@SuppressWarnings("unchecked")
		final Entry<String, Object> current = (Entry<String, Object>) loop.getCurrent(e);
		if (current == null)
			return Classes.getDebugMessage(null);
		return isIndex ? "\"" + current.getKey() + "\"" : Classes.getDebugMessage(current.getValue());
	}
	return Classes.getDebugMessage(loop.getCurrent(e));
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:14,代码来源:ExprLoopValue.java


示例15: checkVariableConflicts

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
private static void checkVariableConflicts(final String name, final StringMode mode, final @Nullable Iterable<Object> string) {
	if (mode != StringMode.VARIABLE_NAME || variableNames.containsKey(name))
		return;
	if (name.startsWith("%")) {// inside the if to only print this message once per variable
		final Config script = ScriptLoader.currentScript;
		if (script != null)
			Skript.warning("Starting a variable's name with an expression is discouraged ({" + name + "}). You could prefix it with the script's name: {" + StringUtils.substring(script.getFileName(), 0, -3) + "." + name + "}");
	}
	
	final Pattern pattern;
	if (string != null) {
		final StringBuilder p = new StringBuilder();
		stringLoop: for (final Object o : string) {
			if (o instanceof Expression) {
				for (final ClassInfo<?> ci : Classes.getClassInfos()) {
					final Parser<?> parser = ci.getParser();
					if (parser != null && ci.getC().isAssignableFrom(((Expression<?>) o).getReturnType())) {
						p.append("(?!%)" + parser.getVariableNamePattern() + "(?<!%)");
						continue stringLoop;
					}
				}
				p.append("[^%*](.*[^%*])?"); // [^*] to not report {var::%index%}/{var::*} as conflict
			} else {
				p.append(Pattern.quote(o.toString()));
			}
		}
		pattern = Pattern.compile(p.toString());
	} else {
		pattern = Pattern.compile(Pattern.quote(name));
	}
	if (!SkriptConfig.disableVariableConflictWarnings.value()) {
		for (final Entry<String, Pattern> e : variableNames.entrySet()) {
			if (e.getValue().matcher(name).matches() || pattern.matcher(e.getKey()).matches()) {
				Skript.warning("Possible name conflict of variables {" + name + "} and {" + e.getKey() + "} (there might be more conflicts).");
				break;
			}
		}
	}
	variableNames.put(name, pattern);
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:41,代码来源:VariableString.java


示例16: acceptChange

import ch.njol.skript.registrations.Classes; //导入依赖的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:nfell2009,项目名称:Skript,代码行数:12,代码来源:SimpleExpression.java


示例17: acceptChange

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


示例18: acceptChange

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


示例19: Option

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
public Option(final String key, final T defaultValue) {
	this.key = "" + key.toLowerCase(Locale.ENGLISH);
	this.defaultValue = defaultValue;
	parsedValue = defaultValue;
	@SuppressWarnings("unchecked")
	final Class<T> c = (Class<T>) defaultValue.getClass();
	if (c == String.class) {
		parser = new Converter<String, T>() {
			@SuppressWarnings("unchecked")
			@Override
			public T convert(final String s) {
				return (T) s;
			}
		};
	} else {
		final ClassInfo<T> ci = Classes.getExactClassInfo(c);
		final Parser<? extends T> p;
		if (ci == null || (p = ci.getParser()) == null)
			throw new IllegalArgumentException(c.getName());
		this.parser = new Converter<String, T>() {
			@Override
			@Nullable
			public T convert(final String s) {
				final T t = p.parse(s, ParseContext.CONFIG);
				if (t != null)
					return t;
				Skript.error("'" + s + "' is not " + ci.getName().withIndefiniteArticle());
				return null;
			}
		};
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:33,代码来源:Option.java


示例20: getID

import ch.njol.skript.registrations.Classes; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Override
@Nullable
public String getID(final @NonNull Class<?> c) {
	if (ConfigurationSerializable.class.isAssignableFrom(c) && Classes.getSuperClassInfo(c) == Classes.getExactClassInfo(Object.class))
		return configurationSerializablePrefix + ConfigurationSerialization.getAlias((Class<? extends ConfigurationSerializable>) c);
	return null;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:Variables.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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