예제 #1
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.");
      }
    }
예제 #2
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.");
      }
    }
  }
예제 #3
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.");
  }
예제 #4
0
  @Command(
      aliases = {"/paste"},
      usage = "",
      flags = "ao",
      desc = "Вставляет содержимое буфера обмена",
      help =
          "Вставить содержимое буфера обмена.\n"
              + "Флаги:\n"
              + "  -a пропускает блоки воздуха\n"
              + "  -o вставляет на позициях, которые были скопированы/вырезаны",
      min = 0,
      max = 0)
  @CommandPermissions("worldedit.clipboard.paste")
  @Logging(PLACEMENT)
  public void paste(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    boolean atOrigin = args.hasFlag('o');
    boolean pasteNoAir = args.hasFlag('a');

    if (atOrigin) {
      Vector pos = session.getClipboard().getOrigin();
      session.getClipboard().place(editSession, pos, pasteNoAir);
      session.getClipboard().pasteEntities(pos);
      player.findFreePosition();
      player.print("Вставлено. Для отмены напишите //undo");
    } else {
      Vector pos = session.getPlacementPosition(player);
      session.getClipboard().paste(editSession, pos, pasteNoAir, true);
      player.findFreePosition();
      player.print("Вставлено. Для отмены напишите //undo");
    }
  }
예제 #5
0
  @Command(
      aliases = {"/hpyramid"},
      usage = "<block> <range>",
      desc = "Generate a hollow pyramid",
      min = 2,
      max = 2)
  @CommandPermissions({"worldedit.generation.pyramid"})
  @Logging(PLACEMENT)
  public static void hpyramid(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern block = we.getBlockPattern(player, args.getString(0));
    int size = Math.max(1, args.getInteger(1));
    Vector pos = session.getPlacementPosition(player);

    int affected = editSession.makePyramid(pos, block, size, false);

    player.findFreePosition();
    player.print(affected + " block(s) have been created.");
  }
예제 #6
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)));
     }
   }
 }
예제 #7
0
 @Command(
     aliases = {"set"},
     desc = "Set a setting to a specific value.",
     usage = "<setting> <value>",
     min = 2)
 public static void set(final CommandContext cmd, CommandSender sender) throws CommandException {
   if (sender instanceof Player) {
     if (Settings.getSettingByName(cmd.getString(0)) != null) {
       if (Settings.getSettingByName(cmd.getString(0)).getSettingValueByName(cmd.getString(1))
           != null) {
         Settings.getSettingByName(cmd.getString(0))
             .setValueByPlayer(
                 (Player) sender,
                 Settings.getSettingByName(cmd.getString(0))
                     .getSettingValueByName(cmd.getString(1)));
         sender.sendMessage(
             ChatColor.YELLOW
                 + Settings.getSettingByName(cmd.getString(0)).getNames().get(0)
                 + ": "
                 + ChatColor.WHITE
                 + Settings.getSettingByName(cmd.getString(0))
                     .getSettingValueByName(cmd.getString(1))
                     .getValue());
         if (Settings.getSettingByName("Observers") != null
             && Settings.getSettingByName(cmd.getString(0))
                 .equals(Settings.getSettingByName("Observers"))) {
           Bukkit.getServer()
               .getPluginManager()
               .callEvent(new PlayerVisibilityChangeEvent((Player) sender));
         }
       } else throw new CommandException("No value by this name!");
     } else throw new CommandException("No setting by this name!");
   } else throw new CommandException("Console cannot use this command.");
 }
  @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.");
  }
예제 #9
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.");
   }
 }
예제 #10
0
  @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.");
  }
  @Command(
      aliases = {"remove", "rem", "rement"},
      usage = "<type> <radius>",
      desc = "Remove all entities of a type",
      min = 2,
      max = 2)
  @CommandPermissions("worldedit.remove")
  @Logging(PLACEMENT)
  public void remove(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    String typeStr = args.getString(0);
    int radius = args.getInteger(1);

    if (radius < -1) {
      player.printError("Use -1 to remove all entities in loaded chunks");
      return;
    }

    EntityType type = null;

    if (typeStr.matches("all")) {
      type = EntityType.ALL;
    } else if (typeStr.matches("projectiles?|arrows?")) {
      type = EntityType.PROJECTILES;
    } else if (typeStr.matches("items?") || typeStr.matches("drops?")) {
      type = EntityType.ITEMS;
    } else if (typeStr.matches("falling(blocks?|sand|gravel)")) {
      type = EntityType.FALLING_BLOCKS;
    } else if (typeStr.matches("paintings?") || typeStr.matches("art")) {
      type = EntityType.PAINTINGS;
    } else if (typeStr.matches("(item)frames?")) {
      type = EntityType.ITEM_FRAMES;
    } else if (typeStr.matches("boats?")) {
      type = EntityType.BOATS;
    } else if (typeStr.matches("minecarts?") || typeStr.matches("carts?")) {
      type = EntityType.MINECARTS;
    } else if (typeStr.matches("tnt")) {
      type = EntityType.TNT;
    } else if (typeStr.matches("xp")) {
      type = EntityType.XP_ORBS;
    } else {
      player.printError(
          "Acceptable types: projectiles, items, paintings, itemframes, boats, minecarts, tnt, xp, or all");
      return;
    }

    Vector origin = session.getPlacementPosition(player);
    int removed = player.getWorld().removeEntities(type, origin, radius);
    player.print("Marked " + removed + " entit(ies) for removal.");
  }
  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);
  }
