Package ch.njol.skript.log

Examples of ch.njol.skript.log.RetainingLogHandler


    return Classes.getSuperClassInfo(e.getReturnType()).getName().withIndefiniteArticle();
  }
 
  @SuppressWarnings("unchecked")
  private boolean init() {
    final RetainingLogHandler log = SkriptLogger.startRetainingLog();
    Expression<?> third = this.third;
    try {
      if (first.getReturnType() == Object.class) {
        final Expression<?> e = first.getConvertedExpression(Object.class);
        if (e == null) {
          log.printErrors();
          return false;
        }
        first = e;
      }
      if (second.getReturnType() == Object.class) {
        final Expression<?> e = second.getConvertedExpression(Object.class);
        if (e == null) {
          log.printErrors();
          return false;
        }
        second = e;
      }
      if (third != null && third.getReturnType() == Object.class) {
        final Expression<?> e = third.getConvertedExpression(Object.class);
        if (e == null) {
          log.printErrors();
          return false;
        }
        this.third = third = e;
      }
      log.printLog();
    } finally {
      log.stop();
    }
   
    final Class<?> f = first.getReturnType(), s = third == null ? second.getReturnType() : Utils.getSuperType(second.getReturnType(), third.getReturnType());
    if (f == Object.class || s == Object.class)
      return true;
View Full Code Here


        if (!SkriptParser.validateLine(name))
          continue;
       
        if (StringUtils.startsWithIgnoreCase(name, "loop ")) {
          final String l = "" + name.substring("loop ".length());
          final RetainingLogHandler h = SkriptLogger.startRetainingLog();
          Expression<?> loopedExpr;
          try {
            loopedExpr = new SkriptParser(l).parseExpression(Object.class);
            if (loopedExpr != null)
              loopedExpr = loopedExpr.getConvertedExpression(Object.class);
            if (loopedExpr == null) {
              h.printErrors("Can't understand this loop: '" + name + "'");
              continue;
            }
            h.printLog();
          } finally {
            h.stop();
          }
          if (loopedExpr.isSingle()) {
            Skript.error("Can't loop " + loopedExpr + " because it's only a single value");
            continue;
          }
View Full Code Here

        Skript.error("The function '" + functionName + "' was redefined with a different, incompatible amount of arguments, but is still used in other script(s). These will continue to use the old version of the function.");
      return false;
    }
    for (int i = 0; i < parameters.length; i++) {
      final Parameter<?> p = newFunc.parameters[i];
      final RetainingLogHandler log = SkriptLogger.startRetainingLog();
      try {
        final Expression<?> e = parameters[i].getConvertedExpression(p.type.getC());
        if (e == null) {
          if (first)
            Skript.error("The " + StringUtils.fancyOrderNumber(i + 1) + " argument of the function '" + functionName + "' is not of the required type " + p.type + ".");
          else
            Skript.error("The function '" + functionName + "' was redefined with different, incompatible arguments, but is still used in other script(s). These will continue to use the old version of the function.");
          return false;
        }
        parameters[i] = e;
      } finally {
        log.printLog();
      }
    }
   
    function = (Function<? extends T>) newFunc;
    Functions.registerCaller(this);
View Full Code Here

//          log.printLog();
//        } finally {
//          log.stop();
//        }
//      } else {
      final RetainingLogHandler log = SkriptLogger.startRetainingLog();
      try {
        if (type.getC() == String.class) {
          if (def.startsWith("\"") && def.endsWith("\""))
            d = (Expression<? extends T>) VariableString.newInstance("" + def.substring(1, def.length() - 1));
          else
            d = (Expression<? extends T>) new SimpleLiteral<String>(def, false);
        } else {
          d = new SkriptParser(def, SkriptParser.PARSE_LITERALS, ParseContext.DEFAULT).parseExpression(type.getC());
        }
        if (d == null) {
          log.printErrors("'" + def + "' is not " + type.getName().withIndefiniteArticle());
          return null;
        }
        log.printLog();
      } finally {
        log.stop();
      }
//      }
    }
    return new Parameter<T>(name, type, single, d);
  }
