Jump to content

Probably a stupid question, but function for getting a player's username.


Recommended Posts

Posted

I feel pretty stupid for even asking this, but I have skimmed the entityplayer files without finding what I am looking for. It is probably right in front of me, but I'll ask here anyway :|

 

I was looking to add a player's username to a render. I unfortunately just can't quite seem to find the function that returns it.

Again, most likely because I am looking right over it. Poooint me in the right direction Forge forum!!(please)

 

 

Thanks in advance.

Posted

EntityPlayer.username

 

Use your javadocs.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

The good news is: I had already tried that.

 

The bad news is: I can't quite return that from my function.

 

 

Function as of now just in case it will help:

 

 public EntityPlayer getName()
    {
        

        return EntityPlayer.username;
    }

Posted

The good news is: I had already tried that.

 

The bad news is: I can't quite return that from my function.

 

 

Function as of now just in case it will help:

 

 public EntityPlayer getName()
    {
        

        return EntityPlayer.username;
    }

 

*Facepalm*

 

First off, the return type of that function is wrong.

 

Second you need a player reference, the username property is not static.

 

 public String getName(EntityPlayer player)
    {
        

        return player.username;
    }

 

Basic programming stuff, this.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

First, I asked for a return statement, so the facepalm is rather rude considering the ---->

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Third, thank you. I've been fumbling around with this too long to not realize I didn't make it a string function. Stupid me is stupid.

 

Going to give you a thanks, but perhaps you should consider not being rude the next time someone makes an easily looked over error.

Posted

First, I asked for a return statement, so the facepalm is rather rude considering the ---->

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Third, thank you. I've been fumbling around with this too long to not realize I didn't make it a string function. Stupid me is stupid.

 

Going to give you a thanks, but perhaps you should consider not being rude the next time someone makes an easily looked over error.

 

Just think about this for one minute... wait, make that a string of minutes.

 

That is not the kind of error that is "easily overlooked". It is basic programming to know that you are wanting a String to return, not an EntityPlayer. If you want a string, the method is a String method!

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Also, once again, basic programming. The reason someone face-palms (albeit sometimes in a rude way, [sorry Draco, it is rude, even if I would do it too :P]) is because someone does something either A) Stupid (like the case sort of is here), or B) Missed something so obvious it should have killed them...

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Posted

First, I asked for a return statement, so the facepalm is rather rude considering the ---->

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Third, thank you. I've been fumbling around with this too long to not realize I didn't make it a string function. Stupid me is stupid.

 

Going to give you a thanks, but perhaps you should consider not being rude the next time someone makes an easily looked over error.

 

Just think about this for one minute... wait, make that a string of minutes.

 

That is not the kind of error that is "easily overlooked". It is basic programming to know that you are wanting a String to return, not an EntityPlayer. If you want a string, the method is a String method!

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Also, once again, basic programming. The reason someone face-palms (albeit sometimes in a rude way, [sorry Draco, it is rude, even if I would do it too :P]) is because someone does something either A) Stupid (like the case sort of is here), or B) Missed something so obvious it should have killed them...

Eh, I wouldn't say "stupid". I know that it seems sometimes like everybody and his dog wants to make a Minecraft mod, and that some people have less knowledge of Java than the aforementioned dogs, but that's not a license to call them "stupid". Tell them to learn Java, certainly. But don't call them stupid.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted
That is not the kind of error that is "easily overlooked". It is basic programming to know that you are wanting a String to return, not an EntityPlayer. If you want a string, the method is a String method!

 

Not to mention that his code should have been throwing errors...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Going to put one more quick post into this since apparently it got more backlash than needed.

 

It is an easily overlooked error. Believe me. So much that I didn't realize that (half) of my problem was that I hadn't noticed it the function being changed at that point and time. I just copied and pasted here with the first "suggestion" Draco18s made.

(while in reality, the nifty Eclipse hover and fix changed the code to Enitplayer getName(), whereas I thought it was still String getName(), but that's what I get for trying to rush around and copy things to the forum for a quick reply)

 

That being said, I made a mistake in copying. My bad. I also stated at least three times that this was probably a stupid question in the original post. I'm not the best programmer in the world, nor did I have any actual teaching. Sometimes I make mistakes. That being said, no need to be a douche when I explicitly state I'm asking a stupid question.

 

Chances are I am asking a stupid question because I know I have made a stupid mistake, and just don't exactly know why.

 

There is no point in making this any more of an ordeal. Feel free to criticize me whenever I do something stupid and I am not ALREADY aware of it.

Posted
It is an easily overlooked error. Believe me. So much that I didn't realize that (half) of my problem was that I hadn't noticed it the function being changed at that point and time. I just copied and pasted here with the first "suggestion" Draco18s made.

 

I don't post code that works because 99% of the time I'm not opening Eclipse and nabbing exact function names.

I do, however, post code that tells people where to look.

 

(while in reality, the nifty Eclipse hover and fix changed the code to Enitplayer getName(), whereas I thought it was still String getName(), but that's what I get for trying to rush around and copy things to the forum for a quick reply)

 

Forums are an asynchronous method of communication.  Therefor you can afford the time to spellcheck and make sure you've got things write.*  About a third of my own questions are solved before I even make my opening post because in the process of copy-pasting and explaining what's going on I realize my error.

 

That being said, I made a mistake in copying. My bad.

 

Which is impossible to know from this end, therefor it is acceptable to point out these errors.

 

There is no point in making this any more of an ordeal. Feel free to criticize me whenever I do something stupid and I am not ALREADY aware of it.

 

This post is not a criticism, it is for future reference.

 

*Even go back and make edits.  This word should be "right" but I have a bad habit of typing the wrong thing and will frequently alter my posts when I notice errors just after clicking submit.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.