Skip to content

Commit

Permalink
Release 4.0.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	annotations/pom.xml
#	commons/pom.xml

#	commons/src/main/java/com/karuslabs/commons/command/types/CartesianType.java
#	pom.xml
  • Loading branch information
Pante committed Apr 9, 2019
2 parents 8db7b4c + a2c086f commit 3523dc2
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Open source spigot libraries & tools devloped by Karus Labs. Allows the Brigadie
#### Annotations - Contains useful, general purpose annotations
[![releases-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-releases/com/karuslabs/chimera/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-releases/)
[![snapshots-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-snapshots/com/karuslabs/chimera/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-snapshots/)
[![javadoc](https://img.shields.io/badge/javadoc-4.0.0-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.0.0/commons/apidocs/index.html)
[![javadoc](https://img.shields.io/badge/javadoc-4.0.1-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.0.1/commons/apidocs/index.html)
```XML

<!-- Stable Builds -->
Expand All @@ -38,7 +38,7 @@ Open source spigot libraries & tools devloped by Karus Labs. Allows the Brigadie
<dependency>
<groupId>com.karuslabs</groupId>
<artifactId>annotations</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
</dependency>
</dependencies>
```
Expand All @@ -47,7 +47,7 @@ Open source spigot libraries & tools devloped by Karus Labs. Allows the Brigadie
#### Chimera - Contains the command framework and other common utilities for Spigot plugin development
[![releases-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-releases/com/karuslabs/chimera/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-releases/)
[![snapshots-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-snapshots/com/karuslabs/chimera/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-snapshots/)
[![javadoc](https://img.shields.io/badge/javadoc-4.0.0-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.0.0/commons/apidocs/index.html)
[![javadoc](https://img.shields.io/badge/javadoc-4.0.1-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.0.1/commons/apidocs/index.html)
```XML

<!-- Stable Builds -->
Expand All @@ -66,7 +66,7 @@ Open source spigot libraries & tools devloped by Karus Labs. Allows the Brigadie
<dependency>
<groupId>com.karuslabs</groupId>
<artifactId>commons</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
</dependency>
</dependencies>
```
Expand Down
2 changes: 1 addition & 1 deletion annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.karuslabs</groupId>
<artifactId>chimera</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
</parent>

<artifactId>annotations</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.karuslabs</groupId>
<artifactId>chimera</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
</parent>

<artifactId>commons</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void suggest(SuggestionsBuilder builder, CommandContext<?> context, Lo
builder.suggest(location.getX() + " " + location.getY());
builder.suggest(location.getX() + " " + location.getY() + " " + location.getZ());
break;

case 1:
builder.suggest(parts[0] + " " + location.getY());
builder.suggest(parts[0] + " " + location.getY() + " " + location.getZ());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
*/
public abstract class CartesianType<T> implements Type<T> {

private static final String[] EMPTY = new String[]{};


/**
* Splits the remaining string of the builder by a whitespace and forwards providing
* suggestions to {@link #suggest(SuggestionsBuilder, CommandContext, Location, String[])}
Expand Down Expand Up @@ -74,7 +77,7 @@ public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> cont
* @return the parts of the given string split by a whitespace
*/
protected String[] split(String remaining) {
return remaining.split(" ");
return remaining.isBlank() ? EMPTY : remaining.split(" ");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Position parse(StringReader reader) throws CommandSyntaxException {
*/
@Override
protected void suggest(SuggestionsBuilder builder, CommandContext<?> context, String[] parts) {
if (builder.getRemaining().isEmpty()) {
if (builder.remaining.isBlank()) {
builder.suggest("~").suggest("~ ~");

} else if (parts.length == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Position parse(StringReader reader) throws CommandSyntaxException {
*/
@Override
protected void suggest(SuggestionsBuilder builder, CommandContext<?> context, String[] parts) {
if (builder.remaining.isEmpty()) {
if (builder.remaining.isBlank()) {
builder.suggest("~").suggest("~ ~").suggest("~ ~ ~");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String parse(StringReader reader) throws CommandSyntaxException {
void suggest_all() {
when(builder.getRemaining()).thenReturn("");
type.suggest(builder, null, location, new String[] {});

verify(builder).suggest("1.0");
verify(builder).suggest("1.0 2.0");
verify(builder).suggest("1.0 2.0 3.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;


Expand All @@ -64,6 +67,13 @@ public String parse(StringReader reader) throws CommandSyntaxException {
});


@ParameterizedTest
@CsvSource({"a b, 2", "' ', 0", "' ', 0"})
void split(String remaining, int expected) {
assertEquals(expected, type.split(remaining).length);
}


@Test
void listSuggestions() {
type.listSuggestions(context, builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void suggest(String[] parts, SuggestionsBuilder expected) {
static Stream<Arguments> suggest_parameters() {
return Stream.of(
of(new String[] {}, new SuggestionsBuilder("", 0).suggest("~").suggest("~ ~")),
of(new String[] {}, new SuggestionsBuilder(" ", 0).suggest("~").suggest("~ ~")),
of(new String[] {}, new SuggestionsBuilder(" ", 0).suggest("~").suggest("~ ~")),
of(new String[] {"^1"}, new SuggestionsBuilder("^1", 0).suggest("^1 ^")),
of(new String[] {"~1"}, new SuggestionsBuilder("~1", 0).suggest("~1 ~"))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void suggest(String[] parts, SuggestionsBuilder expected) {
static Stream<Arguments> suggest_parameters() {
return Stream.of(
of(new String[] {}, new SuggestionsBuilder("", 0).suggest("~").suggest("~ ~").suggest("~ ~ ~")),
of(new String[] {}, new SuggestionsBuilder(" ", 0).suggest("~").suggest("~ ~").suggest("~ ~ ~")),
of(new String[] {}, new SuggestionsBuilder(" ", 0).suggest("~").suggest("~ ~").suggest("~ ~ ~")),
of(new String[] {"^1"}, new SuggestionsBuilder("^1", 0).suggest("^1 ^").suggest("^1 ^ ^")),
of(new String[] {"~1"}, new SuggestionsBuilder("~1", 0).suggest("~1 ~").suggest("~1 ~ ~")),
of(new String[] {"~1", "2"}, new SuggestionsBuilder("~1 2", 0).suggest("~1 2 ~"))
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.karuslabs</groupId>
<artifactId>chimera</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
<packaging>pom</packaging>


Expand Down

0 comments on commit 3523dc2

Please sign in to comment.