View Full Code Here

            string.set(string.size() - 1, (String) string.get(string.size() - 1) + "%");
          } else {
            string.add("%");
          }
        } else {
          final RetainingLogHandler log = SkriptLogger.startRetainingLog();
          try {
            @SuppressWarnings("unchecked")
            final Expression<?> expr = new SkriptParser("" + s.substring(c + 1, c2), SkriptParser.PARSE_EXPRESSIONS, ParseContext.DEFAULT).parseExpression(Object.class);
            if (expr == null) {
              log.printErrors("Can't understand this expression: " + s.substring(c + 1, c2));
              return null;
            } else {
              if (mode != StringMode.MESSAGE) {
                string.add(expr);
              } else {
                final ExpressionInfo i = new ExpressionInfo(expr);
                if (c2 <= s.length() - 2 && s.charAt(c2 + 1) == 's' && (c2 == s.length() - 2 || !Character.isLetter(s.charAt(c2 + 2)))) {
                  i.flags |= Language.F_PLURAL;
                  c2++; // remove the 's'
                }
                if (string.size() > 0 && string.get(string.size() - 1) instanceof String) {
                  final String last = (String) string.get(string.size() - 1);
                  if (c2 <= s.length() - 2 && s.charAt(c2 + 1) == '>' && last.endsWith("<")) {
                    i.toChatStyle = true;
                    string.set(string.size() - 1, last.substring(0, last.length() - 1));
                    c2++; // remove the '>'
                  } else {
                    final int l = last.lastIndexOf(' ', last.endsWith(" ") ? last.length() - 2 : last.length() - 1);
                    final String lastWord = "" + last.substring(l + 1).trim();
                    if (Noun.isLocalIndefiniteArticle(lastWord))
                      i.flags |= Language.F_INDEFINITE_ARTICLE;
                    else if (Noun.isLocalDefiniteArticle(lastWord))
                      i.flags |= Language.F_DEFINITE_ARTICLE;
                    if ((i.flags & (Language.F_INDEFINITE_ARTICLE | Language.F_DEFINITE_ARTICLE)) != 0)
                      string.set(string.size() - 1, last.substring(0, l + 1));
                  }
                }
                string.add(i);
              }
            }
            log.printLog();
          } finally {
            log.stop();
          }
        }
        c = s.indexOf('%', c2 + 1);
        if (c == -1)
          c = s.length();
View Full Code Here

    if (!(sender instanceof ConsoleCommandSender || sender.hasPermission("skript.effectcommands") || SkriptConfig.allowOpsToUseEffectCommands.value() && sender.isOp()))
      return false;
    final boolean wasLocal = Language.setUseLocal(false);
    try {
      command = "" + command.substring(SkriptConfig.effectCommandToken.value().length()).trim();
      final RetainingLogHandler log = SkriptLogger.startRetainingLog();
      try {
        ScriptLoader.setCurrentEvent("effect command", EffectCommandEvent.class);
        final Effect e = Effect.parse(command, null);
        ScriptLoader.deleteCurrentEvent();
       
        if (e != null) {
          log.clear(); // ignore warnings and stuff
          log.printLog();
         
          sender.sendMessage(ChatColor.GRAY + "executing '" + ChatColor.stripColor(command) + "'");
          if (SkriptConfig.logPlayerCommands.value() && !(sender instanceof ConsoleCommandSender))
            Skript.info(sender.getName() + " issued effect command: " + command);
          e.run(new EffectCommandEvent(sender, command));
        } else {
          if (sender == Bukkit.getConsoleSender()) // log as SEVERE instead of INFO like printErrors below
            SkriptLogger.LOGGER.severe("Error in: " + ChatColor.stripColor(command));
          else
            sender.sendMessage(ChatColor.RED + "Error in: " + ChatColor.GRAY + ChatColor.stripColor(command));
          log.printErrors(sender, "(No specific information is available)");
        }
      } finally {
        log.stop();
      }
      return true;
    } catch (final Exception e) {
      Skript.exception(e, "Unexpected error while executing effect command '" + command + "' by '" + sender.getName() + "'");
      sender.sendMessage(ChatColor.RED + "An internal error occurred while executing this effect. Please refer to the server log for details.");
View Full Code Here

      return null;
    }
    Expression<? extends T> d = null;
    if (def != null) {
      if (def.startsWith("%") && def.endsWith("%")) {
        final RetainingLogHandler log = SkriptLogger.startRetainingLog();
        try {
          d = new SkriptParser("" + def.substring(1, def.length() - 1), SkriptParser.PARSE_EXPRESSIONS, ParseContext.COMMAND).parseExpression(type.getC());
          if (d == null) {
            log.printErrors("Can't understand this expression: " + def + "");
            return null;
          }
          log.printLog();
        } finally {
          log.stop();
        }
      } else {
        final RetainingLogHandler log = SkriptLogger.startRetainingLog();
        try {
          if (type.getC() == String.class) {
            if (def.startsWith("\"") && def.endsWith("\""))
              d = (Expression<? extends T>) VariableString.newInstance("" + def.substring(1, def.length() - 1));
            else
              d = (Expression<? extends T>) new SimpleLiteral<String>(def, false);
          } else {
            d = new SkriptParser(def, SkriptParser.PARSE_LITERALS, ParseContext.DEFAULT).parseExpression(type.getC());
          }
          if (d == null) {
            log.printErrors("Can't understand this expression: '" + def + "'");
            return null;
          }
          log.printLog();
        } finally {
          log.stop();
        }
      }
    }
    return new Argument<T>(name, d, type, single, index, def != null || forceOptional);
  }
