public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
    if (src instanceof Player) {
      Player player = (Player) src;
      ExperienceHolderData expHolderData = player.getOrCreate(ExperienceHolderData.class).get();
      player.sendMessage(
          Text.of(
              TextColors.GOLD,
              "Your current experience: ",
              TextColors.GRAY,
              expHolderData.totalExperience().get()));
      player.sendMessage(
          Text.of(
              TextColors.GOLD,
              "Experience to next level: ",
              TextColors.GRAY,
              expHolderData.getExperienceBetweenLevels().get()
                  - expHolderData.experienceSinceLevel().get()));
    } else {
      src.sendMessage(
          Text.of(
              TextColors.DARK_RED,
              "Error! ",
              TextColors.RED,
              "You must be an in-game player to use this command!"));
    }

    return CommandResult.success();
  }
Exemple #2
0
  @Listener
  public void onServerStarting(GameStartingServerEvent event) {
    GlobalCommands globalCommands = new GlobalCommands(this);
    CommandSpec map =
        CommandSpec.builder()
            .description(Text.of("All commands related to the chunk protection"))
            .executor(globalCommands::map)
            .build();

    CommandSpec claim =
        CommandSpec.builder()
            .description(Text.of("Claims the chunk that you are standing"))
            .executor(globalCommands::claim)
            .build();

    CommandSpec chunk =
        CommandSpec.builder()
            .description(Text.of("Commands related to chunk protection"))
            .child(map, "map")
            .child(claim, "claim")
            .build();

    CommandSpec mychunk =
        CommandSpec.builder()
            .description(Text.of("All mychunk commands"))
            .child(chunk, "chunk", "c")
            .build();

    Sponge.getCommandManager().register(this, chunk, "chunk");
    Sponge.getCommandManager().register(this, mychunk, "mychunk");
  }
  @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();
    }
  }
  public static CommandSpec getCommand() {
    return CommandSpec.builder()
        .arguments(
            GenericArguments.player(Text.of("player")), new ChannelArgument(Text.of("channel")))
        .description(Text.of("Unban player from channel."))
        .permission("darmok.mod")
        .executor(
            (source, args) -> {
              Player player = args.<Player>getOne("player").get();
              Channel channel = args.<Channel>getOne("channel").get();

              Darmok.getPlayerRegistry().unbanFromChannel(player, channel);

              player.sendMessage(
                  Format.error(
                      String.format(
                          "You have been unbanned from the %s channel.", channel.getName())));
              source.sendMessage(
                  Format.heading(
                      String.format(
                          "You have unbanned %s from channel %s",
                          player.getName(), channel.getName())));

              return CommandResult.success();
            })
        .build();
  }
Exemple #5
0
 /** @return */
 public Text replaceCensoredWords(Text msg) {
   String msgString = Text.of(msg).toPlain();
   for (String w : censorWords) {
     msgString = msgString.replaceAll("(?i)" + w, "*****");
   }
   return Text.of(msgString);
 }
  public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
    if (src instanceof Player) {
      Player player = (Player) src;

      if (player.getItemInHand().isPresent()) {
        ItemStack itemInHand = player.getItemInHand().get();
        player.sendMessage(
            Text.of(
                TextColors.GOLD,
                "The ID of the item in your hand is: ",
                TextColors.GRAY,
                itemInHand.getItem().getName()));
        player.sendMessage(
            Text.of(
                TextColors.GOLD,
                "The meta of the item in your hand is: ",
                TextColors.GRAY,
                itemInHand.toContainer().get(DataQuery.of("UnsafeDamage")).get().toString()));
      } else {
        player.sendMessage(
            Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must hold an item."));
      }
    } else {
      src.sendMessage(
          Text.of(
              TextColors.DARK_RED,
              "Error! ",
              TextColors.RED,
              "You must be an in-game player to use this command."));
    }

    return CommandResult.success();
  }
