Beispiel #1
0
  public void onEnable() {
    // Set up logging
    if (logger == null) {
      logger = this.getLogger();
    }

    // Initialize default configuration
    saveDefaultConfig();

    // Now get our configuration
    configurePlugin();

    // Set up a Vault economy for actions like "fine" (optional)
    setupEconomy();

    // Create a new RuleSet object, loading in the rulesFile
    ruleset = new RuleSet(this);
    ruleset.init(getRulesFile());

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

    // Now activate our listeners
    registerListeners();

    // Activate Plugin Metrics
    activateMetrics();
  }
Beispiel #2
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;
  }