# SuggestionsBuilderHelper

`com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper`

**Since:** 1.6.5

Wraps Brigadier's builder for command-completion callbacks, exposing the input range and
 methods for adding suggestions.  
 ```js
const command = Chat.getCommandManager().createCommandBuilder("teleport")
  .literalArg("home")
  .suggest(JavaWrapper.methodToJava(function (ctx, suggestions) {
    // what the player has typed, and where the part being completed starts
    if (suggestions.getRemaining().length === 0) {
      suggestions.suggest("spawn").suggest("base").suggest(3);  
    }
  }));  
command.register();  
 ```

## Constructors

### new SuggestionsBuilderHelper {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_constructor-SuggestionsBuilder-}

```js
new SuggestionsBuilderHelper(SuggestionsBuilder base)
```

Wraps the supplied Brigadier suggestion builder directly; it is retained, not copied.  
 Builder operations dereference it, so a `null` builder is not usable for those operations.

**Parameters:**
- `base`: the builder to wrap; may be `null` and is retained as-is

## Methods

### getInput {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_getInput-}

```js
getInput(): String
```

Returns the full command input associated with this completion request.

**Returns:** the full input line the suggestions are for

**Since:** 1.6.5

### getRemaining {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_getRemaining-}

```js
getRemaining(): String
```