Exemple #7
0
  @Override
  public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {

    String name = args.<String>getOne("name").get();
    if (src instanceof Player && EzpzPvpKit.getInstance().isQueueExisting(name)) {
      Player player = (Player) src;
      PvPPlayer pvpPlayer = EzpzPvpKit.getInstance().getPlayer(player.getIdentifier());
      Team team = EzpzPvpKit.getInstance().getTeam(pvpPlayer.getTeam());
      DuelQueue queue = EzpzPvpKit.getInstance().getQueue(name);
      // Size ?
      if (team.getSize() != queue.getSize())
        Utils.sendKitMessage(
            player, Text.of(TextColors.RED, "Party size doesn't match queue size"));
      // Is in duel ?
      else if (team.getInMatch())
        Utils.sendKitMessage(player, Text.of(TextColors.RED, "Cannot join queue in duel"));
      else {
        // is in other queue ?
        if (team.getQueue() != null) EzpzPvpKit.getInstance().getQueue(team.getQueue()).leave(team);
        queue.join(team);
        for (String it : team.getPlayers())
          Utils.sendKitMessage(
              EzpzPvpKit.getInstance().getPlayer(it).getPlayer(),
              Text.of("You joined queue : " + name));
      }

    } else if (src instanceof Player && !EzpzPvpKit.getInstance().isQueueExisting(name))
      Utils.sendKitMessage((Player) src, Text.of(TextColors.RED, "this queue doesn't exist"));
    else if (src instanceof ConsoleSource) Utils.sendMessageC(src);
    else if (src instanceof CommandBlockSource) Utils.sendMessageCB(src);

    return CommandResult.success();
  }
  @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();
  }
Exemple #9
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();
  }
Exemple #10
0
  @Override
  public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (!args.hasAny("old")) {
      src.sendMessage(invalidArg());
      return CommandResult.empty();
    }

    String oldWorldName = args.<String>getOne("old").get();

    if (oldWorldName.equalsIgnoreCase("@w")) {
      if (src instanceof Player) {
        oldWorldName = ((Player) src).getWorld().getName();
      }
    }

    if (!args.hasAny("new")) {
      src.sendMessage(invalidArg());
      return CommandResult.empty();
    }

    String newWorldName = args.<String>getOne("new").get();

    for (WorldProperties world : Main.getGame().getServer().getAllWorldProperties()) {
      if (!world.getWorldName().equalsIgnoreCase(newWorldName)) {
        continue;
      }

      src.sendMessage(Text.of(TextColors.DARK_RED, newWorldName, " already exists"));
      return CommandResult.empty();
    }

    if (!Main.getGame().getServer().getWorld(oldWorldName).isPresent()) {
      src.sendMessage(Text.of(TextColors.DARK_RED, "World ", oldWorldName, " does not exists"));
      return CommandResult.empty();
    }

    Optional<WorldProperties> copy = null;
    try {
      copy =
          Main.getGame()
              .getServer()
              .copyWorld(
                  Main.getGame().getServer().getWorld(oldWorldName).get().getProperties(),
                  newWorldName)
              .get();
    } catch (InterruptedException | ExecutionException e) {
      e.printStackTrace();
    }

    if (!copy.isPresent()) {
      src.sendMessage(Text.of(TextColors.DARK_RED, "Could not copy ", oldWorldName));
      return CommandResult.empty();
    }

    src.sendMessage(Text.of(TextColors.DARK_GREEN, oldWorldName, " copied to ", newWorldName));

    return CommandResult.success();
  }
Exemple #11
0
 /**
  * @param msg
  * @return
  */
 public Text filterCaps(Text msg, int minLength, int capsPercent) {
   String msgString = Text.of(msg).toPlain();
   if (msgString.length() < minLength) {
     return msg;
   }
   if (capsPercentage(msgString) > capsPercent) {
     msgString = msgString.toLowerCase();
   }
   return Text.of(msgString);
 }
  public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
    if (src instanceof Player) {
      Player player = (Player) src;
      String playerTeamName = ConfigManager.getTeam(player.getUniqueId());

      if (playerTeamName != null
          && !ConfigManager.getMembers(playerTeamName).contains(player.getUniqueId().toString())) {
        BigDecimal money =
            ConfigManager.getClaimCost()
                .multiply(new BigDecimal(ConfigManager.getClaims(playerTeamName)));
        Polis.economyService
            .getOrCreateAccount(playerTeamName)
            .get()
            .deposit(
                Polis.economyService.getDefaultCurrency(),
                money,
                Cause.of(NamedCause.source(player)));
        ConfigManager.depositToTownBank(money, playerTeamName);
        ConfigManager.removeClaims(playerTeamName);
        player.sendMessage(
            Text.of(
                TextColors.GREEN,
                "[Polis]: ",
                TextColors.GOLD,
                "Successfully removed all claims!"));
      } else if (playerTeamName != null) {
        player.sendMessage(
            Text.of(
                TextColors.GREEN,
                "[Polis]: ",
                TextColors.DARK_RED,
                "Error! ",
                TextColors.RED,
                "Ask your leader to remove all claims!"));
      } else {
        player.sendMessage(
            Text.of(
                TextColors.GREEN,
                "[Polis]: ",
                TextColors.DARK_RED,
                "Error! ",
                TextColors.RED,
                "You're not part of a town!"));
      }
    } else {
      src.sendMessage(
          Text.of(
              TextColors.DARK_RED,
              "Error! ",
              TextColors.RED,
              "Must be an in-game player to use /polis unclaimall!"));
    }

    return CommandResult.success();
  }
  public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
    if (src instanceof Player) {
      Player player = (Player) src;
      Player target = ctx.<Player>getOne("target").get();

      player.sendMessage(Text.of(TextColors.DARK_AQUA, "You have slapped ", target.getName()));
      target.sendMessage(
          Text.of(TextColors.DARK_AQUA, "You have been slapped by ", player.getName()));
    }
    return CommandResult.success();
  }
 @Nonnull
 @Override
 public CommandSpec getSpec() {
   return CommandSpec.builder()
       .description(Text.of("Mob Spawner Command"))
       .permission("essentialcmds.mobspawner.use")
       .arguments(
           GenericArguments.onlyOne(
               GenericArguments.catalogedElement(Text.of("mob"), EntityType.class)))
       .executor(this)
       .build();
 }
 @Nonnull
 @Override
 public CommandSpec getSpec() {
   return CommandSpec.builder()
       .description(Text.of("Fireball Command"))
       .permission("essentialcmds.fireball.use")
       .arguments(
           GenericArguments.optional(
               GenericArguments.onlyOne(GenericArguments.player(Text.of("player")))))
       .executor(new FireballExecutor())
       .build();
 }
  @Listener
  public void onStopped(MinigameStoppedEvent event) {
    if (event.getMinigame().equals(this)) {
      for (Player player : players()) {
        player.setScoreboard(null);

        if (this.teamAPoints > this.teamBPoints)
          player.sendMessage(
              Text.of(
                  TextColors.BLUE,
                  "[UltimateGames]: ",
                  TextColors.GREEN,
                  "Team A has won the Deathmatch!"));
        else if (this.teamBPoints > this.teamAPoints)
          player.sendMessage(
              Text.of(
                  TextColors.BLUE,
                  "[UltimateGames]: ",
                  TextColors.GREEN,
                  "Team B has won the Deathmatch!"));
        else
          player.sendMessage(
              Text.of(
                  TextColors.BLUE,
                  "[UltimateGames]: ",
                  TextColors.GRAY,
                  "The deathmatch has ended with a draw!"));

        player.sendMessage(
            Text.of(
                TextColors.BLUE, "[UltimateGames]: ", TextColors.GREEN, "Deathmatch has ended!"));

        if (player
            .getWorld()
            .getUniqueId()
            .equals(this.arena.getSpawn().getLocation().getExtent().getUniqueId())) {
          player.setLocation(this.arena.getSpawn().getLocation());
        } else {
          player.transferToWorld(
              this.arena.getSpawn().getLocation().getExtent().getUniqueId(),
              this.arena.getSpawn().getLocation().getPosition());
        }

        player.sendMessage(
            Text.of(
                TextColors.BLUE,
                "[UltimateGames]: ",
                TextColors.GREEN,
                "Teleported back to lobby."));
      }
    }
  }
 private Text invalidArg() {
   Text t1 = Text.of(TextColors.YELLOW, "/world hardcore ");
   Text t2 =
       Text.builder()
           .color(TextColors.YELLOW)
           .onHover(
               TextActions.showText(
                   Text.of("Enter world or @w for current world or @a for all worlds")))
           .append(Text.of("<world> "))
           .build();
   Text t3 = Text.of(TextColors.YELLOW, "[true/false]");
   return Text.of(t1, t2, t3);
 }
Exemple #18
0
 @Nonnull
 @Override
 public CommandSpec getSpec() {
   return CommandSpec.builder()
       .description(Text.of("Experience Give Command"))
       .permission("essentialcmds.exp.give.use")
       .arguments(
           GenericArguments.seq(
               GenericArguments.player(Text.of("target")),
               GenericArguments.integer(Text.of("exp"))))
       .executor(this)
       .build();
 }
 @Nonnull
 @Override
 public CommandSpec getSpec() {
   return CommandSpec.builder()
       .description(Text.of(description))
       .permission(perm)
       .arguments(
           GenericArguments.onlyOne(GenericArguments.player(Text.of("player"))),
           GenericArguments.optional(
               GenericArguments.onlyOne(
                   GenericArguments.remainingJoinedStrings(Text.of("reason")))))
       .executor(this)
       .build();
 }
