Exemplo n.º 1
0
  /**
   * Gets the currently loaded warps, paginates them into pages of size WARPS_PER_PAGE, and sends
   * the warp names in a message to the player
   *
   * @param source
   * @param args
   * @return
   * @throws CommandException
   */
  @Override
  public CommandResult execute(CommandSource source, CommandContext args) throws CommandException {

    if (this.plugin.getWarpManager().getPayload().isEmpty()) {
      source.sendMessage(Constants.NO_WARPS_MSG);
      return CommandResult.success();
    }

    List<Text> warpNames = new ArrayList<Text>();

    for (Warp w : this.plugin.getWarpManager().getPayload()) {
      if (this.plugin.getUtil().hasPermission(source, w)) {
        warpNames.add(Texts.of(Util.warpText(w), TextColors.WHITE, " - ", Util.deleteWarpText(w)));
      }
    }

    PaginationService paginationService =
        this.plugin.getGame().getServiceManager().provide(PaginationService.class).get();
    paginationService
        .builder()
        .contents(warpNames)
        .title(Texts.of(TextColors.BLUE, "Warps"))
        .paddingString("-")
        .sendTo(source);

    return CommandResult.success();
  }
Exemplo n.º 2
0
 public CommandResult process(CommandSource src, String arguments) {
   if (!(src instanceof Player)) {
     src.sendMessage(Texts.of("You cannot use these subcommands."));
     return CommandResult.success();
   }
   Player player = ((Player) src).getPlayer().get();
   if (!player.hasPermission("multiworld.use")) {
     player.sendMessage(
         Texts.of(
             TextColors.DARK_GRAY,
             "[",
             TextColors.BLUE,
             "MultiWorld",
             TextColors.DARK_GRAY,
             "] ",
             TextColors.RED,
             "You do not have permission!"));
     return CommandResult.success();
   }
   String[] args = arguments.toString().split(" ");
   if (args.length > 5 || args.length == 0) {
     sendHelp(player);
     return CommandResult.success();
   }
   player.sendMessage(
       Texts.of(TextColors.BLUE, "MultiWorld version: " + MultiWorld.getInstance().mwVersion));
   return CommandResult.success();
 }
Exemplo n.º 3
0
  @Override
  public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    ConfigurationNode node =
        plugin.rootNode.getNode(
            "commands", args.getOne(util.getStringFromKey("command.param.name")).get().toString());

    node.getNode(CommandSetting.MESSAGE.getName())
        .setValue(args.getOne(util.getStringFromKey("command.param.message")).get().toString());

    node.getNode(CommandSetting.COMMAND.getName())
        .setValue(
            Arrays.asList(
                args.getOne(util.getStringFromKey("command.param.command"))
                    .get()
                    .toString()
                    .split(" ")));

    util.saveConfig();
    util.registerCommand(node);

    plugin.commandMap.put(node.getKey().toString(), node);

    util.updateEditCmd();
    util.updateDeleteCmd();

    src.sendMessage(util.getTextFromJsonByKey("command.add.success", node.getKey()));

    return CommandResult.success();
  }
Exemplo n.º 4
0
  @Override
  public CommandResult execute(CommandSource source, CommandContext args) throws CommandException {
    if (!(source instanceof Player)) {
      source.sendMessage(Constants.MUST_BE_PLAYER_MSG);
      return CommandResult.empty();
    }
    Player player = (Player) source;

    Optional<Warp> optWarp = args.getOne("warp");
    if (!optWarp.isPresent()) {
      source.sendMessage(Constants.WARP_NOT_FOUND_MSG);
      return CommandResult.empty();
    }

    Warp warp = optWarp.get();

    if (this.plugin.getUtil().hasPermission(player, warp) == false) {
      player.sendMessage(Constants.NO_PERMISSION_MSG);
      return CommandResult.empty();
    }

    this.plugin.getWarpManager().scheduleWarp(player, warp);

    return CommandResult.success();
  }
Exemplo n.º 5
0
  public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    Player sender = ((Player) src).getPlayer().get();

    sender.sendMessage(Texts.of(mysql_getClassAttributes.getEXP(sender.getUniqueId().toString())));

    return CommandResult.success();
  }
 public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
   if (src instanceof Player) {
     Player player = (Player) src;
     if (Utils.isSpawnInConfig()) {
       if (!Objects.equals(player.getWorld().getName(), Utils.getSpawnWorldName())) {
         Vector3d position =
             new Vector3d(
                 Utils.getSpawn(player).getX(),
                 Utils.getSpawn(player).getY(),
                 Utils.getSpawn(player).getZ());
         player.transferToWorld(Utils.getSpawnWorldName(), position);
         src.sendMessage(
             Texts.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Teleported to Spawn"));
         return CommandResult.success();
       } else {
         Location<World> spawn =
             new Location<>(
                 player.getWorld(),
                 Utils.getSpawn(player).getX(),
                 Utils.getSpawn(player).getY(),
                 Utils.getSpawn(player).getZ());
         player.setLocation(spawn);
       }
       src.sendMessage(
           Texts.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Teleported to Spawn"));
     } else {
       src.sendMessage(
           Texts.of(
               TextColors.DARK_RED, "Error! ", TextColors.RED, "Spawn has not been set yet!"));
     }
   } else if (src instanceof ConsoleSource) {
     src.sendMessage(
         Texts.of(
             TextColors.DARK_RED,
             "Error! ",
             TextColors.RED,
             "Must be an in-game player to use /spawn!"));
   } else if (src instanceof CommandBlockSource) {
     src.sendMessage(
         Texts.of(
             TextColors.DARK_RED,
             "Error! ",
             TextColors.RED,
             "Must be an in-game player to use /spawn!"));
   }
   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();
  }
 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();
 }
Exemplo n.º 9
0
  public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    String kitName = args.<String>getOne("kit name").get();
    boolean oneTime = false;
    int interval = 0;

    if (args.<Integer>getOne("kit interval").isPresent()) {
      interval = args.<Integer>getOne("kit interval").get();
    } else if (args.<Boolean>getOne("one-time").isPresent()) {
      oneTime = true;
    }

    // Sets the Interval
    if (!oneTime) {
      Utils.setInterval(interval, kitName);
    } else if (oneTime) {
      Utils.setInterval(kitName, oneTime);
    }

    src.sendMessage(
        Texts.of(TextColors.GOLD, "Success! ", TextColors.YELLOW, "The interval was changed!"));
    return CommandResult.success();
  }
Exemplo n.º 10
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();
  }
Exemplo n.º 11
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();
  }