Пример #1
0
  @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);
      }
    }
  }
Пример #2
0
 /**
  * Unmute a player
  *
  * @param name - Name of player to unmute
  * @param by - Who the unmute is by, can be anything
  * @param keepLog - Whether to store the mute as a record or not
  */
 public static void unMute(String name, String by, boolean keepLog) {
   plugin.removePlayerMute(name, by, keepLog);
 }