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


Java Skript类代码示例

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


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

示例1: registerSlimefun

import ch.njol.skript.Skript; //导入依赖的package包/类
public static void registerSlimefun() {
	Skript.registerEvent("On slimefun research", SimpleEvent.class, ResearchUnlockEvent.class,
			"[(slimefun|sf)] research [unlock]");
	EventValues.registerEventValue(ResearchUnlockEvent.class, Player.class,
			new Getter<Player, ResearchUnlockEvent>() {
				@Override
				@Nullable
				public Player get(ResearchUnlockEvent e) {
					Player p = e.getPlayer();
					return p;
				}
			}, 0);
	Skript.registerExpression(ExprSlimefunEvtResearch.class, String.class, ExpressionType.SIMPLE, "event-research");

	Skript.registerEffect(EffSlimefunUnlockResearch.class,
			"[sharpsk] [(slimefun|sf)] unlock research %string% for %player%");
	Skript.registerExpression(ExprSlimefunAllResearches.class, String.class, ExpressionType.SIMPLE,
			"[sharpsk] [(slimefun|sf)] all [(of|the)] researches");
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:20,代码来源:SlimefunRegistry.java

示例2: onEnable

import ch.njol.skript.Skript; //导入依赖的package包/类
public void onEnable() {
      if (!Skript.isRunningMinecraft(1, 9)) {
          getLogger().log(Level.INFO, "Outdated Minecraft version ! Update to 1.9 or newer !");
          getServer().getPluginManager().disablePlugin(this);
      }
      /*
if (getSkriptRevision() < 26) {
	getLogger().log(Level.INFO, "Outdated Skript version ! Update to dev26 or newer ! Your current version is " + Skript.getInstance().getDescription().getVersion());
	getServer().getPluginManager().disablePlugin(this);
}
*/
      plugin = this;
      getLogger().log(Level.INFO, "Starting up Quarsk v" + getPlugin().getDescription().getVersion() + " !");
      normalRegister();
      if (Registration.generateFolder()) {
          getLogger().log(Level.INFO, "Created Quarsk's folder !");
      }
      if (Registration.generateSyntaxFile()) {
          getLogger().log(Level.INFO, "Generated Quarsk's syntax file !");
      }
      getLogger().log(Level.INFO, "Registered " + Registration.getEvents().size() + " events, " + Registration.getConditions().size() + " conditions, " + Registration.getEffects().size() + " effects and " + Registration.getExpressions().size() + " expressions ! Good game !");
  }
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:23,代码来源:QuarSk.java

示例3: init

import ch.njol.skript.Skript; //导入依赖的package包/类
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
	VariableString s = VariableString.newInstance(parseResult.regexes.get(0).group(), StringMode.VARIABLE_NAME);
	if (s == null) {
		Skript.error("Invalid reference naming. A reference should be named like a variable");
		return false;
	}
	variableName = s;
	Expression<?> v = expressions[0];
	if (v instanceof UnparsedLiteral) {
		Skript.error("Unknown expression : " + ((UnparsedLiteral) v).getData());
		return false;
	}
	value = v;
	return true;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:17,代码来源:EffLinkReference.java

示例4: get

import ch.njol.skript.Skript; //导入依赖的package包/类
@Override
@Nullable
protected String[] get(Event arg0) {
	String cmd = commandsk.getSingle(arg0);
	String commandStr = cmd.startsWith("/") ? cmd.substring(1) : cmd;
	PluginCommand command = Bukkit.getServer().getPluginCommand(commandStr);
	if (command != null) {
		if (command.getDescription() != null) {
			return new String[] {command.getDescription()};
		} else {
			Skript.error("Command does not have a description!");
			return null;
		}
	}
	Skript.error("Command not found!");
	return null;
}
 
开发者ID:WheezyGold7931,项目名称:skLib,代码行数:18,代码来源:ExprCommandDescription.java

示例5: check

import ch.njol.skript.Skript; //导入依赖的package包/类
@Override
public boolean check(Event arg0) {
	@SuppressWarnings("unused")
	Boolean goodip = IpTools.validIP(ip.getSingle(arg0));
	if (!goodip) {
		Skript.error("\"" + ip + "\" is not a valid IPv4 address!");
		return false;
	}
	JSONObject jsonparsed = null;
	try {
		jsonparsed = JsonReader.readJsonFromUrl("http://proxycheck.io/v1/" + ip.getSingle(arg0) + "&vpn=1&asn=0&node=1&time=1&tag=skLib");
	} catch (JSONException | IOException e) {
		e.printStackTrace();
	}
	String jsonvalue = (String) jsonparsed.get("proxy");
	if (jsonvalue.equalsIgnoreCase("yes")) {
		return true;
	}
	return false;
}
 
开发者ID:WheezyGold7931,项目名称:skLib,代码行数:21,代码来源:CondVpnCheck.java

示例6: get

import ch.njol.skript.Skript; //导入依赖的package包/类
@Override
@Nullable
protected String[] get(Event arg0) {
	String cmd = commandsk.getSingle(arg0);
	String commandStr = cmd.startsWith("/") ? cmd.substring(1) : cmd;
	PluginCommand command = Bukkit.getServer().getPluginCommand(commandStr);
	if (command != null) {
		if (command.getPermission() != null) {
			return new String[] {command.getPermission()};
		} else {
			Skript.error("Command does not have a permission!");
			return null;
		}
	}
	Skript.error("Command not found!");
	return null;
}
 
开发者ID:WheezyGold7931,项目名称:skLib,代码行数:18,代码来源:ExprCommandPermission.java

示例7: execute

import ch.njol.skript.Skript; //导入依赖的package包/类
@Override
protected void execute(Event e) {
  String cls = className.getSingle(e);

  if (cls == null) {
    return;
  }

  JavaType javaType;
  try {
    javaType = new JavaType(LibraryLoader.getClassLoader().loadClass(cls));
  } catch (ClassNotFoundException ex) {
    Skript.warning(cls + " refers to a non-existent class.");
    return;
  }

  if (var == null) {
    Variables.setVariable(javaType.getJavaClass().getSimpleName().toLowerCase(), javaType, e,
        false);
  } else {
    var.change(e, new Object[]{javaType}, Changer.ChangeMode.SET);
  }
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:24,代码来源:EffImport.java

示例8: getDescriptor

import ch.njol.skript.Skript; //导入依赖的package包/类
@SuppressWarnings("ThrowableNotThrown")
private Descriptor getDescriptor(Event e) {
  if (isDynamic) {
    String desc = dynamicDescriptor.getSingle(e);

    if (desc == null) {
      return null;
    }

    try {
      return Descriptor.parse(desc);
    } catch (ClassNotFoundException ex) {
      if (!suppressErrors) {
        Skript.exception(ex);
      }
      return Descriptor.create(null);
    }
  }

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

示例9: init

import ch.njol.skript.Skript; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed,
                    SkriptParser.ParseResult parseResult) {
  expr = Util.defendExpression(exprs[0]);

  if (!Util.canInitSafely(expr)) {
    return false;
  }

  if (!(expr instanceof ExprJavaCall)) {
    Skript.error("Try may only be used with Java calls");
    return false;
  }

  ((ExprJavaCall) expr).setSuppressErrors(true);

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

示例10: init

import ch.njol.skript.Skript; //导入依赖的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;
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:27,代码来源:ExprExpression.java

示例11: register

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

示例12: getAll

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

示例13: walk

import ch.njol.skript.Skript; //导入依赖的package包/类
@Override
protected TriggerItem walk(Event e) {
  if (e instanceof CustomEffect.EffectEvent) {
    if (((CustomEffect.EffectEvent) e).isSync()) {
      Skript.warning("Synchronous events should not be continued. " +
          "Call 'delay effect' to delay the effect's execution.");
    } else {
      TriggerItem.walk(((CustomEffect.EffectEvent) e).getNext(),
          ((CustomEffect.EffectEvent) e).getDirectEvent());
    }
  } else if (e instanceof CustomExpression.ExpressionGetEvent) {
    if (objects != null) {
      ((CustomExpression.ExpressionGetEvent) e).setOutput(objects.getAll(e));
    } else {
      ((CustomExpression.ExpressionGetEvent) e).setOutput(new Object[0]);
    }
  } else if (e instanceof CustomCondition.ConditionEvent) {
    ((CustomCondition.ConditionEvent) e).markContinue();
  }
  return null;
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:22,代码来源:EffContinue.java

示例14: init

import ch.njol.skript.Skript; //导入依赖的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("Only custom syntax may be continued.", ErrorQuality.SEMANTIC_ERROR);
    return false;
  }

  objects = Util.defendExpression(exprs[0]);

  return Util.canInitSafely(objects);
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:20,代码来源:EffContinue.java

示例15: propagateErrors

import ch.njol.skript.Skript; //导入依赖的package包/类
@SuppressWarnings("ThrowableNotThrown")
public static <T, R> Function<T, R> propagateErrors(ExceptionalFunction<T, R> function) {
  return t -> {
    try {
      return function.apply(t);
    } catch (Exception e) {
      Skript.warning(
          String.format("skript-mirror encountered a %s: %s%n" +
              "Run Skript with the verbosity 'very high' for the stack trace.",
              e.getClass().getSimpleName(), e.getMessage()));

      if (Skript.logVeryHigh()) {
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        Skript.warning(errors.toString());
      }
    }
    return null;
  };
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:21,代码来源:Util.java


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