Ejemplo n.º 1
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();
  }
Ejemplo n.º 2
0
  @Override
  public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
    // Get the home.
    Optional<WarpLocation> owl = args.<WarpLocation>getOne(home);
    if (!owl.isPresent()) {
      owl = plugin.getUserLoader().getUser(src).getHome("home");

      if (!owl.isPresent()) {
        src.sendMessage(
            Text.of(TextColors.RED, Util.getMessageWithFormat("args.home.nohome", "home")));
        return CommandResult.empty();
      }
    }

    WarpLocation wl = owl.get();

    // Warp to it safely.
    if (src.setLocationAndRotationSafely(wl.getLocation(), wl.getRotation())) {
      src.sendMessage(
          Text.of(
              TextColors.GREEN, Util.getMessageWithFormat("command.home.success", wl.getName())));
      return CommandResult.success();
    } else {
      src.sendMessage(
          Text.of(TextColors.RED, Util.getMessageWithFormat("command.home.fail", wl.getName())));
      return CommandResult.empty();
    }
  }
Ejemplo n.º 3
0
 @Override
 public Map<String, PermissionInformation> permissionSuffixesToRegister() {
   Map<String, PermissionInformation> m = new HashMap<>();
   m.put(
       "others",
       new PermissionInformation(
           Util.getMessageWithFormat("permission.others", this.getAliases()[0]),
           SuggestedLevel.ADMIN));
   return m;
 }