Ejemplo n.º 1
0
  public void reload() {

    logger.log(Level.INFO, "Reloading all files.");
    logger.log(Level.INFO, "WE RECOMMEND NOT TO DO THIS BECAUSE IT MIGHT CAUSE SERIUOS PROBLEMS!");
    logger.log(Level.INFO, "SIMPLY RESTART YOUR SERVER INSTEAD; THAT'S MUCH SAFER!");

    // Config
    configHandler.loadConfig();
    if (config.getString("File.Version") == null) {
      logger.log(Level.SEVERE, "Could not initialize config! Disabling the plugin!");
      this.getPluginLoader().disablePlugin(this);
      return;
    } else logger.info("Config loaded successfully.");

    // Messages-file
    messagesHandler.loadMessages();
    if (messages == null) return;

    // StationsDB
    dbStationsHandler.init();

    // HomesDB
    dbHomesHandler.init();

    // StationsDB
    dbFlightsHandler.init();

    logger.log(Level.INFO, "Successfully reloaded all files.");
  }
Ejemplo n.º 2
0
  @Override
  public void onEnable() {

    pm = getServer().getPluginManager();
    PluginDescriptionFile description = getDescription();
    plugin = this;

    // Add the new entity to Minecraft's (Craftbukkit's) entities
    // Returns false if plugin disabled
    if (!registerEntity()) return;

    pm.registerEvents(new EntityListener(this), this);
    pm.registerEvents(new PlayerListener(this), this);
    pm.registerEvents(new FlightEditor(), this);
    pm.registerEvents(new BlockListener(this), this);

    if (!(new File(plugin.getDataFolder(), "databases").exists()))
      new File(plugin.getDataFolder(), "databases").mkdirs();

    // Config
    configHandler = new Config(this);
    configHandler.loadConfig();
    if (config.getString("File.Version") == null) {
      logger.log(Level.SEVERE, "Could not initialize config! Disabling the plugin!");
      this.getPluginLoader().disablePlugin(this);
      return;
    } else logger.info("Config loaded successfully.");

    // Messages-file
    messagesHandler = new Messages(this);
    messagesHandler.loadMessages();
    if (messages == null) return;

    // StationsDB
    dbStationsHandler = new StationsDB(this);
    dbStationsHandler.init();

    // HomesDB
    dbHomesHandler = new HomesDB(this);
    dbHomesHandler.init();

    // StationsDB
    dbFlightsHandler = new FlightsDB(this);
    dbFlightsHandler.init();

    // Commands
    getCommand("dt").setExecutor(new CommandHandler(this));

    // AntiCheat
    if (AntiCheatHandler.getAntiCheat()) logger.info("[DragonTravel] AntiCheat-support enabled");

    // NoCheatPlus
    if (NoCheatPlusHandler.getNoCheatPlus())
      logger.info("[DragonTravel] NoCheatPlus-support enabled");

    // Load some variables from config
    onlydragontraveldragons = config.getBoolean("AntiGriefDragons.ofDragonTravel");
    alldragons = config.getBoolean("AntiGriefDragons.all");
    ignoreAntiMobspawnAreas = config.getBoolean("AntiGriefDragons.bypassWorldGuardAntiSpawn");

    requiredItem = Material.getMaterial(config.getString("RequiredItem.Item"));
    requireItemTravelStation = config.getBoolean("RequiredItem.For.toStation");
    requireItemTravelRandom = config.getBoolean("RequiredItem.For.toRandom");
    requireItemTravelCoordinates = config.getBoolean("RequiredItem.For.toCoordinates");
    requireItemTravelPlayer = config.getBoolean("RequiredItem.For.toPlayer");
    requireItemTravelHome = config.getBoolean("RequiredItem.For.toHome");
    requireItemTravelFactionhome = config.getBoolean("RequiredItem.For.toFactionhome");
    requireItemFlight = config.getBoolean("RequiredItem.For.Flight");

    speed = config.getDouble("DragonSpeed");

    usePayment = config.getBoolean("Payment.usePayment");
    byEconomy = config.getBoolean("Payment.byEconomy");
    byResources = config.getBoolean("Payment.byResources");

    paymentItem = config.getInt("Payment.Resources.Item");

    dragonLimit = config.getInt("DragonLimit");

    onlysigns = config.getBoolean("OnlySigns");

    ptoggleDefault = config.getBoolean("PToggleDefault");

    if (usePayment) {

      if (!byEconomy && !byResources) {
        logger.log(
            Level.SEVERE,
            "[DragonTravel] Payment has been enabled, but both payment-types are disabled, how should a player be able to pay?! Disabling payment...");
        usePayment = false;
      }

      if (byEconomy && byResources) {
        logger.log(
            Level.SEVERE,
            "[DragonTravel] Payment has been set to Economy AND Resources, but you can only use one type of payment! Disabling payment...");
        usePayment = false;
      }

      // Set up Economy (if config-option is set to true)
      if (byEconomy) {
        Plugin x = pm.getPlugin("Vault");
        if (x != null & x instanceof Vault) {
          logger.info(
              String.format("[DragonTravel] Hooked into Vault, using it for economy-support"));
          logger.info(String.format("[DragonTravel] Enabled %s", description.getVersion()));
          new PaymentHandler(this.getServer()).setupEconomy();
        } else {
          logger.log(Level.SEVERE, "[DragonTravel] \"Vault\" was not found,");
          logger.log(Level.SEVERE, "[DragonTravel] disabling economy-support!");
          logger.log(Level.SEVERE, "[DragonTravel] Turn off \"Payment.byEconomy\"");
          logger.log(Level.SEVERE, "[DragonTravel] in the config.yml or install Vault!");
        }
      }
    }

    // MoutingScheduler
    Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new MountingScheduler(), 60L, 30L);
  }