@Override
  public void onEnable() {

    saveDefaultConfig();
    if (getConfig().getBoolean("auto-update")) {
      new Updater(this, id, getFile(), Updater.UpdateType.DEFAULT, false);
    }
    try {
      MetricsLite metrics = new MetricsLite(this);
      metrics.start();
    } catch (IOException e) {
      getLogger().log(Level.WARNING, "Failed to submit stats to mcstats.org", e);
    }

    scoreboard = getServer().getScoreboardManager().getNewScoreboard();

    playerColors = new HashMap<UUID, ChatColor>(16);

    random = new Random();

    getServer().getPluginManager().registerEvents(this, this);

    for (Player player : getServer().getOnlinePlayers()) {
      colorPlayer(player);
    }
  }
示例#2
0
  @Override
  public void onEnable() {
    plugin = this;

    setupConfigs();
    try {
      if (!configuration.isDebugEnabled()) {
        disableDatabaseLogging();
      }

      if (!setupConnections()) {
        return;
      }

      setupStorages();
    } catch (SQLException e) {
      getLogger()
          .warning(
              "An error occurred attempting to make a database connection, please see stack trace below");
      plugin.getPluginLoader().disablePlugin(this);
      e.printStackTrace();
      return;
    }

    try {
      long timeDiff = DateUtils.findTimeDiff();

      if (timeDiff > 1) {
        getLogger()
            .severe(
                "The time on your server and MySQL database are out by "
                    + timeDiff
                    + " seconds, this may cause syncing issues.");
      }
    } catch (SQLException e) {
      getLogger()
          .warning(
              "An error occurred attempting to find the time difference, please see stack trace below");
      plugin.getPluginLoader().disablePlugin(this);
      e.printStackTrace();
    }

    if (conversionConn != null) {
      setupConversion();
    }

    setupListeners();
    setupCommands();
    setupRunnables();

    try {
      MetricsLite metrics = new MetricsLite(this);
      metrics.start();
    } catch (IOException e) {
      // Failed to submit the stats :-(
    }
  }
示例#3
0
  /* (non-Javadoc)
   * @see org.bukkit.plugin.java.JavaPlugin#onEnable()
   */
  @Override
  public void onEnable() {

    myPlugin = this;

    ByteCartAPI.setPlugin(this);

    this.saveDefaultConfig();

    this.loadConfig();

    this.setCam(new CollisionAvoiderManager());
    this.setWf(new BCWandererManager());
    this.setIt(new IsTrainManager());

    getServer().getPluginManager().registerEvents(new ByteCartListener(), this);

    // register updater factory
    if (!this.getWandererManager().isWandererType("Updater"))
      this.getWandererManager().register(new UpdaterFactory(), "Updater");

    getCommand("mego").setExecutor(new BytecartCommandExecutor());
    getCommand("sendto").setExecutor(new BytecartCommandExecutor());
    getCommand("bcreload").setExecutor(new BytecartCommandExecutor());
    getCommand("bcupdater").setExecutor(new BytecartCommandExecutor());
    getCommand("bcticket").setExecutor(new BytecartCommandExecutor());
    getCommand("bcback").setExecutor(new BytecartCommandExecutor());
    getCommand("bcdmapsync").setExecutor(new BytecartCommandExecutor());

    if (Bukkit.getPluginManager().isPluginEnabled("dynmap")) {
      log.info("[ByteCart] loading dynmap plugin.");
      getServer().getPluginManager().registerEvents(new BCDynmapPlugin(), this);
    }

    if (this.getConfig().getBoolean("metrics", true)) {
      try {
        MetricsLite metrics = new MetricsLite(this);
        metrics.start();
        log.info("[ByteCart] Submitting stats to MCStats.");
      } catch (IOException e) {
        // Failed to submit the stats :-(
      }
    }

    if (this.getConfig().getBoolean("hostname_resolution", true)) {
      hostnamePlugin = new BCHostnameResolutionPlugin();
      hostnamePlugin.onLoad();
      ByteCartAPI.setResolver(hostnamePlugin);
      getServer().getPluginManager().registerEvents(hostnamePlugin, this);
      getCommand("host").setExecutor(hostnamePlugin);
    }

    log.info("[ByteCart] plugin has been enabled.");
  }
示例#4
0
  @SuppressWarnings("unused")
  public void onEnable() {
    plugin = this;
    ConfigManager.registerConfig("config", "config.yml", this);
    ConfigManager.registerConfig("stone", "stoniarki.yml", this);
    ConfigUtils.prepareConfig();
    Logs.prepareLogFile();

    try {
      Log.info(prx + " Uruchamianie Metrics! (mcstats.org)");
      MetricsLite metrics = new MetricsLite(this);
      metrics.start();
    } catch (IOException e) {
      Log.info(prx + " Nie mozna bylo uruchomic MetricsLite!");
      Log.info(e.getStackTrace().toString());
    }

    getCommand("stoniarkibynorthpl").setExecutor(new Commands(this));
    getServer().addRecipe(CraftingRegister.recepta_na_stoniarke_by_northpl);
    BukkitTask task = new StoniarkiTask(this).runTaskTimerAsynchronously(Main.plugin, 5, 5);
    Logs.Log("Plugin Stoniarki v" + v + " by NorthPL uruchomiony! :)");
  }