Exemple #1
0
  /** Load the configuration file */
  protected final void loadConfig() {
    debug = this.getConfig().getBoolean("debug", false);
    keepitems = this.getConfig().getBoolean("keepitems", true);

    Lockduration = this.getConfig().getInt("Lockduration", 44);

    if (debug) {
      log.info("ByteCart : debug mode is on.");
    }

    if (this.getConfig().getBoolean("loadchunks")) {
      if (preloadchunklistener == null) {
        preloadchunklistener = new PreloadChunkListener();
        getServer().getPluginManager().registerEvents(preloadchunklistener, this);
      }
    } else if (preloadchunklistener != null) {
      HandlerList.unregisterAll(preloadchunklistener);
      preloadchunklistener = null;
    }

    if (this.getConfig().getBoolean("constantspeed", false)) {
      if (constantspeedlistener == null) {
        constantspeedlistener = new ConstantSpeedListener();
        getServer().getPluginManager().registerEvents(constantspeedlistener, this);
      }
    } else if (constantspeedlistener != null) {
      HandlerList.unregisterAll(constantspeedlistener);
      constantspeedlistener = null;
    }
  }
  private void del(UUID playerUUID, AbstractEffect effect) {
    try {
      for (Class<? extends AbstractEventListener<?>> eventListenerClass :
          effect.getNeededEvents()) {
        AbstractEventListener<?> eventListener;

        eventListener = EventListenerManager.getInstance().getEventListener(eventListenerClass);
        EntityDamageEvent.getHandlerList();
        eventListener.deleteObserver(effect);
        if (eventListener.countObservers() == 0) {
          Class<?> eventClass = eventListener.getObservedEvent();
          Method method = eventClass.getMethod("getHandlerList");
          HandlerList hl = (HandlerList) method.invoke(null);
          hl.unregister(plugin);
        }
      }
    } catch (NoSuchMethodException
        | InstantiationException
        | IllegalAccessException
        | InvocationTargetException
        | SecurityException e) {
      e.printStackTrace();
      throw new IllegalArgumentException(
          "An error occured during the effect deletion: " + e.getClass().toString() + ".", e);
    }
    getEffectsForPlayer(playerUUID).remove(effect);
    ;
  }
  public static void register(Class<? extends Event> pore) {
    checkNotNull(pore, "pore");

    Class<? extends org.spongepowered.api.event.Event> sponge = null;
    for (Constructor<?> constructor : pore.getConstructors()) {
      Class<?>[] parameters = constructor.getParameterTypes();
      if (parameters.length == 1) {
        Class<?> parameter = parameters[0];
        if (org.spongepowered.api.event.Event.class.isAssignableFrom(parameter)) {
          sponge = parameter.asSubclass(org.spongepowered.api.event.Event.class);
        }
      }
    }

    checkArgument(sponge != null, "No event constructor found in %s", pore);

    Class<?> superClass = pore.getSuperclass();
    checkState(
        !Modifier.isAbstract(superClass.getModifiers())
            && superClass.getName().startsWith("org.bukkit.event"),
        "Not a Bukkit handle event %s",
        superClass);
    Class<? extends Event> handle = superClass.asSubclass(Event.class);

    HandlerList list = SimplePluginManager.getEventListeners(handle);
    list.addAdapter(create(pore, sponge));
  }
 /** unregister listeners. */
 public void unregisterListeners() {
   try {
     HandlerList.unregisterAll(this);
     HandlerList.unregisterAll(listener);
   } catch (Exception exc) {
   }
 }
 @Override
 public void onDisable() {
   DataManager.saveAllData();
   HandlerList.unregisterAll(this);
   Bukkit.getScheduler().cancelTasks(this);
   message("disabled");
 }
Exemple #6
0
  @Override
  public void onDisable() {

    // Disable listeners
    HandlerList.unregisterAll(this);

    // Stop shedulers
    getServer().getScheduler().cancelTasks(this);

    if (p == null) {
      return;
    }

    // save Data to Disk
    DataSave.save(true);

    // save LanguageReader
    languageReader.save();

    // delete Data from Ram
    Barrel.barrels.clear();
    BCauldron.bcauldrons.clear();
    BIngredients.possibleIngredients.clear();
    BIngredients.recipes.clear();
    BIngredients.cookedNames.clear();
    BPlayer.clear();
    Brew.potions.clear();
    Wakeup.wakeups.clear();
    Words.words.clear();

    this.log(this.getDescription().getName() + " disabled!");
  }
