@Listener
 public void onPlayerChat(MessageChannelEvent.Chat event) {
   Optional<Player> playerOptional = event.getCause().first(Player.class);
   if (!playerOptional.isPresent()) return;
   Player player = playerOptional.get();
   if (JobsLite.optionEnabled("chatPrefixes")) {
     String uuid = player.getUniqueId().toString();
     if (playerManager.playerExists(uuid)) {
       String currentJob = playerManager.getCurrentJob(uuid).trim();
       if (!currentJob.isEmpty()) {
         String displayName = jobManager.getDisplayName(currentJob);
         if (!displayName.isEmpty()) {
           if (JobsLite.optionEnabled("displayLevel")) {
             event.setMessage(
                 TextUtils.chatMessage(
                     player.getName(),
                     displayName,
                     playerManager.getCurrentLevel(uuid, currentJob),
                     jobManager.getColor(currentJob),
                     event.getRawMessage().toPlain()));
           } else {
             event.setMessage(
                 TextUtils.chatMessage(
                     player.getName(),
                     displayName,
                     jobManager.getColor(currentJob),
                     event.getRawMessage().toPlain()));
           }
         }
       }
     }
   }
 }
  @Listener
  public void onPlayerRespawn(RespawnPlayerEvent event) {
    Player player = event.getTargetEntity();

    if (this.teamA.contains(player)) {
      event.setToTransform(
          event.getToTransform().setLocation(this.arena.getTeamASpawn().getLocation()));

      Sponge.getScheduler()
          .createTaskBuilder()
          .execute(
              () -> {
                if (this.arena.getTeamALoadout() != null)
                  UltimateGames.game
                      .getCommandManager()
                      .process(
                          Sponge.getServer().getConsole(),
                          "kit " + this.arena.getTeamALoadout() + " " + player.getName());
              })
          .delayTicks(10)
          .name("UltimateGames - Give Player Loadout")
          .submit(
              UltimateGames.game
                  .getPluginManager()
                  .getPlugin("io.github.hsyyid.ultimategames")
                  .get()
                  .getInstance()
                  .get());
    } else if (this.teamB.contains(player)) {
      event.setToTransform(
          event.getToTransform().setLocation(this.arena.getTeamBSpawn().getLocation()));

      Sponge.getScheduler()
          .createTaskBuilder()
          .execute(
              () -> {
                if (this.arena.getTeamBLoadout() != null)
                  UltimateGames.game
                      .getCommandManager()
                      .process(
                          Sponge.getServer().getConsole(),
                          "kit " + this.arena.getTeamBLoadout() + " " + player.getName());
              })
          .delayTicks(10)
          .name("UltimateGames - Give Player Loadout")
          .submit(
              UltimateGames.game
                  .getPluginManager()
                  .getPlugin("io.github.hsyyid.ultimategames")
                  .get()
                  .getInstance()
                  .get());
    }
  }
  public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
    if (src instanceof Player) {
      Player player = (Player) src;
      Player target = ctx.<Player>getOne("target").get();

      player.sendMessage(Text.of(TextColors.DARK_AQUA, "You have slapped ", target.getName()));
      target.sendMessage(
          Text.of(TextColors.DARK_AQUA, "You have been slapped by ", player.getName()));
    }
    return CommandResult.success();
  }
  public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
    Optional<Player> p = ctx.<Player>getOne("player");

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

      if (player.hasPermission("heal.others") && p.isPresent()) {
        Player recipient = p.get();
        recipient.offer(Keys.HEALTH, player.get(Keys.MAX_HEALTH).get());
        recipient.sendMessage(
            Texts.of(
                TextColors.GREEN,
                "Success: ",
                TextColors.YELLOW,
                "You've been healed by " + player.getName()));
        src.sendMessage(
            Texts.of(
                TextColors.GREEN,
                "Success: ",
                TextColors.YELLOW,
                "You've healed " + recipient.getName()));
      } else if (p.isPresent()) {
        player.sendMessage(
            Texts.of(
                TextColors.DARK_RED,
                "Error! ",
                TextColors.RED,
                "You do not have permission to heal other players!"));
      } else {
        player.offer(Keys.HEALTH, player.get(Keys.MAX_HEALTH).get());
        src.sendMessage(
            Texts.of(TextColors.GREEN, "Success: ", TextColors.YELLOW, "You've been healed."));
      }
    } else if (src instanceof ConsoleSource) {
      src.sendMessage(
          Texts.of(
              TextColors.DARK_RED,
              "Error! ",
              TextColors.RED,
              "Must be an in-game player to use /heal!"));
    } else if (src instanceof CommandBlockSource) {
      src.sendMessage(
          Texts.of(
              TextColors.DARK_RED,
              "Error! ",
              TextColors.RED,
              "Must be an in-game player to use /heal!"));
    }

    return CommandResult.success();
  }
