Strange bug with player.getName()

Discussion in 'Plugin Development' started by StevenMG, Sep 6, 2013.

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

    StevenMG

    I ran into a rather odd bug where player.getName() is returning the following: "org.theglicks.bukkit.fuedalism.Vassal@7616d3e0"

    Here is the code from "org.theglicks.bukkit.fuedalism.Vassal" class where the method is called:
    Code:
    public Vassal(String vassalName){
        try {
            name = vassalName;
            vData.rs = vData.st.executeQuery("SELECT * FROM `vassals` WHERE `name` = '" + name + "';");
            vData.rs.first();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }   
     
    public String getName(){
        return name;
    }
    The Vassal object is being creating from the following code:
    Code:
    public Vassal getOwner(){
        return new Vassal(owner.getName());
    }
    In the code above owner is a Player object.

    Could this be caused by memory leaks?

    ps. i was gonna edit the first post, but the feature seems to be broken ATM :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  2. Offline

    metalhedd

    You're mistaken about the code that creates the Vassal instance. player.getName will not ever return that string you pasted. that's the string representation of an instance of the Vassal class.


    it's not a memory leak, its definitely just a misunderstanding on your part, but we can't solve it without seeing the rest of the code.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
    StevenMG likes this.
  3. Offline

    StevenMG

    ..I suddenly feel stupid because you're right... Its the string representation of the Vassal object, and i was calling the wrong method when displaying the name. Thanks for the help.
     
  4. Offline

    metalhedd

    Glad to be of assistance :D
     
Thread Status:
Not open for further replies.

Share This Page