예제 #1
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();
  }
예제 #2
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();
  }
 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();
 }
예제 #4
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();
  }
  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();
  }