Exemple #7
0
 @Override
 public void onDisable() {
   HandlerList.unregisterAll();
   //		log.info(String.format("[%s] Disabled Version %s", getDescription().getName(),
   // getDescription().getVersion()));
   Bukkit.getScheduler().cancelTasks(this);
 }
 public void destroy() {
   HandlerList.unregisterAll(this);
   this.handler = null;
   this.plugin = null;
   this.optionNames = null;
   this.optionIcons = null;
 }
Exemple #9
0
 public void onReload() {
   viewMan.clearAll();
   HandlerList.unregisterAll(viewMan);
   configMan.getConfig("kits.yml").reloadConfig();
   kitMan = new KitManager(this);
   viewMan = new ViewManager(this);
   getServer().getPluginManager().registerEvents(viewMan, this);
 }
 @EventHandler
 public void closeEvent(InventoryCloseEvent event) {
   // System.out.println("Closing something");
   if (event.getInventory().getTitle().equals("Auction House")) {
     System.out.println("I am closed");
     HandlerList.unregisterAll(this);
   }
 }
 public void onDisable() {
   getServer().getScheduler().cancelTask(resetTaskId);
   getServer().getScheduler().cancelTask(saveTaskId);
   getServer().getScheduler().cancelTask(updateTaskId);
   HandlerList.unregisterAll(this);
   save();
   logger.info("MineResetLite disabled");
 }
 public static void stop() {
   if (instance == null) return;
   synchronized (lock) {
     if (instance == null) return;
     HandlerList.unregisterAll(instance);
     instance = null;
   }
 }
Exemple #13
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    if (cmd.getName().equalsIgnoreCase("pfreload")) {
      sender.sendMessage(ChatColor.RED + "Reloading config.yml and rules.txt");

      // Remove all our listeners, first.
      HandlerList.unregisterAll(this);

      // Shut down the DataCache
      dataCache.stop();

      reloadConfig();
      configurePlugin();

      ruleset = new RuleSet(this);
      if (ruleset.init(getRulesFile())) {
        logger.config("rules.txt and config.yml reloaded by " + sender.getName());
      } else {
        logger.warning("failed to reload rules.txt as requested by " + sender.getName());
      }

      // Start the DataCache again
      dataCache = new DataCache(this, ruleset.permList);

      // Re-register our listeners
      registerListeners();

      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfcls")) {
      sender.sendMessage(ChatColor.RED + "Clearing chat screen");
      logger.info("chat screen cleared by " + sender.getName());
      int i = 0;
      while (i <= 120) {
        getServer().broadcastMessage(" ");
        i++;
      }
      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfmute")) {
      if (pwnMute) {
        getServer()
            .broadcastMessage(ChatColor.RED + "Global mute cancelled by " + sender.getName());
        logger.info("global mute cancelled by " + sender.getName());
        pwnMute = false;
      } else {
        getServer()
            .broadcastMessage(ChatColor.RED + "Global mute initiated by " + sender.getName());
        logger.info("global mute initiated by " + sender.getName());
        pwnMute = true;
      }
      return true;
    } else if (cmd.getName().equalsIgnoreCase("pfdumpcache")) {
      dataCache.dumpCache(logger);
      sender.sendMessage(ChatColor.RED + "Dumped PwnFilter cache to log.");
      logger.info("Dumped PwnFilter cache to log by " + sender.getName());
    }
    return false;
  }
