-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better adventure support for velocity.
- Loading branch information
Showing
6 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...nds-velocity/src/main/java/dev/rollczi/litecommands/velocity/KyoriAudienceContextual.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package dev.rollczi.litecommands.velocity; | ||
|
||
import com.velocitypowered.api.command.CommandSource; | ||
import dev.rollczi.litecommands.command.Invocation; | ||
import dev.rollczi.litecommands.contextual.Contextual; | ||
import net.kyori.adventure.audience.Audience; | ||
import panda.std.Result; | ||
|
||
class KyoriAudienceContextual implements Contextual<CommandSource, Audience> { | ||
|
||
@Override | ||
public Result<Audience, Object> extract(CommandSource commandSender, Invocation<CommandSource> invocation) { | ||
return Result.ok(commandSender); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...locity/src/main/java/dev/rollczi/litecommands/velocity/KyoriColoredComponentArgument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.rollczi.litecommands.velocity; | ||
|
||
import dev.rollczi.litecommands.argument.ArgumentName; | ||
import dev.rollczi.litecommands.argument.simple.OneArgument; | ||
import dev.rollczi.litecommands.command.LiteInvocation; | ||
import dev.rollczi.litecommands.suggestion.Suggestion; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import panda.std.Result; | ||
|
||
@ArgumentName("text") | ||
class KyoriColoredComponentArgument implements OneArgument<Component> { | ||
|
||
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder() | ||
.postProcessor(new LegacyProcessor()) | ||
.build(); | ||
|
||
@Override | ||
public Result<Component, ?> parse(LiteInvocation invocation, String argument) { | ||
return Result.ok(MINI_MESSAGE.deserialize(argument)); | ||
} | ||
|
||
@Override | ||
public boolean validate(LiteInvocation invocation, Suggestion suggestion) { | ||
return true; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...ands-velocity/src/main/java/dev/rollczi/litecommands/velocity/KyoriComponentArgument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dev.rollczi.litecommands.velocity; | ||
|
||
import dev.rollczi.litecommands.argument.ArgumentName; | ||
import dev.rollczi.litecommands.argument.simple.OneArgument; | ||
import dev.rollczi.litecommands.command.LiteInvocation; | ||
import dev.rollczi.litecommands.suggestion.Suggestion; | ||
import net.kyori.adventure.text.Component; | ||
import panda.std.Result; | ||
|
||
@ArgumentName("text") | ||
class KyoriComponentArgument implements OneArgument<Component> { | ||
|
||
@Override | ||
public Result<Component, ?> parse(LiteInvocation invocation, String argument) { | ||
return Result.ok(Component.text(argument)); | ||
} | ||
|
||
@Override | ||
public boolean validate(LiteInvocation invocation, Suggestion suggestion) { | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters