CommandAPI 9.3.0
An API for the command UI introduced in Minecraft 1.13
com.mojang.brigadier.ImmutableStringReader Interface Reference

A string reader can be used to progressively read through a string. More...

+ Inheritance diagram for com.mojang.brigadier.ImmutableStringReader:

Public Member Functions

String getString ()
 Returns the full input string. More...
 
int getRemainingLength ()
 Returns the remaining length, so the distance from the cursor to the end of the input. More...
 
int getTotalLength ()
 Returns the total length of the input. More...
 
int getCursor ()
 Returns the current cursor position. More...
 
String getRead ()
 Returns the part of the input that was already read. More...
 
String getRemaining ()
 Returns the part of the input that was not yet read. More...
 
boolean canRead (int length)
 Checks if the reader has enough input to read length more characters. More...
 
boolean canRead ()
 Checks if the reader can read at least one more character. More...
 
char peek ()
 Returns the next character but without consuming it (so the cursor stays at its current position). More...
 
char peek (int offset)
 Returns the character offset places from the cursor position without consuming it (so the cursor stays at its current position). More...
 

Detailed Description

A string reader can be used to progressively read through a string.

To do this the string reader has the concept of a "cursor", which is the current position in the input string. All operations not explicitly stating otherwise, like peek or canRead, are relative to the cursor position.

Member Function Documentation

◆ canRead() [1/2]

boolean com.mojang.brigadier.ImmutableStringReader.canRead ( )

Checks if the reader can read at least one more character.

Returns
true if the reader can read at least one more character
See also
canRead(int)

Implemented in com.mojang.brigadier.StringReader.

◆ canRead() [2/2]

boolean com.mojang.brigadier.ImmutableStringReader.canRead ( int  length)

Checks if the reader has enough input to read length more characters.

Parameters
lengththe amount of characters to read
Returns
true if the reader has enough input to read length more characters

Implemented in com.mojang.brigadier.StringReader.

◆ getCursor()

int com.mojang.brigadier.ImmutableStringReader.getCursor ( )

Returns the current cursor position.

Returns
the current cursor position

Implemented in com.mojang.brigadier.StringReader.

◆ getRead()

String com.mojang.brigadier.ImmutableStringReader.getRead ( )

Returns the part of the input that was already read.

Returns
the part of the input that was already read

Implemented in com.mojang.brigadier.StringReader.

◆ getRemaining()

String com.mojang.brigadier.ImmutableStringReader.getRemaining ( )

Returns the part of the input that was not yet read.

Returns
the part of the input that was not yet read

Implemented in com.mojang.brigadier.StringReader.

◆ getRemainingLength()

int com.mojang.brigadier.ImmutableStringReader.getRemainingLength ( )

Returns the remaining length, so the distance from the cursor to the end of the input.

Returns
the remaining length, so the distance from the cursor to the end of the input

Implemented in com.mojang.brigadier.StringReader.

◆ getString()

String com.mojang.brigadier.ImmutableStringReader.getString ( )

Returns the full input string.

Returns
the full input string

Implemented in com.mojang.brigadier.StringReader.

◆ getTotalLength()

int com.mojang.brigadier.ImmutableStringReader.getTotalLength ( )

Returns the total length of the input.

Returns
the total length of the input

Implemented in com.mojang.brigadier.StringReader.

◆ peek() [1/2]

char com.mojang.brigadier.ImmutableStringReader.peek ( )

Returns the next character but without consuming it (so the cursor stays at its current position).

Returns
the next character
See also
peek(int)

Implemented in com.mojang.brigadier.StringReader.

◆ peek() [2/2]

char com.mojang.brigadier.ImmutableStringReader.peek ( int  offset)

Returns the character offset places from the cursor position without consuming it (so the cursor stays at its current position).

Parameters
offsetthe offset of the character to peek at
Returns
the character offset places from the current cursor position

Implemented in com.mojang.brigadier.StringReader.