Example #1
0
 /** @param args */
 public static void main(String[] args) {
   // TODO Auto-generated method stub
   Repairorder order = RepairOrderSvc.getInstance().findById(30);
   Date startDate = order.getStartdate();
   System.out.println(startDate.toGMTString());
   System.out.println(startDate.toLocaleString());
   System.out.println(startDate.toString());
   Date date = new Date();
   System.out.println(date.toGMTString());
   System.out.println(date.toLocaleString());
   System.out.println(date.toString());
   System.out.println(date.toGMTString());
   System.out.println(date.toLocaleString());
   System.out.println(date.toString());
 }
Example #2
0
  public static void main(String args[]) throws Exception {
    Date d0 = new Date(TIME);
    System.out.println(d0.toGMTString());

    checkUTC(d0, UTC_ZULU, "Zulu");
    checkUTC(d0, UTC_PLUS1, "+0100");
    checkUTC(d0, UTC_MINUS1, "-0100");

    checkGeneralized(d0, GEN_ZULU, "Zulu");
    checkGeneralized(d0, GEN_PLUS1, "+0100");
    checkGeneralized(d0, GEN_MINUS1, "-0100");

    Date d1 = new Date(TIME_FRACT1);
    checkGeneralized(d1, GEN_FRACT1_ZULU, "fractional seconds (Zulu)");
    checkGeneralized(d1, GEN_FRACT1_PLUS1, "fractional seconds (+0100)");

    Date d2 = new Date(TIME_FRACT2);
    checkGeneralized(d2, GEN_FRACT2_ZULU, "fractional seconds (Zulu)");
    checkGeneralized(d2, GEN_FRACT2_PLUS1, "fractional seconds (+0100)");

    Date d3 = new Date(TIME_FRACT3);
    checkGeneralized(d3, GEN_FRACT3_ZULU, "fractional seconds (Zulu)");
    checkGeneralized(d3, GEN_FRACT3_PLUS1, "fractional seconds (+0100)");
    checkGeneralized(d3, GEN_FRACT3_COMMA_PLUS1, "fractional seconds (+0100)");
  }
Example #3
0
  public String makeMimeMessage(final int maxMessageSize) {
    final StringBuffer mailRaw = new StringBuffer();

    mailRaw.append("Date: " + timestamp.toGMTString() + "\r\n");
    mailRaw.append("From: " + fromAddress + "\r\n");

    mailRaw.append("To: " + toAddresses + "\r\n");
    mailRaw.append("Cc: " + ccAddresses + "\r\n");

    mailRaw.append("Subject: " + subject + "\r\n");

    // comincia la ricostruzione del MIME
    // 18.14=MIME-Version: 1.0
    mailRaw.append(M.e("MIME-Version: 1.0") + "\r\n"); // $NON-NLS-1$
    final long rnd = Math.abs(Utils.getRandom());
    // 18.15=------_NextPart_
    final String boundary = M.e("------_NextPart_") + rnd; // $NON-NLS-1$

    if (isMultipart()) {
      // 18.16=Content-Type: multipart/alternative; boundary=
      mailRaw.append(
          M.e("Content-Type: multipart/alternative; boundary=") // $NON-NLS-1$
              + boundary
              + "\r\n"); //$NON-NLS-1$
      mailRaw.append("\r\n--" + boundary + "\r\n"); // $NON-NLS-1$ //$NON-NLS-2$
    }
    // j_19=Content-Transfer-Encoding: quoted-printable
    mailRaw.append(M.e("Content-Transfer-Encoding: 8bit") + "\r\n");
    // 18.17=Content-type: text/plain; charset=UTF8
    mailRaw.append(M.e("Content-type: text/plain; charset") + "\r\n\r\n");
    String msg = snippet;
    if (maxMessageSize > 0 && msg.length() > maxMessageSize) {
      msg = msg.substring(0, maxMessageSize);
    }

    mailRaw.append(msg);

    if (isMultipart()) {
      mailRaw.append("\r\n--" + boundary + "\r\n"); // $NON-NLS-1$ //$NON-NLS-2$

      // j_18=Content-type: text/html; charset=UTF8
      // j_19=Content-Transfer-Encoding: quoted-printable
      mailRaw.append(M.e("Content-Transfer-Encoding: 8bit") + "\r\n");
      mailRaw.append(M.e("Content-type: text/html; charset") + "\r\n\r\n");
      // mailRaw.append(htmlMessageContentType);

      if (maxMessageSize > 0 && body.length() > maxMessageSize) {
        body = body.substring(0, maxMessageSize);
      }
      mailRaw.append(body);

      mailRaw.append("\r\n--" + boundary + "--\r\n"); // $NON-NLS-1$ //$NON-NLS-2$
    }

    mailRaw.append("\r\n"); // $NON-NLS-1$

    final String craftedMail = mailRaw.toString();
    return craftedMail;
  }
