Beispiel #1
0
  /**
   * Teleports a player to a warp's location.
   *
   * @param player The player who sent the command.
   * @param name The name of the warp.
   */
  public void warp(Player player, String name) {
    if (!config.checkWarp(name)) {
      player.sendMessage("§cInvalid warp. Use §6/expugn warplist §cfor a list of warps.");
      return;
    }

    int value = config.getWarp_Value(name);
    UUID playerUUID = player.getUniqueId();

    if (value != 0) {
      switch (config.getWarp_Type(name)) {
        case "cooldown":
          long canUseAgain = config.getData_Cooldown(name, playerUUID);

          if (canUseAgain >= System.currentTimeMillis()) {
            player.sendMessage("§cYou cannot use this warp again just yet.");
            convert(player, (canUseAgain - System.currentTimeMillis()));

            if (config.getWarp_Else(name) != null && !config.getWarp_Else(name).isEmpty()) {
              warp(player, config.getWarp_Else(name));
              player.sendMessage(
                  "§cYou have been moved to a different location because you failed to warp.");
            }
            return;
          }

          long addedTime = value * 3600000;
          config.setData_Cooldown(name, playerUUID, (System.currentTimeMillis() + addedTime));
          break;

        case "limit":
          config.checkMidnight();
          int amountUsed = config.getData_Limit(name, playerUUID);
          if (amountUsed >= value) {
            player.sendMessage("§cYou have exceeded the daily limit to use this warp.");
            convert(player, config.getTimeTilMidnightInMillis());

            if (config.getWarp_Else(name) != null && !config.getWarp_Else(name).isEmpty()) {
              warp(player, config.getWarp_Else(name));
              player.sendMessage(
                  "§cYou have been moved to a different location because you failed to warp.");
            }
            return;
          } else if (value != 0) {
            amountUsed++;
            config.setData_Limit(name, playerUUID, amountUsed);
          }
          break;
      }
    }

    player.teleport(config.getWarp_Location(name));
  }
Beispiel #2
0
 /**
  * Reads the information of the warp in the configuration file and returns it back to the player.
  *
  * @param player The player who sent the command.
  * @param name The name of the warp.
  */
 public void warpInfo(Player player, String name) {
   if (!config.checkWarp(name)) {
     player.sendMessage("§cInvalid warp. Use §6/expugn warplist §cfor a list of warps.");
     return;
   }
   player.sendMessage("§6Information for warp §c" + name + "§6:");
   player.sendMessage("x: " + config.getWarp_X(name));
   player.sendMessage("y: " + config.getWarp_Y(name));
   player.sendMessage("z: " + config.getWarp_Z(name));
   player.sendMessage("yaw: " + config.getWarp_Yaw(name));
   player.sendMessage("pitch: " + config.getWarp_Pitch(name));
   player.sendMessage("world: " + config.getWarp_World(name));
   player.sendMessage("type: " + config.getWarp_Type(name));
   player.sendMessage("value: " + config.getWarp_Value(name) + " hours/daily entry limit");
   player.sendMessage("else: " + config.getWarp_Else(name) + " alternate warp");
 }