Exemple #14
0
  @Override
  public void onDisable() {
    HandlerList.unregisterAll(this);
    saveTask.cancel();

    unloadExplosives();
    saveData();

    consoleLogger.info("Plugin disabled");
  }
 public void removeBlocks(LivingEntity entity, String name) {
   Iterator<Block> iceIter = this.blocks.iterator();
   while (iceIter.hasNext()) {
     Block bChange = iceIter.next();
     if (bChange.getType() == Material.ICE) {
       bChange.setType(Material.AIR);
     }
   }
   HandlerList.unregisterAll(this.listener);
   broadcast(entity.getLocation(), this.expireText, name);
 }
  private final void close() {
    if (!closed) {
      closed = true;

      for (Player player : plugin.getServer().getOnlinePlayers()) {
        uninjectPlayer(player);
      }

      HandlerList.unregisterAll(listener);
      unregisterChannelHandler();
    }
  }
 public void clearPlugins() {
   synchronized (this) {
     disablePlugins();
     plugins.clear();
     lookupNames.clear();
     HandlerList.unregisterAll();
     fileAssociations.clear();
     permissions.clear();
     defaultPerms.get(true).clear();
     defaultPerms.get(false).clear();
   }
 }
  private void fireEvent(Event event) {
    HandlerList handlers = event.getHandlers();
    RegisteredListener[] listeners = handlers.getRegisteredListeners();

    for (RegisteredListener registration : listeners) {
      if (!registration.getPlugin().isEnabled()) {
        continue;
      }

      try {
        registration.callEvent(event);
      } catch (AuthorNagException ex) {
        Plugin plugin = registration.getPlugin();

        if (plugin.isNaggable()) {
          plugin.setNaggable(false);

          server
              .getLogger()
              .log(
                  Level.SEVERE,
                  String.format(
                      "Nag author(s): '%s' of '%s' about the following: %s",
                      plugin.getDescription().getAuthors(),
                      plugin.getDescription().getFullName(),
                      ex.getMessage()));
        }
      } catch (Throwable ex) {
        server
            .getLogger()
            .log(
                Level.SEVERE,
                "Could not pass event "
                    + event.getEventName()
                    + " to "
                    + registration.getPlugin().getDescription().getFullName(),
                ex);
      }
    }
  }
Exemple #19
0
  public void onDisable() {

    ruleset = null;
    if (logfileHandler != null) {
      logfileHandler.close();
      logger.removeHandler(logfileHandler);
      logfileHandler = null;
    }
    // Remove all our listeners, first.
    HandlerList.unregisterAll(this);

    // Shutdown the DataCache
    dataCache.stop();
    dataCache = null;
  }
  @EventHandler
  public void onInventoryClose(InventoryCloseEvent event) {
    if (event.getView() != this) return;

    openInterfaces.remove(this);
    if (isOpeningNewInv) {
      // We get a close from the new Window opening.
      isOpeningNewInv = false;
      return;
    }

    openParent();

    HandlerList.unregisterAll(this);
  }
 @Override
 public void onDisable() {
   for (Player p : Bukkit.getOnlinePlayers()) {
     if (plugin.getUtilPartciles().hasEffect(p)) {
       plugin.getUtilPartciles().stopAll(p);
     }
     if (Pets.PetsType.HasPet(p)) {
       Pets.PetsType.removePet(p);
     }
     if (MountHandler.HasPet(p)) {
       MountHandler.removePlayerMount(p);
     }
     if (Tipos.playerHasGadget(p)) {
       Tipos.setGadget(p, Tipos.NENHUM);
     }
     if (plugin.getDisguiseMenu().hasDisguise(p)) {
       plugin.getDisguiseMenu().removeAllDisguises(p);
     }
   }
   HandlerList.unregisterAll(this);
 }
  public void enablePlugin(final Plugin plugin) {
    if (!plugin.isEnabled()) {
      List<Command> pluginCommands = PluginCommandYamlParser.parse(plugin);

      if (!pluginCommands.isEmpty()) {
        commandMap.registerAll(plugin.getDescription().getName(), pluginCommands);
      }

      try {
        plugin.getPluginLoader().enablePlugin(plugin);
      } catch (Throwable ex) {
        server
            .getLogger()
            .log(
                Level.SEVERE,
                "Error occurred (in the plugin loader) while enabling "
                    + plugin.getDescription().getFullName()
                    + " (Is it up to date?)",
                ex);
      }

      HandlerList.bakeAll();
    }
  }
  @Override
  public boolean execute() {
    Util.sendMessage(sender, "&c-----------&8[ &7Reload Process Started &8]&c-----------");

    HawkEye hawk = HawkEye.instance;

    hawk.reloadConfig();
    hawk.config = new Config(hawk);

    for (DataType dt : DataType.values()) {
      dt.reload();
    }

    Util.sendMessage(sender, "&8|  &7- &cConfig has been reloaded..");

    HandlerList.unregisterAll(hawk); // Unregisters all listeners registered to hawkeye

    hawk.registerListeners(Bukkit.getPluginManager());

    Util.sendMessage(sender, "&8|  &7- &cListeners have been reloaded..");

    Util.sendMessage(sender, "&c-----------&8[ &7Reload Process Finished &8]&c-----------");
    return true;
  }
