コード例 #1
0
  // 起動処理
  public void onEnable() {
    // mcstats
    try {
      Metrics metrics = new Metrics(this);
      metrics.start();
    } catch (IOException e) {
      this.getLogger().info(ChatColor.RED + "Failed to submit the stats");
      // Failed to submit the stats
    }

    this.getServer().getPluginManager().registerEvents(new RainBreakBlock(this), this);
  }
コード例 #2
0
  @Override
  public void onEnable() {

    // mcstats
    try {
      Metrics metrics = new Metrics(this);
      metrics.start();
    } catch (IOException e) {
      this.getLogger().info(ChatColor.RED + "Failed to submit the stats");
      // Failed to submit the stats
    }

    // config
    if (!new File(this.getDataFolder().getAbsolutePath() + "/config.yml").exists()) {
      getLogger().info("creating config.yml file...");
      this.saveDefaultConfig();
    }

    // read save data
    Scanner sc = null;

    try {
      sc = new Scanner(new File(matching_path));
    } catch (FileNotFoundException e) {
      return;
    }

    if (sc != null) {
      while (sc.hasNextLine()) {
        String str = sc.nextLine();

        // ignore comment line
        if (str.toCharArray()[0] == '#') {
          continue;
        }

        String data[] = str.split(",");

        UUID uuid = UUID.fromString(data[1]);
        String name = data[0];

        this.matching_map.put(uuid, name);
      }

      sc.close();
    }

    // register listener
    this.getServer().getPluginManager().registerEvents(this, this);
  }
コード例 #3
0
ファイル: PwnFilter.java プロジェクト: riking/PwnFilter3
  public void activateMetrics() {
    // Activate Plugin Metrics
    try {
      Metrics metrics = new Metrics(this);

      metrics.addCustomData(
          new Metrics.Plotter("Total Number of Server Rules") {
            @Override
            public int getValue() {
              return ruleset.ruleCount();
            }
          });

      Metrics.Graph graph = metrics.createGraph("Rules by Event");

      for (final EventType r : EventType.values()) {
        graph.addPlotter(
            new Metrics.Plotter(r.toString()) {
              @Override
              public int getValue() {
                return ruleset.ruleCount(r); // Number of rules for this event type
              }
            });
      }

      Metrics.Graph matchGraph = metrics.createGraph("Matches");
      matchTracker = new Tracker("Matches");

      matchGraph.addPlotter(matchTracker);

      metrics.start();

    } catch (IOException e) {
      logger.fine(e.getMessage());
    }
  }
コード例 #4
0
 public void onEnable() {
   mines = new ArrayList<Mine>();
   logger = getLogger();
   if (!setupConfig()) {
     logger.severe("Since I couldn't setup config files properly, I guess this is goodbye. ");
     logger.severe("Plugin Loading Aborted!");
     return;
   }
   commandManager = new CommandManager();
   commandManager.register(MineCommands.class, new MineCommands(this));
   commandManager.register(CommandManager.class, commandManager);
   commandManager.register(PluginCommands.class, new PluginCommands(this));
   Locale locale = Locale.ENGLISH;
   Phrases.getInstance().initialize(locale);
   // Look for worldedit
   if (getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
     worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
   }
   // Metrics
   try {
     metrics = new Metrics(this);
     metrics.start();
   } catch (IOException e) {
     logger.warning("MineResetLite couldn't initialize metrics!");
     e.printStackTrace();
   }
   // Load mines
   File[] mineFiles = new File(getDataFolder(), "mines").listFiles(new IsMineFile());
   for (File file : mineFiles) {
     FileConfiguration fileConf = YamlConfiguration.loadConfiguration(file);
     try {
       Object o = fileConf.get("mine");
       if (!(o instanceof Mine)) {
         logger.severe("Mine wasn't a mine object! Something is off with serialization!");
         continue;
       }
       Mine mine = (Mine) o;
       mines.add(mine);
     } catch (Throwable t) {
       logger.severe("Unable to load mine!");
     }
   }
   resetTaskId =
       getServer()
           .getScheduler()
           .scheduleSyncRepeatingTask(
               this,
               new Runnable() {
                 public void run() {
                   for (Mine mine : mines) {
                     mine.cron();
                   }
                 }
               },
               60 * 20L,
               60 * 20L);
   // Check for updates
   if (!getDescription().getVersion().contains("dev")) {
     updateTaskId =
         getServer()
             .getScheduler()
             .scheduleAsyncDelayedTask(
                 this,
                 new Runnable() {
                   public void run() {
                     checkUpdates();
                   }
                 },
                 20 * 15);
   }
   getServer().getPluginManager().registerEvents(new UpdateWarner(), this);
   logger.info("MineResetLite version " + getDescription().getVersion() + " enabled!");
 }
