Java Code Examples for org.bukkit.command.CommandSender

The following examples show how to use org.bukkit.command.CommandSender. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Sentinel   Source File: SentinelTargetCommands.java    License: MIT License 6 votes vote down vote up
public static boolean testLabel(CommandSender sender, SentinelTargetLabel label) {
    if (!label.isValidTarget()) {
        sender.sendMessage(SentinelCommand.prefixBad + "Invalid target! See the readme for a list of valid targets.");
        return false;
    }
    if (!label.isValidRegex()) {
        sender.sendMessage(SentinelCommand.prefixBad + "Bad regular expression!");
        return false;
    }
    if (!label.isValidPrefix()) {
        sender.sendMessage(SentinelCommand.prefixBad + "The target prefix '" + label.prefix + "' is unknown!");
        return false;
    }
    if (!label.isValidMulti()) {
        sender.sendMessage(SentinelCommand.prefixBad + "The multi-target '" + label.value + "' is invalid (targets within don't exist?)!");
        return false;
    }
    return true;
}
 
Example 2
@Test
public void shouldForwardToService() {
    // given
    String interval = "45";
    CommandSender sender = mock(CommandSender.class);

    // when
    command.executeCommand(sender, Collections.singletonList(interval));

    // then
    ArgumentCaptor<Long> captor = ArgumentCaptor.forClass(Long.class);
    verify(purgeService).runPurge(eq(sender), captor.capture());

    // Check the timestamp with a certain tolerance
    int toleranceMillis = 100;
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -Integer.valueOf(interval));
    assertIsCloseTo(captor.getValue(), calendar.getTimeInMillis(), toleranceMillis);
}
 
Example 3
Source Project: Minepacks   Source File: MinepacksCommand.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Executes some basic checks and runs the command afterwards.
 *
 * @param sender           Source of the command.
 * @param mainCommandAlias Alias of the plugins main command which was used.
 * @param alias            Alias of the command which has been used.
 * @param args             Passed command arguments.
 */
@Override
public void doExecute(@NotNull CommandSender sender, @NotNull String mainCommandAlias, @NotNull String alias, @NotNull String... args)
{
	if(playerOnly && !(sender instanceof Player))
	{
		messageNotFromConsole.send(sender);
	}
	else if(getPermission() != null && !sender.hasPermission(getPermission()))
	{
		messageNoPermission.send(sender);
	}
	else
	{
		execute(sender, mainCommandAlias, alias, args);
	}
}
 
Example 4
Source Project: NyaaUtils   Source File: CommandHandler.java    License: MIT License 6 votes vote down vote up
@SubCommand(value = "addlore", permission = "nu.setlore")
public void addlore(CommandSender sender, Arguments args) {
    if (!(args.length() > 1)) {
        msg(sender, "manual.addlore.usage");
        return;
    }
    String lore = args.next().replace("§", "");
    Player p = asPlayer(sender);
    lore = ChatColor.translateAlternateColorCodes('&', lore);
    ItemStack item = p.getInventory().getItemInMainHand();
    if (item == null || item.getType().equals(Material.AIR)) {
        msg(sender, "user.info.no_item_hand");
        return;
    }
    String[] line = lore.split("/n");
    List<String> lines = item.getItemMeta().getLore() == null ? new ArrayList<>() : item.getItemMeta().getLore();
    for (String s : line) {
        lines.add(ChatColor.translateAlternateColorCodes('&', s));
    }
    ItemMeta itemStackMeta = item.getItemMeta();
    itemStackMeta.setLore(lines);
    item.setItemMeta(itemStackMeta);
    msg(sender, "user.setlore.success", lore);
}
 
Example 5
@Override
public void execute(CommandSender sender, String[] args) throws Exception {
	NovaPlayer nPlayer = PlayerManager.getPlayer(sender);

	if(!nPlayer.hasGuild()) {
		Message.CHAT_GUILD_NOTINGUILD.send(sender);
		return;
	}

	if(!nPlayer.hasPermission(GuildPermission.PVPTOGGLE)) {
		Message.CHAT_GUILD_NOGUILDPERM.send(sender);
		return;
	}

	nPlayer.getGuild().setFriendlyPvp(!nPlayer.getGuild().getFriendlyPvp());
	TabUtils.refresh(nPlayer.getGuild());

	Message.CHAT_GUILD_FPVPTOGGLED.clone().setVar(VarKey.GUILD_PVP, Message.getOnOff(nPlayer.getGuild().getFriendlyPvp())).send(sender);
}
 
Example 6
@Test
public void shouldNotCallExecutableForFailedParsing() {
    // given
    String bukkitLabel = "unreg";
    String[] bukkitArgs = {"testPlayer"};
    CommandSender sender = mock(CommandSender.class);
    CommandDescription command = mock(CommandDescription.class);
    given(commandMapper.mapPartsToCommand(any(CommandSender.class), anyList())).willReturn(
        new FoundCommandResult(command, asList("unreg"), asList("testPlayer"), 0.0, MISSING_BASE_COMMAND));

    // when
    handler.processCommand(sender, bukkitLabel, bukkitArgs);

    // then
    verify(commandMapper).mapPartsToCommand(sender, asList("unreg", "testPlayer"));
    verify(command, never()).getExecutableCommand();
    verify(sender).sendMessage(argThat(containsString("Failed to parse")));
}
 
Example 7
Source Project: NickNamer   Source File: NickCommands.java    License: MIT License 6 votes vote down vote up
@Command(name = "refreshNick",
		 aliases = {
				 "nickrefresh",
				 "refreshskin",
				 "reloadskin",
				 "reloadnick"
		 },
		 usage = "[Player]",
		 description = "Refresh the displayed skin",
		 min = 0,
		 max = 1)
@Permission("nick.command.refresh")
public void refreshNick(final CommandSender sender, @OptionalArg String targetName) {
	boolean otherTarget = targetName != null && !targetName.isEmpty();
	final CommandUtil.TargetInfo target = CommandUtil.findTargetInfo(sender, targetName, otherTarget, plugin.allowOfflineTargets);
	if (target == null) { return; }

	if (otherTarget && !sender.hasPermission("nick.other")) {
		throw new PermissionException("nick.other");
	}
	NickNamerAPI.getNickManager().refreshPlayer(target.uuid);
}
 
Example 8
@Test
public void shouldShowDetailedHelpForChildCommand() {
    List<String> arguments = asList("authme", "getpos");
    CommandSender sender = mock(CommandSender.class);
    CommandDescription commandDescription = mock(CommandDescription.class);
    given(commandDescription.getLabelCount()).willReturn(2);
    FoundCommandResult foundCommandResult = new FoundCommandResult(commandDescription, asList("authme", "getpos"),
        Collections.emptyList(), 0.0, INCORRECT_ARGUMENTS);
    given(commandMapper.mapPartsToCommand(sender, arguments)).willReturn(foundCommandResult);

    // when
    command.executeCommand(sender, arguments);

    // then
    verify(sender, never()).sendMessage(anyString());
    verify(helpProvider).outputHelp(sender, foundCommandResult, HelpProvider.ALL_OPTIONS);
}
 
Example 9
Source Project: Sentinel   Source File: SentinelTargetCommands.java    License: MIT License 6 votes vote down vote up
@Command(aliases = {"sentinel"}, usage = "removeignore TYPE",
        desc = "Allows targeting a target.",
        modifiers = {"removeignore"}, permission = "sentinel.removeignore", min = 2, max = 2)
@Requirements(livingEntity = true, ownership = true, traits = {SentinelTrait.class})
public void removeIgnore(CommandContext args, CommandSender sender, SentinelTrait sentinel) {
    SentinelTargetLabel targetLabel = new SentinelTargetLabel(args.getString(1));
    if (!testLabel(sender, targetLabel)) {
        return;
    }
    if (targetLabel.removeFromList(sentinel.allIgnores)) {
        sender.sendMessage(SentinelCommand.prefixGood + "No longer ignoring that target!");
    }
    else {
        sender.sendMessage(SentinelCommand.prefixBad + "Was already not ignoring that target!");
    }
}
 
