Example #1
0
  @Command(
      aliases = {"forestgen"},
      usage = "[size] [type] [density]",
      desc = "Generate a forest",
      min = 0,
      max = 3)
  @CommandPermissions({"worldedit.generation.forest"})
  @Logging(POSITION)
  public static void forestGen(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
    TreeGenerator.TreeType type =
        args.argsLength() > 1
            ? type = TreeGenerator.lookup(args.getString(1))
            : TreeGenerator.TreeType.TREE;
    double density = args.argsLength() > 2 ? args.getDouble(2) / 100 : 0.05;

    if (type == null) {
      player.printError("Tree type '" + args.getString(1) + "' is unknown.");
      return;
    } else {
    }

    int affected =
        editSession.makeForest(player.getPosition(), size, density, new TreeGenerator(type));
    player.print(affected + " trees created.");
  }
Example #2
0
 @Command(
     aliases = {"join", "play"},
     desc = "Join a team.",
     usage = "[team]")
 public static void join(final CommandContext cmd, CommandSender sender) throws CommandException {
   if (!(sender instanceof Player)) {
     throw new CommandException(
         ChatConstant.ERROR_CONSOLE_NO_USE.getMessage(ChatUtil.getLocale(sender)));
   }
   if (GameHandler.getGameHandler().getMatch().getState().equals(MatchState.ENDED)
       || GameHandler.getGameHandler().getMatch().getState().equals(MatchState.CYCLING)) {
     throw new CommandException(
         ChatUtil.getWarningMessage(
             new LocalizedChatMessage(ChatConstant.ERROR_MATCH_OVER)
                 .getMessage(((Player) sender).getLocale())));
   }
   Optional<TeamModule> originalTeam = Teams.getTeamByPlayer((Player) sender);
   if (cmd.argsLength() == 0 && originalTeam.isPresent() && !originalTeam.get().isObserver()) {
     throw new CommandException(
         ChatUtil.getWarningMessage(
             ChatColor.RED
                 + new LocalizedChatMessage(
                         ChatConstant.ERROR_ALREADY_JOINED,
                         Teams.getTeamByPlayer((Player) sender).get().getCompleteName()
                             + ChatColor.RED)
                     .getMessage(((Player) sender).getLocale())));
   }
   Optional<TeamModule> destinationTeam = Optional.absent();
   if (cmd.argsLength() > 0) {
     for (TeamModule teamModule :
         GameHandler.getGameHandler().getMatch().getModules().getModules(TeamModule.class)) {
       if (teamModule.getName().toLowerCase().startsWith(cmd.getJoinedStrings(0).toLowerCase())) {
         destinationTeam = Optional.of(teamModule);
         break;
       }
     }
     if (!destinationTeam.isPresent()) {
       throw new CommandException(
           ChatConstant.ERROR_NO_TEAM_MATCH.getMessage(ChatUtil.getLocale(sender)));
     }
     if (destinationTeam.get().contains(sender)) {
       throw new CommandException(
           ChatUtil.getWarningMessage(
               ChatColor.RED
                   + new LocalizedChatMessage(
                           ChatConstant.ERROR_ALREADY_JOINED,
                           destinationTeam.get().getCompleteName() + ChatColor.RED)
                       .getMessage(ChatUtil.getLocale(sender))));
     }
     destinationTeam.get().add((Player) sender, false);
   } else {
     destinationTeam = Teams.getTeamWithFewestPlayers(GameHandler.getGameHandler().getMatch());
     if (destinationTeam.isPresent()) {
       destinationTeam.get().add((Player) sender, false);
     } else {
       throw new CommandException(
           ChatConstant.ERROR_TEAMS_FULL.getMessage(ChatUtil.getLocale(sender)));
     }
   }
 }
    @Command(
        aliases = {"take"},
        usage = "<target> <item[:data]> [amount]",
        desc = "Take an item",
        flags = "",
        min = 2,
        max = 3)
    @CommandPermissions({"commandbook.take.other"})
    public void take(CommandContext args, CommandSender sender) throws CommandException {
      ItemStack item = null;
      int amt = config.defaultItemStackSize;
      Player target = null;

      // Two arguments: Player, item type
      if (args.argsLength() == 2) {
        target = PlayerUtil.matchSinglePlayer(sender, args.getString(0));
        item = matchItem(sender, args.getString(1));
        // Three arguments: Player, item type, and item amount
      } else if (args.argsLength() == 3) {
        target = PlayerUtil.matchSinglePlayer(sender, args.getString(0));
        item = matchItem(sender, args.getString(1));
        amt = args.getInteger(2);
      }

      if (item == null) {
        throw new CommandException("Something went wrong parsing the item info!");
      }
      takeItem(sender, item, amt, target);
    }
    @Command(
        aliases = {"item", "i"},
        usage = "[target] <item[:data]> [amount]",
        desc = "Give an item",
        flags = "do",
        min = 1,
        max = 3)
    @CommandPermissions({"commandbook.give"})
    public void item(CommandContext args, CommandSender sender) throws CommandException {
      ItemStack item = null;
      int amt = config.defaultItemStackSize;
      Iterable<Player> targets = null;

      // How this command handles parameters depends on how many there
      // are, so the following code splits the incoming input
      // into three different possibilities

      // One argument: Just the item type and amount 1
      if (args.argsLength() == 1) {
        item = matchItem(sender, args.getString(0));
        targets = PlayerUtil.matchPlayers(PlayerUtil.checkPlayer(sender));
        // Two arguments: Item type and amount
      } else if (args.argsLength() == 2) {
        item = matchItem(sender, args.getString(0));
        amt = args.getInteger(1);
        targets = PlayerUtil.matchPlayers(PlayerUtil.checkPlayer(sender));
        // Three arguments: Player, item type, and item amount
      } else if (args.argsLength() == 3) {
        item = matchItem(sender, args.getString(1));
        amt = args.getInteger(2);
        targets = PlayerUtil.matchPlayers(sender, args.getString(0));

        // Make sure that this player has permission to give items to other
        /// players!
        CommandBook.inst().checkPermission(sender, "commandbook.give.other");
      }

      if (item == null) {
        throw new CommandException("Something went wrong parsing the item info!");
      }
      giveItem(
          sender,
          item,
          amt,
          targets,
          InventoryComponent.this,
          args.hasFlag('d'),
          args.hasFlag('o'));
    }
  @Command(
      aliases = {"/move"},
      usage = "[count] [direction] [leave-id]",
      flags = "s",
      desc = "Move the contents of the selection",
      min = 0,
      max = 3)
  @CommandPermissions("worldedit.region.move")
  @Logging(ORIENTATION_REGION)
  public static void move(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
    Vector dir =
        we.getDirection(player, args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");
    BaseBlock replace;

    // Replacement block argument
    if (args.argsLength() > 2) {
      replace = we.getBlock(player, args.getString(2));
    } else {
      replace = new BaseBlock(BlockID.AIR);
    }

    int affected =
        editSession.moveCuboidRegion(
            session.getSelection(player.getWorld()), dir, count, true, replace);

    if (args.hasFlag('s')) {
      try {
        Region region = session.getSelection(player.getWorld());
        region.expand(dir.multiply(count));
        region.contract(dir.multiply(count));

        session.getRegionSelector().learnChanges();
        session.getRegionSelector().explainRegionAdjust(player, session);
      } catch (RegionOperationException e) {
        player.printError(e.getMessage());
      }
    }

    player.print(affected + " blocks moved.");
  }
Example #6
0
  @Command(
      aliases = {"/redo", "redo"},
      usage = "[times] [player]",
      desc = "Redoes the last action (from history)",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.history.redo")
  public void redo(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    int times = Math.max(1, args.getInteger(0, 1));

    for (int i = 0; i < times; ++i) {
      EditSession redone;
      if (args.argsLength() < 2) {
        redone = session.redo(session.getBlockBag(player));
      } else {
        player.checkPermission("worldedit.history.redo.other");
        LocalSession sess = we.getSession(args.getString(1));
        if (sess == null) {
          player.printError("Unable to find session for " + args.getString(1));
          break;
        }
        redone = sess.redo(session.getBlockBag(player));
      }
      if (redone != null) {
        player.print("Redo successful.");
        we.flushBlockBag(player, redone);
      } else {
        player.printError("Nothing left to redo.");
      }
    }
  }
  @Command(
      aliases = {"/smooth"},
      usage = "[iterations]",
      flags = "n",
      desc = "Smooth the elevation in the selection",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.region.smooth")
  @Logging(REGION)
  public static void smooth(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int iterations = 1;
    if (args.argsLength() > 0) {
      iterations = args.getInteger(0);
    }

    HeightMap heightMap =
        new HeightMap(editSession, session.getSelection(player.getWorld()), args.hasFlag('n'));
    HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
    int affected = heightMap.applyFilter(filter, iterations);
    player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
  }
Example #8
0
 @Command(
     aliases = {"descend"},
     usage = "[# of floors]",
     desc = "Go down a floor",
     min = 0,
     max = 1)
 @CommandPermissions({"worldedit.navigation.descend"})
 public static void descend(
     CommandContext args,
     WorldEdit we,
     LocalSession session,
     LocalPlayer player,
     EditSession editSession)
     throws WorldEditException {
   int levelsToDescend = 0;
   if (args.argsLength() == 0) {
     levelsToDescend = 1;
   } else {
     levelsToDescend = args.getInteger(0);
   }
   int descentLevels = 1;
   while (player.descendLevel() && levelsToDescend != descentLevels) {
     ++descentLevels;
   }
   if (descentLevels == 0) {
     player.printError("No free spot above you found.");
   } else {
     player.print(
         (descentLevels != 1)
             ? "Descended " + Integer.toString(descentLevels) + " levels."
             : "Descended a level.");
   }
 }
  @Command(
      aliases = {"/fillr"},
      usage = "<block> <radius> [depth]",
      desc = "Fill a hole recursively",
      min = 2,
      max = 3)
  @CommandPermissions("worldedit.fill.recursive")
  @Logging(PLACEMENT)
  public void fillr(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    Pattern pattern = we.getBlockPattern(player, args.getString(0));
    double radius = Math.max(1, args.getDouble(1));
    we.checkMaxRadius(radius);
    int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;

    Vector pos = session.getPlacementPosition(player);
    int affected = 0;
    if (pattern instanceof SingleBlockPattern) {
      affected =
          editSession.fillXZ(pos, ((SingleBlockPattern) pattern).getBlock(), radius, depth, true);
    } else {
      affected = editSession.fillXZ(pos, pattern, radius, depth, true);
    }
    player.print(affected + " block(s) have been created.");
  }
Example #10
0
    @Command(
        aliases = {"banip", "ipban"},
        usage = "<target> [reason...]",
        desc = "Ban an IP address",
        flags = "st:",
        min = 1,
        max = -1)
    @CommandPermissions({"commandbook.bans.ban.ip"})
    public void banIP(CommandContext args, CommandSender sender) throws CommandException {

      String message = args.argsLength() >= 2 ? args.getJoinedStrings(1) : "Banned!";
      long endDate = args.hasFlag('t') ? CommandBookUtil.matchFutureDate(args.getFlag('t')) : 0L;

      String addr =
          args.getString(0).replace("\r", "").replace("\n", "").replace("\0", "").replace("\b", "");

      // Need to kick + log
      for (Player player : CommandBook.server().getOnlinePlayers()) {
        if (player.getAddress().getAddress().getHostAddress().equals(addr)) {
          player.kickPlayer(message);
          getBanDatabase().logKick(player, sender, message);
        }
      }

      getBanDatabase().ban(null, addr, sender, message, endDate);

      sender.sendMessage(ChatColor.YELLOW + addr + " banned.");

      if (!getBanDatabase().save()) {
        sender.sendMessage(ChatColor.RED + "Bans database failed to save. See console.");
      }
    }
Example #11
0
  @Command(
      aliases = {"/hsphere"},
      usage = "<block> <radius> [raised?] ",
      desc = "Generate a hollow sphere",
      min = 2,
      max = 3)
  @CommandPermissions({"worldedit.generation.sphere"})
  @Logging(PLACEMENT)
  public static void hsphere(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern block = we.getBlockPattern(player, args.getString(0));
    double radius = Math.max(1, args.getDouble(1));
    boolean raised =
        args.argsLength() > 2
            ? (args.getString(2).equalsIgnoreCase("true")
                || args.getString(2).equalsIgnoreCase("yes"))
            : false;

    Vector pos = session.getPlacementPosition(player);
    if (raised) {
      pos = pos.add(0, radius, 0);
    }

    int affected = editSession.makeSphere(pos, block, radius, false);
    player.findFreePosition();
    player.print(affected + " block(s) have been created.");
  }
  @Command(
      aliases = {"delete"},
      desc = "Lists the areas of the given namespace or lists all areas.",
      usage = "[-n namespace] [area]",
      flags = "an:")
  public void delete(CommandContext context, CommandSender sender) throws CommandException {

    if (!(sender instanceof Player)) return;
    LocalPlayer player = plugin.wrapPlayer((Player) sender);

    String namespace = "~" + player.getName();
    String areaId = null;

    // Get the namespace
    if (context.hasFlag('n')
        && player.hasPermission("craftbook.mech.area.delete." + context.getFlag('n'))) {
      namespace = context.getFlag('n');
    } else if (!player.hasPermission("craftbook.mech.area.delete.self"))
      throw new CommandPermissionsException();

    if (plugin.getConfiguration().areaShortenNames && namespace.length() > 14)
      namespace = namespace.substring(0, 14);

    boolean deleteAll = false;
    if (context.argsLength() > 0 && !context.hasFlag('a')) {
      areaId = context.getString(0);
    } else if (context.hasFlag('a')
        && player.hasPermission("craftbook.mech.area.delete." + namespace + ".all")) {
      deleteAll = true;
    } else throw new CommandException("You need to define an area or -a to delete all areas.");

    // add the area suffix
    areaId = areaId + (config.areaUseSchematics ? ".schematic" : ".cbcopy");

    File areas = null;
    try {
      areas = new File(plugin.getDataFolder(), "areas/" + namespace);
    } catch (Exception ignored) {
    }

    if (areas == null || !areas.exists())
      throw new CommandException("The namespace " + namespace + " does not exist.");

    if (deleteAll) {
      if (deleteDir(areas)) {
        player.print("All areas in the namespace " + namespace + " have been deleted.");
      }
    } else {
      File file = new File(areas, areaId);
      if (file.delete()) {
        player.print(
            "The area '" + areaId + " in the namespace '" + namespace + "' has been deleted.");
      }
    }
  }
Example #13
0
  @Command(
      aliases = {"/stack"},
      usage = "[count] [direction]",
      flags = "sa",
      desc = "Repeat the contents of the selection",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.region.stack")
  @Logging(ORIENTATION_REGION)
  public static void stack(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
    Vector dir =
        we.getDiagonalDirection(
            player, args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");

    int affected =
        editSession.stackCuboidRegion(
            session.getSelection(player.getWorld()), dir, count, !args.hasFlag('a'));

    if (args.hasFlag('s')) {
      try {
        Region region = session.getSelection(player.getWorld());
        region.expand(dir.multiply(count));
        region.contract(dir.multiply(count));

        session.getRegionSelector().learnChanges();
        session.getRegionSelector().explainRegionAdjust(player, session);
      } catch (RegionOperationException e) {
        player.printError(e.getMessage());
      }
    }

    player.print(affected + " blocks changed. Undo with //undo");
  }
  public static void help(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession) {
    final CommandsManager<LocalPlayer> commandsManager = we.getCommandsManager();

    if (args.argsLength() == 0) {
      SortedSet<String> commands =
          new TreeSet<String>(
              new Comparator<String>() {
                @Override
                public int compare(String o1, String o2) {
                  final int ret =
                      o1.replaceAll("/", "").compareToIgnoreCase(o2.replaceAll("/", ""));
                  if (ret == 0) {
                    return o1.compareToIgnoreCase(o2);
                  }
                  return ret;
                }
              });
      commands.addAll(commandsManager.getCommands().keySet());

      StringBuilder sb = new StringBuilder();
      boolean first = true;
      for (String command : commands) {
        if (!first) {
          sb.append(", ");
        }

        sb.append('/');
        sb.append(command);
        first = false;
      }

      player.print(sb.toString());

      return;
    }

    String command = args.getJoinedStrings(0).replaceAll("/", "");

    String helpMessage = commandsManager.getHelpMessages().get(command);
    if (helpMessage == null) {
      player.printError("Unknown command '" + command + "'.");
      return;
    }

    player.print(helpMessage);
  }
  @Command(
      aliases = {"/removebelow", "removebelow"},
      usage = "[size] [height]",
      desc = "Remove blocks below you.",
      min = 0,
      max = 2)
  @CommandPermissions("worldedit.removebelow")
  @Logging(PLACEMENT)
  public void removeBelow(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
    we.checkMaxRadius(size);
    LocalWorld world = player.getWorld();
    int height =
        args.argsLength() > 1
            ? Math.min((world.getMaxY() + 1), args.getInteger(1) + 2)
            : (world.getMaxY() + 1);

    int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height);
    player.print(affected + " block(s) have been removed.");
  }
Example #16
0
  @Command(
      aliases = {"/cut"},
      usage = "[leave-id]",
      desc = "Вырезает выделенную территорию в буфер обмена",
      help =
          "Вырезает выделенную территорию в буфер обмена\n"
              + "Флаги:\n"
              + "  -e controls определяет, будут ли объекты копироваться в буфер обмена\n"
              + "ПРЕДУПРЕЖДЕНИЕ: Вырезанные и вставленные объекты не могут быть отменены!",
      flags = "e",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.clipboard.cut")
  @Logging(REGION)
  public void cut(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    BaseBlock block = new BaseBlock(BlockID.AIR);
    LocalWorld world = player.getWorld();

    if (args.argsLength() > 0) {
      block = we.getBlock(player, args.getString(0));
    }

    Region region = session.getSelection(world);
    Vector min = region.getMinimumPoint();
    Vector max = region.getMaximumPoint();
    Vector pos = session.getPlacementPosition(player);

    CuboidClipboard clipboard =
        new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min, min.subtract(pos));
    clipboard.copy(editSession);
    if (args.hasFlag('e')) {
      LocalEntity[] entities = world.getEntities(region);
      for (LocalEntity entity : entities) {
        clipboard.storeEntity(entity);
      }
      world.killEntities(entities);
    }
    session.setClipboard(clipboard);

    int affected = editSession.setBlocks(session.getSelection(world), block);
    player.print(
        affected
            + " "
            + StringUtil.plural(affected, "блок вырезан", "блока вырезано", "блоков вырезано")
            + ".");
  }
  @Command(
      aliases = {"butcher", "kill"},
      usage = "[radius]",
      flags = "plangbtfr",
      desc = "Butcher brush",
      help =
          "Kills nearby mobs within the specified radius.\n"
              + "Flags:\n"
              + "  -p also kills pets.\n"
              + "  -n also kills NPCs.\n"
              + "  -g also kills Golems.\n"
              + "  -a also kills animals.\n"
              + "  -b also kills ambient mobs.\n"
              + "  -t also kills mobs with name tags.\n"
              + "  -f compounds all previous flags.\n"
              + "  -r also destroys armor stands.\n"
              + "  -l currently does nothing.",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.brush.butcher")
  public void butcherBrush(
      Player player, LocalSession session, EditSession editSession, CommandContext args)
      throws WorldEditException {
    LocalConfiguration config = worldEdit.getConfiguration();

    double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
    double maxRadius = config.maxBrushRadius;
    // hmmmm not horribly worried about this because -1 is still rather efficient,
    // the problem arises when butcherMaxRadius is some really high number but not infinite
    // - original idea taken from https://github.com/sk89q/worldedit/pull/198#issuecomment-6463108
    if (player.hasPermission("worldedit.butcher")) {
      maxRadius = Math.max(config.maxBrushRadius, config.butcherMaxRadius);
    }
    if (radius > maxRadius) {
      player.printError("Maximum allowed brush radius: " + maxRadius);
      return;
    }

    CreatureButcher flags = new CreatureButcher(player);
    flags.fromCommand(args);

    BrushTool tool = session.getBrushTool(player.getItemInHand());
    tool.setSize(radius);
    tool.setBrush(new ButcherBrush(flags), "worldedit.brush.butcher");

    player.print(String.format("Butcher brush equipped (%.0f).", radius));
  }
  @Command(
      aliases = {"/snow", "snow"},
      usage = "[radius]",
      desc = "Simulates snow",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.snow")
  @Logging(PLACEMENT)
  public void snow(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;

    int affected = editSession.simulateSnow(session.getPlacementPosition(player), size);
    player.print(affected + " surfaces covered. Let it snow~");
  }
  @Command(
      aliases = {"/green", "green"},
      usage = "[radius]",
      desc = "Greens the area",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.green")
  @Logging(PLACEMENT)
  public void green(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;

    int affected = editSession.green(session.getPlacementPosition(player), size);
    player.print(affected + " surfaces greened.");
  }
Example #20
0
    @Command(
        aliases = {"kick"},
        usage = "<target> [reason...]",
        desc = "Kick a user",
        flags = "os",
        min = 1,
        max = -1)
    @CommandPermissions({"commandbook.kick"})
    public void kick(CommandContext args, CommandSender sender) throws CommandException {
      Iterable<Player> targets = PlayerUtil.matchPlayers(sender, args.getString(0));
      String message = args.argsLength() >= 2 ? args.getJoinedStrings(1) : "Kicked!";

      String broadcastPlayers = "";
      for (Player player : targets) {
        if (CommandBook.inst().hasPermission(player, "commandbook.kick.exempt")
            && !(args.hasFlag('o')
                && CommandBook.inst().hasPermission(sender, "commandbook.kick.exempt.override"))) {
          sender.sendMessage(
              ChatColor.RED
                  + "Player "
                  + player.getName()
                  + ChatColor.RED
                  + " is exempt from being kicked!");
          continue;
        }
        player.kickPlayer(message);
        broadcastPlayers += PlayerUtil.toColoredName(player, ChatColor.YELLOW) + " ";
        getBanDatabase().logKick(player, sender, message);
      }

      if (broadcastPlayers.length() > 0) {
        sender.sendMessage(ChatColor.YELLOW + "Player(s) kicked.");
        // Broadcast the Message
        if (config.broadcastKicks && !args.hasFlag('s')) {
          BasePlugin.server()
              .broadcastMessage(
                  ChatColor.YELLOW
                      + PlayerUtil.toColoredName(sender, ChatColor.YELLOW)
                      + " has kicked "
                      + broadcastPlayers
                      + " - "
                      + message);
        }
      }
    }
  @Override
  public void processCommand(String header, CommandContext args, Player player) {
    if (!header.equals("sb")) return;

    if (args.argsLength() == 0) {
      player.sendMessage("SoundByte!");
      return;
    }
    if (Helper.argEquals(args.getString(0), "CreateSoundByte")) {
      Block st = player.getLocation().getBlock();
      BlockFace face = getCardinalDirection(player);
      createBoard(st, face);
      created = true;
      return;
    }

    player.sendMessage("Tetris Command not found: " + args.getString(0));
  }
 @Command(
     aliases = {"flushstates", "clearstates"},
     usage = "[player]",
     desc = "Flush the state manager",
     max = 1)
 @CommandPermissions("worldguard.flushstates")
 public void flushStates(CommandContext args, CommandSender sender) throws CommandException {
   if (args.argsLength() == 0) {
     plugin.getFlagStateManager().forgetAll();
     sender.sendMessage("Cleared all states.");
   } else {
     Player player = plugin.getServer().getPlayer(args.getString(0));
     if (player != null) {
       plugin.getFlagStateManager().forget(player);
       sender.sendMessage("Cleared states for player \"" + player.getName() + "\".");
     }
   }
 }
 @Command(
     aliases = {"settings"},
     desc = "List all settings.",
     usage = "[page]")
 public static void settings(final CommandContext cmd, CommandSender sender)
     throws CommandException {
   if (cmd.argsLength() == 0) {
     Bukkit.dispatchCommand(sender, "settings 1");
   } else {
     int page = cmd.getInteger(0);
     if (page > (Settings.getSettings().size() + 7) / 8)
       throw new CommandException(
           "Invalid page number specified! "
               + ((Settings.getSettings().size() + 7) / 8)
               + " total pages.");
     sender.sendMessage(
         ChatColor.RED
             + ""
             + ChatColor.STRIKETHROUGH
             + "--------------"
             + ChatColor.YELLOW
             + " Settings (Page "
             + page
             + " of "
             + ((Settings.getSettings().size() + 7) / 8)
             + ") "
             + ChatColor.RED
             + ""
             + ChatColor.STRIKETHROUGH
             + "--------------");
     for (int i = (page - 1) * 8; i < page * 8; i++) {
       if (i < Settings.getSettings().size())
         sender.sendMessage(
             ChatColor.YELLOW
                 + Settings.getSettings().get(i).getNames().get(0)
                 + ": "
                 + ChatColor.WHITE
                 + Settings.getSettings().get(i).getDescription());
     }
   }
 }
Example #24
0
  @Command(
      aliases = {"pumpkins"},
      usage = "[size]",
      desc = "Generate pumpkin patches",
      min = 0,
      max = 1)
  @CommandPermissions({"worldedit.generation.pumpkins"})
  @Logging(POSITION)
  public static void pumpkins(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;

    int affected = editSession.makePumpkinPatches(player.getPosition(), size);
    player.print(affected + " pumpkin patches created.");
  }
  @Command(
      aliases = {"/ex", "/ext", "/extinguish", "ex", "ext", "extinguish"},
      usage = "[radius]",
      desc = "Extinguish nearby fire",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.extinguish")
  @Logging(PLACEMENT)
  public void extinguish(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    LocalConfiguration config = we.getConfiguration();

    int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
    int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : defaultRadius;
    we.checkMaxRadius(size);

    int affected = editSession.removeNear(session.getPlacementPosition(player), 51, size);
    player.print(affected + " block(s) have been removed.");
  }
  @Command(
      aliases = {"addserver"},
      desc = "Add a BungeeCord server",
      usage = "<name> <address> [port]",
      flags = "r",
      min = 2,
      max = 4)
  @CommandPermissions("bungeeutils.addserver")
  public static void addserver(final CommandContext args, CommandSender sender)
      throws CommandException {
    String name = args.getString(0);
    String address = args.getString(1);
    int port = args.argsLength() > 2 ? args.getInteger(2) : 25565;
    boolean restricted = args.hasFlag('r');

    ServerInfo serverInfo =
        ProxyServer.getInstance()
            .constructServerInfo(name, new InetSocketAddress(address, port), "", restricted);
    ProxyServer.getInstance().getServers().put(name, serverInfo);

    sender.sendMessage(ChatColor.GREEN + "Added server " + ChatColor.GOLD + name);
  }
Example #27
0
  @Command(
      aliases = {"/replace"},
      usage = "[from-block] <to-block>",
      desc = "Replace all blocks in the selection with another",
      flags = "f",
      min = 1,
      max = 2)
  @CommandPermissions("worldedit.region.replace")
  @Logging(REGION)
  public static void replace(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Set<BaseBlock> from;
    Pattern to;
    if (args.argsLength() == 1) {
      from = null;
      to = we.getBlockPattern(player, args.getString(0));
    } else {
      from = we.getBlocks(player, args.getString(0), true, !args.hasFlag('f'));
      to = we.getBlockPattern(player, args.getString(1));
    }

    int affected = 0;
    if (to instanceof SingleBlockPattern) {
      affected =
          editSession.replaceBlocks(
              session.getSelection(player.getWorld()), from, ((SingleBlockPattern) to).getBlock());
    } else {
      affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to);
    }

    player.print(affected + " block(s) have been replaced.");
  }
Example #28
0
  @Command(
      aliases = {"/flip"},
      usage = "[dir]",
      flags = "p",
      desc = "Переворачивает содержимое буфера обмена.",
      help =
          "Переворачивает содержимое буфера обмена.\n"
              + "Флаг -p переворачивает выделенную территорию вокруг игрока,\n"
              + "а не центра выделения.",
      min = 0,
      max = 1)
  @CommandPermissions("worldedit.clipboard.flip")
  public void flip(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    CuboidClipboard.FlipDirection dir =
        we.getFlipDirection(player, args.argsLength() > 0 ? args.getString(0).toLowerCase() : "me");

    CuboidClipboard clipboard = session.getClipboard();
    clipboard.flip(dir, args.hasFlag('p'));
    player.print("Содержимое буфера обмена перевернуто.");
  }
Example #29
0
    @Command(
        aliases = {"unbanip", "unipban"},
        usage = "<target> [reason...]",
        desc = "Unban an IP address",
        min = 1,
        max = -1)
    @CommandPermissions({"commandbook.bans.unban.ip"})
    public void unbanIP(CommandContext args, CommandSender sender) throws CommandException {

      String addr =
          args.getString(0).replace("\r", "").replace("\n", "").replace("\0", "").replace("\b", "");
      String message = args.argsLength() >= 2 ? args.getJoinedStrings(1) : "Unbanned!";

      if (getBanDatabase().unban(null, addr, sender, message)) {
        sender.sendMessage(ChatColor.YELLOW + addr + " unbanned.");

        if (!getBanDatabase().save()) {
          sender.sendMessage(ChatColor.RED + "Bans database failed to save. See console.");
        }
      } else {
        sender.sendMessage(ChatColor.RED + addr + " was not banned.");
      }
    }
  @Command(
      aliases = {"/replacenear", "replacenear"},
      usage = "<size> <from-id> <to-id>",
      desc = "Replace nearby blocks",
      flags = "f",
      min = 3,
      max = 3)
  @CommandPermissions("worldedit.replacenear")
  @Logging(PLACEMENT)
  public void replaceNear(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    int size = Math.max(1, args.getInteger(0));
    int affected;
    Set<BaseBlock> from;
    Pattern to;
    if (args.argsLength() == 2) {
      from = null;
      to = we.getBlockPattern(player, args.getString(1));
    } else {
      from = we.getBlocks(player, args.getString(1), true, !args.hasFlag('f'));
      to = we.getBlockPattern(player, args.getString(2));
    }

    Vector base = session.getPlacementPosition(player);
    Vector min = base.subtract(size, size, size);
    Vector max = base.add(size, size, size);
    Region region = new CuboidRegion(player.getWorld(), min, max);

    if (to instanceof SingleBlockPattern) {
      affected = editSession.replaceBlocks(region, from, ((SingleBlockPattern) to).getBlock());
    } else {
      affected = editSession.replaceBlocks(region, from, to);
    }
    player.print(affected + " block(s) have been replaced.");
  }