Exemple #20
0
 @Override
 public CommandSpec createSpec() {
   return CommandSpec.builder()
       .executor(this)
       .arguments(
           GenericArguments.optionalWeak(
               GenericArguments.onlyOne(
                   GenericArguments.requiringPermission(
                       GenericArguments.player(Text.of(player)),
                       permissions.getPermissionWithSuffix("others")))),
           GenericArguments.optional(
               GenericArguments.onlyOne(GenericArguments.bool(Text.of(toggle)))))
       .build();
 }
  @Override
  public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {

    if (src instanceof Player) {
      Player player = (Player) src;
      Optional<String> optionalKitName = args.getOne("kitName");
      Optional<String> optionalArgs = args.getOne("args");
      if (optionalKitName.isPresent()) {
        String kitName = optionalKitName.get().toUpperCase();
        CommandKitManager kitManager = plugin.getKitManager();
        if (kitManager.isKit(kitName)) {
          CommandKit kit = kitManager.getKit(kitName);
          if (kit.hasPermission(player)) {
            if (kit.hasRequirements(player)) {
              if (kitManager.checkInterval(player, kitName) == 0) {
                String[] argArray = new String[0];
                if (optionalArgs.isPresent()) {
                  argArray = optionalArgs.get().split(" ");
                }
                kit.execute(player, argArray);
                kitManager.markInterval(player, kitName);
              } else {
                src.sendMessage(
                    Text.of(
                        TextColors.RED,
                        Strings.getInstance().getStrings().get("intervalDenial")
                            + kitManager.checkInterval(player, kitName)));
              }
            } else {
              src.sendMessage(
                  Text.of(
                      TextColors.RED, Strings.getInstance().getStrings().get("requirementDenial")));
            }
          } else {
            src.sendMessage(
                Text.of(
                    TextColors.RED, Strings.getInstance().getStrings().get("permissionDenial")));
          }
        } else {
          src.sendMessage(
              Text.of(TextColors.RED, Strings.getInstance().getStrings().get("unknownKit")));
        }
        return CommandResult.success();
      }
      src.sendMessage(
          Text.of(TextColors.RED, Strings.getInstance().getStrings().get("unknownKit")));
    }
    return CommandResult.empty();
  }
Exemple #22
0
  @Listener
  public void onPlayerDropItem(DropItemEvent.Dispense event, @Root Player player) {
    if (!ConfigManager.canPlayersDropItems()) {
      final String playerPolisName = ConfigManager.getTeam(player.getUniqueId());
      event
          .getEntities()
          .forEach(
              e -> {
                String isClaimed = ConfigManager.isClaimed(e.getLocation());

                if (!isClaimed.equals("false")) {
                  if (playerPolisName == null || !playerPolisName.equals(isClaimed)) {
                    player.sendMessage(
                        Text.of(
                            TextColors.DARK_RED,
                            "Error! ",
                            TextColors.RED,
                            "You cannot drop items in claimed areas."));
                    event.setCancelled(true);
                    return;
                  }
                }
              });
    }
  }
 @Override
 protected boolean set(EntityMinecartCommandBlock container, Optional<Text> value) {
   container
       .getCommandBlockLogic()
       .setLastOutput(SpongeTexts.toComponent(value.orElse(Text.of())));
   return true;
 }
Exemple #24
0
 @Override
 public synchronized void start() {
   if (this.sender instanceof RconSource) {
     this.sender.sendMessage(
         Text.of(TextColors.RED, "Warning: Timings report done over RCON will cause lag spikes."));
     this.sender.sendMessage(
         Text.of(
             TextColors.RED,
             "You should use ",
             TextColors.YELLOW,
             "/sponge timings report" + TextColors.RED,
             " in game or console."));
     run();
   } else {
     super.start();
   }
 }
 @Override
 public CommandSpec createSpec() {
   return CommandSpec.builder()
       .executor(this)
       .arguments(
           GenericArguments.onlyOne(
               GenericArguments.optional(new HomeParser(Text.of(home), plugin))))
       .build();
 }
 @Nonnull
 @Override
 public CommandSpec getSpec() {
   return CommandSpec.builder()
       .description(Text.of("ItemInfo Command"))
       .permission("essentialcmds.iteminfo.use")
       .executor(this)
       .build();
 }
