本文整理汇总了Java中ch.njol.skript.util.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于ch.njol.skript.util包,在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ExprJavaCall
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@SafeVarargs
private ExprJavaCall(ExprJavaCall<?> source, Class<? extends T>... types) {
this.source = source;
if (source != null) {
this.targetArg = source.targetArg;
this.args = source.args;
this.type = source.type;
this.suppressErrors = source.suppressErrors;
this.staticDescriptor = source.staticDescriptor;
this.dynamicDescriptor = source.dynamicDescriptor;
}
this.types = types;
this.superType = (Class<T>) Utils.getSuperType(types);
}
示例2: init
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed,
SkriptParser.ParseResult parseResult) {
if (!ScriptLoader.isCurrentEvent(
CustomEffect.EffectEvent.class,
CustomExpression.ExpressionGetEvent.class,
CustomExpression.ExpressionChangeEvent.class,
CustomCondition.ConditionEvent.class
)) {
Skript.error("The expression 'expression' may only be used in a custom syntax.",
ErrorQuality.SEMANTIC_ERROR);
return false;
}
index = Utils.parseInt(parseResult.regexes.get(0).group(1));
if (index <= 0) {
Skript.error("The expression index must be a natural number.", ErrorQuality.SEMANTIC_ERROR);
return false;
}
index--;
plural = parseResult.mark == 1;
return true;
}
示例3: getConvertedExpr
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
@Nullable
protected <R> ConvertedExpression<Object, ? extends R> getConvertedExpr(final Class<R>... to) {
if (isVariableLoop && !isIndex) {
return new ConvertedExpression<Object, R>(this, (Class<R>) Utils.getSuperType(to), new Converter<Object, R>() {
@Override
@Nullable
public R convert(final Object o) {
return Converters.convert(o, to);
}
});
} else {
return super.getConvertedExpr(to);
}
}
示例4: get
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@Override
protected Entity[] get(final Event e, final LivingEntity[] source) {
return get(source, new Converter<LivingEntity, Entity>() {
@Override
@Nullable
public Entity convert(final LivingEntity en) {
if (getTime() >= 0 && e instanceof EntityTargetEvent && en.equals(((EntityTargetEvent) e).getEntity()) && !Delay.isDelayed(e)) {
final Entity t = ((EntityTargetEvent) e).getTarget();
if (t == null || type != null && !type.isInstance(t))
return null;
return t;
}
return Utils.getTarget(en, type);
}
});
}
示例5: SkriptAddon
import ch.njol.skript.util.Utils; //导入依赖的package包/类
/**
* Package-private constructor. Use {@link Skript#registerAddon(JavaPlugin)} to get a SkriptAddon for your plugin.
*
* @param p
*/
SkriptAddon(final JavaPlugin p) {
plugin = p;
name = "" + p.getName();
Version v;
try {
v = new Version("" + p.getDescription().getVersion());
} catch (final IllegalArgumentException e) {
final Matcher m = Pattern.compile("(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?").matcher(p.getDescription().getVersion());
if (!m.find())
throw new IllegalArgumentException("The version of the plugin " + p.getName() + " does not contain any numbers: " + p.getDescription().getVersion());
v = new Version(Utils.parseInt("" + m.group(1)), m.group(2) == null ? 0 : Utils.parseInt("" + m.group(2)), m.group(3) == null ? 0 : Utils.parseInt("" + m.group(3)));
Skript.warning("The plugin " + p.getName() + " uses a non-standard version syntax: '" + p.getDescription().getVersion() + "'. Skript will use " + v + " instead.");
}
version = v;
}
示例6: init
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("null")
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
if (isDelayed == Kleenean.TRUE) {
Skript.error("Can't cancel an event anymore after is has already passed", ErrorQuality.SEMANTIC_ERROR);
return false;
}
cancel = matchedPattern == 0;
final Class<? extends Event>[] es = ScriptLoader.getCurrentEvents();
if (es == null)
return false;
for (final Class<? extends Event> e : es) {
if (Cancellable.class.isAssignableFrom(e) || BlockCanBuildEvent.class.isAssignableFrom(e))
return true; // TODO warning if some event(s) cannot be cancelled even though some can (needs a way to be suppressed)
}
if (ScriptLoader.isCurrentEvent(PlayerLoginEvent.class))
Skript.error("A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')", ErrorQuality.SEMANTIC_ERROR);
else
Skript.error(Utils.A(ScriptLoader.getCurrentEventName()) + " event cannot be cancelled", ErrorQuality.SEMANTIC_ERROR);
return false;
}
示例7: init
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed,
SkriptParser.ParseResult parseResult) {
if (!ScriptLoader.isCurrentEvent(
CustomEffect.EffectEvent.class,
CustomExpression.ExpressionGetEvent.class,
CustomExpression.ExpressionChangeEvent.class,
CustomCondition.ConditionEvent.class
)) {
Skript.error("The parsed regular expression may only be used in custom syntax.",
ErrorQuality.SEMANTIC_ERROR);
}
index = Utils.parseInt(parseResult.regexes.get(0).group(0));
if (index <= 0) {
Skript.error("The expression index must be a natural number.", ErrorQuality.SEMANTIC_ERROR);
return false;
}
index--;
return true;
}
示例8: ExprExpression
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@SafeVarargs
private ExprExpression(ExprExpression<?> source, Class<? extends T>... types) {
if (source != null) {
index = source.index;
plural = source.plural;
}
this.source = source;
this.types = types;
this.superType = (Class<T>) Utils.getSuperType(types);
}
示例9: ExpressionHandler
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@SafeVarargs
private ExpressionHandler(ExpressionHandler<?> source, Class<? extends T>... types) {
this.source = source;
if (source != null) {
this.which = source.which;
this.exprs = source.exprs;
this.parseResult = source.parseResult;
}
this.types = types;
this.superType = (Class<T>) Utils.getSuperType(types);
}
示例10: ExprChangeValue
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@SafeVarargs
private ExprChangeValue(ExprChangeValue<?> source, Class<? extends T>... types) {
if (source != null) {
index = source.index;
plural = source.plural;
}
this.source = source;
this.types = types;
this.superType = (Class<T>) Utils.getSuperType(types);
}
示例11: ExprSpread
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@SafeVarargs
private ExprSpread(ExprSpread<?> source, Class<? extends T>... types) {
this.source = source;
if (source != null) {
this.object = source.object;
}
this.types = types;
this.superType = (Class<T>) Utils.getSuperType(types);
}
示例12: onCommand
import ch.njol.skript.util.Utils; //导入依赖的package包/类
public static boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!sender.hasPermission("skript.config")) {
sender.sendMessage("You do not have permission to use this command");
return true;
}
if (args.length == 0 || args[0].equalsIgnoreCase("h") || args[0].equalsIgnoreCase("help")) {
int page = 1;
try {
page = Math.min((int) Math.ceil(commandHelp.length / linesPerPage), Math.max(1, Integer.parseInt(args[1])));
} catch (final Exception e) {}
sender.sendMessage("§8== Skript help (page " + page + " of " + Math.ceil(commandHelp.length / linesPerPage) + ")");
for (int i = (page - 1) * linesPerPage; i < page * linesPerPage; i++) {
sender.sendMessage(commandHelp[i]);
}
}
// output the input, so one can see what the messages refer to.
sender.sendMessage("&7" + label + Utils.join(args, " "));
PlayerCommand data = playerCommandDatas.get(sender.getName());
if (data == null) {
data = new PlayerCommand();
playerCommandDatas.put(sender.getName(), data);
}
data.onCommand(sender, command, label, args);
return true;
}
示例13: get
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@Override
protected String[] get(final Event e, final String[] source) {
return get(source, new Converter<String, String>() {
@Override
public String convert(final String s) {
return color ? Utils.replaceChatStyles(s) : "" + ChatColor.stripColor(s);
}
});
}
示例14: getConvertedExpression
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
@Nullable
public <R> Literal<? extends R> getConvertedExpression(final Class<R>... to) {
final Literal<? extends R>[] exprs = new Literal[expressions.length];
final Class<?>[] classes = new Class[expressions.length];
for (int i = 0; i < exprs.length; i++) {
if ((exprs[i] = (Literal<? extends R>) expressions[i].getConvertedExpression(to)) == null)
return null;
classes[i] = exprs[i].getReturnType();
}
return new LiteralList<R>(exprs, (Class<R>) Utils.getSuperType(classes), and, this);
}
示例15: getConvertedExpression
import ch.njol.skript.util.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
@Nullable
public <R> Expression<? extends R> getConvertedExpression(final Class<R>... to) {
final Expression<? extends R>[] exprs = new Expression[expressions.length];
for (int i = 0; i < exprs.length; i++)
if ((exprs[i] = expressions[i].getConvertedExpression(to)) == null)
return null;
return new ExpressionList<R>(exprs, (Class<R>) Utils.getSuperType(to), and, this);
}