Example 10
@Override
public void onExecute(String[] args, CommandSender sender) {
    Player player = (Player) sender;

    if (args[1].equalsIgnoreCase("reset")) {
        // Placeholder to reset to default
        player.setResourcePack("http://google.com");
        return;
    }

    String url = (String) config.getResourcePacks().get(args[1]);
    if (url == null) {
        MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_RESOURCE_PACK.getMessage(args[1]));
        return;
    }

    player.setResourcePack(url);
}
 
Example 11
@Override
public void execute(CommandSender sender, String[] args) throws Exception {
	if(plugin.getGuildManager().getGuilds().isEmpty()) {
		Message.CHAT_GUILD_NOGUILDS.send(sender);
		return;
	}

	for(NovaGuild guild : new ArrayList<>(plugin.getGuildManager().getGuilds())) {
		//fire event
		GuildAbandonEvent guildAbandonEvent = new GuildAbandonEvent(guild, AbandonCause.ADMIN_ALL);
		ListenerManager.getLoggedPluginManager().callEvent(guildAbandonEvent);

		//if event is not cancelled
		if(!guildAbandonEvent.isCancelled()) {
			//delete guild
			plugin.getGuildManager().delete(guildAbandonEvent);

			Map<VarKey, String> vars = new HashMap<>();
			vars.put(VarKey.PLAYER_NAME, sender.getName());
			vars.put(VarKey.GUILD_NAME, guild.getName());
			Message.BROADCAST_ADMIN_GUILD_ABANDON.clone().vars(vars).broadcast();
		}
	}
}
 
Example 12
Source Project: CombatLogX   Source File: CommandCombatLogX.java    License: GNU General Public License v3.0 6 votes vote down vote up
private boolean reloadConfigCommand(CommandSender sender) {
    if(checkNoPermission(sender, "combatlogx.command.combatlogx.reload")) return true;

    try {
        this.plugin.reloadConfig("config.yml");
        this.plugin.reloadConfig("language.yml");
        
        ExpansionManager expansionManager = this.plugin.getExpansionManager();
        expansionManager.reloadExpansionConfigs();
    } catch(Exception ex) {
        String message1 = MessageUtil.color("&f&l[&6CombatLogX&f&l] &cAn error has occurred while loading your configurations. &cPlease check console for further details.");
        String message2 = MessageUtil.color("&f&l[&6CombatLogX&f&l[ &c&lError Message: &7" + ex.getMessage());

        this.plugin.sendMessage(sender, message1, message2);
        ex.printStackTrace();
        return true;
    }

    String message = this.plugin.getLanguageMessageColoredWithPrefix("commands.combatlogx.reloaded");
    this.plugin.sendMessage(sender, message);
    return true;
}
 
Example 13
public MapPoolAdjustEvent(
    MapPool oldMapPool,
    MapPool newMapPool,
    Match match,
    boolean forced,
    @Nullable CommandSender sender,
    @Nullable Duration timeLimit,
    int matchLimit) {
  this.oldPool = oldMapPool;
  this.newPool = newMapPool;
  this.match = match;
  this.forced = forced;
  this.sender = sender;
  this.timeLimit = timeLimit;
  this.matchLimit = matchLimit;
}
 
Example 14
Source Project: Sentinel   Source File: SentinelTargetCommands.java    License: MIT License 6 votes vote down vote up
@Command(aliases = {"sentinel"}, usage = "removetarget TYPE",
        desc = "Removes a target.",
        modifiers = {"removetarget"}, permission = "sentinel.removetarget", min = 2, max = 2)
@Requirements(livingEntity = true, ownership = true, traits = {SentinelTrait.class})
public void removeTarget(CommandContext args, CommandSender sender, SentinelTrait sentinel) {
    SentinelTargetLabel targetLabel = new SentinelTargetLabel(args.getString(1));
    if (!testLabel(sender, targetLabel)) {
        return;
    }
    if (targetLabel.removeFromList(sentinel.allTargets)) {
        sender.sendMessage(SentinelCommand.prefixGood + "No longer tracking that target!");
    }
    else {
        sender.sendMessage(SentinelCommand.prefixBad + "Was already not tracking that target!");
    }
}
 
