Пример #1
0
  public void onEnable() {

    if (getServer().getPluginManager().getPlugin("Citizens") == null
        || getServer().getPluginManager().getPlugin("Citizens").isEnabled() == false) {
      getLogger().log(java.util.logging.Level.SEVERE, "Citizens 2.0 not found or not enabled");
      getServer().getPluginManager().disablePlugin(this);
      return;
    }

    if (getServer().getPluginManager().getPlugin("dynmap") == null
        || getServer().getPluginManager().getPlugin("dynmap").isEnabled() == false) {
      getLogger().log(java.util.logging.Level.SEVERE, "dynmap not found or not enabled");
      getServer().getPluginManager().disablePlugin(this);
    }

    if (getServer().getPluginManager().getPlugin("HyperConomy") == null) {
      getLogger().log(java.util.logging.Level.SEVERE, "Hyperconomoy Not found");
      bHyperConomyExists = false;
    } else {
      for (Plugin oPlug : getServer().getPluginManager().getPlugins()) {
        getLogger().log(java.util.logging.Level.SEVERE, "plugin:" + oPlug.getName());
      }

      if (getServer().getPluginManager().getPlugin("HyperMerchant") == null) {
        getLogger().log(java.util.logging.Level.SEVERE, "HyperMerchant Not found");
        bHyperConomyExists = false;
      } else {
        getLogger()
            .log(java.util.logging.Level.SEVERE, "Hyperconomy / Hypermerchant found. Enabled");
        bHyperConomyExists = true;
      }
    }

    SetupConfig();

    getLogger().log(java.util.logging.Level.INFO, "Connecting to DynMap");

    try {
      SetupDynMap();
    } catch (Exception err) {
      getLogger().log(java.util.logging.Level.INFO, "Errors while connecting to the Dynmap API");
      getServer().getPluginManager().disablePlugin(this);
      cDyn_Plugin = null;
      cDyn_MarkAPI = null;
      cDyn_Markers = null;
      return;
    }

    // Setup the Citizens NPC link
    net.citizensnpcs.api.CitizensAPI.getTraitFactory()
        .registerTrait(
            net.citizensnpcs.api.trait.TraitInfo.create(DynMapNPC_Trait.class)
                .withName("dynmapnpc"));

    // Schedule the main thread to monitor for NPCs
    cProcessing_Task =
        new DynMapNPC_Task(this)
            .runTaskTimer(
                this,
                this.getConfig().getLong("interval", 100L),
                this.getConfig().getLong("interval", 100L));

    if (this.getConfig().getBoolean("mcstats", true)) {
      try {
        MCStatsMetrics metrics = new MCStatsMetrics(this);
        metrics.start();
      } catch (Exception e) {
        // Failed to submit the stats :-(
      }
    }
  }
Пример #2
0
 public void onEnable() {
   Bukkit.broadcastMessage("RELOADING TEST FIVE");
   pl = this;
   MySQL = new MySQL((Plugin) this, "localhost", "3306", "RPG", "root", "enter11284");
   MySQL.openConnection();
   connect =
       new BukkitRunnable() {
         public void run() {
           if (!MySQL.checkConnection()) {
             BlackLance.openConnect();
           }
         }
       }.runTaskTimer(this, 20, 60);
   c = MySQL.getConnection();
   try {
     RPGPlayer.createRPGPlayers();
   } catch (SQLException e) {
     e.printStackTrace();
   }
   try {
     ResourceNodes.generateHay();
     ResourceNodes.generateSweetGum();
   } catch (SQLException e) {
     e.printStackTrace();
   }
   File configFile = new File(this.getDataFolder(), "config.yml");
   PluginManager pm = getServer().getPluginManager();
   pm.registerEvents(new CombatListeners(this), this);
   pm.registerEvents(new Horses(), this);
   pm.registerEvents(new PlayerListeners(this, configFile), this);
   pm.registerEvents(new ExperienceListeners(), this);
   pm.registerEvents(new ObjectiveProcessor(this), this);
   pm.registerEvents(new DropListeners(this), this);
   pm.registerEvents(new NPCListeners(this), this);
   pm.registerEvents(new SmeltingListeners(), this);
   pm.registerEvents(new SmithingListeners(), this);
   pm.registerEvents(new HerbloreListeners(), this);
   pm.registerEvents(new BlockListeners(this), this);
   pm.registerEvents(new MenuListeners(this), this);
   pm.registerEvents(new ItemListeners(this), this);
   pm.registerEvents(new ConsumableListener(this), this);
   pm.registerEvents(new TradeListener(), this);
   pm.registerEvents(new Alchemy.MenuListeners(), this);
   getCommand("horse").setExecutor(new CommandParser());
   getCommand("setup").setExecutor(new CommandParser());
   getCommand("blevel").setExecutor(new CommandParser());
   getCommand("blreload").setExecutor(new CommandParser());
   getCommand("lookup").setExecutor(new CommandParser());
   getCommand("resource").setExecutor(new CommandParser());
   net.citizensnpcs.api.CitizensAPI.getTraitFactory()
       .registerTrait(net.citizensnpcs.api.trait.TraitInfo.create(blm.class).withName("blm"));
   HashMap<Location, Material> toRegen = Mine.getRegen();
   Iterable<Location> locar = toRegen.keySet();
   for (locar.iterator(); locar.iterator().hasNext(); ) {
     Location l1 = locar.iterator().next();
     Bukkit.broadcastMessage("Loc: " + l1.getX());
     l1.getBlock().setType(toRegen.get(l1));
   }
   if (!configFile.exists()) {
     this.saveDefaultConfig();
   }
 }