2018-10-28 12:02:55 +01:00
|
|
|
# MCUUID
|
|
|
|
Getting Minecraft Player Information from Mojang API.
|
2015-03-11 20:20:20 +01:00
|
|
|
|
2015-03-11 20:34:28 +01:00
|
|
|
## Usage
|
2018-10-28 13:14:08 +01:00
|
|
|
1. `pip install mcuuid`
|
2018-10-28 12:02:55 +01:00
|
|
|
2. Use the module like this:
|
|
|
|
|
2018-10-28 15:07:58 +01:00
|
|
|
### API
|
2018-10-28 12:02:55 +01:00
|
|
|
```
|
2018-10-28 13:21:23 +01:00
|
|
|
from mcuuid.api import GetPlayerData
|
2018-10-28 12:02:55 +01:00
|
|
|
|
2018-10-28 15:07:58 +01:00
|
|
|
player = GetPlayerData(identifier)
|
2018-10-28 12:02:55 +01:00
|
|
|
|
|
|
|
if player.valid is True:
|
|
|
|
uuid = player.uuid
|
|
|
|
name = player.username
|
2015-03-11 20:20:20 +01:00
|
|
|
```
|
|
|
|
|
2018-10-28 15:07:58 +01:00
|
|
|
Identifier can be a username or a UUID.
|
2018-10-28 12:02:55 +01:00
|
|
|
|
2018-10-28 15:07:58 +01:00
|
|
|
When `identifier = "gronkh"`:
|
2018-10-28 12:02:55 +01:00
|
|
|
`uuid` will be `"a2080281c2784181b961d99ed2f3347c"`
|
|
|
|
and `name` will be `"Gronkh"`
|
2015-03-11 20:20:20 +01:00
|
|
|
|
2018-10-28 15:07:58 +01:00
|
|
|
|
2018-10-28 16:40:35 +01:00
|
|
|
```
|
|
|
|
player = GetPlayerData(identifier, timestamp)
|
|
|
|
```
|
|
|
|
|
|
|
|
Some names are time-sensitive. (When they are changed)
|
|
|
|
So you can choose a special time.
|
|
|
|
|
|
|
|
It even works with UUIDs. They respond the username at the given time.
|
|
|
|
|
2018-10-28 15:07:58 +01:00
|
|
|
### Tools
|
|
|
|
Syntax check of username
|
|
|
|
```
|
|
|
|
from mcuuid.tools import is_valid_minecraft_username
|
|
|
|
|
|
|
|
if is_valid_minecraft_username('gronkh'):
|
|
|
|
print('Valid')
|
|
|
|
```
|
|
|
|
|
|
|
|
Syntaxcheck of UUID
|
|
|
|
```
|
|
|
|
from mcuuid.tools import is_valid_mojang_uuid
|
|
|
|
|
|
|
|
if is_valid_mojang_uuid('a2080281c2784181b961d99ed2f3347c'):
|
|
|
|
print('Valid')
|
|
|
|
```
|
|
|
|
|
2018-10-28 20:46:18 +01:00
|
|
|
## Documentation
|
|
|
|
### Module `mcuuid.api`
|
|
|
|
#### Class `GetPlayerData(indentifier, timestamp=None)`
|
|
|
|
##### Parameters
|
|
|
|
- `identifier`: string - a Minecraft username or Mojang UUID
|
|
|
|
- `timestamp`: int - a unix timestamp
|
|
|
|
|
|
|
|
##### Returns
|
|
|
|
`player` object
|
|
|
|
|
|
|
|
#### Object `player`
|
|
|
|
##### Value `player.uuid`
|
|
|
|
Mojang UUID
|
|
|
|
|
|
|
|
##### Value `player.username`
|
|
|
|
Minecraft username
|
|
|
|
|
|
|
|
### Module `mcuuid.tools`
|
|
|
|
#### Function `is_valid_minecraft_username(username)`
|
|
|
|
##### Parameters
|
|
|
|
- `username`: string - a Minecraft username
|
|
|
|
|
|
|
|
##### Returns
|
|
|
|
`True` or `False`
|
|
|
|
|
|
|
|
#### Function `is_valid_mojang_uuid(uuid)`
|
|
|
|
##### Parameters
|
|
|
|
- `uuid`: string - a Mojang UUID
|
|
|
|
|
|
|
|
##### Returns
|
|
|
|
`True` or `False`
|
|
|
|
|
|
|
|
#### Function `cleanup_uuid(uuid)`
|
|
|
|
##### Parameters
|
|
|
|
- `uuid`: string - a Mojang UUID
|
|
|
|
|
|
|
|
##### Returns
|
|
|
|
`uuid` as string, lowered. Without dashes
|
|
|
|
|
2018-10-28 12:02:55 +01:00
|
|
|
## Test file
|
|
|
|
Usage
|
|
|
|
```
|
|
|
|
$ python test.py gronkh
|
|
|
|
```
|
|
|
|
or
|
|
|
|
```
|
2018-10-28 15:07:58 +01:00
|
|
|
$ python test.py a2080281c2784181b961d99ed2f3347c
|
|
|
|
```
|
|
|
|
or
|
|
|
|
```
|
2018-10-28 12:02:55 +01:00
|
|
|
$ python test.py
|
2018-10-28 15:07:58 +01:00
|
|
|
Please enter a username or UUID:
|
2018-10-28 12:02:55 +01:00
|
|
|
gronkh
|
|
|
|
```
|
2018-10-28 15:07:58 +01:00
|
|
|
or
|
|
|
|
```
|
|
|
|
$ python test.py
|
|
|
|
Please enter a username or UUID:
|
|
|
|
a2080281c2784181b961d99ed2f3347c
|
|
|
|
```
|
2018-10-28 12:02:55 +01:00
|
|
|
|
|
|
|
Response:
|
|
|
|
```
|
|
|
|
UUID: a2080281c2784181b961d99ed2f3347c
|
|
|
|
correct name: Gronkh
|
2015-03-11 20:20:20 +01:00
|
|
|
```
|
|
|
|
|
2015-03-11 20:39:44 +01:00
|
|
|
## License
|
2015-03-11 20:41:43 +01:00
|
|
|
This software is licensed under the MIT license. Feel free to use it however you like.
|