Mojang Account Support

For all mod-related questions and custom code.
Post Reply
User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Mojang Account Support

Post by LeChosenOne »

Hello! I'm sure that most people here are aware that Mojang has made it so that users could only have a MineCraft account if they purchased premium. Users can still make mojang accounts, but their log-in-name is the email they used for verification. This means that when logging into a server, their name is [email protected] or something along those lines. Obviously, IsValidName catches the '@' (at sign), and returns false, kicking the player before they can log in. By allowing the at-sign into a player name, we can allow mojang accounts to log into fcraft servers.

Image

Now, what I'm here to ask is, how can we trim a player.Name to something more appealing than [email protected] over to SirTacoMan314_.

I tried something to edit the name, but player.Name is readonly. Does anyone know a proper fix to this?
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Mojang Account Support

Post by fragmer »

For "proper fix" information, see this post.

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

So, its all on Mojang? The only real issue with emails is that it looks bad in chat and, well, people will know your email. Obviously it is easy to set a displayed name for a player, but is it even possible to modify a user's name in the db?
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Mojang Account Support

Post by Hellenion »

It's not possible to change the playerDB names automatically, you could do it by hand but then fragmer will shout at you for not being responsible for loss of data and stuff.

I could probably paste some code to work around your read-only problem but I don't think I have time for that until thursday.

Hey why not give all players with email a displayedname automatically? I think that may solve your issues
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

Hellenion wrote:It's not possible to change the playerDB names automatically, you could do it by hand but then fragmer will shout at you for not being responsible for loss of data and stuff.

I could probably paste some code to work around your read-only problem but I don't think I have time for that until thursday.

Hey why not give all players with email a displayedname automatically? I think that may solve your issues
Making a displayedname for users logging in is pretty simple, but what about when players want to whisper or /info the mojang account user. They would have to type the whole thing out. Plus, since the mojang account user's still have their email as their player name, their email is still rather public, posing a privacy issue. Finally, if a mojang account user sets their displayedname to something else, when they reset that name, it would just go back to showing the server their email. Changing the displayedname is only a very temporary fix. If we could somehow make the player name read-write instead of read, then we could automatically catch emails, and rewrite their names to be more user friendly. Also, there really is no reason for the player name to be readonly. It shouldn't pose any data risk, should it?
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Mojang Account Support

Post by Hellenion »

Well, everything that can change poses a risk. Just as an example, I'm sure this is not the only issue, but Playernames must be unique, if it somehow happened that a duplicate playername was written, the player in question would most likely be unidentifiable by the server. As it is now this cannot happen.

I don't know why playername was decided upon to be read-only, but I myself have a habit of making rewritable variables the exception. That way the systems I develop are much more predictable and understandable. If you have any skill in modding then let me hint you this:
read-only variables cannot only be read, they can be assigned to exactly once, which is then usually done at a defined (early) point in time such as the constructor. They are often initialized from the value of another object, so if you modify the value before it is first assigned, then you can still make the change you want to. But find where it is written and where the value comes from.

Hope that helps!
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

Well, it kidna works. But the playernames don't bypass the player verification yet.

Image
Honestly, for now, I am okay with this. I'm prob going to give mojang account users a default displayedname without the @, but I'll have to leave the @ so that their name wont conflict with normal account names. Also, I'll need to work with the error message above.
Thanks for your little hints hellenion!

Edit: Email users now get a displayedname without the @!
(All of this is on git if anyone was actually interested.)
The early bird gets the worm, but the second mouse gets the cheese.

matelo2
Offline
Posts: 24
Joined: January 6th, 2013, 12:17 am

Re: Mojang Account Support

Post by matelo2 »

Hellenion wrote:Well, everything that can change poses a risk. Just as an example, I'm sure this is not the only issue, but Playernames must be unique, if it somehow happened that a duplicate playername was written, the player in question would most likely be unidentifiable by the server. As it is now this cannot happen.
Hi,
I would like to comment on the above statement first.
On maiome (an fcraft server) we have a character called jacob (he is staff) if you do /info jacob it brings up a comment stating there are a number of names conforming to that and gives a list i.e. jacob, jacob154, jacobsname etc (i cant remember the exact names here). I can /info any of the others but can't /info jacob. is this what you are implying above? Is there any way I can /info him?

I am trying to get on maiome. I can get on as matelo2, I am a moderator. To do some testing I wanted to get on as a newb so I registered with mojang and got, unfortunately, an e-mail address. The server refuses to let me on, sometimes it lets me on with the e-mail address but recognises me as matelo2 a moderator? This might be because I am pressing the resume button on the wom client after checking the server is online with my matelo2 password now I think about it.
I don't have the facility to get at the source software but could you give me some idea how I could alter the source code to get round this so I can pass it on to the owner if I can contact him?
Thanks.
Matelo2

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

