本文整理汇总了Java中ch.njol.skript.lang.Literal类的典型用法代码示例。如果您正苦于以下问题:Java Literal类的具体用法?Java Literal怎么用?Java Literal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Literal类属于ch.njol.skript.lang包,在下文中一共展示了Literal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import ch.njol.skript.lang.Literal; //导入依赖的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
示例2: init
import ch.njol.skript.lang.Literal; //导入依赖的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
示例3: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
invis = (Expression<Inventory>) vars[0];
items = (Expression<ItemType>) vars[1];
if (items instanceof Literal) {
for (ItemType t : ((Literal<ItemType>) items).getAll()) {
t = t.getItem();
if (!(t.isAll() || (t.getTypes().size() == 1 && !t.getTypes().get(0).hasDataRange() && t.getTypes().get(0).getId() != -1))) {
Skript.error("The condition 'can hold' can currently only be used with aliases that start with 'every' or 'all', or only represent one item and one data value.", ErrorQuality.SEMANTIC_ERROR);
return false;
}
}
}
setNegated(matchedPattern == 1);
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:18,代码来源:CondCanHold.java
示例4: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
final Object type = exprs[0] == null ? null : ((Literal<?>) exprs[0]).getSingle();
if (type instanceof EntityData) {
entityType = (EntityData<?>) type;
if (!ScriptLoader.isCurrentEvent(PlayerInteractEntityEvent.class)) {
Skript.error("The expression 'clicked entity' can only be used in a click event", ErrorQuality.SEMANTIC_ERROR);
return false;
}
} else {
itemType = (ItemType) type;
if (!ScriptLoader.isCurrentEvent(PlayerInteractEvent.class)) {
Skript.error("The expression 'clicked block' can only be used in a click event", ErrorQuality.SEMANTIC_ERROR);
return false;
}
}
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:19,代码来源:ExprClicked.java
示例5: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
effects = (Expression<VisualEffect>) exprs[0];
direction = (Expression<Direction>) exprs[1];
where = exprs[2];
players = (Expression<Player>) exprs[3];
if (effects instanceof Literal) {
final VisualEffect[] effs = effects.getAll(null);
boolean hasLocationEffect = false, hasEntityEffect = false;
for (final VisualEffect e : effs) {
if (e.isEntityEffect())
hasEntityEffect = true;
else
hasLocationEffect = true;
}
if (!hasLocationEffect && players != null)
Skript.warning("Entity effects are visible to all players");
if (!hasLocationEffect && !direction.isDefault())
Skript.warning("Entity effects are always played on an entity");
if (hasEntityEffect && !Entity.class.isAssignableFrom(where.getReturnType()))
Skript.warning("Entity effects can only be played on entities");
}
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:26,代码来源:EffVisualEffect.java
示例6: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@Override
public boolean init(final Literal<?>[] args, final int matchedPattern, final SkriptParser.ParseResult parser) {
prefix = ((Literal<String>) args[0]).getSingle();
if ("".equals(prefix)) {
Skript.error(prefix + " is not a valid placeholder", ErrorQuality.SEMANTIC_ERROR);
return false;
}
new PlaceholderAPIListener(Main.getInstance(), prefix).hook();
return true;
}
开发者ID:Pikachu920,项目名称:Ersatz,代码行数:11,代码来源:EvtPlaceholderRequest.java
示例7: defendExpression
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> Expression<T> defendExpression(Expression<?> expr) {
if (expr instanceof UnparsedLiteral) {
Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class);
return (Expression<T>) (parsed == null ? expr : parsed);
} else if (expr instanceof ExpressionList) {
Expression[] exprs = ((ExpressionList) expr).getExpressions();
for (int i = 0; i < exprs.length; i++) {
exprs[i] = defendExpression(exprs[i]);
}
}
return (Expression<T>) expr;
}
开发者ID:btk5h,项目名称:skript-mirror,代码行数:14,代码来源:Util.java
示例8: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Literal<?>[] lit, int arg1, ParseResult arg2) {
String[] strings = ((Literal<String>) lit[0]).getAll();
for (int i = 0; i < strings.length; i ++) {
ids.add(strings[i].toLowerCase());
}
return true;
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:10,代码来源:EvtCustomEvent.java
示例9: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
String string;
isSingle = i == 0;
if (expressions[0] == null) {
string = getConverterNameByIndex(parseResult.mark, isSingle);
} else if (expressions[0] instanceof Literal<?>) {
string = ((Literal<String>) expressions[0]).getSingle();
} else if (expressions[0] instanceof VariableString) {
String fullstring = ((VariableString) expressions[0]).toString();
string = fullstring.substring(1, fullstring.length() - 1);
} else {
Skript.error("The string '" + expressions[0] + "' is not a literal string! Only literal strings can be used in the pjson expression!");
return false;
}
Logging.debug(this, "String == " + string + " isSingle == " + isSingle);
index = (Expression<Number>) expressions[1];
packetContainerExpression = (Expression<PacketContainer>) expressions[2];
singleConverter = getSingleConverter(string.toLowerCase());
pluralConverter = getPluralConverter(string.toLowerCase());
Logging.debug(this, "Converters == " + singleConverter + " , " + pluralConverter);
if (isSingle ? singleConverter == null : pluralConverter == null) {
Skript.error("The string " + string + " is not a valid packetinfo!");
return false;
}
return true;
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:28,代码来源:ExprJSONObjectOfPacket.java
示例10: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@Override
public boolean init(Literal<?>[] literals, int i, SkriptParser.ParseResult parseResult) {
packetType = ((Literal<PacketType>) literals[0]).getSingle();
SectionNode topNode = (SectionNode) SkriptLogger.getNode();
try {
List<PacketInfoAlias> aliases = new ArrayList<>();
for (Node node : topNode) {
SkriptLogger.setNode(node);
if (node instanceof SectionNode) {
Skript.error("Packet info aliases should not be sections!");
return false;
}
int separatorIndex = node.getKey().indexOf(SEPARATOR);
if (separatorIndex == -1) {
Skript.error("Packet info aliases should be in the format '<new syntax> " + SEPARATOR + " <old syntax>'");
return false;
}
String syntax = node.getKey().substring(0, separatorIndex).trim();
Optional<String> validatedSyntax = validateAliasSyntax(syntax);
if (!validatedSyntax.isPresent()) {
return false;
}
String original = node.getKey().substring(separatorIndex + 1).trim();
Optional<PacketInfoAlias> aliasOptional = PacketInfoAlias.create(packetType, validatedSyntax.get(), original);
if (!aliasOptional.isPresent()) {
Skript.error("Invalid target syntax in the packet info alias!");
return false;
}
aliases.add(aliasOptional.get());
}
key = ExprPacketInfoAlias.registerAliases(aliases);
return true;
} finally {
ScopeUtil.removeSubNodes(topNode);
}
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:37,代码来源:ScopePacketInfoAliases.java
示例11: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@Override
public boolean init(Literal<?>[] literals, int i, SkriptParser.ParseResult parseResult) {
PacketType[] packetTypeArray = ((Literal<PacketType>) literals[0]).getAll();
packetTypesToString = literals[0].toString();
MundoPacketEvent.addListener(packetTypeArray);
packetTypes = Arrays.asList(packetTypeArray);
return true;
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:9,代码来源:EvtPacketEvent.java
示例12: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
int index = parseResult.mark;
char ch = chars[index];
Number preValue = ((Literal<Number>) expressions[0]).getSingle();
value = getValue(preValue, ch);
toString = preValue + "" + ch;
return true;
}
开发者ID:MundoSK,项目名称:MundoSK,代码行数:10,代码来源:ExprNumber.java
示例13: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@Override
protected boolean init(final Literal<?>[] exprs, final int matchedPattern, final ParseResult parseResult) {
variant = Variant.values()[matchedPattern];
// if (variant == Variant.HORSE) {
// // TODO color and style // rem: toString
// }
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:HorseData.java
示例14: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected boolean init(final Literal<?>[] exprs, final int matchedPattern, final ParseResult parseResult) {
if (exprs[0] != null)
hand = ((Literal<ItemType>) exprs[0]).getAll();
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:8,代码来源:EndermanData.java
示例15: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@Override
protected boolean init(final Literal<?>[] exprs, final int matchedPattern, final ParseResult parseResult) {
if (matchedPattern <= 2)
angry = matchedPattern - 1;
else
tamed = matchedPattern == 3 ? -1 : 1;
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:WolfData.java
示例16: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected boolean init(final Literal<?>[] exprs, final int matchedPattern, final ParseResult parseResult) {
if (exprs.length > 0 && exprs[0] != null) {
if ((types = Converters.convert(((Literal<ItemType>) exprs[0]).getAll(), ItemType.class, new Converter<ItemType, ItemType>() {
@Override
@Nullable
public ItemType convert(ItemType t) {
t = t.getBlock().clone();
final Iterator<ItemData> iter = t.iterator();
while (iter.hasNext()) {
final int id = iter.next().getId();
if (id <= 0 || id > Skript.MAXBLOCKID)
iter.remove();
}
if (t.numTypes() == 0)
return null;
t.setAmount(-1);
t.setAll(false);
t.clearEnchantments();
return t;
}
})).length == 0) {
Skript.error(m_not_a_block_error.toString());
return false;
}
}
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:30,代码来源:FallingBlockData.java
示例17: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings("null")
@Override
public final boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
this.matchedPattern = matchedPattern;
// plural bits (0x3): 0 = singular, 1 = plural, 2 = unknown
final int pluralBits = parseResult.mark & 0x3;
this.plural = pluralBits == 1 ? Kleenean.TRUE : pluralBits == 0 ? Kleenean.FALSE : Kleenean.UNKNOWN;
// age bits (0xC): 0 = unknown, 4 = baby, 8 = adult
final int ageBits = parseResult.mark & 0xC;
this.baby = ageBits == 4 ? Kleenean.TRUE : ageBits == 8 ? Kleenean.FALSE : Kleenean.UNKNOWN;
return init(Arrays.copyOf(exprs, exprs.length, Literal[].class), matchedPattern, parseResult);
}
开发者ID:nfell2009,项目名称:Skript,代码行数:13,代码来源:EntityData.java
示例18: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings("null")
@Override
protected boolean init(final Literal<?>[] exprs, final int matchedPattern, final ParseResult parseResult) {
info = types.get(matchedPattern);
assert info != null : matchedPattern;
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:8,代码来源:SimpleEntityData.java
示例19: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected boolean init(final Literal<?>[] exprs, final int matchedPattern, final ParseResult parseResult) {
sheared = matchedPattern - 1;
if (exprs[0] != null)
colors = ((Literal<Color>) exprs[0]).getAll();
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:SheepData.java
示例20: init
import ch.njol.skript.lang.Literal; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
amount = (Expression<Number>) exprs[0];
unit = ((Literal<Unit>) exprs[1]).getSingle();
return true;
}
开发者ID:nfell2009,项目名称:Skript,代码行数:8,代码来源:ExprValue.java
注:本文中的ch.njol.skript.lang.Literal类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论