Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Get UUID from name for offline player


Recommended Posts

I am having difficulty with my mod in getting the UUID of an offline player from their name. How can I do this? I am using forge version 1.12.2 - 14.23.1.2555.

•Fact: Updating a mod to a new version of minecraft takes time. Especially if the original mod was never open source.

•Fact: The more users pester people who make mods to update their mods to a new version of minecraft, the less likely it is that it will be quickly updated.

•Fact: The more you comment about it, the more likely you are to be ignored.

•Fact: The more recent the last post about updating a mod is, the more annoying yours will be.

•Fact: Using all caps does not reverse any of the above effects

Link to post
Share on other sites

I don't know if it's possible to get from UUID from offline player (I haven't tried it before) but you can save player uuid to configuration file when he logged in server first time, and you can check his nickname from configuration file. If I remember correct, playerLoginEvent or LoggedIn event could be suitable for this.

Link to post
Share on other sites
9 hours ago, DaComputerNerd said:

I am having difficulty with my mod in getting the UUID of an offline player from their name. How can I do this? I am using forge version 1.12.2 - 14.23.1.2555.

An offline player by definition has no real UUID. There is code to create some fake UUID based on the name, but this is terrible, since the UUID will then change once they are online again (this will make the player's pets forget their owner, etc.).

 

You should not play offline :P

Link to post
Share on other sites
11 hours ago, diesieben07 said:

An offline player by definition has no real UUID. There is code to create some fake UUID based on the name, but this is terrible, since the UUID will then change once they are online again (this will make the player's pets forget their owner, etc.).

 

You should not play offline :P

Maybe the OP is talking about player's that are not present on the world or players that are not really logged on?

Edited by Differentiation
Link to post
Share on other sites
  • 2 weeks later...

I mean the UUID that is used to keep stuff like inventory when you change your username and track previous names.

 

By  offline I mean they are not on the server. Not that they pirated the game or something.

 

I figured it out. Make an HTTP GET request to https://api.mojang.com/users/profiles/minecraft/username?at=time, but replacing the username and time with the actual username and time. the ?at= portion is not required. It returns the UUID and the name they had at the given time, in JSON format. You can go there with your own name to check this. 

Edited by DaComputerNerd

•Fact: Updating a mod to a new version of minecraft takes time. Especially if the original mod was never open source.

•Fact: The more users pester people who make mods to update their mods to a new version of minecraft, the less likely it is that it will be quickly updated.

•Fact: The more you comment about it, the more likely you are to be ignored.

•Fact: The more recent the last post about updating a mod is, the more annoying yours will be.

•Fact: Using all caps does not reverse any of the above effects

Link to post
Share on other sites
11 hours ago, DaComputerNerd said:

By  offline I mean they are not on the server. Not that they pirated the game or something.

 

I figured it out. Make an HTTP GET request to https://api.mojang.com/users/profiles/minecraft/username?at=time, but replacing the username and time with the actual username and time. the ?at= portion is not required. It returns the UUID and the name they had at the given time, in JSON format. You can go there with your own name to check this. 

You should use PlayerProfileCache::getGameProfileForUsername instead, which will only make a request to the API if needed and cache results.

Link to post
Share on other sites
  • 3 weeks later...
On 1/28/2018 at 7:35 AM, diesieben07 said:

You should use PlayerProfileCache::getGameProfileForUsername instead, which will only make a request to the API if needed and cache results.

Good to know. Finding documentation was difficult.

My mod stores the data during runtime anyways, and makes the request when the command is run and the player is not found in the hashmap. 

•Fact: Updating a mod to a new version of minecraft takes time. Especially if the original mod was never open source.

•Fact: The more users pester people who make mods to update their mods to a new version of minecraft, the less likely it is that it will be quickly updated.

•Fact: The more you comment about it, the more likely you are to be ignored.

•Fact: The more recent the last post about updating a mod is, the more annoying yours will be.

•Fact: Using all caps does not reverse any of the above effects

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Whenever i try to run the installer it says This application requires a java runtime environment 1.6.0 im runing windows 10
    • So I thought that I had gotten pretty far on my own but now apparently my code crashes the game. I am new to using the forge API and modding in general and some help on why this crashes the game and how to fix it would be greatly appreciated:   public class SpecialItem extends ShootableItem {      public SpecialItem(Properties properties){ super(properties); }      @Override      public Predicate<ItemStack> getInventoryAmmoPredicate() { return null; }      @Override      public int func_230305_d_() { return 15; }      public int tcount=0;      @SubscribeEvent public void ontick(TickEvent.ClientTickEvent event){            tcount++;      }      @Override      public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {      if (!playerIn.getCooldownTracker().hasCooldown(this)) {           playerIn.getCooldownTracker().setCooldown(this, 40);           Vector3d v3 = playerIn.getLook(1);           for (tcount = 0; tcount <= 40;) {                if (tcount%10 == 0 && tcount!= 40) {                     final SmallFireballEntity entitysmallfireball = new SmallFireballEntity(playerIn.getEntityWorld(), playerIn.getPosX(), playerIn.getPosY() + playerIn.getEyeHeight() - 0.4, playerIn.getPosZ(), v3.x + playerIn.getRNG().nextGaussian() * 0.05, v3.y, v3.z);                     entitysmallfireball./* shoot */func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0f, 1.5f, 1.0f); worldIn.addEntity(entitysmallfireball); } } tcount = 0;                     return ActionResult.resultSuccess(playerIn.getHeldItem(handIn));            } return ActionResult.resultFail(playerIn.getHeldItem(handIn));      } }
    • I found a way to handle this, using javapoet as you suggested. For those who are interested in how it works, you can take a look at my sample here: https://github.com/DarkShadow44/compatibilitymod/tree/sourcegen Might not work with eclipse yet, but it builds properly.
    • It's fired on the logical client and logical server. Most likely you'll only need to execute the logic on the server.
    • If you're translating individual files, there's not much you can do about it. You could use the updateMappings gradlew task, but that's better for large batches of code. As for JSON item models, that is a much more complicated issue that involves layers and custom transform types. While still possible, the tradeoff isn't really worth it.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.