Example 15
@Test
public void shouldPerformAdminUnregister() {
    // given
    Player player = mock(Player.class);
    String name = "Frank21";
    given(player.isOnline()).willReturn(true);
    given(dataSource.removeAuth(name)).willReturn(true);
    given(service.getProperty(RegistrationSettings.FORCE)).willReturn(true);
    given(service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)).willReturn(false);
    CommandSender initiator = mock(CommandSender.class);
    setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService);

    // when
    asynchronousUnregister.adminUnregister(initiator, name, player);

    // then
    verify(service).send(player, MessageKey.UNREGISTERED_SUCCESS);
    verify(service).send(initiator, MessageKey.UNREGISTERED_SUCCESS);
    verify(dataSource).removeAuth(name);
    verify(playerCache).removePlayer(name);
    verify(teleportationService).teleportOnJoin(player);
    verifyCalledUnregisterEventFor(player);
    verify(commandManager).runCommandsOnUnregister(player);
    verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name);
}
 
Example 16
Source Project: LagMonitor   Source File: PaginationCommand.java    License: MIT License 6 votes vote down vote up
private void onPageNumber(String subCommand, CommandSender sender, Pages pagination) {
    Integer page = Ints.tryParse(subCommand);
    if (page == null) {
        sendError(sender, "Unknown subcommand or not a valid page number");
    } else {
        if (page < 1) {
            sendError(sender, "Page number too small");
            return;
        } else if (page > pagination.getTotalPages(sender instanceof Player)) {
            sendError(sender, "Page number too high");
            return;
        }

        pagination.send(sender, page);
    }
}
 
Example 17
Source Project: Chimera   Source File: SpigotMapperTest.java    License: MIT License 5 votes vote down vote up
@Test
void requirement() {
    assertSame(SpigotMapper.TRUE, mapper.requirement(Literal.of("a").requires(null).build()));
    
    Predicate<CommandSender> predicate = mock(Predicate.class);
    mapper.requirement(Literal.of("a").requires(predicate).build()).test(listener);
    
    verify(predicate).test(sender);
}
 
Example 18
@Override
protected void execute(CommandSender sender, String[] args) {
    if (args.length == 0) {
        HubBasics.getMessenger().send(sender, getHelp());
    } else if (args.length == 1) {
        if (args[0].equalsIgnoreCase("reload")) {
            // Disable
            HubBasics.getConfigManager().onDisable();
            HubBasics.getModuleManager().onDisable();
            HubBasics.getItemManager().onDisable();
            HubBasics.getMenuManager().onDisable();
            // Enable
            HubBasics.getModuleManager().onEnable();
            HubBasics.getItemManager().onEnable();
            HubBasics.getMenuManager().onEnable();
            // Message
            HubBasics.getMessenger().send(sender, Messages.get(sender, "PLUGIN_RELOADED"));
        } else if (args[0].equalsIgnoreCase("version")) {
            HubBasics.getMessenger().send(sender, Messages.get(sender, "PLUGIN_VERSION",
                    HubBasics.getDescription().getVersion()));
        } else {
            HubBasics.getMessenger().send(sender, Messages.get(sender, "UNKNOWN_SUBCOMMAND"));
        }
    } else if (args.length == 2) {
        if (args[0].equalsIgnoreCase("item") && (sender instanceof Player)) {
            Player player = (Player) sender;
            String name = args[1];
            CustomItem item = HubBasics.getItemManager().get(name);
            if (item == null) {
                HubBasics.getMessenger().send(player, Messages.get(player, "ITEM_NOT_FOUND"));
                return;
            }
            player.getInventory().addItem(item.toItemStack(player));
        } else {
            HubBasics.getMessenger().send(sender, Messages.get(sender, "UNKNOWN_SUBCOMMAND"));
        }
    }
}
 
Example 19
public static void triggerEventCommand(CommandSender commandSender, String[] args){

        if (CommandHandler.permCheck(CommandHandler.EVENT_LAUNCH_SMALLTREASUREGOBLIN, commandSender) && args[1].equalsIgnoreCase("smalltreasuregoblin")) {
            SmallTreasureGoblin.initializeEvent();
            commandSender.sendMessage("Queued small treasure goblin event for next valid zombie spawn");
        }
        if (CommandHandler.permCheck(CommandHandler.EVENT_LAUNCH_DEADMOON, commandSender) && args[1].equalsIgnoreCase("deadmoon")) {
            DeadMoon.initializeEvent();
            commandSender.sendMessage("Queued deadmoon event for next new moon");
        }

    }
 
Example 20
Source Project: FunnyGuilds   Source File: AxcDeaths.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandSender sender, String[] args) {
    MessageConfiguration messages = FunnyGuilds.getInstance().getMessageConfiguration();

    if (args.length < 1) {
        sender.sendMessage(messages.generalNoNickGiven);
        return;
    }
    
    if (args.length < 2) {
        sender.sendMessage(messages.adminNoDeathsGiven);
        return;
    }

    int deaths;
    try {
        deaths = Integer.valueOf(args[1]);
    } catch (NumberFormatException e) {
        sender.sendMessage(messages.adminErrorInNumber.replace("{ERROR}", args[1]));
        return;
    }

    User user = User.get(args[0]);

    if (user == null) {
        sender.sendMessage(messages.generalNotPlayedBefore);
        return;
    }

    Rank userRank = user.getRank();
    
    int change = deaths - userRank.getDeaths();
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new DeathsChangeEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, userRank, admin, change))) {
        return;
    }
    
    userRank.setDeaths(deaths);
    sender.sendMessage(messages.adminDeathsChanged.replace("{PLAYER}", user.getName()).replace("{DEATHS}", Integer.toString(deaths)));
}
 
Example 21
Source Project: civcraft   Source File: MobLibCommand.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	
	if (sender instanceof Player) {

		Player player = (Player)sender;
		if (player.isOp()) {
			player.sendMessage("Spawning test yobo");
			MobLib.spawnCustom(args[0], player.getLocation());
		}
	}
	
	return false;
}
 
Example 22
Source Project: Holograms   Source File: CommandInfo.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Usage: /hologram info <name>");
    } else {
        String hologramName = args[1];
        Hologram hologram = plugin.getHologramManager().getHologram(hologramName);

        if (hologram == null) {
            sender.sendMessage(ChatColor.RED + "Hologram " + hologramName + " does not exist");
        } else {
            sender.sendMessage(ChatColor.GREEN + "Hologram \"" + hologram.getId() + "\"");
            Collection<HologramLine> lines = hologram.getLines();
            sender.sendMessage(ChatColor.GRAY + "Location: " + ChatColor.WHITE + TextUtil.locationAsString(hologram.getLocation()));
            if (lines.isEmpty()) {
                sender.sendMessage(ChatColor.GRAY + "Hologram has no lines.");
            } else {
                sender.sendMessage(ChatColor.GRAY + "Lines:");
                for (HologramLine line : lines) {
                    sender.sendMessage(" - \"" + line.getRaw() + ChatColor.WHITE + "\"");
                }
            }
        }
    }

    return true;
}
 
Example 23
Source Project: fanciful   Source File: FancyMessage.java    License: MIT License 5 votes vote down vote up
private void send(CommandSender sender, String jsonString) {
	if (!(sender instanceof Player)) {
		sender.sendMessage(toOldMessageFormat());
		return;
	}
	Player player = (Player) sender;
	Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jsonString);
}
 
Example 24
Source Project: uSkyBlock   Source File: WorldGuardHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void islandLock(final CommandSender sender, final String islandName) {
    try {
        RegionManager regionManager = getRegionManager(uSkyBlock.getInstance().getWorldManager().getWorld());
        if (regionManager.hasRegion(islandName + "island")) {
            ProtectedRegion region = regionManager.getRegion(islandName + "island");
            updateLockStatus(region, true);
            sender.sendMessage(tr("\u00a7eYour island is now locked. Only your party members may enter."));
        } else {
            sender.sendMessage(tr("\u00a74You must be the party leader to lock your island!"));
        }
    } catch (Exception ex) {
        LogUtil.log(Level.SEVERE, "ERROR: Failed to lock " + islandName + "'s Island (" + sender.getName() + ")", ex);
    }
}
 
