Пример #1
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 {
    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();
  }
Пример #3
0
  @Override
  public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {

    Player player = (Player) src;

    PlayerGymInfoData playerGymInfoData = player.get(PlayerGymInfoData.class).get();
    List<ItemStackSnapshot> itemStackSnapshots = playerGymInfoData.badgeItems().get();
    InventoryBasic inventoryBasic = new InventoryBasic("Badges", true, 54);

    for (int i = 0; i < itemStackSnapshots.size(); i++) {
      if (i < inventoryBasic.getSizeInventory()) {
        ItemStackSnapshot snapshot = itemStackSnapshots.get(i);
        ItemStack stack = snapshot.createStack();
        inventoryBasic.setInventorySlotContents(i, (net.minecraft.item.ItemStack) stack);
      }
    }
    ((EntityPlayerMP) player).displayGUIChest(inventoryBasic);

    /*
    try {
        GameProfile gameProfile = Sponge.getServer().getGameProfileManager().get("clienthax").get(); // <-- why the hell doesnt this return a optional.. -.-
        System.out.println(gameProfile.getUniqueId());

    } catch (Exception e) {
        e.printStackTrace();
    }*/

    return CommandResult.success();
  }
Пример #4
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();
 }