示例#5
0
  @Override
  public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
    Optional<Player> opl = this.getUser(Player.class, src, player, args);
    if (!opl.isPresent()) {
      return CommandResult.empty();
    }

    Player pl = opl.get();

    InternalQuickStartUser uc = plugin.getUserLoader().getUser(pl);
    boolean fly = args.<Boolean>getOne(toggle).orElse(!uc.isFlying());

    if (!uc.setFlying(fly)) {
      src.sendMessages(Text.of(TextColors.RED, Util.getMessageWithFormat("command.fly.error")));
      return CommandResult.empty();
    }

    if (pl != src) {
      src.sendMessages(
          Text.of(
              TextColors.GREEN,
              MessageFormat.format(
                  Util.getMessageWithFormat(
                      fly ? "command.fly.player.on" : "command.fly.player.off"),
                  pl.getName())));
    }

    pl.sendMessage(
        Text.of(
            TextColors.GREEN,
            Util.getMessageWithFormat(fly ? "command.fly.on" : "command.fly.off")));
    return CommandResult.success();
  }
示例#6
0
  public static CommandSpec getCommand() {
    return CommandSpec.builder()
        .arguments(
            GenericArguments.player(Text.of("player")), new ChannelArgument(Text.of("channel")))
        .description(Text.of("Unban player from channel."))
        .permission("darmok.mod")
        .executor(
            (source, args) -> {
              Player player = args.<Player>getOne("player").get();
              Channel channel = args.<Channel>getOne("channel").get();

              Darmok.getPlayerRegistry().unbanFromChannel(player, channel);

              player.sendMessage(
                  Format.error(
                      String.format(
                          "You have been unbanned from the %s channel.", channel.getName())));
              source.sendMessage(
                  Format.heading(
                      String.format(
                          "You have unbanned %s from channel %s",
                          player.getName(), channel.getName())));

              return CommandResult.success();
            })
        .build();
  }
