If player name is.. Do..

Discussion in 'Bukkit Help' started by segovo, Apr 20, 2016.

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

    segovo

    hi i am thinking about making a plugin (i have made plugins before) that when /give stuff it will check if the players name is: <players name> And allow or deny the command to run. So basically if players name is TheHolyOne then let them /give stuff if not TheHolyOne don't do anything.
    So is this possible?
     
  2. Offline

    TheEntropy

    @segovo

    That can be achieved fairly easily:
    Code:
    Player target = // get the player object here
    
    // check if the player in question has the name you are looking for
    if (target.getName().equalsIgnoreCase("TheHolyOne")) {
        // This will run if the targeted player is named TheHolyOne
    } else {
        // This will run if the targeted player is not named TheHolyOne
    }
     
  3. Offline

    jsutaria

    Code:
    Player p = (Player) sender;
    String pname = "myname"
    if (p.getName().equalsIgnoreCase(myname) {
        p.sendMessage("You have the name " + p.getName());
    } else {
        p.sendMessage("You have the name " + p.getName() + ", not the name " + myname);
    
    }
     
Thread Status:
Not open for further replies.

Share This Page