Example #4
0
 private static void checkGeneralized(Date d0, byte[] b, String text) throws Exception {
   Date d1 = decodeGeneralized(b);
   if (!d0.equals(d1)) {
     throw new Exception("GeneralizedTime " + text + " failed: " + d1.toGMTString());
   } else {
     System.out.println("GeneralizedTime " + text + " ok");
   }
 }
Example #5
0
 private String getHttpCookie() {
   StringBuilder strHeader = new StringBuilder();
   Cookie[] cookies = httpClient.getState().getCookies();
   for (Cookie cookie : cookies) {
     String domain = cookie.getDomain();
     String path = cookie.getPath();
     String name = cookie.getName();
     String value = cookie.getValue();
     Date expired = cookie.getExpiryDate();
     boolean isSecure = cookie.getSecure();
     strHeader.append("domain=" + domain + ";");
     strHeader.append("path=" + path + ";");
     strHeader.append(name + "=" + value + ";");
     if (expired != null) {
       strHeader.append("expired=" + expired.toGMTString() + ";");
     }
     strHeader.append("isSecure=" + isSecure + "/n");
   }
   return strHeader.toString();
 }
 @SuppressWarnings("deprecation")
 private String makeExpiringCookieMs(String cookie, int millisecondsTillExpiry) {
   Date date = new Date();
   date.setTime(date.getTime() + millisecondsTillExpiry);
   return cookie + "; expires=" + date.toGMTString();
 }