Yes, mojang accounts will give you an email username, that's the whole reason I was trying to add mojang account support. The resume button on wom will bring you back to the last server you successfully joined. Also, I'm pretty sure fCraft will look at your ip and try to allow you to connect if ips match.
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

In order to guarantee unique names, I'm thinking of adding a small xml database for all mojang account users. When logging in, the server checks if the xml db has the player. If not, it creates a new element for that user, with an attribute of a number. The number increases as the entrees increase. So for example, the first user to log in with a mojang account would get the a number one of 1, and the second person would get 2. Then, when they log in from that point, a person with an email of [email protected] becomes minecraftlolz1412@(the number of their position in the xml db goes here).

It's a work in progress :D
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Mojang Account Support

Post by Hellenion »

matelo2 wrote:
Hellenion wrote:if it somehow happened that a duplicate playername was written, the player in question would most likely be unidentifiable by the server.
we have a character called jacob (he is staff) if you do /info jacob it brings up a comment stating there are a number of names conforming to that and gives a list i.e. jacob, jacob154, jacobsname etc (i cant remember the exact names here). I can /info any of the others but can't /info jacob. is this what you are implying above? Is there any way I can /info him?
That is a great example of what I meant, but you should be able to /info jacob by typing jacobs exact playername. It might be jacob is just a "displayedname", which is like a nickname. If you type the exact and real name of jacob you should get their info.

The source code is accessible by something called "subversion", here is the latest tag: http://svn.fcraft.net:8080/svn/fcraft/tags/0.639/
I believe fcraft's author recommends some version of Microsoft Visual Studio to edit the source, but I use monodevelop, myself. This all does require quite some practise, though, it is certainly not something you can learn in a few days.

LechosenOne, your project has some very interesting solutions for the problems with e-mail accounts. I cannot find the Git repository you mean (or is it Legendcraft?) Would you mind throwing in a link?
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

Yes, LegendCraft is my mod on 800Craft. It's mostly for educational purposes but 3-4 servers use it as their server software. Here's the link if you wanted https://github.com/LeChosenOne/LegendCr ... its/master

Edit: Updated the software again with the experimental xml db.
The early bird gets the worm, but the second mouse gets the cheese.

matelo2
Offline
Posts: 24
Joined: January 6th, 2013, 12:17 am

Re: Mojang Account Support

Post by matelo2 »

Hellenion wrote:
matelo2 wrote:
Hellenion wrote:if it somehow happened that a duplicate playername was written, the player in question would most likely be unidentifiable by the server.
we have a character called jacob (he is staff) if you do /info jacob it brings up a comment stating there are a number of names conforming to that and gives a list i.e. jacob, jacob154, jacobsname etc (i cant remember the exact names here). I can /info any of the others but can't /info jacob. is this what you are implying above? Is there any way I can /info him?
That is a great example of what I meant, but you should be able to /info jacob by typing jacobs exact playername. It might be jacob is just a "displayedname", which is like a nickname. If you type the exact and real name of jacob you should get their info.
How do I find jacobs full name, everything I have tried just calls him jacob?
I don't know if you could go on maiome and get the info as a newb but you would see what I mean.
Thanks anyway.

Is it possible to be able to alter the messages that keep appearing on the server globally as an administrator or can it only be done from the consol? Including the one that appears every time someone joins the server?

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

When a player logs into a server, the console will be able to see their full name. I don't know if fCraft has /whois, which in 800craft, displays the all the names associated with a given displayedname. Otherwise, I'm pretty sure when a player logs in, there is a server message that displays both the full player.Name, and the displayedname. Here, I'll go see if that's true.

Edit:

Code: Select all

Logger.Log( LogType.UserActivity,
                        "Player {0} connected from {1} (session #{2})",
                        Name, IP, Info.TimesVisited );
Yup, when a player joins a server, the console is given their full username.
Also, you should be able to type /list displayednames, which will give a list of all nicknames, along with the players' full usernames.
The early bird gets the worm, but the second mouse gets the cheese.

matelo2
Offline
Posts: 24
Joined: January 6th, 2013, 12:17 am

Re: Mojang Account Support

Post by matelo2 »

if I do /whois jacob I get a list of names including jacob but no other name for him?
there is no /list displayednames in maiome but we are using a fairly old version, is the one in the present version?
Either way it gives me no way of getting info on our jacob the moderator

matelo2
Offline
Posts: 24
Joined: January 6th, 2013, 12:17 am

Re: Mojang Account Support

Post by matelo2 »

