-
-
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.
GH-296 Add a contextual bind for console command source on Velocity p…
…latform (#296) * Add a contextual bind for console command source on Velocity platform * Update publish.yml --------- Co-authored-by: Norbert Dejlich <[email protected]>
- Loading branch information
Showing
2 changed files
with
25 additions
and
2 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
23 changes: 23 additions & 0 deletions
23
.../src/main/java/dev/rollczi/litecommands/velocity/tools/VelocityOnlyConsoleContextual.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.tools; | ||
|
||
import com.velocitypowered.api.command.CommandSource; | ||
import com.velocitypowered.api.proxy.ConsoleCommandSource; | ||
import dev.rollczi.litecommands.command.Invocation; | ||
import dev.rollczi.litecommands.contextual.Contextual; | ||
import panda.std.Option; | ||
import panda.std.Result; | ||
|
||
public class VelocityOnlyConsoleContextual<MESSAGE> implements Contextual<CommandSource, ConsoleCommandSource> { | ||
|
||
private final MESSAGE onlyConsoleMessage; | ||
|
||
public VelocityOnlyConsoleContextual(MESSAGE onlyConsoleMessage) { | ||
this.onlyConsoleMessage = onlyConsoleMessage; | ||
} | ||
|
||
@Override | ||
public Result<ConsoleCommandSource, Object> extract(CommandSource source, Invocation<CommandSource> invocation) { | ||
return Option.of(source).is(ConsoleCommandSource.class).toResult(onlyConsoleMessage); | ||
} | ||
|
||
} |