public CachedCommandResult(CommandResult result) { super(null); this.affectedBlocks = result.getAffectedBlocks().orElse(null); this.affectedEntities = result.getAffectedEntities().orElse(null); this.affectedItems = result.getAffectedItems().orElse(null); this.queryResult = result.getQueryResult().orElse(null); this.successCount = result.getSuccessCount().orElse(null); }
/** * Tests that if a {@link CommandSource} that is not a player is provided, they can execute a standard command. * * @throws CommandException */ @Test public void testThatCommandSourcesCanExecuteStandardCommand() throws CommandException { setupSpongeMock(); BasicCommand cmd = new BasicCommand(); getInjector().injectMembers(cmd); cmd.postInit(); CommandSource mock = getMockCommandSource(); CommandResult result = cmd.process(mock, ""); Assert.assertTrue("There should have been one success!", result.getSuccessCount().orElse(0) == 1); }
/** * Tests that if a {@link Player} is provided, they can execute a command for players. * * @throws CommandException */ @Test public void testThatPlayersCanExecutePlayerCommand() throws CommandException { setupSpongeMock(); PlayerCommand cmd = new PlayerCommand(); getInjector().injectMembers(cmd); cmd.postInit(); Player mock = getMockPlayer(); CommandResult result = cmd.process(mock, ""); Assert.assertTrue("There should have been one success!", result.getSuccessCount().orElse(0) == 1); }
/** * Tests that if a {@link Player} is provided, they can execute a standard command. * * @throws CommandException */ @Test public void testThatPlayerSourcesCanExecuteStandardCommand() throws CommandException { setupSpongeMock(); BasicCommand cmd = new BasicCommand(); getInjector().injectMembers(cmd); cmd.postInit(); Player mock = getMockPlayer(); CommandResult result = cmd.process(mock, ""); Assert.assertTrue("There should have been one success!", result.getSuccessCount().orElse(0) == 1); }