Console Commands

Discussion in 'Plugin Development' started by djscoobyg, Mar 11, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    djscoobyg

    How would I make a command usable by both a player AND the console?
     
  2. If you need an example (open)
    if (sender instanceof player) {
    Player player = (Player) sender; }
    DONT DO THIS
    @djscoobyg Don't check if the sender is an instance of player, and don't cast sender to player.
     
    Konato_K likes this.
  3. Offline

    djscoobyg

  4. @djscoobyg Okay don't do the Player player = (Player) sender; Besides, you shouldn't be casting sender to player without checking if it's a player. If your problem still persists, post your full class and a stacktrace if you get one.
     
  5. Offline

    djscoobyg

  6. Offline

    teej107

    Player is always a ConsoleSender, but a ConsoleSender won't always be a Player. If you want a command to be ran by any ConsoleSender, then you just need to use the ConsoleSender that is passed through parameters.
     
  7. Offline

    Konato_K

    @teej107 You mean CommandSender, ConsoleSender it's another thing.
     
    teej107 likes this.
  8. Offline

    teej107

Thread Status:
Not open for further replies.

Share This Page