Compare commits
2 commits
master
...
feature/ch
Author | SHA1 | Date | |
---|---|---|---|
|
1d8b865845 | ||
|
6c12f8fa08 |
12 changed files with 39 additions and 100 deletions
|
@ -9,8 +9,7 @@ pr: none
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
rConnection: 'mc-java-sc'
|
rConnection: 'mc-java-sc'
|
||||||
storageAccount: 'librariesminecraftnet'
|
storageAccount: 'pistonprod'
|
||||||
storageAccountContainer: 'librariesminecraftnet'
|
|
||||||
keyVault: 'mc-java-vault'
|
keyVault: 'mc-java-vault'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -74,9 +73,18 @@ jobs:
|
||||||
inputs:
|
inputs:
|
||||||
azureSubscription: '$(rConnection)'
|
azureSubscription: '$(rConnection)'
|
||||||
KeyVaultName: '$(keyVault)'
|
KeyVaultName: '$(keyVault)'
|
||||||
SecretsFilter: 'access-key-prod-librariesminecraftnet'
|
SecretsFilter: 'aws-access-key-id, aws-secret-access-key, pistonprod-access-key'
|
||||||
RunAsPreJob: false
|
RunAsPreJob: false
|
||||||
|
|
||||||
|
- task: S3Upload@1
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: '$(aws-access-key-id)'
|
||||||
|
AWS_SECRET_ACCESS_KEY: '$(aws-secret-access-key)'
|
||||||
|
inputs:
|
||||||
|
bucketName: 'minecraft-libraries'
|
||||||
|
globExpressions: '**'
|
||||||
|
sourceFolder: '$(Pipeline.Workspace)/repo'
|
||||||
|
|
||||||
- task: AzureCLI@2
|
- task: AzureCLI@2
|
||||||
displayName: Azure CLI
|
displayName: Azure CLI
|
||||||
inputs:
|
inputs:
|
||||||
|
@ -84,4 +92,4 @@ jobs:
|
||||||
scriptType: 'bash'
|
scriptType: 'bash'
|
||||||
scriptLocation: 'inlineScript'
|
scriptLocation: 'inlineScript'
|
||||||
inlineScript: |
|
inlineScript: |
|
||||||
az storage blob upload-batch -s '$(Pipeline.Workspace)/repo' -d $(storageAccountContainer) --account-name $(storageAccount) --account-key $(access-key-prod-librariesminecraftnet)
|
az storage blob upload-batch -s '$(Pipeline.Workspace)/repo' -d libraries --account-name $(storageAccount) --account-key $(pistonprod-access-key)
|
||||||
|
|
22
.github/workflows/pr-check.yml
vendored
22
.github/workflows/pr-check.yml
vendored
|
@ -1,22 +0,0 @@
|
||||||
name: pr-check
|
|
||||||
|
|
||||||
on: [ pull_request ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build and test
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: adoptopenjdk/openjdk8:latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Build with Gradle
|
|
||||||
uses: gradle/gradle-build-action@v2
|
|
||||||
with:
|
|
||||||
arguments: build test
|
|
||||||
- name: Publish Test Report
|
|
||||||
uses: mikepenz/action-junit-report@v3
|
|
||||||
if: always()
|
|
||||||
with:
|
|
||||||
report_paths: '**/build/test-results/test/TEST-*.xml'
|
|
17
.travis.yml
Normal file
17
.travis.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
sudo: false
|
||||||
|
dist: trusty
|
||||||
|
language: java
|
||||||
|
|
||||||
|
before_cache:
|
||||||
|
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||||
|
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.gradle/caches/
|
||||||
|
- $HOME/.gradle/wrapper/
|
||||||
|
|
||||||
|
jdk:
|
||||||
|
- oraclejdk8
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./gradlew check --info -S --parallel
|
|
@ -231,6 +231,7 @@ public class CommandDispatcher<S> {
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
forked |= context.isForked();
|
forked |= context.isForked();
|
||||||
if (child.hasNodes()) {
|
if (child.hasNodes()) {
|
||||||
|
foundCommand = true;
|
||||||
final RedirectModifier<S> modifier = context.getRedirectModifier();
|
final RedirectModifier<S> modifier = context.getRedirectModifier();
|
||||||
if (modifier == null) {
|
if (modifier == null) {
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
|
@ -247,8 +248,6 @@ public class CommandDispatcher<S> {
|
||||||
for (final S source : results) {
|
for (final S source : results) {
|
||||||
next.add(child.copyFor(source));
|
next.add(child.copyFor(source));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
foundCommand = true;
|
|
||||||
}
|
}
|
||||||
} catch (final CommandSyntaxException ex) {
|
} catch (final CommandSyntaxException ex) {
|
||||||
consumer.onCommandComplete(context, false, 0);
|
consumer.onCommandComplete(context, false, 0);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
package com.mojang.brigadier.builder;
|
package com.mojang.brigadier.builder;
|
||||||
|
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.Message;
|
|
||||||
import com.mojang.brigadier.RedirectModifier;
|
import com.mojang.brigadier.RedirectModifier;
|
||||||
import com.mojang.brigadier.SingleRedirectModifier;
|
import com.mojang.brigadier.SingleRedirectModifier;
|
||||||
import com.mojang.brigadier.tree.CommandNode;
|
import com.mojang.brigadier.tree.CommandNode;
|
||||||
|
@ -21,7 +20,6 @@ public abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, T>> {
|
||||||
private CommandNode<S> target;
|
private CommandNode<S> target;
|
||||||
private RedirectModifier<S> modifier = null;
|
private RedirectModifier<S> modifier = null;
|
||||||
private boolean forks;
|
private boolean forks;
|
||||||
private Message description;
|
|
||||||
|
|
||||||
protected abstract T getThis();
|
protected abstract T getThis();
|
||||||
|
|
||||||
|
@ -54,15 +52,6 @@ public abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, T>> {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T describe(final Message description) {
|
|
||||||
this.description = description;
|
|
||||||
return getThis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Message getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T requires(final Predicate<S> requirement) {
|
public T requires(final Predicate<S> requirement) {
|
||||||
this.requirement = requirement;
|
this.requirement = requirement;
|
||||||
return getThis();
|
return getThis();
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class LiteralArgumentBuilder<S> extends ArgumentBuilder<S, LiteralArgumen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LiteralCommandNode<S> build() {
|
public LiteralCommandNode<S> build() {
|
||||||
final LiteralCommandNode<S> result = new LiteralCommandNode<>(getLiteral(), getCommand(), getRequirement(), getRedirect(), getRedirectModifier(), isFork(), getDescription());
|
final LiteralCommandNode<S> result = new LiteralCommandNode<>(getLiteral(), getCommand(), getRequirement(), getRedirect(), getRedirectModifier(), isFork());
|
||||||
|
|
||||||
for (final CommandNode<S> argument : getArguments()) {
|
for (final CommandNode<S> argument : getArguments()) {
|
||||||
result.addChild(argument);
|
result.addChild(argument);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class RequiredArgumentBuilder<S, T> extends ArgumentBuilder<S, RequiredAr
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArgumentCommandNode<S, T> build() {
|
public ArgumentCommandNode<S, T> build() {
|
||||||
final ArgumentCommandNode<S, T> result = new ArgumentCommandNode<>(getName(), getType(), getCommand(), getRequirement(), getRedirect(), getRedirectModifier(), isFork(), getSuggestionsProvider(), getDescription());
|
final ArgumentCommandNode<S, T> result = new ArgumentCommandNode<>(getName(), getType(), getCommand(), getRequirement(), getRedirect(), getRedirectModifier(), isFork(), getSuggestionsProvider());
|
||||||
|
|
||||||
for (final CommandNode<S> argument : getArguments()) {
|
for (final CommandNode<S> argument : getArguments()) {
|
||||||
result.addChild(argument);
|
result.addChild(argument);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
package com.mojang.brigadier.tree;
|
package com.mojang.brigadier.tree;
|
||||||
|
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.Message;
|
|
||||||
import com.mojang.brigadier.RedirectModifier;
|
import com.mojang.brigadier.RedirectModifier;
|
||||||
import com.mojang.brigadier.StringReader;
|
import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
|
@ -30,11 +29,7 @@ public class ArgumentCommandNode<S, T> extends CommandNode<S> {
|
||||||
private final SuggestionProvider<S> customSuggestions;
|
private final SuggestionProvider<S> customSuggestions;
|
||||||
|
|
||||||
public ArgumentCommandNode(final String name, final ArgumentType<T> type, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final SuggestionProvider<S> customSuggestions) {
|
public ArgumentCommandNode(final String name, final ArgumentType<T> type, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final SuggestionProvider<S> customSuggestions) {
|
||||||
this(name, type, command, requirement, redirect, modifier, forks, customSuggestions, null);
|
super(command, requirement, redirect, modifier, forks);
|
||||||
}
|
|
||||||
|
|
||||||
public ArgumentCommandNode(final String name, final ArgumentType<T> type, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final SuggestionProvider<S> customSuggestions, final Message description) {
|
|
||||||
super(command, requirement, redirect, modifier, forks, description);
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.customSuggestions = customSuggestions;
|
this.customSuggestions = customSuggestions;
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
|
|
||||||
package com.mojang.brigadier.tree;
|
package com.mojang.brigadier.tree;
|
||||||
|
|
||||||
import com.mojang.brigadier.*;
|
import com.mojang.brigadier.AmbiguityConsumer;
|
||||||
|
import com.mojang.brigadier.Command;
|
||||||
|
import com.mojang.brigadier.RedirectModifier;
|
||||||
|
import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.context.CommandContextBuilder;
|
import com.mojang.brigadier.context.CommandContextBuilder;
|
||||||
|
@ -29,29 +32,19 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
||||||
private final RedirectModifier<S> modifier;
|
private final RedirectModifier<S> modifier;
|
||||||
private final boolean forks;
|
private final boolean forks;
|
||||||
private Command<S> command;
|
private Command<S> command;
|
||||||
private Message description;
|
|
||||||
|
|
||||||
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
|
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
|
||||||
this(command, requirement, redirect, modifier, forks, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final Message description) {
|
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.requirement = requirement;
|
this.requirement = requirement;
|
||||||
this.redirect = redirect;
|
this.redirect = redirect;
|
||||||
this.modifier = modifier;
|
this.modifier = modifier;
|
||||||
this.forks = forks;
|
this.forks = forks;
|
||||||
this.description = description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command<S> getCommand() {
|
public Command<S> getCommand() {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<CommandNode<S>> getChildren() {
|
public Collection<CommandNode<S>> getChildren() {
|
||||||
return children.values();
|
return children.values();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
package com.mojang.brigadier.tree;
|
package com.mojang.brigadier.tree;
|
||||||
|
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.Message;
|
|
||||||
import com.mojang.brigadier.RedirectModifier;
|
import com.mojang.brigadier.RedirectModifier;
|
||||||
import com.mojang.brigadier.StringReader;
|
import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
@ -26,11 +25,7 @@ public class LiteralCommandNode<S> extends CommandNode<S> {
|
||||||
private final String literalLowerCase;
|
private final String literalLowerCase;
|
||||||
|
|
||||||
public LiteralCommandNode(final String literal, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
|
public LiteralCommandNode(final String literal, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
|
||||||
this(literal, command, requirement, redirect, modifier, forks, null);
|
super(command, requirement, redirect, modifier, forks);
|
||||||
}
|
|
||||||
|
|
||||||
public LiteralCommandNode(final String literal, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks, final Message description) {
|
|
||||||
super(command, requirement, redirect, modifier, forks, description);
|
|
||||||
this.literal = literal;
|
this.literal = literal;
|
||||||
this.literalLowerCase = literal.toLowerCase(Locale.ROOT);
|
this.literalLowerCase = literal.toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class RootCommandNode<S> extends CommandNode<S> {
|
public class RootCommandNode<S> extends CommandNode<S> {
|
||||||
public RootCommandNode() {
|
public RootCommandNode() {
|
||||||
super(null, c -> true, null, s -> Collections.singleton(s.getSource()), false, null);
|
super(null, c -> true, null, s -> Collections.singleton(s.getSource()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
package com.mojang.brigadier;
|
package com.mojang.brigadier;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.context.CommandContextBuilder;
|
import com.mojang.brigadier.context.CommandContextBuilder;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
@ -15,9 +14,6 @@ import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||||
import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal;
|
import static com.mojang.brigadier.builder.LiteralArgumentBuilder.literal;
|
||||||
import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument;
|
import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument;
|
||||||
|
@ -330,37 +326,6 @@ public class CommandDispatcherTest {
|
||||||
verify(command).run(argThat(hasProperty("source", is(source2))));
|
verify(command).run(argThat(hasProperty("source", is(source2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIncompleteRedirectShouldThrow() {
|
|
||||||
final LiteralCommandNode<Object> foo = subject.register(literal("foo")
|
|
||||||
.then(literal("bar")
|
|
||||||
.then(argument("value", integer()).executes(context -> IntegerArgumentType.getInteger(context, "value"))))
|
|
||||||
.then(literal("awa").executes(context -> 2)));
|
|
||||||
final LiteralCommandNode<Object> baz = subject.register(literal("baz").redirect(foo));
|
|
||||||
try {
|
|
||||||
int result = subject.execute("baz bar", source);
|
|
||||||
fail("Should have thrown an exception");
|
|
||||||
} catch (CommandSyntaxException e) {
|
|
||||||
assertThat(e.getType(), is(CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRedirectModifierEmptyResult() {
|
|
||||||
final LiteralCommandNode<Object> foo = subject.register(literal("foo")
|
|
||||||
.then(literal("bar")
|
|
||||||
.then(argument("value", integer()).executes(context -> IntegerArgumentType.getInteger(context, "value"))))
|
|
||||||
.then(literal("awa").executes(context -> 2)));
|
|
||||||
final RedirectModifier<Object> emptyModifier = context -> Collections.emptyList();
|
|
||||||
final LiteralCommandNode<Object> baz = subject.register(literal("baz").fork(foo, emptyModifier));
|
|
||||||
try {
|
|
||||||
int result = subject.execute("baz bar 100", source);
|
|
||||||
assertThat(result, is(0)); // No commands executed, so result is 0
|
|
||||||
} catch (CommandSyntaxException e) {
|
|
||||||
fail("Should not throw an exception");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteOrphanedSubcommand() throws Exception {
|
public void testExecuteOrphanedSubcommand() throws Exception {
|
||||||
subject.register(literal("foo").then(
|
subject.register(literal("foo").then(
|
||||||
|
|
Loading…
Reference in a new issue