Example #1
0
 @Override
 public boolean init() {
   final ParseLogHandler log = SkriptLogger.startParseLogHandler();
   try {
     boolean hasValue = false;
     for (final Class<? extends Event> e : ScriptLoader.getCurrentEvents()) {
       if (getters.containsKey(e)) {
         hasValue = true;
         continue;
       }
       final SerializableGetter<? extends T, ?> getter =
           EventValues.getEventValueGetter(e, c, getTime());
       if (getter != null) {
         getters.put(e, getter);
         hasValue = true;
       }
     }
     if (!hasValue) {
       log.printError(
           "There's no "
               + Classes.getSuperClassInfo(c).getName()
               + " in "
               + Utils.a(ScriptLoader.currentEventName)
               + " event");
       return false;
     }
     log.printLog();
     return true;
   } finally {
     log.stop();
   }
 }
Example #2
0
  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;
  }