Exemplo n.º 1
0
  public Cyborg() {
    if (instance != null) {
      throw new IllegalAccessError("There is already an instance of Cyborg!");
    }
    pluginManager = new CommonPluginManager(this);
    pluginManager.registerPluginLoader(CommonPluginLoader.class);
    eventManager = new SimpleEventManager();
    commandManager = new CommonCommandManager();

    // Register Internal Listeners
    bot.getListenerManager().addListener(new PircBotXListener());
    eventManager.registerEvents(new CommandListener(), this);
    eventManager.registerEvents(new InternalListener(), this);

    // Setup Bot \\
    bot.setVerbose(StartupArguments.getInstance().isVerbose());
    bot.setName(Settings.getNick());
    bot.setLogin(Settings.getIdent());
    setMessageDelay(Settings.getMessageDelay());

    // Register Default Commands \\
    commandManager.registerCommands(
        new Named() {
          @Override
          public String getName() {
            return Cyborg.class.getCanonicalName();
          }
        },
        TerminalCommands.class,
        new EmptyConstructorInjector());

    instance = this;
  }
Exemplo n.º 2
0
  public void shutdown() {
    try {
      bot.disconnect();
    } catch (Exception ignore) {

    }
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    bot.dispose();
    pluginManager.disablePlugins();
    System.exit(0);
  }
Exemplo n.º 3
0
  public void shutdown(String reason) {
    try {
      bot.quitServer(reason);
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    } catch (Exception ignored) {

    }
    bot.dispose();
    pluginManager.disablePlugins();
    Main.getTerminalThread().interrupt();
    try {
      Thread.sleep(500);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    System.exit(0);
  }
Exemplo n.º 4
0
 protected final void enablePlugins() {
   for (Plugin plugin : pluginManager.getPlugins()) {
     pluginManager.enablePlugin(plugin);
   }
 }
Exemplo n.º 5
0
 protected final void loadPlugins() {
   if (!pluginDir.exists()) {
     pluginDir.mkdirs();
   }
   pluginManager.loadPlugins(pluginDir);
 }