Example #7
0
  private void practice() {
    SimpleDateFormat date_format = new SimpleDateFormat("yyyy MMM dd HH:mm z", Locale.ENGLISH);

    String location = "40.77,-73.77";

    String url =
        "https://maps.googleapis.com/maps/api/timezone/json?location=" + location + "&timestamp=";
    try {
      Date date =
          //					new Date();
          (Date) date_format.parse("2015 Feb 10 10:47 GMT");
      System.out.println(date.getTime() / 1000);
      System.out.println(date.toString());

      url += "" + date.getTime() / 1000;
      URL u = new URL(url);
      u =
          new URL(
              "https://maps.googleapis.com/maps/api/timezone/json?location=39.053528,-84.66307&timestamp=1423565220");

      URL u2 =
          new URL(
              "http://api.timezonedb.com/?lat=40.7833&lng=-73.75&format=json&key=NMBW9G7ILB6H&timestamp=1418208420");
      HttpsURLConnection connection = (HttpsURLConnection) u.openConnection();
      //			HttpURLConnection connection = (HttpURLConnection) u2.openConnection();

      connection.setRequestMethod("GET");

      int responseCode = connection.getResponseCode();

      if ((responseCode >= 200) && (responseCode <= 299)) {
        InputStream is = connection.getInputStream();

        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        StringBuilder str = new StringBuilder();
        String line = "";

        while ((line = reader.readLine()) != null) {
          str.append(line);
        }

        JSONObject obj = new JSONObject(str.toString());
        //				System.out.println(obj.get("status"));
        //				System.out.println(obj.get("abbreviation"));
        System.out.println(obj.getString("timeZoneName"));
        System.out.println(obj.getLong("dstOffset"));

        //				String timezone = obj.getString("zoneName");
        //				String[] sArray = timezone.split(" ");
        //				int length = 0;
        //				String acronym = "";
        //				while(length<sArray.length){
        //					acronym += sArray[length].charAt(0);
        //					length++;
        //				}
        //				long offset =
        //						(obj.getInt("dst")-1)*3600 +
        //						obj.getLong("gmtOffset");

        Date da2 = new Date();
        da2.setTime(date.getTime() + (obj.getLong("dstOffset") + obj.getLong("rawOffset")) * 1000);
        //				date.setMonth(5);
        //				System.out.println(acronym);

        System.out.println(da2.toGMTString());
        System.out.println(date.toString());
      }

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  @TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "removeSessionCookie",
        args = {}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "removeExpiredCookie",
        args = {})
  })
  @SuppressWarnings("deprecation")
  public void testRemoveCookies() throws InterruptedException {
    // enable cookie
    mCookieManager.setAcceptCookie(true);
    assertTrue(mCookieManager.acceptCookie());
    assertFalse(mCookieManager.hasCookies());

    final String url = "http://www.example.com";
    final String cookie1 = "cookie1=peter";
    final String cookie2 = "cookie2=sue";
    final String cookie3 = "cookie3=marc";

    mCookieManager.setCookie(url, cookie1); // session cookie

    Date date = new Date();
    date.setTime(date.getTime() + 1000 * 600);
    String value2 = cookie2 + "; expires=" + date.toGMTString();
    mCookieManager.setCookie(url, value2); // expires in 10min

    long expiration = 3000;
    date = new Date();
    date.setTime(date.getTime() + expiration);
    String value3 = cookie3 + "; expires=" + date.toGMTString();
    mCookieManager.setCookie(url, value3); // expires in 3s

    String allCookies = mCookieManager.getCookie(url);
    assertTrue(allCookies.contains(cookie1));
    assertTrue(allCookies.contains(cookie2));
    assertTrue(allCookies.contains(cookie3));

    mCookieManager.removeSessionCookie();
    new DelayedCheck(TEST_DELAY) {
      protected boolean check() {
        String c = mCookieManager.getCookie(url);
        return !c.contains(cookie1) && c.contains(cookie2) && c.contains(cookie3);
      }
    }.run();

    Thread.sleep(expiration + 1000); // wait for cookie to expire
    mCookieManager.removeExpiredCookie();
    new DelayedCheck(TEST_DELAY) {
      protected boolean check() {
        String c = mCookieManager.getCookie(url);
        return !c.contains(cookie1) && c.contains(cookie2) && !c.contains(cookie3);
      }
    }.run();

    mCookieManager.removeAllCookie();
    new DelayedCheck(TEST_DELAY) {
      protected boolean check() {
        return mCookieManager.getCookie(url) == null;
      }
    }.run();
  }
Example #9
0
 public static void main(String[] args) {
   Date date = Tools.getDateTime(new Date(), -7);
   System.out.println(date.toGMTString() + " == " + date.getTime());
   String str = "唐淑敏";
   byte[] bytes = str.getBytes(UTF8);
 }
