Example #1
0
  public boolean execute(final FilterState state) {
    Player p = state.getPlayer();

    if (p == null) return false;

    PointManager pm;
    try {
      pm = PointManager.getInstance();
    } catch (IllegalStateException ex) {
      LogManager.getInstance()
          .debugLow(
              String.format(
                  "Rule: %s has 'then points', but PointManager is disabled in config.yml",
                  state.rule.getId()));
      return false;
    }

    // TODO: Add more comprehensive messaging, as well as details about thresholds.

    pm.addPlayerPoints(p.getName(), pointsAmount);

    state.addLogMessage(
        String.format(
            "Points Accumulated %s : %f. Total: %f",
            state.playerName, pointsAmount, pm.getPlayerPoints(p)));

    if (!messageString.isEmpty()) {
      Bukkit.getScheduler()
          .runTask(
              state.plugin,
              new Runnable() {
                @Override
                public void run() {
                  state.getPlayer().sendMessage(messageString);
                }
              });
    }

    return true;
  }
Example #2
0
 /** {@inheritDoc} */
 public boolean execute(final FilterState state) {
   final String cmd = Patterns.replaceVars(command, state);
   state.addLogMessage("Sending console command: " + cmd);
   BukkitRunnable task =
       new BukkitRunnable() {
         @Override
         public void run() {
           Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
         }
       };
   task.runTask(state.plugin);
   return true;
 }