public static void updateSensors(MMMinecart minecart, MMMinecart input) {

    HashSet<Block> blockList = minecart.getAdjacentBlocks(1);
    blockList.addAll(minecart.getBlocksBeneath(3));
    HashSet<Block> oldBlockList = minecart.getPreviousLocationAdjacentBlocks(1);
    oldBlockList.addAll(minecart.getPreviousLocationBlocksBeneath(3));
    oldBlockList.removeAll(blockList);

    // Activate new sensors
    for (Block block : blockList) {
      Sensor s = SensorManager.getSensor(block);
      if (s != null) {
        try {
          s.input(input);
        } catch (Exception e) {
          SensorManager.delSensor(s.getLocation());
        }
      }
    }

    // deactivate old sensors
    for (Block block : oldBlockList) {
      Sensor s = SensorManager.getSensor(block);
      if (s != null) {
        try {
          s.input(null);
        } catch (Exception e) {
          SensorManager.delSensor(s.getLocation());
        }
      }
    }
  }
  private void tryLoadOldSensors() {

    java.io.File f = null;

    for (File fi : this.getDataFolder().listFiles()) {
      if (fi.getName().toLowerCase().contains("minecartmaniarebornsigncommands.db")) {
        f = fi;
        break;
      }
    }

    if (f == null) {
      return;
    }

    Logger.debug("Found old sensor DB. Attempting load...");

    com.avaje.ebean.config.DataSourceConfig dsc = new com.avaje.ebean.config.DataSourceConfig();
    dsc.setUsername("temp");
    dsc.setPassword("temp");
    dsc.setDriver("org.sqlite.JDBC");
    dsc.setIsolationLevel(8);

    dsc.setUrl("jdbc:sqlite:plugins/minecartmania/minecartmaniarebornsigncommands.db");

    ServerConfig config = new ServerConfig();
    config.setDataSourceConfig(dsc);
    config.setName("Old DB");
    config.addClass(com.afforess.minecartmaniasigncommands.sensor.SensorDataTable.class);
    config.addJar("MinecartMania.jar");
    SensorManager.database = com.avaje.ebean.EbeanServerFactory.create(config);

    SensorManager.loadsensors();

    if (SensorManager.getCount() > 0) {
      Logger.severe("Found sensors in old db, moving...");
      // loaded old sensors
      for (Sensor s : SensorManager.getSensorList().values()) {
        SensorManager.saveSensor(s);
      }
      Logger.severe("Complete. Removing old db.");
    }

    SensorManager.database = this.getDatabase();

    f.delete();
  }
  public void onEnable() {
    instance = this;
    file = this.getFile();

    writeItemsFile();

    //	MinecartManiaConfigurationParser.read("MinecartManiaConfiguration.xml", dataDirectory, new
    // CoreSettingParser());
    //	MinecartManiaConfigurationParser.read("MinecartManiaLocale.xml", getDataFolder(), new
    // LocaleParser());
    // MinecartManiaConfigurationParser.read(this.getDescription().getName().replace("Reborn", "") +
    // "Configuration.xml", MinecartManiaCore.getDataDirectoryRelativePath(), new
    // AdminControlsSettingParser());
    // MinecartManiaConfigurationParser.read(this.getDescription().getName().replace("Reborn", "") +
    // "Configuration.xml", MinecartManiaCore.getDataDirectoryRelativePath(), new
    // SignCommandsSettingParser());
    //	MinecartManiaConfigurationParser.read(this.getDescription().getName().replace("Reborn", "") +
    // "Configuration.xml", MinecartManiaCore.getDataDirectoryRelativePath(), new
    // ChestControlSettingParser());

    permissions = new PermissionManager(getServer());

    getServer().getPluginManager().registerEvents(new CoreListener(), this);
    getServer().getPluginManager().registerEvents(new ChunkListener(), this);
    getServer().getPluginManager().registerEvents(new BlockListener(), this);
    getServer().getPluginManager().registerEvents(new PlayerListener(), this);
    getServer().getPluginManager().registerEvents(new MinecartTimer(), this);

    // TODO - don't use these anymore
    getServer().getPluginManager().registerEvents(new SignsActionListener(), this);
    getServer().getPluginManager().registerEvents(new StationsActionListener(), this);
    getServer().getPluginManager().registerEvents(new FarmingActionListener(), this);
    getServer().getPluginManager().registerEvents(new ChestActionListener(), this);

    reloadMyConfig();

    // database setup
    File ebeans =
        new File(new File(this.getDataFolder().getParent()).getParent(), "ebean.properties");
    if (!ebeans.exists()) {
      try {
        ebeans.createNewFile();
        PrintWriter pw = new PrintWriter(ebeans);
        pw.append("# General logging level: (none, explicit, all)");
        pw.append('\n');
        pw.append("ebean.logging=none");
        pw.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    setupDatabase();

    // tryLoadOldSensors();

    SensorManager.loadsensors();

    if (Settings.PreserveMinecartsonRiderLogout) LoadCartsForRiders();

    //		StringBuilder sb = new StringBuilder();
    //		Logger.debug("Sign Permissions:");
    //		for(ActionList sa : com.afforess.minecartmania.signs.ActionList.values()){
    //			sb.append("           minecartmania.signs.create." + sa.getInstance().getPermissionName() +
    // ": true\n");
    //		}
    //
    //		for(ActionList sa : com.afforess.minecartmania.signs.ActionList.values()){
    //			sb.append("    minecartmania.signs.create." + sa.getInstance().getPermissionName() +
    // ":\n");
    //			sb.append("        description: " + sa.getInstance().getFriendlyName() + "\n");
    //			sb.append("        default: true\n");
    //		}
    //
    //		sb.append("|=Sign Type|=Permission");
    //		for(ActionList sa : com.afforess.minecartmania.signs.ActionList.values()){
    //			sb.append("|" + sa.getInstance().getFriendlyName() + "|minecartmania.signs.create." +
    // sa.getInstance().getPermissionName() + "\n");
    //
    //		}
    //
    //		File f = new File("plugins" + File.separator + "MinecartMania" + File.separator +
    // "signperms.txt");
    //		PrintWriter pw;
    //
    //		try {
    //			pw = new PrintWriter(f);
    //			pw.append(sb.toString());
    //			pw.close();
    //		} catch (FileNotFoundException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		}

    Logger.info(
        this.getDescription().getName()
            + " version "
            + this.getDescription().getVersion()
            + " is enabled!");
  }