LeChosenOne wrote:Yes, mojang accounts will give you an email username, that's the whole reason I was trying to add mojang account support. The resume button on wom will bring you back to the last server you successfully joined. Also, I'm pretty sure fCraft will look at your ip and try to allow you to connect if ips match.
Which is possibly why it is logging me on a matelo2 when i try to go on as my e-mail user name from the same ip address do you think. If so is there any way of correcting this?

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

...Yup I lost you. Just try updating to the latest fCraft, and then use /list displayednames.
The early bird gets the worm, but the second mouse gets the cheese.

matelo2
Offline
Posts: 24
Joined: January 6th, 2013, 12:17 am

Re: Mojang Account Support

Post by matelo2 »

i will try to get the owner to do that. He doesn't use the fb any more so it is not easy to contact him.

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Mojang Account Support

Post by fragmer »

LeChosenOne wrote:...Yup I lost you. Just try updating to the latest fCraft, and then use /list displayednames.
There is no such feature in vanilla fCraft. You must be thinking of a mod.

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

Back on track, does anyone know the best way to work the playerDB instead of making and xml (it is probably faster and easier from the playerDB).
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Mojang Account Support

Post by fragmer »

Adding PlayerDB fields is not that hard. Just keep in mind that you can't back away from an added field -- if you change your mind at a later date, and you'll have to add compatibility code forever to avoid breaking old files.

There are four basic steps to adding a PlayerDB field:
  1. add a new property to the PlayerInfo class
  2. add code to serialize/save this property, at the end of PlayerInfo.Serialize()
  3. add code to parse/load this property at the end of PlayerInfo.LoadFormat2()
  4. document what you did: add new property's name to PlayerDB.Header string, and write some comments

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

The only issue is, it seems rather difficult to determine how many of a certain playerDB's are filled in. Also, for players that don't need this feature, can their section on the DB be left blank.

pseudo code:
if(player is using mojangaccout)
int i = (players in the playerDB using a mojang account) +1
player.Name = player.Name + 1;

If you can understand that, then that is where my dilemma comes into play. Is it possible to count up the playerDB and find how many players have a certain field in use?
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Mojang Account Support

Post by Hellenion »

Easy with LINQ, just select the playerInfos Where the field is not blank and retrieve the Count

It'll look a bit like:

Code: Select all

playerinfos.Where( info => info.mojang != null ).Count();
Probably.

Instead of my unchecked, probably horribly wrong LINQ, have a reference: http://msdn.microsoft.com/en-us/library/bb308959.aspx
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Mojang Account Support

Post by fragmer »

Hellenion wrote:

Code: Select all

playerinfos.Where( info => info.mojang != null ).Count();
Even simpler:

Code: Select all

playerinfos.Count( info => info.mojang != null );

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

I think i'll make info.mojang an int, and on default it will be zero.

Code: Select all

playerinfos.Count( info => info.mojang < 0 );
I can take that count, and set that number + 1, then set that as the current player's info.mojang. Does that seem reasonable?
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Mojang Account Support

Post by Hellenion »

What exactly were you planning on doing with your number? Did you not need a way to relate an e-mail address to a playerinfo object?
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

I want to shorten a player's name when they use a mojang account. Chart thing:

[email protected]
becomes
minecraftFAN@

The problem here is that [email protected], [email protected], [email protected] and etc all would fit under the same playerDB slot, since they would all have the same name. In order to prevent this, I needed to create a playerDB entree with a unique number for each mojang account user. Now, the outcome for the first player to log in with a mojang account would look like this.

minecraftFAN@1

If the 253th player to log on with a mojang account had an email of [email protected], then that would become

minecraftIsGreat@253

The entire purpose of this is to guarantee each player a unique name, while still granting them privacy for their email. I have to leave the @ in the name, otherwise there is a risk of mojang account [email protected] and normal account minecraftFan1 logging in under the same name in the player database. Does that clarify it up? I'm going to go ahead and serialize this and see if I get a result. I'll post back if I run into a brick wall or get it to work.
The early bird gets the worm, but the second mouse gets the cheese.

User avatar
LeChosenOne
Offline
Posts: 32
Joined: May 6th, 2012, 8:01 pm
Location: Classified

Re: Mojang Account Support

Post by LeChosenOne »

The early bird gets the worm, but the second mouse gets the cheese.

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Mojang Account Support

Post by fragmer »

As of fCraft 0.640, there is now built-in Mojang account support.

To create a "Name" from an email address, the domain part of the email is cut off, so e.g. "[email protected]" becomes "admin@". If more players later join with the same local part, but different domain part, a number is added after the @-sign, starting with number 2. So e.g. "[email protected]" joining later would become "admin@2".

Adding support included adding Email (string) field to PlayerDB, modifying Trie<T> to support dots and @-signs in player names, changing Player.IsValidName logic, changes to PlayerDB.FindOrCreatePlayerInfo, and changes to Player.LoginSequence.

Post Reply