Skip to content

Commit

Permalink
GH-296 Add a contextual bind for console command source on Velocity p…
Browse files Browse the repository at this point in the history
…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
rchomczyk and Rollczi authored Nov 23, 2023
1 parent 140d9ce commit 2c52711
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish LiteCommands
on:
push:
branches: [ master ]
branches: [ master, v2.x.x ]
jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -27,4 +27,4 @@ jobs:
ETERNAL_CODE_MAVEN_USERNAME: ${{ secrets.ETERNAL_CODE_MAVEN_USERNAME }}
ETERNAL_CODE_MAVEN_PASSWORD: ${{ secrets.ETERNAL_CODE_MAVEN_PASSWORD }}
MINE_CODES_MAVEN_USERNAME: ${{ secrets.MINE_CODES_MAVEN_USERNAME }}
MINE_CODES_MAVEN_PASSWORD: ${{ secrets.MINE_CODES_MAVEN_PASSWORD }}
MINE_CODES_MAVEN_PASSWORD: ${{ secrets.MINE_CODES_MAVEN_PASSWORD }}
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);
}

}

0 comments on commit 2c52711

Please sign in to comment.