Exemple #24
0
  /** Things to be run when the plugin is disabled. */
  @Override
  public void onDisable() {
    try {
      Alchemy
          .finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla
                             // brewing continuation on restart
      UserManager.saveAll(); // Make sure to save player information if the server shuts down
      PartyManager.saveParties(); // Save our parties
      ScoreboardManager.teardownAll();
      formulaManager.saveFormula();
      placeStore.saveAll(); // Save our metadata
      placeStore.cleanUp(); // Cleanup empty metadata stores
    } catch (NullPointerException e) {
    }

    getServer().getScheduler().cancelTasks(this); // This removes our tasks
    HandlerList.unregisterAll(this); // Cancel event registrations

    if (Config.getInstance().getBackupsEnabled()) {
      // Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
      try {
        ZipLibrary.mcMMOBackup();
      } catch (IOException e) {
        getLogger().severe(e.toString());
      } catch (Throwable e) {
        if (e instanceof NoClassDefFoundError) {
          getLogger().severe("Backup class not found!");
          getLogger().info("Please do not replace the mcMMO jar while the server is running.");
        } else {
          getLogger().severe(e.toString());
        }
      }
    }

    debug("Was disabled."); // How informative!
  }
Exemple #25
0
 @Override
 public void onDisable() {
   HandlerList.unregisterAll(this);
 }
Exemple #26
0
 /** Unregister Listener. */
 public void removeListener() {
   HandlerList.unregisterAll(this);
 }
  public void disablePlugin(final Plugin plugin) {
    if (plugin.isEnabled()) {
      try {
        plugin.getPluginLoader().disablePlugin(plugin);
      } catch (Throwable ex) {
        server
            .getLogger()
            .log(
                Level.SEVERE,
                "Error occurred (in the plugin loader) while disabling "
                    + plugin.getDescription().getFullName()
                    + " (Is it up to date?)",
                ex);
      }

      try {
        server.getScheduler().cancelTasks(plugin);
      } catch (Throwable ex) {
        server
            .getLogger()
            .log(
                Level.SEVERE,
                "Error occurred (in the plugin loader) while cancelling tasks for "
                    + plugin.getDescription().getFullName()
                    + " (Is it up to date?)",
                ex);
      }

      try {
        server.getServicesManager().unregisterAll(plugin);
      } catch (Throwable ex) {
        server
            .getLogger()
            .log(
                Level.SEVERE,
                "Error occurred (in the plugin loader) while unregistering services for "
                    + plugin.getDescription().getFullName()
                    + " (Is it up to date?)",
                ex);
      }

      try {
        HandlerList.unregisterAll(plugin);
      } catch (Throwable ex) {
        server
            .getLogger()
            .log(
                Level.SEVERE,
                "Error occurred (in the plugin loader) while unregistering events for "
                    + plugin.getDescription().getFullName()
                    + " (Is it up to date?)",
                ex);
      }

      try {
        server.getMessenger().unregisterIncomingPluginChannel(plugin);
        server.getMessenger().unregisterOutgoingPluginChannel(plugin);
      } catch (Throwable ex) {
        server
            .getLogger()
            .log(
                Level.SEVERE,
                "Error occurred (in the plugin loader) while unregistering plugin channels for "
                    + plugin.getDescription().getFullName()
                    + " (Is it up to date?)",
                ex);
      }
    }
  }
 @Override
 public void onDisable() {
   HandlerList.unregisterAll((JavaPlugin) this);
 }
 @Override
 public void unload() {
   HandlerList.unregisterAll(this);
 }
 @Override
 public void stop() {
   HandlerList.unregisterAll(this);
 }