Returns the input suffix beginning at [getStart()](#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_getStart-).

**Returns:** the unfinished tail of the input

**Since:** 1.6.5

### getRemainingLowerCase {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_getRemainingLowerCase-}

```js
getRemainingLowerCase(): String
```

Returns the input suffix beginning at [getStart()](#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_getStart-), lowercased without trimming
 leading spaces.

**Returns:** the unfinished tail of the input, lowercased

**Since:** 1.6.5

### getStart {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_getStart-}

```js
getStart(): int
```

Returns the start offset of the text being completed, measured in [getInput()](#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_getInput-).

**Returns:** the character index in the input where completion starts

**Since:** 1.6.5

### suggest {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggest-String-}

```js
suggest(String suggestion): SuggestionsBuilderHelper
```

Adds a text suggestion and returns this helper for chaining.

**Parameters:**
- `suggestion`: the text to offer

**Returns:** self for chaining

**Since:** 1.6.5

### suggest {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggest-int-}

```js
suggest(int value): SuggestionsBuilderHelper
```

Adds the decimal string representation of a number as a suggestion and returns this helper.

**Parameters:**
- `value`: the number to offer

**Returns:** self for chaining

**Since:** 1.6.5

### suggestBlockPositions {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestBlockPositions-BlockPosHelper[]-}

```js
suggestBlockPositions(BlockPosHelper... positions): SuggestionsBuilderHelper
```

Offers block positions as `x y z` coordinate suggestions.  
 ```js
const command = Chat.getCommandManager().createCommandBuilder("tp")
  .literalArg("pos")
  .suggestBlockPositions(
    PositionCommon.createBlockPos(0, 64, 0),  
    PositionCommon.createBlockPos(100, 64, 100)
  );  
command.register();  
 ```

**Parameters:**
- `positions`: the positions to suggest

**Returns:** self for chaining

**Since:** 1.8.4

### suggestBlockPositions {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestBlockPositions-Collection-}

```js
suggestBlockPositions(Collection<BlockPosHelper> positions): SuggestionsBuilderHelper
```

Offers the block positions in a collection as `x y z` coordinate suggestions.

**Parameters:**
- `positions`: the positions to suggest

**Returns:** self for chaining

**Since:** 1.8.4

### suggestIdentifier {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestIdentifier-String[]-}

```js
suggestIdentifier(String... identifiers): SuggestionsBuilderHelper
```

Offers registry identifier suggestions, parsing each string as a resource location before
 passing it to the game's resource matcher.  
 ```js
const command = Chat.getCommandManager().createCommandBuilder("give")
  .literalArg("item")
  .suggestIdentifier("diamond", "emerald", "gold_ingot");  
command.register();  
 ```

**Parameters:**
- `identifiers`: the identifiers to match

**Returns:** self for chaining

**Since:** 1.8.4

### suggestIdentifier {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestIdentifier-Collection-}

```js
suggestIdentifier(Collection<String> identifiers): SuggestionsBuilderHelper
```

Offers registry identifier suggestions from a collection, parsing each string as a resource
 location before passing it to the game's resource matcher.  
 ```js
const blocks = ["stone", "dirt", "oak_log"];  
const command = Chat.getCommandManager().createCommandBuilder("setblock")
  .literalArg("block")
  .suggest(JavaWrapper.methodToJava(function (ctx, suggestions) {
    suggestions.suggestIdentifier(blocks);  
  }));  
command.register();  
 ```

**Parameters:**
- `identifiers`: the identifiers to match

**Returns:** self for chaining

**Since:** 1.8.4

### suggestMatching {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestMatching-String[]-}

```js
suggestMatching(String... suggestions): SuggestionsBuilderHelper
```

Offers string suggestions filtered against the text currently being completed.  
 ```js
const command = Chat.getCommandManager().createCommandBuilder("difficulty")
  .literalArg("value")
  .suggestMatching("peaceful", "easy", "normal", "hard");  
command.register();  
 ```

**Parameters:**
- `suggestions`: the strings to match

**Returns:** self for chaining

**Since:** 1.8.4

### suggestMatching {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestMatching-Collection-}

```js
suggestMatching(Collection<String> suggestions): SuggestionsBuilderHelper
```

Offers string suggestions filtered against the text currently being completed.  
 ```js
const names = ["alpha", "beta", "gamma"];  
const command = Chat.getCommandManager().createCommandBuilder("select")
  .literalArg("name")
  .suggest(JavaWrapper.methodToJava(function (ctx, suggestions) {
    suggestions.suggestMatching(names);  
  }));  
command.register();  
 ```

**Parameters:**
- `suggestions`: the strings to match

**Returns:** self for chaining

**Since:** 1.8.4

### suggestPositions {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestPositions-String[]-}

```js
suggestPositions(String... positions): SuggestionsBuilderHelper
```

Offers coordinate strings containing two or three whitespace-separated components; all
 strings in a call must have the same number of components. Strings are passed to the
 collection overload for validation and suggestion.

**Parameters:**
- `positions`: the positions to suggest

**Returns:** self for chaining.

**Since:** 1.8.4

### suggestPositions {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestPositions-Collection-}

```js
suggestPositions(Collection<String> positions): SuggestionsBuilderHelper
```

Validates coordinate strings containing two or three whitespace-separated components, with
 the same component count throughout the collection, then offers them through the game's
 2D or 3D coordinate matcher against the current unfinished input. Components are split on
 whitespace (surrounding and repeated spaces are not retained); relative-coordinate tokens
 are passed to the matcher. An empty collection adds no suggestions and a `null`
 collection is not accepted.

**Parameters:**
- `positions`: the coordinate strings to suggest

**Returns:** self for chaining

**Since:** 1.8.4

### suggestWithTooltip {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestWithTooltip-String-TextHelper-}

```js
suggestWithTooltip(String suggestion, TextHelper tooltip): SuggestionsBuilderHelper
```

Adds a text suggestion with a tooltip and returns this helper for chaining.  
 ```js
const command = Chat.getCommandManager().createCommandBuilder("teleport")
  .literalArg("home")
  .suggest(JavaWrapper.methodToJava(function (ctx, suggestions) {
    suggestions.suggestWithTooltip("spawn", Chat.createTextHelperFromString("world spawn point"));  
    suggestions.suggestWithTooltip("base", Chat.createTextHelperFromString("your base, set with /sethome"));  
  }));  
command.register();  
 ```

**Parameters:**
- `suggestion`: the text to offer
- `tooltip`: the text to show beside the suggestion

**Returns:** self for chaining

**Since:** 1.6.5

### suggestWithTooltip {#com.jsmacrosce.jsmacros.client.api.helper.SuggestionsBuilderHelper_suggestWithTooltip-int-TextHelper-}

```js
suggestWithTooltip(int value, TextHelper tooltip): SuggestionsBuilderHelper
```

Adds the decimal string representation of a number with a tooltip and returns this helper
 for chaining.  
 ```js
const command = Chat.getCommandManager().createCommandBuilder("setgamemode")
  .literalArg("value")
  .suggest(JavaWrapper.methodToJava(function (ctx, suggestions) {
    const survival = Chat.createTextHelperFromString("take damage, need to eat");  
    const creative = Chat.createTextHelperFromString("fly and break blocks");  
    suggestions.suggestWithTooltip(0, survival).suggestWithTooltip(1, creative);  
  }));  
command.register();  
 ```

**Parameters:**
- `value`: the number to offer
- `tooltip`: the text to show beside the suggestion

**Returns:** self for chaining

**Since:** 1.6.5