Example #10
0
  public static Token generateToken(
      String email, String password, String ip_address, String user_agent) {
    Token token = new Token();
    // Check if email and password match
    DBConnection dbc = new DBConnection();
    PreparedStatement stmt = dbc.getDBStmt();
    Connection conn = dbc.getConn();
    try {
      String sql = "SELECT * FROM user " + "WHERE email = ? AND password = MD5(?)";
      stmt = conn.prepareStatement(sql);
      stmt.setString(1, email);
      stmt.setString(2, password);
      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {
        int user_id = rs.getInt("id_user");
        token.access_token = getRandomToken();

        java.util.Date dt = new java.util.Date();
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String currentTime = sdf.format(dt);

        Calendar c = Calendar.getInstance();
        c.setTime(sdf.parse(currentTime));
        c.add(Calendar.DATE, 2);

        dt.setTime(dt.getTime() + (2 * 24 * 3600 * 1000)); // 2 hari

        String cookieExpire = "expires=" + dt.toGMTString();
        token.expire = cookieExpire;
        System.out.println("expired on: " + token.expire);
        while (!(isTokenUnique(token))) {
          token.access_token = getRandomToken();
        }

        sql = "DELETE FROM token WHERE id_user = ? AND IP_Address = ? AND user_agent = ?";
        stmt = conn.prepareStatement(sql);
        stmt.setInt(1, user_id);
        stmt.setString(2, ip_address);
        stmt.setString(3, user_agent);
        stmt.executeUpdate();

        sql =
            "INSERT INTO token(access_token,id_user,timestamp,IP_Address,user_agent) "
                + "VALUES(?,?,?,?,?);";
        stmt = conn.prepareStatement(sql);
        stmt.setString(1, token.access_token);
        stmt.setInt(2, user_id);
        stmt.setString(3, currentTime);
        stmt.setString(4, ip_address);
        stmt.setString(5, user_agent);
        stmt.executeUpdate();
      }
      stmt.close();
      conn.close();
    } catch (SQLException se) {
      // Handle errors for JDBC
      se.printStackTrace();
    } catch (Exception e) {
      // Handle errors for Class.forName
      e.printStackTrace();
    } finally {
      try {
        if (stmt != null) stmt.close();
      } catch (SQLException se2) {

      }
      try {
        if (conn != null) conn.close();
      } catch (SQLException se) {
        se.printStackTrace();
      }
    }
    return token;
  }
Example #11
0
  public static Token generateToken(String access_token) {
    Token token = new Token();
    // Check if email and password match
    DBConnection dbc = new DBConnection();
    PreparedStatement stmt = dbc.getDBStmt();
    Connection conn = dbc.getConn();
    String[] token_data = access_token.split("#");
    String token_code = token_data[0];
    String user_agent = token_data[1];
    String ip_address = token_data[2];
    try {
      String sql =
          "SELECT * FROM token " + "WHERE access_token = ? AND IP_Address = ? AND user_agent = ?";
      stmt = conn.prepareStatement(sql);
      stmt.setString(1, token_code);
      stmt.setString(2, ip_address);
      stmt.setString(3, user_agent);
      System.out.println(stmt);
      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {

        int user_id = rs.getInt("id_user");

        token.access_token = getRandomToken();

        java.util.Date dt = new java.util.Date();
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String currentTime = sdf.format(dt);

        Calendar c = Calendar.getInstance();
        c.setTime(sdf.parse(currentTime));
        c.add(Calendar.DATE, 2);

        dt.setTime(dt.getTime() + (2 * 60 * 1000)); // 2 hari

        String cookieExpire = "expires=" + dt.toGMTString();
        token.expire = cookieExpire;
        System.out.println(token.expire);
        while (!(isTokenUnique(token))) {
          token = generateToken(access_token);
        }
        sql = "UPDATE token SET access_token = ?, timestamp = ? WHERE access_token = ?";
        stmt = conn.prepareStatement(sql);
        stmt.setString(1, token.access_token);
        stmt.setString(2, currentTime);
        stmt.setString(3, token_code);
        stmt.executeUpdate();
        System.out.println("OK");
      }
      stmt.close();
      conn.close();
    } catch (SQLException se) {
      // Handle errors for JDBC
      se.printStackTrace();
    } catch (Exception e) {
      // Handle errors for Class.forName
      e.printStackTrace();
    } finally {
      try {
        if (stmt != null) stmt.close();
      } catch (SQLException se2) {

      }
      try {
        if (conn != null) conn.close();
      } catch (SQLException se) {
        se.printStackTrace();
      }
    }
    return token;
  }
