How to get a player's name and store it in a string?

Discussion in 'Plugin Development' started by DaddyDBJ21, Sep 10, 2013.

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

    DaddyDBJ21

    Hello everyone,
    I'm working on a plugin that detects a player's name and does stuff based off of what their username is.
    Some peusdo-code for what I'm trying to do:
    Code:
    name = getPlayerName();
     
    if(name = "DaddyDBJ21"){
    //Do stuff
    }
    How might I go about doing that? Code examples are appreciated, I'm a still a noob to Bukkit plugin programming.
     
  2. Offline

    Chinwe

    Look at the docs, it's player.getName() :)
    (Use .equals() to compare strings instead of = or == (= is for defining variables, == is for comparing objects) ;)
     
    DaddyDBJ21 likes this.
  3. Offline

    tommycake50

    player.getName();
    player being an instance of Player.
     
  4. Offline

    xBlackLightx

    Code:java
    1. String playerName = player.getName;
    2. if(playerName.equals("DaddyDBJ21")){
    3. //do stuff
    4. }

    DaddyDBJ21
    Just in case you couldn't figure it out by their examples (And also to get posts :) )
     
    DaddyDBJ21 likes this.
  5. Offline

    DaddyDBJ21

Thread Status:
Not open for further replies.

Share This Page