⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ build/
libs/

*.log*

# Jetbrains IDE
.idea
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ object Libs {
private const val kyoriTextVersion = "3.0.4"
const val kyoriText = "net.kyori:text-api:$kyoriTextVersion"
const val kyoriTextPlain = "net.kyori:text-serializer-plain:$kyoriTextVersion"
private const val kyoriAdventureVersion = "4.14.0"
const val kyoriAdventure = "net.kyori:adventure-api:$kyoriAdventureVersion"
const val kyoriAdventureTextPlain = "net.kyori:adventure-text-serializer-plain:$kyoriAdventureVersion"
const val autoCommon = "com.google.auto:auto-common:1.2.2"
private const val autoValueVersion = "1.11.0"
const val autoValueAnnotations = "com.google.auto.value:auto-value-annotations:$autoValueVersion"
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.api.tasks.testing.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import com.google.common.collect.ImmutableList;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.TypeName;
import net.kyori.text.TextComponent;
import net.kyori.text.TranslatableComponent;
import net.kyori.adventure.text.Component;
import org.enginehub.piston.internal.RegistrationUtil;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -72,11 +71,11 @@ public static CodeBlock listForGen(Stream<CodeBlock> rawCode) {
}

public static CodeBlock textCompOf(String text) {
return CodeBlock.of("$T.of($S)", TextComponent.class, text);
return CodeBlock.of("$T.text($S)", Component.class, text);
}

public static CodeBlock transCompOf(String text) {
return CodeBlock.of("$T.of($S)", TranslatableComponent.class, text);
return CodeBlock.of("$T.translatable($S)", Component.class, text);
}

public static Collector<CodeBlock, ?, CodeBlock> joining(String delimiter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.enginehub.piston

import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.commands.RegressionCommands
import org.enginehub.piston.commands.RegressionCommandsRegistration
import org.enginehub.piston.converter.SimpleArgumentConverter
Expand All @@ -36,7 +36,6 @@ import org.junit.jupiter.api.assertThrows
import org.mockito.Mockito.mock
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyNoInteractions

@DisplayName("Regression tests")
class RegressionTest {
Expand Down Expand Up @@ -94,10 +93,10 @@ class RegressionTest {
action(it.valueOf(arg).asString())
1
}
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
description(TextComponent.of("Issue 9 #2"))
description(Component.text("Issue 9 #2"))
// Optional arg prior to sub-command
addPart(arg)
addPart(subs(sub))
Expand Down Expand Up @@ -137,11 +136,11 @@ class RegressionTest {
}
val sub = manager.newCommand("vert")
.action { SUB_ACTION }
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
action { ROOT_ACTION }
description(TextComponent.of("Issue 14"))
description(Component.text("Issue 14"))
addPart(subs(sub, required = false))
addPart(req)
addPart(optAfter)
Expand Down Expand Up @@ -171,10 +170,10 @@ class RegressionTest {
val sub = manager.newCommand("world")
.action { SUB_ACTION }
.aliases(setOf("there"))
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
description(TextComponent.of("hello"))
description(Component.text("hello"))
addPart(subs(sub, required = true))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ package org.enginehub.piston

import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableSet
import net.kyori.text.TextComponent
import net.kyori.text.TranslatableComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.gen.CommandRegistration
import org.enginehub.piston.part.ArgAcceptingCommandFlag
import org.enginehub.piston.part.CommandArgument
Expand Down Expand Up @@ -54,30 +53,30 @@ inline fun <reified CI> withMockedContainer(block: (CI) -> Unit) {

inline fun arg(name: String, desc: String, block: CommandArgument.Builder.() -> Unit = {}): CommandArgument =
CommandParts.arg(
TranslatableComponent.of(name),
TextComponent.of(desc)
Component.translatable(name),
Component.text(desc)
).also(block).build()

inline fun flag(name: Char, desc: String, block: NoArgCommandFlag.Builder.() -> Unit = {}): NoArgCommandFlag =
CommandParts.flag(
name,
TextComponent.of(desc)
Component.text(desc)
).also(block).build()

inline fun argFlag(name: Char, desc: String, argName: String,
block: ArgAcceptingCommandFlag.Builder.() -> Unit = {}): ArgAcceptingCommandFlag =
CommandParts.flag(
name,
TextComponent.of(desc)
Component.text(desc)
)
.withRequiredArg()
.argNamed(argName)
.also(block).build()

fun subs(vararg subCommands: Command, required: Boolean = true): SubCommandPart =
SubCommandPart.builder(
TranslatableComponent.of("actions"),
TextComponent.of("Sub-actions")
SubCommandPart.builder(
Component.translatable("actions"),
Component.text("Sub-actions")
).run {
withCommands(ImmutableList.copyOf(subCommands))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

package org.enginehub.piston.suggestion

import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import org.enginehub.piston.Command
import org.enginehub.piston.CommandManager
import org.enginehub.piston.assertEqualUnordered
Expand Down Expand Up @@ -57,12 +58,12 @@ class ManagerSuggestionTest {
}

register("notpermitted") { cmd ->
cmd.description(TextComponent.of("Command with false condition"))
cmd.description(Component.text("Command with false condition"))
cmd.condition(Command.Condition.FALSE)
}

register("sub") { cmd ->
cmd.description(TextComponent.of("Sub-commands test command"))
cmd.description(Component.text("Sub-commands test command"))
cmd.addPart(subs(*allCommands.toList().toTypedArray()))
}
}
Expand Down Expand Up @@ -91,7 +92,7 @@ class ManagerSuggestionTest {
withSuggestionManager { manager ->
manager.registerManager(newManager().apply {
register("permitted") { cmd ->
cmd.description(TextComponent.of("Command with true condition"))
cmd.description(Component.text("Command with true condition"))
cmd.condition(Command.Condition.TRUE)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

package org.enginehub.piston.suggestion

import net.kyori.text.Component
import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import org.enginehub.piston.converter.ArgumentConverter
import org.enginehub.piston.converter.ConversionResult
import org.enginehub.piston.converter.FailedConversion
Expand All @@ -37,7 +37,7 @@ class SimpleSuggestingConverter(private val suggestions: List<String>) : Argumen
}

override fun describeAcceptableArguments(): Component {
return TextComponent.of("Any of $suggestions")
return Component.text("Any of $suggestions")
}

override fun getSuggestions(input: String, context: InjectedValueAccess): List<String> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.enginehub.piston.util

import com.google.common.collect.ImmutableList
import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.TestCommandMetadata
import org.enginehub.piston.TestCommandParameters
import org.enginehub.piston.TestParseResult
Expand Down Expand Up @@ -98,7 +98,7 @@ class HelpGeneratorTest {
@Test
fun singleArgOptionalNotNoneHelp() {
val command = listOf(newManager().newCommand("single-arg-opt")
.description(TextComponent.of("description"))
.description(Component.text("description"))
.addParts(
arg("piston.argument.first","First argument") {
defaultsTo(ImmutableList.of("a", "b"))
Expand All @@ -116,7 +116,7 @@ class HelpGeneratorTest {
@Test
fun flagsHelp() {
val command = listOf(newManager().newCommand("flags")
.description(TextComponent.of("description"))
.description(Component.text("description"))
.addParts(
flag('f', "Flag"),
argFlag('q', "Quibble", "qux"),
Expand All @@ -138,12 +138,12 @@ class HelpGeneratorTest {
@Test
fun subCommandsHelp() {
val subCommand = newManager().newCommand("sub-command")
.description(TextComponent.of("sub-description"))
.description(Component.text("sub-description"))
.build()
val interArg = arg("intermediate", "inter-arg")
val subCommands = subs(subCommand)
val command = newManager().newCommand("main")
.description(TextComponent.of("description"))
.description(Component.text("description"))
.addParts(interArg, subCommands)
.build()
assertEquals("""
Expand Down Expand Up @@ -180,4 +180,4 @@ class HelpGeneratorTest {
).fullName))
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
import java.lang.Throwable;
import java.lang.reflect.Method;
import java.util.Collection;
import net.kyori.text.TextComponent;
import net.kyori.text.TranslatableComponent;
import net.kyori.adventure.text.Component;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.CommandParameters;
import org.enginehub.piston.gen.CommandCallListener;
Expand All @@ -55,12 +54,12 @@ final class CollectionArgRegistration implements CommandRegistration<CollectionA

private ImmutableList<CommandCallListener> listeners;

private final CommandArgument argPart = arg(TranslatableComponent.of("piston.argument.arg"), TextComponent.of("ARG DESCRIPTION"))
private final CommandArgument argPart = arg(Component.translatable("piston.argument.arg"), Component.text("ARG DESCRIPTION"))
.defaultsTo(ImmutableList.of())
.ofTypes(ImmutableList.of(string_Key))
.build();

private final CommandArgument argPart2 = arg(TranslatableComponent.of("piston.argument.arg"), TextComponent.of("ARG DESCRIPTION"))
private final CommandArgument argPart2 = arg(Component.translatable("piston.argument.arg"), Component.text("ARG DESCRIPTION"))
.defaultsTo(ImmutableList.of())
.ofTypes(ImmutableList.of(object_Key))
.build();
Expand Down Expand Up @@ -91,13 +90,13 @@ public CollectionArgRegistration listeners(Collection<CommandCallListener> liste
public void build() {
commandManager.register("collectionArgument", b -> {
b.aliases(ImmutableList.of());
b.description(TextComponent.of("DESCRIPTION"));
b.description(Component.text("DESCRIPTION"));
b.parts(ImmutableList.of(argPart));
b.action(this::cmd$collectionArgument);
});
commandManager.register("objectArgument", b -> {
b.aliases(ImmutableList.of());
b.description(TextComponent.of("DESCRIPTION"));
b.description(Component.text("DESCRIPTION"));
b.parts(ImmutableList.of(argPart2));
b.action(this::cmd$objectArgument);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import java.lang.Throwable;
import java.lang.reflect.Method;
import java.util.Collection;
import net.kyori.text.TextComponent;
import net.kyori.text.TranslatableComponent;

import net.kyori.adventure.text.Component;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.CommandParameters;
import org.enginehub.piston.CommandValue;
Expand All @@ -50,7 +50,7 @@ final class CommandValueArgRegistration implements CommandRegistration<CommandVa

private ImmutableList<CommandCallListener> listeners;

private final CommandArgument argPart = arg(TranslatableComponent.of("piston.argument.arg"), TextComponent.of("ARG DESCRIPTION"))
private final CommandArgument argPart = arg(Component.translatable("piston.argument.arg"), Component.text("ARG DESCRIPTION"))
.defaultsTo(ImmutableList.of())
.build();

Expand Down Expand Up @@ -80,7 +80,7 @@ public CommandValueArgRegistration listeners(Collection<CommandCallListener> lis
public void build() {
commandManager.register("valueArgument", b -> {
b.aliases(ImmutableList.of());
b.description(TextComponent.of("DESCRIPTION"));
b.description(Component.text("DESCRIPTION"));
b.parts(ImmutableList.of(argPart));
b.action(this::cmd$valueArgument);
});
Expand Down
19 changes: 9 additions & 10 deletions core-ap/processor/src/test/resources/gen/FlagsRegistration.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
import java.lang.Throwable;
import java.lang.reflect.Method;
import java.util.Collection;
import net.kyori.text.TextComponent;
import net.kyori.text.TranslatableComponent;
import net.kyori.adventure.text.Component;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.CommandParameters;
import org.enginehub.piston.gen.CommandCallListener;
Expand All @@ -52,18 +51,18 @@ final class FlagsRegistration implements CommandRegistration<Flags> {

private ImmutableList<CommandCallListener> listeners;

private final NoArgCommandFlag flagPart = flag('f', TextComponent.of("ARG DESCRIPTION")).build();
private final NoArgCommandFlag flagPart = flag('f', Component.text("ARG DESCRIPTION")).build();

private final ArgAcceptingCommandFlag flagPart2 = flag('f', TextComponent.of("ARG DESCRIPTION"))
private final ArgAcceptingCommandFlag flagPart2 = flag('f', Component.text("ARG DESCRIPTION"))
.withRequiredArg()
.argNamed(TranslatableComponent.of("piston.argument.flag"))
.argNamed(Component.translatable("piston.argument.flag"))
.defaultsTo(ImmutableList.of("DEFAULT"))
.ofTypes(ImmutableList.of(string_Key))
.build();

private final ArgAcceptingCommandFlag flagPart3 = flag('f', TextComponent.of("ARG DESCRIPTION"))
private final ArgAcceptingCommandFlag flagPart3 = flag('f', Component.text("ARG DESCRIPTION"))
.withRequiredArg()
.argNamed(TranslatableComponent.of("piston.argument.ARG NAME"))
.argNamed(Component.translatable("piston.argument.ARG NAME"))
.defaultsTo(ImmutableList.of("DEFAULT"))
.ofTypes(ImmutableList.of(string_Key))
.build();
Expand Down Expand Up @@ -94,19 +93,19 @@ public FlagsRegistration listeners(Collection<CommandCallListener> listeners) {
public void build() {
commandManager.register("booleanFlag", b -> {
b.aliases(ImmutableList.of());
b.description(TextComponent.of("DESCRIPTION"));
b.description(Component.text("DESCRIPTION"));
b.parts(ImmutableList.of(flagPart));
b.action(this::cmd$booleanFlag);
});
commandManager.register("stringArgFlag", b -> {
b.aliases(ImmutableList.of());
b.description(TextComponent.of("DESCRIPTION"));
b.description(Component.text("DESCRIPTION"));
b.parts(ImmutableList.of(flagPart2));
b.action(this::cmd$stringArgFlag);
});
commandManager.register("stringArgFlagCustom", b -> {
b.aliases(ImmutableList.of());
b.description(TextComponent.of("DESCRIPTION"));
b.description(Component.text("DESCRIPTION"));
b.parts(ImmutableList.of(flagPart3));
b.action(this::cmd$stringArgFlagCustom);
});
Expand Down
Loading