Skip to content

How do I get Player object of player, who ran command, inside command. #2111

Answered by vearen1
AntonIXO asked this question in Help
Discussion options

You must be logged in to vote
public final class ExampleCommand extends Command {
   public ExampleCommand() {
       super("test");
       addSyntax(this::onTestCommand);
   }

   private void onTestCommand(CommandSender sender, CommandContext context) {
       if (!(sender instanceof Player player)) {
           return;
       }
       final Instance playerInstance = player.getInstance();
   }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AntonIXO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants