예제 #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();
   }
 }
예제 #3
0
  /**
   * Creates a new server on TCP port 25565 and starts listening for connections.
   *
   * @param args The command-line arguments.
   */
  public static void main(String[] args) {
    try {
      ConfigurationSerialization.registerClass(GlowOfflinePlayer.class);
      GlowPotionEffect.register();

      // parse arguments and read config
      final ServerConfig config = parseArguments(args);
      if (config == null) {
        return;
      }

      // start server
      final GlowServer server = new GlowServer(config);
      server.start();
      server.bind();
      server.bindQuery();
      server.bindRcon();
      logger.info("Ready for connections.");
    } catch (Throwable t) {
      logger.log(Level.SEVERE, "Error during server startup.", t);
      System.exit(1);
    }
  }