View Full Code Here

  @SuppressWarnings("null")
  private EventValueExpression<Entity> entity;
 
  @Override
  public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
    final RetainingLogHandler log = SkriptLogger.startRetainingLog();
    try {
      if (!StringUtils.startsWithIgnoreCase(parseResult.expr, "the ") && !StringUtils.startsWithIgnoreCase(parseResult.expr, "event-")) {
        final ItemType item = Aliases.parseItemType("" + parseResult.regexes.get(0).group());
        log.clear();
        if (item != null) {
          log.printLog();
          return false;
        }
      }
      final EntityData<?> type = EntityData.parseWithoutIndefiniteArticle("" + parseResult.regexes.get(0).group());
      log.clear();
      log.printLog();
      if (type == null || type.isPlural().isTrue())
        return false;
      this.type = type;
    } finally {
      log.stop();
    }
    entity = new EventValueExpression<Entity>(type.getType());
    return entity.init();
  }
View Full Code Here

    return new SkriptParser(text, PARSE_LITERALS, ParseContext.COMMAND).parse_i(pattern, 0, 0);
  }
 
  @Nullable
  public static NonNullPair<SkriptEventInfo<?>, SkriptEvent> parseEvent(final String event, final String defaultError) {
    final RetainingLogHandler log = SkriptLogger.startRetainingLog();
    try {
      final NonNullPair<SkriptEventInfo<?>, SkriptEvent> e = new SkriptParser(event, PARSE_LITERALS, ParseContext.EVENT).parseEvent();
      if (e != null) {
        log.printLog();
        return e;
      }
      log.printErrors(defaultError);
      return null;
    } finally {
      log.stop();
    }
  }
View Full Code Here

    final ClassInfo<?> rt = function.getReturnType();
    if (rt == null) {
      Skript.error("This function doesn't return any value. Please use 'stop' or 'exit' if you want to stop the function.");
      return false;
    }
    final RetainingLogHandler log = SkriptLogger.startRetainingLog();
    final Expression<?> v;
    try {
      v = exprs[0].getConvertedExpression(rt.getC());
      if (v == null) {
        log.printErrors("This function is declared to return " + rt.getName().withIndefiniteArticle() + ", but " + exprs[0].toString(null, false) + " is not of that type.");
        return false;
      }
      log.printLog();
    } finally {
      log.stop();
    }
    if (f.isSingle() && !v.isSingle()) {
      Skript.error("This function is defined to only return a single " + rt.toString() + ", but this return statement can return multiple values.");
      return false;
    }
View Full Code Here

TOP

Related Classes of ch.njol.skript.log.RetainingLogHandler

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.