Exemple #27
0
 @Nonnull
 @Override
 public CommandSpec getSpec() {
   return CommandSpec.builder()
       .description(Text.of("Experience Command"))
       .children(getChildrenList(new GiveExecutor(), new SetExecutor(), new TakeExecutor()))
       .permission("essentialcmds.exp.use")
       .executor(this)
       .build();
 }
  @Override
  protected CommandResult ExecCommand(Player player, CommandContext context) {
    int id, permId, permId2, permId3;
    String name = null;

    id = Core.getPlayerHandler().<Integer>getElement(player, GlobalPlayer.cityId);
    name = Core.getCityHandler().<String>getElement(id, GlobalCity.displayName);
    permId = Core.getCityHandler().<Integer>getElement(id, GlobalCity.permRes);
    permId2 = Core.getCityHandler().<Integer>getElement(id, GlobalCity.permOutside);
    permId3 = Core.getCityHandler().<Integer>getElement(id, GlobalCity.permAllies);
    Core.getCityHandler().delete(id);
    Core.getPermissionHandler().delete(permId);
    Core.getPermissionHandler().delete(permId2);
    Core.getPermissionHandler().delete(permId3);
    Text message = Text.of("[BREAKING NEWS] " + name + " has fallen !");
    Core.SendText(Text.of(TextColors.GOLD, message, TextColors.RESET));

    return CommandResult.success();
  }
  @Listener(order = Order.LATE)
  public void onMessageChannelEventChat(MessageChannelEvent.Chat event, @First Player player) {
    Builder playerTag = Text.builder().onHover(TextActions.showText(Text.of(player.getName())));

    Optional<PlayerTag> optionalPlayerTag = PlayerTag.get(player);

    if (!optionalPlayerTag.isPresent()) {
      playerTag.append(PlayerTag.getDefault(player));
    } else {
      playerTag.append(optionalPlayerTag.get().getTag());
    }

    Text worldTag = Text.EMPTY;

    Optional<WorldTag> optionalWorldTag = WorldTag.get(player.getWorld().getProperties());

    if (optionalWorldTag.isPresent()) {
      worldTag = optionalWorldTag.get().getTag();
    }

    Builder groupTagBuilder = Text.builder();

    for (Entry<Set<Context>, List<Subject>> parent :
        player.getSubjectData().getAllParents().entrySet()) {
      for (Subject subject : parent.getValue()) {
        String group = subject.getIdentifier();

        if (group.equalsIgnoreCase("op_0")
            || group.equalsIgnoreCase("op_1")
            || group.equalsIgnoreCase("op_2")
            || group.equalsIgnoreCase("op_3")
            || group.equalsIgnoreCase("op_4")) {
          group = "op";
        }

        Optional<GroupTag> optionalGroupTag = GroupTag.get(group);

        if (optionalGroupTag.isPresent()) {
          groupTagBuilder.append(optionalGroupTag.get().getTag());
        }
      }
    }

    MessageFormatter formatter = event.getFormatter();

    String oldStr = TextSerializers.FORMATTING_CODE.serialize(formatter.getHeader().toText());

    String name = oldStr.substring(oldStr.indexOf("<"), oldStr.lastIndexOf(">") + 1);

    Text old = TextSerializers.FORMATTING_CODE.deserialize(oldStr.replace(name, ""));

    formatter.setHeader(
        TextTemplate.of(
            worldTag, groupTagBuilder.build(), playerTag.build(), old, TextColors.RESET));
  }
  public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
    EntityType entityType = ctx.<EntityType>getOne("mob").get();

    if (src instanceof Player) {
      Player player = (Player) src;

      ItemStack mobSpawnerStack =
          ItemStack.builder().itemType(ItemTypes.MOB_SPAWNER).quantity(1).build();
      Optional<MobSpawnerData> mobSpawnerData = mobSpawnerStack.getOrCreate(MobSpawnerData.class);

      if (mobSpawnerData.isPresent()) {
        MobSpawnerData data = mobSpawnerData.get();
        data.nextEntityToSpawn().set(entityType, null);

        if (mobSpawnerStack.offer(data).isSuccessful()) {
          player.setItemInHand(mobSpawnerStack);
          player.sendMessage(
              Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Created mob spawner."));
        } else {
          player.sendMessage(
              Text.of(
                  TextColors.DARK_RED,
                  "Error! ",
                  TextColors.RED,
                  "Failed to set mob spawner entity."));
        }
      } else {
        player.sendMessage(
            Text.of(
                TextColors.DARK_RED, "Error! ", TextColors.RED, "Failed to create mob spawner."));
      }
    } else {
      src.sendMessage(
          Text.of(
              TextColors.DARK_RED,
              "Error! ",
              TextColors.RED,
              "Must be an in-game player to use /mobspawner!"));
    }

    return CommandResult.success();
  }