예제 #13
0
    @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'));
    }
예제 #14
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 = "toggle",
      desc = "Toggle an area sign at the given location.",
      usage = "[-w world] <x,y,z>",
      flags = "sw:",
      min = 1)
  @CommandPermissions("craftbook.mech.area.command.toggle")
  public void toggle(CommandContext context, CommandSender sender) throws CommandException {

    World world = null;
    boolean hasWorldFlag = context.hasFlag('w');

    if (hasWorldFlag) {
      world = Bukkit.getWorld(context.getFlag('w'));
    } else if (sender instanceof Player) {
      world = ((Player) sender).getWorld();
    }

    if (world == null) {
      throw new CommandException(
          "You must be a player or specify a valid world to use this command.");
    }

    int[] xyz = new int[3];
    String[] loc = context.getString(0).split(",");

    if (loc.length != 3) {
      throw new CommandException("Invalid location specified.");
    }

    try {
      for (int i = 0; i < xyz.length; i++) {
        xyz[i] = Integer.parseInt(loc[i]);
      }
    } catch (NumberFormatException ex) {
      throw new CommandException("Invalid location specified.");
    }

    Block block = world.getBlockAt(xyz[0], xyz[1], xyz[2]);
    if (!SignUtil.isSign(block))
      throw new CommandException("No sign found at the specified location.");

    if (!Area.toggleCold(BukkitUtil.toChangedSign(block))) {
      throw new CommandException("Failed to toggle an area at the specified location.");
    }
    // TODO Make a sender wrap for this
    if (!context.hasFlag('s')) sender.sendMessage(ChatColor.YELLOW + "Area toggled!");
  }
예제 #16
0
  @Command(
      aliases = {"/set"},
      usage = "<block>",
      desc = "Set all the blocks inside the selection to a block",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.region.set")
  @Logging(REGION)
  public static void set(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern pattern = we.getBlockPattern(player, args.getString(0));

    int affected;

    if (pattern instanceof SingleBlockPattern) {
      affected =
          editSession.setBlocks(
              session.getSelection(player.getWorld()), ((SingleBlockPattern) pattern).getBlock());
    } else {
      affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern);
    }

    player.print(affected + " block(s) have been changed.");
  }
예제 #17
0
    @Command(
        aliases = {"baninfo"},
        usage = "<target>",
        desc = "Check if a user is banned",
        min = 1,
        max = 1)
    @CommandPermissions({"commandbook.bans.baninfo"})
    public void banInfo(CommandContext args, CommandSender sender) throws CommandException {
      String banName =
          args.getString(0).replace("\r", "").replace("\n", "").replace("\0", "").replace("\b", "");

      Ban ban = getBanDatabase().getBannedName(banName);

      if (ban == null) {
        sender.sendMessage(ChatColor.YELLOW + banName + " is NOT banned.");
      } else {
        sender.sendMessage(
            ChatColor.YELLOW
                + "Ban for "
                + banName
                + ":"
                + ban.getAddress()
                + " for reason: '"
                + ban.getReason()
                + "' until "
                + (ban.getEnd() == 0L ? " forever" : dateFormat.format(new Date(ban.getEnd()))));
      }
    }
예제 #18
0
  @Command(
      aliases = {"/overlay"},
      usage = "<block>",
      desc = "Set a block on top of blocks in the region",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.region.overlay")
  @Logging(REGION)
  public static void overlay(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern pat = we.getBlockPattern(player, args.getString(0));

    Region region = session.getSelection(player.getWorld());
    int affected = 0;
    if (pat instanceof SingleBlockPattern) {
      affected = editSession.overlayCuboidBlocks(region, ((SingleBlockPattern) pat).getBlock());
    } else {
      affected = editSession.overlayCuboidBlocks(region, pat);
    }
    player.print(affected + " block(s) have been overlayed.");
  }
예제 #19
0
  @Command(
      aliases = {"/faces", "/outline"},
      usage = "<block>",
      desc = "Build the walls, ceiling, and floor of a selection",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.region.faces")
  @Logging(REGION)
  public static void faces(
      CommandContext args,
      WorldEdit we,
      LocalSession session,
      LocalPlayer player,
      EditSession editSession)
      throws WorldEditException {

    Pattern pattern = we.getBlockPattern(player, args.getString(0));
    int affected;
    if (pattern instanceof SingleBlockPattern) {
      affected =
          editSession.makeCuboidFaces(
              session.getSelection(player.getWorld()), ((SingleBlockPattern) pattern).getBlock());
    } else {
      affected = editSession.makeCuboidFaces(session.getSelection(player.getWorld()), pattern);
    }

    player.print(affected + " block(s) have been changed.");
  }
예제 #20
0
  @Command(
      aliases = {"/copy"},
      flags = "e",
      desc = "Копирует выделенную территорию в буфер обмена",
      help =
          "Копирует выделенную территорию в буфер обмен\n"
              + "Флаги:\n"
              + "  -e определяет, будут ли объекты копироваться в буфер обмена\n"
              + "ПРЕДУПРЕЖДЕНИЕ: Вставленные объекты не могут быть отменены!",
      min = 0,
      max = 0)
  @CommandPermissions("worldedit.clipboard.copy")
  public void copy(
      CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
      throws WorldEditException {

    Region region = session.getSelection(player.getWorld());
    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')) {
      for (LocalEntity entity : player.getWorld().getEntities(region)) {
        clipboard.storeEntity(entity);
      }
    }
    session.setClipboard(clipboard);

    player.print("Блок(и) скопирован(ы).");
  }
  @Command(
      aliases = {"serverlist"},
      desc = "List all BungeeCord servers",
      usage = "[page]",
      min = 0,
      max = 1)
  @CommandPermissions("bungeeutils.serverlist")
  public static void serverlist(final CommandContext args, CommandSender sender)
      throws CommandException {
    final Collection<ServerInfo> servers = BungeeCord.getInstance().getServers().values();

    new SimplePaginatedResult<ServerInfo>("BungeeCord Servers") {
      @Override
      public String format(ServerInfo server, int index) {
        return (index + 1)
            + ". "
            + ChatColor.RED
            + server.getName()
            + ChatColor.GREEN
            + server.getAddress().getHostString()
            + ":"
            + server.getAddress().getPort();
      }
    }.display(new BungeeWrappedCommandSender(sender), servers, args.getInteger(0, 1) /* page */);
  }
예제 #22
0
 @Command(
     aliases = {"dispenser"},
     usage = "<nom_distributeur>",
     desc = "Information sur un distributeur.",
     min = 1,
     max = 1)
 @CommandPermissions({"mho.donjon.admin"})
 public void dispenser(CommandContext args, CommandSender sender) {
   Player player = null;
   if (sender instanceof Player) {
     player = (Player) sender;
   } else {
     return;
   }
   String donjon = Manager.getDonjon().getDonjon(player.getName());
   String dispenser = args.getString(0).toLowerCase();
   if (Manager.getDonjon().existDonjon(donjon)) {
     if (Manager.getDonjon().existDispenser(donjon, dispenser)) {
       player.sendMessage(
           "Information du Distributeur: " + ChatColor.GREEN + dispenser + ChatColor.RESET);
       player.sendMessage(Manager.getDonjon().infoLocationDispenser(donjon, dispenser));
       String[] items = Manager.getDonjon().infoItemsDispenser(donjon, dispenser);
       for (String item : items) {
         player.sendMessage("Item: " + item);
       }
     } else {
       player.sendMessage(ChatColor.RED + "Le distributeur n'existe pas." + ChatColor.RESET);
     }
   } else {
     player.sendMessage(ChatColor.RED + "Le donjon n'existe pas." + ChatColor.RESET);
   }
 }
예제 #23
0
 @Command(
     aliases = {"chest"},
     usage = "<nom_coffre>",
     desc = "Information sur un coffre.",
     min = 1,
     max = 1)
 @CommandPermissions({"mho.donjon.admin"})
 public void chest(CommandContext args, CommandSender sender) {
   Player player = null;
   if (sender instanceof Player) {
     player = (Player) sender;
   } else {
     return;
   }
   String donjon = Manager.getDonjon().getDonjon(player.getName());
   String chest = args.getString(0).toLowerCase();
   if (Manager.getDonjon().existDonjon(donjon)) {
     if (Manager.getDonjon().existChest(donjon, chest)) {
       player.sendMessage("Information du Coffre: " + ChatColor.GREEN + chest + ChatColor.RESET);
       player.sendMessage(Manager.getDonjon().infoLocationChest(donjon, chest));
       String[] items = Manager.getDonjon().infoItemsChest(donjon, chest);
       for (String item : items) {
         player.sendMessage("Item: " + item);
       }
     } else {
       player.sendMessage(ChatColor.RED + "Le coffre n'existe pas." + ChatColor.RESET);
     }
   } else {
     player.sendMessage(ChatColor.RED + "Le donjon n'existe pas." + ChatColor.RESET);
   }
 }
  @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.");
  }
예제 #27
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.");
  }
예제 #28
0
    @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);
    }
예제 #29
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);
        }
      }
    }
예제 #30
0
  @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));
  }