Esempio n. 1
0
  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();
  }
Esempio n. 2
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();
  }
Esempio n. 3
0
 private PVPClass(Builder builder) {
   weapon = ItemStack.of(builder.weapon, 1);
   inventory =
       builder
           .inventory
           .stream()
           .map(pair -> ItemStack.of(pair.getA(), pair.getB()))
           .collect(Collectors.toList());
   meleModifier = builder.meleModifier;
   bowModifier = builder.bowModifier;
   projectileVelocityModifier = builder.projectileVelocity;
   icon = weapon.copy();
   List<Text> lore =
       Arrays.asList(
           Text.builder(builder.title)
               .color(TextColors.DARK_PURPLE)
               .style(TextStyles.BOLD)
               .build(),
           Text.builder(builder.description).color(TextColors.DARK_AQUA).build());
   icon.offer(Keys.ITEM_LORE, lore);
   /*
   helmet.get(Keys.ITEM_ENCHANTMENTS).get().add(new ItemEnchantment(Enchantments.PROTECTION, 1));
   chest.get(Keys.ITEM_ENCHANTMENTS).get().add(new ItemEnchantment(Enchantments.PROTECTION, 1));
   leggings.get(Keys.ITEM_ENCHANTMENTS).get().add(new ItemEnchantment(Enchantments.PROTECTION, 1));
   boots.get(Keys.ITEM_ENCHANTMENTS).get().add(new ItemEnchantment(Enchantments.PROTECTION, 1));
   */
 }
Esempio n. 4
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");
  }
Esempio n. 5
0
  @Override
  public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
    Optional<Player> opl = this.getUser(Player.class, src, player, args);
    if (!opl.isPresent()) {
      return CommandResult.empty();
    }

    Player pl = opl.get();

    InternalQuickStartUser uc = plugin.getUserLoader().getUser(pl);
    boolean fly = args.<Boolean>getOne(toggle).orElse(!uc.isFlying());

    if (!uc.setFlying(fly)) {
      src.sendMessages(Text.of(TextColors.RED, Util.getMessageWithFormat("command.fly.error")));
      return CommandResult.empty();
    }

    if (pl != src) {
      src.sendMessages(
          Text.of(
              TextColors.GREEN,
              MessageFormat.format(
                  Util.getMessageWithFormat(
                      fly ? "command.fly.player.on" : "command.fly.player.off"),
                  pl.getName())));
    }

    pl.sendMessage(
        Text.of(
            TextColors.GREEN,
            Util.getMessageWithFormat(fly ? "command.fly.on" : "command.fly.off")));
    return CommandResult.success();
  }
  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();
  }
Esempio n. 7
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);
 }
Esempio n. 8
0
  @Override
  public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
    // Get the home.
    Optional<WarpLocation> owl = args.<WarpLocation>getOne(home);
    if (!owl.isPresent()) {
      owl = plugin.getUserLoader().getUser(src).getHome("home");

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

    WarpLocation wl = owl.get();

    // Warp to it safely.
    if (src.setLocationAndRotationSafely(wl.getLocation(), wl.getRotation())) {
      src.sendMessage(
          Text.of(
              TextColors.GREEN, Util.getMessageWithFormat("command.home.success", wl.getName())));
      return CommandResult.success();
    } else {
      src.sendMessage(
          Text.of(TextColors.RED, Util.getMessageWithFormat("command.home.fail", wl.getName())));
      return CommandResult.empty();
    }
  }
Esempio n. 9
0
  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();
  }
Esempio n. 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();
  }
Esempio n. 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);
 }
Esempio n. 12
0
  @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));
  }
Esempio n. 13
0
  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();
  }
Esempio n. 14
0
  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();
  }
Esempio n. 15
0
  @Override
  public CommandResult executeCommand(final CommandSource src, CommandContext args)
      throws Exception {
    if (service == null) {
      service = Sponge.getServiceManager().provideUnchecked(NucleusWarpService.class);
    }

    PaginationService ps = Sponge.getServiceManager().provideUnchecked(PaginationService.class);

    // Get the warp list.
    Set<String> ws = service.getWarpNames();
    if (ws.isEmpty()) {
      src.sendMessage(Util.getTextMessageWithFormat("command.warps.list.nowarps"));
      return CommandResult.empty();
    }

    List<Text> lt =
        ws.stream()
            .filter(s -> canView(src, s.toLowerCase()))
            .map(
                s -> {
                  if (service.getWarp(s).isPresent()) {
                    return Text.builder(s)
                        .color(TextColors.GREEN)
                        .style(TextStyles.UNDERLINE)
                        .onClick(TextActions.runCommand("/warp " + s))
                        .onHover(
                            TextActions.showText(
                                Util.getTextMessageWithFormat("command.warps.warpprompt", s)))
                        .build();
                  } else {
                    return Text.builder(s)
                        .color(TextColors.RED)
                        .onHover(
                            TextActions.showText(
                                Util.getTextMessageWithFormat("command.warps.unavailable")))
                        .build();
                  }
                })
            .collect(Collectors.toList());

    PaginationList.Builder pb =
        ps.builder()
            .title(Util.getTextMessageWithFormat("command.warps.list.header"))
            .padding(Text.of(TextColors.GREEN, "-"))
            .contents(lt);
    if (!(src instanceof Player)) {
      pb.linesPerPage(-1);
    }

    pb.sendTo(src);
    return CommandResult.success();
  }
 @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();
 }
Esempio n. 17
0
 @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();
 }
Esempio n. 18
0
  @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."));
      }
    }
  }
Esempio n. 19
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();
 }
Esempio n. 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();
 }
Esempio n. 21
0
 @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();
 }
Esempio n. 22
0
  @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();
  }
Esempio n. 23
0
 public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
   URL memberLink = null;
   try {
     memberLink = new URL(ConfigHandler.get().getMemberLink());
     src.sendMessage(
         Text.of(
             TextColors.DARK_AQUA,
             "Become a Member for free by following the instructions ",
             TextColors.AQUA,
             Text.builder("here").onClick(TextActions.openUrl(memberLink)).build()));
   } catch (MalformedURLException e) {
     DTEssentialsPlugin.getLogger().error("Invalid URL format for memberLink in config file");
   }
   return CommandResult.success();
 }
Esempio n. 24
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();
  }
Esempio n. 25
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;
 }
Esempio n. 27
0
  @Override
  public CommandResult process(CommandSource sender, String arguments) throws CommandException {

    String[] args = arguments.split(" ");

    if (sender instanceof Player == false) {
      sender.sendMessage(
          Text.builder("Cannot be run by the console!").color(TextColors.RED).build());
      return CommandResult.success();
    }

    if (args.length < 1 || args.length > 2) {
      sender.sendMessage(usage);
      return CommandResult.success();
    }

    if (args[0].equalsIgnoreCase("day")) {
      new CommandTimeDay(sender, args, game);
      return CommandResult.success();
    } else if (args[0].equalsIgnoreCase("night")) {
      new CommandTimeNight(sender, args, game);
      return CommandResult.success();
    } else if (args[0].equalsIgnoreCase("sunrise")) {
      new CommandTimeSunrise(sender, args, game);
      return CommandResult.success();
    } else if (args[0].equalsIgnoreCase("sunset")) {
      new CommandTimeSunset(sender, args, game);
      return CommandResult.success();
    } else {
      sender.sendMessage(usage);
    }

    return CommandResult.success();
  }
Esempio n. 28
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();
   }
 }
 @Nonnull
 @Override
 public CommandSpec getSpec() {
   return CommandSpec.builder()
       .description(Text.of("ItemInfo Command"))
       .permission("essentialcmds.iteminfo.use")
       .executor(this)
       .build();
 }
Esempio n. 30
0
 @Override
 public CommandSpec createSpec() {
   return CommandSpec.builder()
       .executor(this)
       .arguments(
           GenericArguments.onlyOne(
               GenericArguments.optional(new HomeParser(Text.of(home), plugin))))
       .build();
 }