Exemplo n.º 1
0
  /**
   * Register a array of mechanics if possible
   *
   * @param factories
   */
  @SuppressWarnings("unused")
  private void registerMechanic(MechanicFactory<? extends Mechanic>[] factories) {

    for (MechanicFactory<? extends Mechanic> aFactory : factories) {
      registerMechanic(aFactory);
    }
  }
Exemplo n.º 2
0
  @Override
  public void onEnable() {

    super.onEnable();

    // Register command classes
    registerCommand(MechanismCommands.class);

    createDefaultConfiguration("books.txt", false);
    createDefaultConfiguration("cauldron-recipes.txt", false);
    createDefaultConfiguration("config.yml", false);
    createDefaultConfiguration("custom-mob-drops.txt", false);
    createDefaultConfiguration("custom-block-drops.txt", false);
    createDefaultConfiguration("recipes.txt", false);
    createDefaultConfiguration("cauldron-recipes.yml", false);
    createDefaultConfiguration("crafting-recipes.yml", false);

    config = new MechanismsConfiguration(getConfig(), getDataFolder());
    saveConfig();

    languageManager = new LanguageManager(this);

    if (getServer().getPluginManager().isPluginEnabled("Vault")) setupEconomy();

    manager = new MechanicManager(this);
    MechanicListenerAdapter adapter = new MechanicListenerAdapter(this);
    adapter.register(manager);

    // Let's register mechanics!
    if (getLocalConfiguration().ammeterSettings.enable) registerMechanic(new Ammeter.Factory(this));
    if (getLocalConfiguration().bookcaseSettings.enable)
      registerMechanic(new Bookcase.Factory(this));
    if (getLocalConfiguration().gateSettings.enable) registerMechanic(new Gate.Factory(this));
    if (getLocalConfiguration().bridgeSettings.enable) registerMechanic(new Bridge.Factory(this));
    if (getLocalConfiguration().doorSettings.enable) registerMechanic(new Door.Factory(this));
    if (getLocalConfiguration().elevatorSettings.enable)
      registerMechanic(new Elevator.Factory(this));
    if (getLocalConfiguration().teleporterSettings.enable)
      registerMechanic(new Teleporter.Factory(this));
    if (getLocalConfiguration().areaSettings.enable) registerMechanic(new Area.Factory(this));
    if (getLocalConfiguration().commandSettings.enable) registerMechanic(new Command.Factory(this));
    if (getLocalConfiguration().anchorSettings.enable)
      registerMechanic(new ChunkAnchor.Factory(this));
    if (getLocalConfiguration().lightStoneSettings.enable)
      registerMechanic(new LightStone.Factory(this));
    if (getLocalConfiguration().lightSwitchSettings.enable)
      registerMechanic(new LightSwitch.Factory(this));
    if (getLocalConfiguration().hiddenSwitchSettings.enable)
      registerMechanic(new HiddenSwitch.Factory(this));
    if (getLocalConfiguration().cookingPotSettings.enable)
      registerMechanic(new CookingPot.Factory(this));
    if (getLocalConfiguration().cauldronSettings.enable)
      registerMechanic(new Cauldron.Factory(this));
    if (getLocalConfiguration().cauldronSettings.enableNew)
      registerMechanic(new ImprovedCauldron.Factory(this));
    if (getLocalConfiguration().customCraftingSettings.enable) new CustomCrafting(this);

    // Special mechanics.
    if (economy != null) registerMechanic(new Payment.Factory(this));

    setupSelfTriggered(manager);

    // Register events
    registerEvents();
  }