Пример #1
0
 public synchronized void start() throws Exception {
   final long start = System.currentTimeMillis();
   taskID = logblock.getServer().getScheduler().scheduleSyncRepeatingTask(logblock, this, 0, 1);
   if (taskID == -1) throw new Exception("Failed to schedule task");
   try {
     wait();
   } catch (final InterruptedException ex) {
     throw new Exception("Interrupted");
   }
   elapsedTime = System.currentTimeMillis() - start;
 }
Пример #2
0
 @SuppressWarnings("incomplete-switch")
 @Override
 public synchronized void run() {
   final List<WorldEditorException> errorList = new ArrayList<WorldEditorException>();
   int counter = 0;
   while (!edits.isEmpty() && counter < 100) {
     try {
       switch (edits.poll().perform()) {
         case SUCCESS:
           successes++;
           break;
         case BLACKLISTED:
           blacklistCollisions++;
           break;
       }
     } catch (final WorldEditorException ex) {
       errorList.add(ex);
     } catch (final Exception ex) {
       getLogger().log(Level.WARNING, "[LogBlock WorldEditor] Exeption: ", ex);
     }
     counter++;
   }
   if (edits.isEmpty()) {
     logblock.getServer().getScheduler().cancelTask(taskID);
     if (errorList.size() > 0)
       try {
         final File file =
             new File(
                 "plugins/LogBlock/error/WorldEditor-"
                     + new SimpleDateFormat("yy-MM-dd-HH-mm-ss").format(System.currentTimeMillis())
                     + ".log");
         file.getParentFile().mkdirs();
         final PrintWriter writer = new PrintWriter(file);
         for (final LookupCacheElement err : errorList) writer.println(err.getMessage());
         writer.close();
       } catch (final Exception ex) {
       }
     errors = errorList.toArray(new WorldEditorException[errorList.size()]);
     notify();
   }
 }