Command on action

Discussion in 'Plugin Development' started by TGF, Oct 14, 2012.

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

    TGF

    Hi!
    I have a little problem. I don't know how to make it:p
    I would like to send a command on action.
    That mean: player do sth(action) > action = command.
    For example: when player left click on block then this action execute /kill command for this player (just like that when player type /kill in chat but its important to player dont know that he sent a command)

    Code:
    if(event.getAction() == Action.LEFT_CLICK_BLOCK){
    //AND HERE ACTION SEND A COMMAND
                }
    I really need help with that:p
     
  2. Offline

    Hoolean Retired Staff

    TGF

    Do this:
    Code:java
    1. if(event.getAction() == Action.LEFT_CLICK_BLOCK){
    2. player.performCommand("kill");
    3. }


    Although, if you just want the player to die, do this:
    Code:java
    1. player.setHealth(0);
     
  3. Offline

    TGF

    You are great:p I'm gonna check this but I'm sure it's a solution for me.

    Can I override permissions on some way?
    For example player don't have perms to /gm.
    But when he click on block he perform command /gm successful.
     
  4. Offline

    Hoolean Retired Staff

    Unfortunately no, I don't think so :(
     
  5. Offline

    TGF

    Then hmm.
    Is it possible to block executing specific command for a player?
    Then I would like to give to player perm gm.* and block executing this from chat but execute only with left click action.
     
  6. Offline

    Hoolean Retired Staff

    I guess you could do this:
    Code:
    getServer().dispatchCommand(getServer().getConsoleSender(), "command "+player.getName());
    That code would make the console perform the command "command <player name>"!

    May I ask what gm does?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
    zack6849 likes this.
  7. Offline

    TGF

    Last edited by a moderator: May 29, 2016
  8. Offline

    CevinWa

    you could just give the permission peform the command and then remove the permission if he didn't had it before
     
  9. Offline

    Hoolean Retired Staff

    ^ Is true ^
     
  10. Offline

    TGF

    Good idea:p
     
Thread Status:
Not open for further replies.

Share This Page