Example 25
Source Project: Survival-Games   Source File: Flag.java    License: GNU General Public License v3.0 5 votes vote down vote up
public boolean onCommand(CommandSender sender, String[] args) {
    
    if (!sender.hasPermission(permission())) {
        MessageManager.getInstance().sendFMessage(MessageManager.PrefixType.ERROR, "error.nopermission", sender);
        return true;
    }
    
    if(args.length < 2){
    	sender.sendMessage(help());
        return true;
    }
    
    Game g = GameManager.getInstance().getGame(Integer.parseInt(args[0]));
    
    if(g == null){
        MessageManager.getInstance().sendFMessage(MessageManager.PrefixType.ERROR, "error.gamedoesntexist", sender, "arena-" + args[0]);
        return true;
    }
    
    HashMap<String, Object>z = SettingsManager.getInstance().getGameFlags(g.getID());
    z.put(args[1].toUpperCase(), g.getID());
    SettingsManager.getInstance().saveGameFlags(z, g.getID());
    		

    
    return false;
}
 
Example 26
Source Project: MineableSpawners   Source File: ConfigurationHandler.java    License: MIT License 5 votes vote down vote up
public void sendMessage(String section, String key, CommandSender sender) {
    if (getMessage(section, key) == null) {
        return;
    }

    String message = getMessage(section, key);
    if (message.equals("") || message.equals(" ")) {
        return;
    }

    sender.sendMessage(message);
}
 
Example 27
/**
 * Check if the command sender has permission for the given permissions node. If no permissions system is used or
 * if the sender is not a player (e.g. console user), the player has to be OP in order to have the permission.
 *
 * @param sender         The command sender.
 * @param permissionNode The permissions node to verify.
 *
 * @return True if the sender has the permission, false otherwise.
 */
public boolean hasPermission(CommandSender sender, PermissionNode permissionNode) {
    // Check if the permission node is null
    if (permissionNode == null) {
        return true;
    }

    // Return default if sender is not a player or no permission system is in use
    if (!(sender instanceof Player) || !isEnabled()) {
        return permissionNode.getDefaultPermission().evaluate(sender);
    }

    Player player = (Player) sender;
    return player.hasPermission(permissionNode.getNode());
}
 
Example 28
Source Project: intake   Source File: BukkitUtil.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public static World getWorld(CommandSender sender) {
  if (sender instanceof Player) {
    return ((Player) sender).getWorld();
  } else if (sender instanceof Block) {
    return ((Block) sender).getWorld();
  } else if (sender instanceof Entity) {
    return ((Entity) sender).getWorld();
  } else {
    return null;
  }
}
 
Example 29
Source Project: LagMonitor   Source File: PaginationCommand.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!canExecute(sender, command)) {
        return true;
    }

    Pages pagination = plugin.getPageManager().getPagination(sender.getName());
    if (pagination == null) {
        sendError(sender, "You have no pagination session");
        return true;
    }

    if (args.length > 0) {
        String subCommand = args[0].toLowerCase();
        switch (subCommand) {
            case "next":
                onNextPage(pagination, sender);
                break;
            case "prev":
                onPrevPage(pagination, sender);
                break;
            case "all":
                onShowAll(pagination, sender);
                break;
            case "save":
                onSave(pagination, sender);
                break;
            default:
                onPageNumber(subCommand, sender, pagination);
        }
    } else {
        sendError(sender, "Not enough arguments");
    }

    return true;
}
 
Example 30
Source Project: Chimera   Source File: DispatcherCommandTest.java    License: MIT License 5 votes vote down vote up
@Test
void execute_CommandSyntaxException() throws CommandSyntaxException {
    doReturn(true).when(command).testPermission(sender);
    doThrow(new CommandSyntaxException(null, new LiteralMessage("message"), "abc", 2)).when(dispatcher).execute(any(StringReader.class), any(CommandSender.class));
    
    assertTrue(command.execute(sender, "command", "a", "b"));
    verify(listener, times(2)).sendFailureMessage(any());
}