Ejemplo n.º 1
0
  public static void startLockDown(String sender, Long expiryTime, String msg) {
    setExpiryTime(expiryTime);
    setOptionalMessage(msg);
    setLockedDown(true);
    CommandSender target = getSender(sender);
    if (LockDownManager.isLockedDown()) {
      if (target != null) {
        PlayerManager.sendMessageToTarget(
            target,
            ChatColor.RED
                + "Server is locked down until: "
                + LockDownManager.getExpiryTimeString());
        if (!optionalMessage.isEmpty()) {
          PlayerManager.sendMessageToTarget(
              target, ChatColor.RED + "Msg shown to unknown (blocked) players: " + optionalMessage);
        }

        LoggingManager.log(
            "Lockdown start by "
                + target.getName()
                + "  ON."
                + " Expiry in "
                + Utilities.buildShortTimeDiffString(expiryTime - System.currentTimeMillis(), 2)
                + " Msg shown to unknown (blocked) players: "
                + optionalMessage);
      }
    } else {

      if (target != null) {
        PlayerManager.sendMessageToTarget(target, ChatColor.RED + "Lockdown failed to start");
      }
    }
  }
Ejemplo n.º 2
0
  public static boolean checkExpiry(String sender) {
    if (isLockedDown()) {
      if (System.currentTimeMillis() >= expiryTime) {
        setExpiryTime(0);
        setLockedDown(false);
        setOptionalMessage(null);
        LoggingManager.log("Lockdown has expired automatically, time and message cleared.");
        CommandSender target = getSender(sender);
        if (target != null) {
          PlayerManager.sendMessageToTarget(target, ChatColor.RED + "Server is not Locked down");
        }
        return true;
      } else {
        CommandSender target = getSender(sender);
        if (target != null) {
          PlayerManager.sendMessageToTarget(
              target,
              ChatColor.RED
                  + "Server is locked down until: "
                  + LockDownManager.getExpiryTimeString());
        }
        return false;
      }
    } else {

      return true;
    }
  }