示例#7
0
  @Override
  public CommandResult process(CommandSource sender, String arguments) throws CommandException {

    String[] args = arguments.split(" ");

    if (!PermissionsUtils.has(sender, "core.heal")) {
      sender.sendMessage(
          Text.builder("You do not have permissions!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    if (args.length > 1) {
      sender.sendMessage(Text.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/heal [player]"));
      return CommandResult.success();
    }

    if (arguments.equalsIgnoreCase("")) {

      if (sender instanceof Player == false) {
        sender.sendMessage(
            Text.builder("Cannot be run by the console!").color(TextColors.RED).build());
        return CommandResult.success();
      }

      Player p = (Player) sender;
      double max = p.get(Keys.MAX_HEALTH).get();
      p.offer(Keys.HEALTH, max);

      sender.sendMessage(Text.of(TextColors.YELLOW, "You ", TextColors.GRAY, "have been healed."));

    } else if (args.length == 1) {

      if (!PermissionsUtils.has(sender, "core.heal-others")) {
        sender.sendMessage(
            Text.builder("You do not have permissions to heal other players!")
                .color(TextColors.RED)
                .build());
        return CommandResult.success();
      }

      Player p = ServerUtils.getPlayer(args[0]);
      if (p == null) {
        sender.sendMessage(Text.builder("Player not found!").color(TextColors.RED).build());
        return CommandResult.success();
      }

      double max = p.get(Keys.MAX_HEALTH).get();
      p.offer(Keys.HEALTH, max);

      sender.sendMessage(
          Text.of(TextColors.YELLOW, p.getName(), TextColors.GRAY, " has been healed."));
      p.sendMessage(
          Text.of(
              TextColors.GRAY, "You have been healed by ", TextColors.YELLOW, sender.getName()));
    }

    return CommandResult.success();
  }
 public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
   Player p = ctx.<Player>getOne("player").get();
   String command = ctx.<String>getOne("command").get();
   if (src instanceof Player) {
     Player player = (Player) src;
     CommandService cmdService = game.getCommandDispatcher();
     if (!(p.hasPermission("sudo.exempt"))) {
       cmdService.process(p, command);
       player.sendMessage(
           Texts.of(
               TextColors.GREEN,
               "Success! ",
               TextColors.GOLD,
               "Forcing " + p.getName() + " to run /" + command));
       p.sendMessage(
           Texts.of(
               TextColors.GOLD,
               "[Sudo]: ",
               TextColors.WHITE,
               player.getName() + " has forced you to run /" + command));
     } else {
       player.sendMessage(
           Texts.of(
               TextColors.DARK_RED,
               "Error! ",
               TextColors.RED,
               "This player is exempt from sudo!"));
     }
   } else if (src instanceof ConsoleSource) {
     src.sendMessage(
         Texts.of(
             TextColors.DARK_RED,
             "Error! ",
             TextColors.RED,
             "Must be an in-game player to use /sudo!"));
   } else if (src instanceof CommandBlockSource) {
     src.sendMessage(
         Texts.of(
             TextColors.DARK_RED,
             "Error! ",
             TextColors.RED,
             "Must be an in-game player to use /sudo!"));
   }
   return CommandResult.success();
 }
示例#9
0
  @Listener(order = Order.LATE)
  public void onMessageChannelEventChat(MessageChannelEvent.Chat event, @First Player player) {
    Builder playerTag = Text.builder().onHover(TextActions.showText(Text.of(player.getName())));

    Optional<PlayerTag> optionalPlayerTag = PlayerTag.get(player);

    if (!optionalPlayerTag.isPresent()) {
      playerTag.append(PlayerTag.getDefault(player));
    } else {
      playerTag.append(optionalPlayerTag.get().getTag());
    }

    Text worldTag = Text.EMPTY;

    Optional<WorldTag> optionalWorldTag = WorldTag.get(player.getWorld().getProperties());

    if (optionalWorldTag.isPresent()) {
      worldTag = optionalWorldTag.get().getTag();
    }

    Builder groupTagBuilder = Text.builder();

    for (Entry<Set<Context>, List<Subject>> parent :
        player.getSubjectData().getAllParents().entrySet()) {
      for (Subject subject : parent.getValue()) {
        String group = subject.getIdentifier();

        if (group.equalsIgnoreCase("op_0")
            || group.equalsIgnoreCase("op_1")
            || group.equalsIgnoreCase("op_2")
            || group.equalsIgnoreCase("op_3")
            || group.equalsIgnoreCase("op_4")) {
          group = "op";
        }

        Optional<GroupTag> optionalGroupTag = GroupTag.get(group);

        if (optionalGroupTag.isPresent()) {
          groupTagBuilder.append(optionalGroupTag.get().getTag());
        }
      }
    }

    MessageFormatter formatter = event.getFormatter();

    String oldStr = TextSerializers.FORMATTING_CODE.serialize(formatter.getHeader().toText());

    String name = oldStr.substring(oldStr.indexOf("<"), oldStr.lastIndexOf(">") + 1);

    Text old = TextSerializers.FORMATTING_CODE.deserialize(oldStr.replace(name, ""));

    formatter.setHeader(
        TextTemplate.of(
            worldTag, groupTagBuilder.build(), playerTag.build(), old, TextColors.RESET));
  }
示例#10
0
 @Override
 public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
   int expLevel = ctx.<Integer>getOne("exp").get();
   Player player = ctx.<Player>getOne("target").get();
   player.offer(Keys.TOTAL_EXPERIENCE, player.get(Keys.TOTAL_EXPERIENCE).get() - expLevel);
   src.sendMessage(
       Text.of(
           TextColors.GREEN,
           "Success! ",
           TextColors.YELLOW,
           "Took " + expLevel + " experience from " + player.getName() + "."));
   return CommandResult.success();
 }
示例#11
0
文件: Channel.java 项目: prism/Darmok
  /**
   * @param msg
   * @return
   * @throws TextMessageException
   */
  public Text formatMessage(Object sender, Text msg) throws TextMessageException {
    Hashtable<String, String> tokens = new Hashtable<String, String>();
    tokens.put("color", color);
    tokens.put("command", command);

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

      Subject subject = player.getContainingCollection().get(player.getIdentifier());
      String prefix = "";
      String suffix = "";

      if (subject instanceof OptionSubject) {
        Optional<String> optionalPrefix = ((OptionSubject) subject).getOption("prefix");
        if (optionalPrefix.isPresent()) {
          prefix = optionalPrefix.get();
        }

        Optional<String> optionalSuffix = ((OptionSubject) subject).getOption("suffix");
        if (optionalSuffix.isPresent()) {
          suffix = optionalSuffix.get();
        }
      }

      tokens.put("msg", "");
      tokens.put("sender", player.getName());
      tokens.put("prefix", prefix);
      tokens.put("suffix", suffix);
    } else {
      tokens.put("msg", "");
      tokens.put(
          "sender", sender != null ? sender.getClass().getSimpleName().toString() : "unknown");
      tokens.put("prefix", "");
      tokens.put("suffix", "");
    }

    Text replaced = TextSerializers.FORMATTING_CODE.deserialize(getString(format, tokens));
    return Text.of(replaced, msg);
  }
  @Listener
  public void onStart(MinigameStartedEvent event) {
    if (event.getMinigame().equals(this)) {
      for (Player player : players()) {
        player.sendMessage(
            Text.of(
                TextColors.BLUE, "[UltimateGames]: ", TextColors.GREEN, "Deathmatch starting..."));
      }

      for (Player player : this.teamA) {
        player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
        player.setScoreboard(scoreboard);
        this.teamAScoreboardTeam.addMember(player.getTeamRepresentation());

        if (this.arena.getTeamALoadout() != null)
          UltimateGames.game
              .getCommandManager()
              .process(
                  Sponge.getServer().getConsole(),
                  "kit " + this.arena.getTeamALoadout() + " " + player.getName());

        if (player
            .getWorld()
            .getUniqueId()
            .equals(this.arena.getTeamASpawn().getLocation().getExtent().getUniqueId())) {
          player.setLocation(this.arena.getTeamASpawn().getLocation());
        } else {
          player.transferToWorld(
              this.arena.getTeamASpawn().getLocation().getExtent().getUniqueId(),
              this.arena.getTeamASpawn().getLocation().getPosition());
        }

        player.sendMessage(
            Text.of(TextColors.BLUE, "[UltimateGames]: ", TextColors.GOLD, "May the games begin!"));
      }

      for (Player player : this.teamB) {
        player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
        player.setScoreboard(scoreboard);
        this.teamBScoreboardTeam.addMember(player.getTeamRepresentation());

        if (this.arena.getTeamBLoadout() != null)
          UltimateGames.game
              .getCommandManager()
              .process(
                  Sponge.getServer().getConsole(),
                  "kit " + this.arena.getTeamBLoadout() + " " + player.getName());

        if (player
            .getWorld()
            .getUniqueId()
            .equals(this.arena.getTeamBSpawn().getLocation().getExtent().getUniqueId())) {
          player.setLocation(this.arena.getTeamBSpawn().getLocation());
        } else {
          player.transferToWorld(
              this.arena.getTeamBSpawn().getLocation().getExtent().getUniqueId(),
              this.arena.getTeamBSpawn().getLocation().getPosition());
        }

        player.sendMessage(
            Text.of(TextColors.BLUE, "[UltimateGames]: ", TextColors.GOLD, "May the games begin!"));
      }

      Scheduler scheduler = UltimateGames.game.getScheduler();
      Task.Builder taskBuilder = scheduler.createTaskBuilder();

      taskBuilder
          .execute(
              () -> {
                try {
                  Ember.unregister(this.arena);
                } catch (Exception e) {
                  System.out.println(
                      "[UltimateGames]: Error when ending deathmatch in arena " + arena.getName());
                }
              })
          .delay(this.arena.getLength(), TimeUnit.MINUTES)
          .name("UltimateGames - End Deathmatch")
          .submit(
              UltimateGames.game
                  .getPluginManager()
                  .getPlugin("io.github.hsyyid.ultimategames")
                  .get()
                  .getInstance()
                  .get());
    }
  }
  public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
    Optional<Player> optionalTarget = ctx.<Player>getOne("player");

    if (!optionalTarget.isPresent()) {
      if (src instanceof Player) {
        Player player = (Player) src;
        BlockRay<World> playerBlockRay = BlockRay.from(player).blockLimit(350).build();

        Location<World> spawnLocation = null;
        int i = 0;

        while (playerBlockRay.hasNext()) {
          // TODO: Come up with a better way of making sure it doesn't hit the player.
          i++;

          BlockRayHit<World> currentHitRay = playerBlockRay.next();

          if (i > 5) {
            // We can set the spawn location, so break here.
            spawnLocation = currentHitRay.getLocation();
            break;
          }
        }

        Vector3d velocity = player.getTransform().getRotationAsQuaternion().getDirection();
        spawnEntity(spawnLocation, velocity, player);
        player.sendMessage(
            Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Created Fireball!"));
      } else if (src instanceof ConsoleSource) {
        src.sendMessage(
            Text.of(
                TextColors.DARK_RED,
                "Error! ",
                TextColors.RED,
                "Must be an in-game player to use /fireball!"));
      } else if (src instanceof CommandBlockSource) {
        src.sendMessage(
            Text.of(
                TextColors.DARK_RED,
                "Error! ",
                TextColors.RED,
                "Must be an in-game player to use /fireball!"));
      }
    } else {
      Player player = optionalTarget.get();
      Location<World> playerLocation = player.getLocation();

      Vector3d velocity = player.getTransform().getRotationAsQuaternion().getDirection();
      spawnEntity(playerLocation, velocity, src);
      player.sendMessage(
          Text.of(
              TextColors.GRAY, src.getName(), TextColors.GOLD, " has struck you with a fireball."));
      src.sendMessage(
          Text.of(
              TextColors.GREEN,
              "Success! ",
              TextColors.YELLOW,
              "Struck " + player.getName() + " with fireball."));
    }

    return CommandResult.success();
  }