Example #12
0
 @Override
 public boolean onCommand(final PlotPlayer player, final String... args) {
   final List<String> allowed_params =
       Arrays.asList(
           "calibrate-analysis",
           "remove-flag",
           "stop-expire",
           "start-expire",
           "show-expired",
           "update-expired",
           "seen",
           "trim-check");
   if (args.length > 0) {
     final String arg = args[0].toLowerCase();
     String script;
     boolean async = false;
     switch (arg) {
       case "analyze":
         {
           final Plot plot = MainUtil.getPlotAbs(player.getLocation());
           if (plot == null) {
             MainUtil.sendMessage(player, C.NOT_IN_PLOT);
             return false;
           }
           final PlotAnalysis analysis = plot.getComplexity();
           if (analysis != null) {
             final int complexity = analysis.getComplexity();
             MainUtil.sendMessage(player, "Changes/column: " + (analysis.changes / 1.0));
             MainUtil.sendMessage(player, "Complexity: " + complexity);
             return true;
           }
           MainUtil.sendMessage(player, "$1Starting task...");
           HybridUtils.manager.analyzePlot(
               plot,
               new RunnableVal<PlotAnalysis>() {
                 @Override
                 public void run() {
                   MainUtil.sendMessage(
                       player, "$1Done: $2use $3/plot debugexec analyze$2 for more information");
                 }
               });
           return true;
         }
       case "calibrate-analysis":
         {
           if (args.length != 2) {
             MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec analyze <threshold>");
             MainUtil.sendMessage(
                 player,
                 "$1<threshold> $2= $1The percentage of plots you want to clear (100 clears 100% of plots so no point calibrating it)");
             return false;
           }
           double threshold;
           try {
             threshold = Integer.parseInt(args[1]) / 100d;
           } catch (final NumberFormatException e) {
             MainUtil.sendMessage(player, "$2Invalid threshold: " + args[1]);
             MainUtil.sendMessage(
                 player,
                 "$1<threshold> $2= $1The percentage of plots you want to clear as a number between 0 - 100");
             return false;
           }
           PlotAnalysis.calcOptimalModifiers(
               new Runnable() {
                 @Override
                 public void run() {
                   MainUtil.sendMessage(
                       player, "$1Thank you for calibrating PlotSquared plot expiry");
                 }
               },
               threshold);
           return true;
         }
       case "stop-expire":
         {
           if (ExpireManager.task != -1) {
             PS.get().TASK.cancelTask(ExpireManager.task);
           } else {
             return MainUtil.sendMessage(player, "Task already halted");
           }
           ExpireManager.task = -1;
           return MainUtil.sendMessage(player, "Cancelled task.");
         }
       case "remove-flag":
         {
           if (args.length != 2) {
             MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec remove-flag <flag>");
             return false;
           }
           final String flag = args[1];
           for (final Plot plot : PS.get().getPlots()) {
             if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
               FlagManager.removePlotFlag(plot, flag);
             }
           }
           return MainUtil.sendMessage(player, "Cleared flag: " + flag);
         }
       case "start-rgar":
         {
           if (args.length != 2) {
             MainUtil.sendMessage(player, "&cInvalid syntax: /plot debugexec start-rgar <world>");
             return false;
           }
           boolean result;
           if (!PS.get().isPlotWorld(args[1])) {
             MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]);
             return false;
           }
           if (HybridUtils.regions != null) {
             result =
                 ((BukkitHybridUtils) (HybridUtils.manager))
                     .scheduleRoadUpdate(args[1], HybridUtils.regions, 0);
           } else {
             result = HybridUtils.manager.scheduleRoadUpdate(args[1], 0);
           }
           if (!result) {
             MainUtil.sendMessage(
                 player, "&cCannot schedule mass schematic update! (Is one already in progress?)");
             return false;
           }
           return true;
         }
       case "stop-rgar":
         {
           if (!HybridUtils.UPDATE) {
             MainUtil.sendMessage(player, "&cTASK NOT RUNNING!");
             return false;
           }
           HybridUtils.UPDATE = false;
           MainUtil.sendMessage(player, "&cCancelling task... (please wait)");
           return true;
         }
       case "start-expire":
         {
           if (ExpireManager.task == -1) {
             ExpireManager.runTask();
           } else {
             return MainUtil.sendMessage(player, "Plot expiry task already started");
           }
           return MainUtil.sendMessage(player, "Started plot expiry task");
         }
       case "update-expired":
         {
           if (args.length > 1) {
             final String world = args[1];
             if (!BlockManager.manager.isWorld(world)) {
               return MainUtil.sendMessage(player, "Invalid world: " + args[1]);
             }
             MainUtil.sendMessage(player, "Updating expired plot list");
             ExpireManager.updateExpired(args[1]);
             return true;
           }
           return MainUtil.sendMessage(player, "Use /plot debugexec update-expired <world>");
         }
       case "show-expired":
         {
           if (args.length > 1) {
             final String world = args[1];
             if (!BlockManager.manager.isWorld(world)) {
               return MainUtil.sendMessage(player, "Invalid world: " + args[1]);
             }
             if (!ExpireManager.expiredPlots.containsKey(args[1])) {
               return MainUtil.sendMessage(player, "No task for world: " + args[1]);
             }
             MainUtil.sendMessage(
                 player,
                 "Expired plots (" + ExpireManager.expiredPlots.get(args[1]).size() + "):");
             for (final Plot plot : ExpireManager.expiredPlots.get(args[1])) {
               MainUtil.sendMessage(
                   player,
                   " - "
                       + plot.world
                       + ";"
                       + plot.id.x
                       + ";"
                       + plot.id.y
                       + ";"
                       + UUIDHandler.getName(plot.owner)
                       + " : "
                       + ExpireManager.dates.get(plot.owner));
             }
             return true;
           }
           return MainUtil.sendMessage(player, "Use /plot debugexec show-expired <world>");
         }
       case "seen":
         {
           if (args.length != 2) {
             return MainUtil.sendMessage(player, "Use /plot debugexec seen <player>");
           }
           final UUID uuid = UUIDHandler.getUUID(args[1], null);
           if (uuid == null) {
             return MainUtil.sendMessage(player, "player not found: " + args[1]);
           }
           final OfflinePlotPlayer op = UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid);
           if ((op == null) || (op.getLastPlayed() == 0)) {
             return MainUtil.sendMessage(player, "player hasn't connected before: " + args[1]);
           }
           final Timestamp stamp = new Timestamp(op.getLastPlayed());
           final Date date = new Date(stamp.getTime());
           MainUtil.sendMessage(player, "PLAYER: " + args[1]);
           MainUtil.sendMessage(player, "UUID: " + uuid);
           MainUtil.sendMessage(player, "Object: " + date.toGMTString());
           MainUtil.sendMessage(player, "GMT: " + date.toGMTString());
           MainUtil.sendMessage(player, "Local: " + date.toLocaleString());
           return true;
         }
       case "trim-check":
         {
           if (args.length != 2) {
             MainUtil.sendMessage(player, "Use /plot debugexec trim-check <world>");
             MainUtil.sendMessage(player, "&7 - Generates a list of regions to trim");
             return MainUtil.sendMessage(player, "&7 - Run after plot expiry has run");
           }
           final String world = args[1];
           if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(args[1])) {
             return MainUtil.sendMessage(player, "Invalid world: " + args[1]);
           }
           final ArrayList<ChunkLoc> empty = new ArrayList<>();
           final boolean result =
               Trim.getTrimRegions(
                   empty,
                   world,
                   new Runnable() {
                     @Override
                     public void run() {
                       Trim.sendMessage(
                           "Processing is complete! Here's how many chunks would be deleted:");
                       Trim.sendMessage(" - MCA #: " + empty.size());
                       Trim.sendMessage(" - CHUNKS: " + (empty.size() * 1024) + " (max)");
                       Trim.sendMessage("Exporting log for manual approval...");
                       final File file =
                           new File(PS.get().IMP.getDirectory() + File.separator + "trim.txt");
                       PrintWriter writer;
                       try {
                         writer = new PrintWriter(file);
                         for (final ChunkLoc loc : empty) {
                           writer.println(world + "/region/r." + loc.x + "." + loc.z + ".mca");
                         }
                         writer.close();
                         Trim.sendMessage("File saved to 'plugins/PlotSquared/trim.txt'");
                       } catch (final FileNotFoundException e) {
                         e.printStackTrace();
                         Trim.sendMessage("File failed to save! :(");
                       }
                       Trim.sendMessage("How to get the chunk coords from a region file:");
                       Trim.sendMessage(
                           " - Locate the x,z values for the region file (the two numbers which are separated by a dot)");
                       Trim.sendMessage(
                           " - Multiply each number by 32; this gives you the starting position");
                       Trim.sendMessage(" - Add 31 to each number to get the end position");
                     }
                   });
           if (!result) {
             MainUtil.sendMessage(player, "Trim task already started!");
           }
           return result;
         }
       case "h":
       case "he":
       case "?":
       case "help":
         {
           MainUtil.sendMessage(
               player,
               "Possible sub commands: /plot debugexec <"
                   + StringMan.join(allowed_params, "|")
                   + ">");
           return false;
         }
       case "addcmd":
         {
           try {
             final String cmd =
                 StringMan.join(
                     Files.readLines(
                         new File(
                             new File(PS.get().IMP.getDirectory() + File.separator + "scripts"),
                             args[1]),
                         StandardCharsets.UTF_8),
                     System.getProperty("line.separator"));
             final Command<PlotPlayer> subcommand =
                 new Command<PlotPlayer>(args[1].split("\\.")[0]) {
                   @Override
                   public boolean onCommand(final PlotPlayer plr, final String[] args) {
                     try {
                       scope.put("PlotPlayer", plr);
                       scope.put("args", args);
                       engine.eval(cmd, scope);
                       return true;
                     } catch (final ScriptException e) {
                       e.printStackTrace();
                       MainUtil.sendMessage(player, C.COMMAND_WENT_WRONG);
                       return false;
                     }
                   }
                 };
             MainCommand.getInstance().addCommand(subcommand);
             return true;
           } catch (final Exception e) {
             e.printStackTrace();
             MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec addcmd <file>");
             return false;
           }
         }
       case "runasync":
         {
           async = true;
         }
       case "run":
         {
           try {
             script =
                 StringMan.join(
                     Files.readLines(
                         new File(
                             new File(PS.get().IMP.getDirectory() + File.separator + "scripts"),
                             args[1]),
                         StandardCharsets.UTF_8),
                     System.getProperty("line.separator"));
             if (args.length > 2) {
               final HashMap<String, String> replacements = new HashMap<>();
               for (int i = 2; i < args.length; i++) {
                 replacements.put("%s" + (i - 2), args[i]);
               }
               script = StringMan.replaceFromMap(script, replacements);
             }
           } catch (final IOException e) {
             e.printStackTrace();
             return false;
           }
           break;
         }
       default:
         {
           script = StringMan.join(args, " ");
         }
     }
     if (!ConsolePlayer.isConsole(player)) {
       MainUtil.sendMessage(player, C.NOT_CONSOLE);
       return false;
     }
     init();
     scope.put("PlotPlayer", player);
     PS.debug("> " + script);
     try {
       if (async) {
         final String toExec = script;
         TaskManager.runTaskAsync(
             new Runnable() {
               @Override
               public void run() {
                 final long start = System.currentTimeMillis();
                 Object result = null;
                 try {
                   result = engine.eval(toExec, scope);
                 } catch (final ScriptException e) {
                   e.printStackTrace();
                 }
                 PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
               }
             });
       } else {
         final long start = System.currentTimeMillis();
         Object result = engine.eval(script, scope);
         PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
       }
       return true;
     } catch (final ScriptException e) {
       e.printStackTrace();
       return false;
     }
   }
   return false;
 }