コード例 #5
0
  public void run(String[] args) {

    // Need to initialize config before console
    try {
      config = new ServerConfig();
    } catch (IOException ex) {
      logger.severe("Failed to load configuration file!");
      ex.printStackTrace();
      return;
    }

    // Initialize console
    console = new ConsoleManager(this);
    console.startConsole();

    checkArguments(args);

    if (config.getConfig().getProperty("log_console").toLowerCase().contains("true")) {
      console.startFile("console.log");
      logger.info("Saving console output enabled"); // TODO: Translations
    } else {
      logger.info("Saving console output disabled");
    }

    try {
      lang = new Lang(config.getConfig().getProperty(ServerConfig.LANG_FILE));
    } catch (IOException ex) {
      logger.severe("Failed to load language file!");
      ex.printStackTrace();
      return;
    }
    logger.info(lang.get(Lang.INIT_LOADING, Versioning.RELEASE_VERSION));
    logger.info(lang.get(Lang.INIT_MC_PC_SUPPORT, Versioning.MINECRAFT_PC_VERSION));
    logger.info(lang.get(Lang.INIT_MC_PE_SUPPORT, Versioning.MINECRAFT_PE_VERSION));
    authMode = config.getConfig().getProperty("mode").toLowerCase();
    if (!authMode.equals("cls") && !authMode.equals("online") && !authMode.equals("offline")) {
      logger.severe(
          "Invalid 'mode' option detected, must be cls/online/offline, you set it to '"
              + authMode
              + "'! ");
      return;
    }
    remoteServerAddress =
        new InetSocketAddress(
            config.getConfig().getProperty("remote_ip"),
            Integer.parseInt(config.getConfig().getProperty("remote_port")));
    sessionRegister = new SessionRegister(this);
    commandRegister = new CommandRegister(this);
    if (IS_RELEASE) {
      try {
        metrics = new ServerMetrics(this);
        metrics.start();
      } catch (IOException ex) {
      }
    } else {
      logger.info("\n-----------------------------");
      logger.info(" This is a DEVELOPMENT build ");
      logger.info("     It may contain bugs     ");
      logger.info("-----------------------------\n");
    }

    // Create thread pool
    logger.info(
        lang.get(
            Lang.INIT_CREATING_THREAD_POOL,
            Integer.parseInt(config.getConfig().getProperty("thread_pool_size"))));
    generalThreadPool =
        Executors.newScheduledThreadPool(
            Integer.parseInt(config.getConfig().getProperty("thread_pool_size")));

    // Bind
    logger.info(
        lang.get(
            Lang.INIT_BINDING,
            config.getConfig().getProperty("udp_bind_ip"),
            config.getConfig().getProperty("udp_bind_port")));
    network =
        new RaknetInterface(
            this,
            config.getConfig().getProperty("udp_bind_ip"), // IP
            Integer.parseInt(config.getConfig().getProperty("udp_bind_port"))); // Port

    // MOTD
    motd = config.getConfig().getProperty("motd");
    motd = motd.replace("&", "§");
    motd = motd.replace("%ip%", remoteServerAddress.getHostString());
    motd = motd.replace("%port%", remoteServerAddress.getPort() + "");

    network.setBroadcastName(motd, -1, -1);
    ticker.start();
    logger.info(lang.get(Lang.INIT_DONE));

    // Ping the PC server to show the players online
    pingPCServer();
  }