public boolean onCommand(
      CommandSender sender, Command command, String commandLabel, String args[]) {

    if (sender instanceof Player) {
      Player player = (Player) sender;

      if (!player.hasPermission("bm.reload")) {
        Util.sendMessage(player, plugin.getMessage("commandPermissionError"));
        return true;
      }
    }

    Util.sendMessage(sender, plugin.getMessage("configReloaded"));

    plugin.configReload();

    return true;
  }
  @EventHandler
  public void onPlayerChat(final AsyncPlayerChatEvent event) {
    Player player = event.getPlayer();
    String playerName = player.getName();

    if (plugin.isPlayerMutedInMem(playerName)) {

      MuteData muteData = plugin.getPlayerMuteFromMem(playerName);
      long expires = muteData.getExpires() * 1000;
      String expiresFormat = Util.formatDateDiff(expires);

      if (muteData.getExpires() != 0) {
        if (System.currentTimeMillis() < expires) {
          event.setCancelled(true);
          String mutedMessage =
              plugin
                  .getMessage("tempMuted")
                  .replace("[expires]", expiresFormat)
                  .replace("[reason]", muteData.getReason())
                  .replace("[by]", muteData.getBy());
          player.sendMessage(mutedMessage);
        } else {
          // Removes them from the database and the HashMap
          player.sendMessage("Unmuted!");
          plugin.removePlayerMute(playerName, plugin.getMessage("consoleName"), true);
        }
      } else {
        event.setCancelled(true);
        String mutedMessage =
            plugin
                .getMessage("muted")
                .replace("[reason]", muteData.getReason())
                .replace("[by]", muteData.getBy());
        player.sendMessage(mutedMessage);
      }
    }
  }
Exemple #3
0
 /**
  * @param message - The message config node
  * @return String
  */
 public static String getMessage(String message) {
   return plugin.getMessage(message);
 }