Package ch.njol.skript

Examples of ch.njol.skript.SkriptAPIException


  }
 
  @Override
  public boolean init(final Literal<?>[] args, final int matchedPattern, final ParseResult parser) {
    if (args.length != 0)
      throw new SkriptAPIException("Invalid use of SimpleEvent");
    return true;
  }
View Full Code Here


    return l.toArray();
  }
 
  public Iterator<Pair<String, Object>> variablesIterator(final Event e) {
    if (!list)
      throw new SkriptAPIException("Looping a non-list variable");
    final String name = StringUtils.substring(this.name.toString(e), 0, -1).toLowerCase(Locale.ENGLISH);
    final Object val = Variables.getVariable(name + "*", e, local);
    if (val == null)
      return new EmptyIterator<Pair<String, Object>>();
    assert val instanceof TreeMap;
View Full Code Here

  }
 
  @Override
  public Iterator<T> iterator(final Event e) {
    if (!list)
      throw new SkriptAPIException("");
    final String name = StringUtils.substring(this.name.toString(e), 0, -1).toLowerCase(Locale.ENGLISH);
    final Object val = Variables.getVariable(name + "*", e, local);
    if (val == null)
      return new EmptyIterator<T>();
    assert val instanceof TreeMap;
View Full Code Here

 
  @Override
  @Nullable
  public T getSingle(final Event e) {
    if (list)
      throw new SkriptAPIException("Invalid call to getSingle");
    return getConverted(e);
  }
View Full Code Here

    assert variables.hashMap.isEmpty();
    assert storages.isEmpty();
   
    final Config c = SkriptConfig.getConfig();
    if (c == null)
      throw new SkriptAPIException("Cannot load variables before the config");
    final Node databases = c.getMainNode().get("databases");
    if (databases == null || !(databases instanceof SectionNode)) {
      Skript.error("The config is missing the required 'databases' section that defines where the variables are saved");
      return false;
    }
View Full Code Here

  final static Map<String, FunctionData> functions = new HashMap<String, FunctionData>();
 
  public final static void registerFunction(final JavaFunction<?> function) {
    Skript.checkAcceptRegistrations();
    if (!function.name.matches(functionNamePattern))
      throw new SkriptAPIException("Invalid function name '" + function.name + "'");
    if (functions.containsKey(function.name))
      throw new SkriptAPIException("Duplicate function " + function.name);
    functions.put(function.name, new FunctionData(function));
  }
View Full Code Here

  }
 
  @Override
  public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
    if (exprs.length != 0)
      throw new SkriptAPIException(this.getClass().getName() + " has expressions in its pattern but does not override init(...)");
    return init();
  }
View Full Code Here

    assert events != null && events.length > 0;
   
    for (int i = 0; i < events.length; i++) {
      for (int j = i + 1; j < events.length; j++) {
        if (events[i].isAssignableFrom(events[j]) || events[j].isAssignableFrom(events[i]))
          throw new SkriptAPIException("The event " + name + " (" + c.getName() + ") registers with super/subclasses " + events[i].getName() + " and " + events[j].getName());
      }
    }
   
    this.events = events;
   
View Full Code Here

                  final String name = pattern.substring(x + 1, x2);
                  if (!name.startsWith("-")) {
                    final ExprInfo vi = getExprInfo(name);
                    final DefaultExpression<?> expr = vi.classes[0].getDefaultExpression();
                    if (expr == null)
                      throw new SkriptAPIException("The class '" + vi.classes[0].getCodeName() + "' does not provide a default expression. Either allow null (with %-" + vi.classes[0].getCodeName() + "%) or make it mandatory [pattern: " + info.patterns[i] + "]");
                    if (!(expr instanceof Literal) && (vi.flagMask & PARSE_EXPRESSIONS) == 0)
                      throw new SkriptAPIException("The default expression of '" + vi.classes[0].getCodeName() + "' is not a literal. Either allow null (with %-*" + vi.classes[0].getCodeName() + "%) or make it mandatory [pattern: " + info.patterns[i] + "]");
                    if (expr instanceof Literal && (vi.flagMask & PARSE_LITERALS) == 0)
                      throw new SkriptAPIException("The default expression of '" + vi.classes[0].getCodeName() + "' is a literal. Either allow null (with %-~" + vi.classes[0].getCodeName() + "%) or make it mandatory [pattern: " + info.patterns[i] + "]");
                    if (!vi.isPlural[0] && !expr.isSingle())
                      throw new SkriptAPIException("The default expression of '" + vi.classes[0].getCodeName() + "' is not a single-element expression. Change your pattern to allow multiple elements or make the expression mandatory [pattern: " + info.patterns[i] + "]");
                    if (vi.time != 0 && !expr.setTime(vi.time))
                      throw new SkriptAPIException("The default expression of '" + vi.classes[0].getCodeName() + "' does not have distinct time states. [pattern: " + info.patterns[i] + "]");
                    if (!expr.init())
                      continue patternsLoop;
                    res.exprs[j] = expr;
                  }
                }
View Full Code Here

TOP

Related Classes of ch.njol.skript.SkriptAPIException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.