Exemplo n.º 1
0
  private static void initializePlugin(
      String name, Plugin plugin) { // Really messy, right? But it's short and fast :)
    Dependency dependency;

    try {
      dependency = Dependency.valueOf(name);
    } catch (IllegalArgumentException exception) {
      return;
    }

    Listener listener = null;

    switch (dependency) {
        // Protection plugins
      case LWC:
        listener = new LightweightChestProtection();
        break;
      case Lockette:
        listener = new Lockette();
        break;
      case Deadbolt:
        listener = new Deadbolt();
        break;
      case SimpleChestLock:
        listener = SimpleChestLock.getSimpleChestLock(plugin);
        break;
      case Residence:
        listener = new ResidenceChestProtection();
        break;

        // Terrain protection plugins
      case Towny:
        Towny towny = Towny.getTowny();

        if (towny == null || !Properties.TOWNY_INTEGRATION) {
          return;
        }

        listener = towny;

        break;
      case WorldGuard:
        WorldGuardPlugin worldGuard = (WorldGuardPlugin) plugin;
        boolean inUse = Properties.WORLDGUARD_USE_PROTECTION || Properties.WORLDGUARD_INTEGRATION;

        if (!inUse) {
          return;
        }

        if (Properties.WORLDGUARD_USE_PROTECTION) {
          ChestShop.registerListener(new WorldGuardProtection(worldGuard));
        }

        if (Properties.WORLDGUARD_INTEGRATION) {
          listener = new WorldGuardBuilding(worldGuard);
        }

        break;

        // Other plugins
      case Heroes:
        Heroes heroes = Heroes.getHeroes(plugin);

        if (heroes == null) {
          return;
        }

        listener = heroes;
        break;
      case OddItem:
        MaterialUtil.Odd.initialize();
        break;
    }

    if (listener != null) {
      ChestShop.registerListener(listener);
    }

    PluginDescriptionFile description = plugin.getDescription();
    ChestShop.getBukkitLogger()
        .info(description.getName() + " version " + description.getVersion() + " loaded.");
  }