示例#14
0
  @Override
  public CommandResult process(CommandSource sender, String arguments) throws CommandException {

    String[] args = arguments.split(" ");

    if (!PermissionsUtils.has(sender, "core.tp")) {
      sender.sendMessage(
          Texts.builder("You do not have permissions!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    if (arguments.equalsIgnoreCase("")) {
      sender.sendMessage(
          Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/tp <player> [target]"));
      return CommandResult.success();
    }
    if (args.length < 1 || args.length > 2) {
      sender.sendMessage(
          Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/tp <player> [target]"));
      return CommandResult.success();
    }

    Player player = null;
    Player target = null;

    if (args.length == 1) {

      if (sender instanceof Player == false) {
        sender.sendMessage(
            Texts.builder("Cannot be run by the console!").color(TextColors.RED).build());
        return CommandResult.success();
      }

      player = (Player) sender;
      target = ServerUtils.getPlayer(args[0]);

    } else if (args.length == 2) {

      if (!PermissionsUtils.has(sender, "core.tp-others")) {
        sender.sendMessage(
            Texts.builder("You do not have permissions to teleport others!")
                .color(TextColors.RED)
                .build());
        return CommandResult.success();
      }

      player = ServerUtils.getPlayer(args[0]);
      target = ServerUtils.getPlayer(args[1]);
    }

    if (player == null) {
      sender.sendMessage(Texts.builder("Player not found!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    if (target == null) {
      sender.sendMessage(Texts.builder("Target not found!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    player.setLocation(target.getLocation());

    if (args.length == 1) {

      sender.sendMessage(
          Texts.of(TextColors.GRAY, "Teleported to ", TextColors.YELLOW, target.getName()));

    } else if (args.length == 2) {

      sender.sendMessage(
          Texts.of(
              TextColors.GRAY,
              "Teleported ",
              TextColors.YELLOW,
              player.getName(),
              TextColors.GRAY,
              " to ",
              TextColors.YELLOW,
              target.getName()));
    }

    return CommandResult.success();
  }
  @Override
  public CommandResult execute(CommandSource src, CommandContext ctx) {
    Player player;
    try {
      player = GriefPrevention.checkPlayer(src);
    } catch (CommandException e) {
      src.sendMessage(e.getText());
      return CommandResult.success();
    }
    // which claim is being abandoned?
    PlayerData playerData =
        GriefPrevention.instance.dataStore.getOrCreatePlayerData(
            player.getWorld(), player.getUniqueId());
    Claim claim =
        GriefPrevention.instance.dataStore.getClaimAtPlayer(playerData, player.getLocation(), true);
    UUID ownerId = claim.ownerID;
    if (claim.parent != null) {
      ownerId = claim.parent.ownerID;
    }
    if (claim.isWildernessClaim()) {
      GriefPrevention.sendMessage(player, TextMode.Instr, Messages.AbandonClaimMissing);
      return CommandResult.success();
    } else if (claim.allowEdit(player) != null
        || (!claim.isAdminClaim() && !player.getUniqueId().equals(ownerId))) {
      // verify ownership
      GriefPrevention.sendMessage(player, TextMode.Err, Messages.NotYourClaim);
      return CommandResult.success();
    }

    // warn if has children and we're not explicitly deleting a top level claim
    else if (claim.children.size() > 0 && !deleteTopLevelClaim) {
      GriefPrevention.sendMessage(player, TextMode.Instr, Messages.DeleteTopLevelClaim);
      return CommandResult.empty();
    } else {
      // delete it
      claim.removeSurfaceFluids(null);
      // remove all context permissions
      player.getSubjectData().clearPermissions(ImmutableSet.of(claim.getContext()));
      GriefPrevention.GLOBAL_SUBJECT
          .getSubjectData()
          .clearPermissions(ImmutableSet.of(claim.getContext()));
      GriefPrevention.instance.dataStore.deleteClaim(claim, true);

      // if in a creative mode world, restore the claim area
      if (GriefPrevention.instance.claimModeIsActive(
          claim.getLesserBoundaryCorner().getExtent().getProperties(), ClaimsMode.Creative)) {
        GriefPrevention.addLogEntry(
            player.getName()
                + " abandoned a claim @ "
                + GriefPrevention.getfriendlyLocationString(claim.getLesserBoundaryCorner()));
        GriefPrevention.sendMessage(player, TextMode.Warn, Messages.UnclaimCleanupWarning);
        GriefPrevention.instance.restoreClaim(claim, 20L * 60 * 2);
      }

      // this prevents blocks being gained without spending adjust claim blocks when abandoning a
      // top level claim
      if (!claim.isSubdivision() && !claim.isAdminClaim()) {
        int newAccruedClaimCount =
            playerData.getAccruedClaimBlocks()
                - ((int) Math.ceil(claim.getArea() * (1 - playerData.optionAbandonReturnRatio)));
        playerData.setAccruedClaimBlocks(newAccruedClaimCount);
      }

      // tell the player how many claim blocks he has left
      int remainingBlocks = playerData.getRemainingClaimBlocks();
      GriefPrevention.sendMessage(
          player, TextMode.Success, Messages.AbandonSuccess, String.valueOf(remainingBlocks));
      // revert any current visualization
      playerData.revertActiveVisual(player);
      playerData.warnedAboutMajorDeletion = false;
    }

    return CommandResult.success();
  }
示例#16
0
  @Override
  public CommandResult process(CommandSource sender, String arguments) throws CommandException {

    String[] args = arguments.split(" ");

    if (sender instanceof Player == false) {
      sender.sendMessage(
          Texts.builder("Cannot be run by the console!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    if (!PermissionsUtils.has(sender, "core.tpa")) {
      sender.sendMessage(
          Texts.builder("You do not have permissions!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    if (arguments.equalsIgnoreCase("")) {
      sender.sendMessage(Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/tpa <player>"));
      return CommandResult.success();
    }
    if (args.length < 1 || args.length > 1) {
      sender.sendMessage(Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/tpa <player>"));
      return CommandResult.success();
    }

    Player s = (Player) sender;
    String uuid = s.getUniqueId().toString();

    Player player = CoreServer.getPlayer(args[0]);

    if (player == null) {
      sender.sendMessage(Texts.builder("Player not found!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    CorePlayer p = CoreDatabase.getPlayer(player.getUniqueId().toString());
    HashMap<String, Double> tpa = p.getTPA();
    HashMap<String, Double> tpahere = p.getTPAHere();

    double duration = 0;
    if (tpa.containsKey(uuid)) duration = tpa.get(uuid);
    if (duration != 0) {
      if (duration <= System.currentTimeMillis()) {
        tpa.remove(uuid);
        p.setTPA(tpa);
      } else {
        sender.sendMessage(
            Texts.builder("You already requested a teleport from that player!")
                .color(TextColors.RED)
                .build());
        return CommandResult.success();
      }
    }

    duration = 0;

    if (tpahere.containsKey(uuid)) duration = tpahere.get(uuid);
    if (duration != 0) {
      if (duration <= System.currentTimeMillis()) {
        tpahere.remove(uuid);
        p.setTPAHere(tpahere);
      } else {
        sender.sendMessage(
            Texts.builder("You already requested a teleport from that player!")
                .color(TextColors.RED)
                .build());
        return CommandResult.success();
      }
    }

    duration = System.currentTimeMillis() + 30 * 1000;

    tpa.put(uuid, duration);
    p.setTPA(tpa);

    sender.sendMessage(
        Texts.of(
            TextColors.GRAY,
            "Teleport request has been sent to ",
            TextColors.YELLOW,
            player.getName()));
    player.sendMessage(
        Texts.of(
            TextColors.YELLOW,
            sender.getName(),
            TextColors.GRAY,
            " requested to teleport to you."));
    player.sendMessage(
        Texts.of(
            TextColors.GRAY,
            "Type ",
            TextColors.YELLOW,
            "/tpaccept ",
            sender.getName(),
            TextColors.GRAY,
            " or",
            TextColors.YELLOW,
            " /tpdeny ",
            sender.getName()));
    player.sendMessage(Texts.of(TextColors.GRAY, "to accept/decline the request."));

    return CommandResult.success();
  }