minecraft-data-v1 2.0.8 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/baseMethods/names.js +14 -0
- package/baseMethods/profile.js +38 -0
- package/baseMethods/skinRender.js +17 -0
- package/baseMethods/uuid.js +12 -0
- package/index.js +6 -4
- package/package.json +3 -4
- package/readme.md +24 -19
- package/userMethods/getCape.js +10 -0
- package/userMethods/getHead.js +10 -0
- package/userMethods/getNames.js +10 -0
- package/userMethods/getSkin.js +10 -0
- package/userMethods/getUuid.js +10 -0
- package/utils/decode.js +7 -0
- package/utils/errors.js +7 -0
- package/minecraft-data/head.js +0 -11
- package/minecraft-data/names.js +0 -16
- package/minecraft-data/skin.js +0 -10
- package/minecraft-data/uuid.js +0 -14
- package/util/image.js +0 -11
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const fetch = require("node-fetch")
|
|
2
|
+
const uuid = require("./uuid.js");
|
|
3
|
+
const names = async (user) => {
|
|
4
|
+
if (!user) throw new TypeError("A name is required.");
|
|
5
|
+
if (typeof user != "string") throw new TypeError("Names error | 2");
|
|
6
|
+
let name = await uuid(user);
|
|
7
|
+
const history = await fetch("https://api.mojang.com/user/profiles/" + name + "/names");
|
|
8
|
+
const json = await history.json();
|
|
9
|
+
const array = json.map(e => e.name);
|
|
10
|
+
return array;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = names;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const fetch = require("node-fetch");
|
|
2
|
+
const decode = require("../utils/decode.js");
|
|
3
|
+
const id = require("./uuid.js");
|
|
4
|
+
const names = require("./names.js")
|
|
5
|
+
const skinRender = require("./skinRender.js");
|
|
6
|
+
const profile = async (user) => {
|
|
7
|
+
if (!user) throw new TypeError(errors.noName);
|
|
8
|
+
if (typeof user != "string") throw new TypeError(errors.noString);
|
|
9
|
+
const uuid = await id(user);
|
|
10
|
+
const history = await fetch("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid);
|
|
11
|
+
const json = await history.json();
|
|
12
|
+
const render = await skinRender(user);
|
|
13
|
+
const data = json["properties"][0].value;
|
|
14
|
+
const string = decode(data);
|
|
15
|
+
const stringJson = JSON.parse(string);
|
|
16
|
+
const userInformation = {
|
|
17
|
+
name: stringJson.profileName,
|
|
18
|
+
//names: await names(user),
|
|
19
|
+
uuid: uuid,
|
|
20
|
+
textures: {
|
|
21
|
+
skin: {
|
|
22
|
+
textureSkin: stringJson.textures.SKIN.url,
|
|
23
|
+
renderSkin: render.skin,
|
|
24
|
+
},
|
|
25
|
+
cape: {
|
|
26
|
+
textureCape: stringJson.textures.CAPE ? stringJson.textures.CAPE.url : "No cape",
|
|
27
|
+
renderCape: render.cape,
|
|
28
|
+
},
|
|
29
|
+
head: {
|
|
30
|
+
head: render.head,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
return userInformation;
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = profile;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const fetch = require("node-fetch")
|
|
2
|
+
const uuid = require("./uuid.js");
|
|
3
|
+
const errors = require("../utils/errors.js");
|
|
4
|
+
const skinRender = async (user) => {
|
|
5
|
+
if (!user) throw new TypeError(errors.noName);
|
|
6
|
+
if (typeof user != "string") throw new TypeError(errors.noString);
|
|
7
|
+
let name = await uuid(user);
|
|
8
|
+
const history = await fetch("https://api.capes.dev/load/" + user);
|
|
9
|
+
const json = await history.json();
|
|
10
|
+
return {
|
|
11
|
+
skin: "https://mc-heads.net/body/" + name,
|
|
12
|
+
cape: json.minecraft.exists ? json.minecraft.frontImageUrl : "No cape",
|
|
13
|
+
head: "https://mc-heads.net/head/" + name,
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = skinRender;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const fetch = require("node-fetch");
|
|
2
|
+
const errors = require("../utils/errors.js");
|
|
3
|
+
const uuid = async (user) => {
|
|
4
|
+
if (!user) throw new TypeError(errors.noName);
|
|
5
|
+
if (typeof user != "string") throw new TypeError(errors.noString);
|
|
6
|
+
const url = "https://api.mojang.com/users/profiles/minecraft/";
|
|
7
|
+
const result = await fetch(url + user)
|
|
8
|
+
const json = await result.json().catch(err => console.log(err))
|
|
9
|
+
return json.id;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = uuid;
|
package/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
head: require("./
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
head: require("./userMethods/getHead.js"),
|
|
3
|
+
//names: require("./userMethods/getNames.js"),
|
|
4
|
+
skin: require("./userMethods/getSkin.js"),
|
|
5
|
+
uuid: require("./userMethods/getUuid.js"),
|
|
6
|
+
cape: require("./userMethods/getCape.js"),
|
|
6
7
|
}
|
|
8
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minecraft-data-v1",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "Minecraft profile data",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"
|
|
14
|
-
"node-fetch": "^2.6.1"
|
|
13
|
+
"node-fetch": "^2.7.0"
|
|
15
14
|
}
|
|
16
15
|
}
|
package/readme.md
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
# **MINECRAFT-DATA-V1**
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Get Minecraft player data and use it in your projects!
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Function | Usage
|
|
6
6
|
-|-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
cape | `await <MC>.cape(<playerName>);`
|
|
8
|
+
head | `await <MC>.head(<playerName>);`
|
|
9
|
+
skin | `await <MC>.skin(<playerName>);`
|
|
10
|
+
uuid | `await <MC>.uuid(<playerName>);`
|
|
11
|
+
|
|
12
|
+
### Cape
|
|
13
|
+
* Type: **Object**
|
|
14
|
+
* Returns an object with two properties: **textureCape** and **renderCape**.
|
|
11
15
|
|
|
12
16
|
### Head
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Tipo: String\
|
|
17
|
-
**Devuelve el uuid del jugador**
|
|
18
|
-
### Names
|
|
19
|
-
* Tipo: Array\
|
|
20
|
-
**Devuelve los nombres del jugador**
|
|
17
|
+
* Type: **String**
|
|
18
|
+
* Returns a URL string of the player head image.
|
|
19
|
+
|
|
21
20
|
### Skin
|
|
22
|
-
*
|
|
23
|
-
|
|
21
|
+
* Type: **Object**
|
|
22
|
+
* Returns an object with two properties: **textureSkin** and **renderSkin**.
|
|
23
|
+
|
|
24
|
+
### UUID
|
|
25
|
+
* Type: **String**
|
|
26
|
+
* Returns player UUID
|
|
27
|
+
|
|
28
|
+
|
|
24
29
|
|
|
30
|
+
> Used APIs: https://api.mojang.com/, https://mc-heads.net/
|
|
25
31
|
|
|
26
|
-
>
|
|
32
|
+
> If you have any issues, join this [Discord server](https://discord.gg/n25aytTSXX) for help.
|
|
27
33
|
|
|
28
34
|
|
|
29
|
-
> En el caso de encontrar un error dirijase a https://discord.com/invite/smcREX7xUD y informelo a algun staff.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const profile = require("../baseMethods/profile");
|
|
2
|
+
const errors = require("../utils/errors.js");
|
|
3
|
+
const getCape = async (player) => {
|
|
4
|
+
if (!player) throw new TypeError(errors.noName);
|
|
5
|
+
if (typeof player != "string") throw new TypeError(errors.noString);
|
|
6
|
+
const user = await profile(player);
|
|
7
|
+
return user.textures.cape;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = getCape;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const profile = require("../baseMethods/profile");
|
|
2
|
+
const errors = require("../utils/errors.js");
|
|
3
|
+
const getHead = async (player) => {
|
|
4
|
+
if (!player) throw new TypeError(errors.noName);
|
|
5
|
+
if (typeof player != "string") throw new TypeError(errors.noString);
|
|
6
|
+
const user = await profile(player);
|
|
7
|
+
return user.textures.head.head;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = getHead;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const profile = require("../baseMethods/profile");
|
|
2
|
+
const errors = require("../utils/errors.js");
|
|
3
|
+
const getNames = async (player) => {
|
|
4
|
+
if (!player) throw new TypeError("A name is required.");
|
|
5
|
+
if (typeof player != "string") throw new TypeError("The name must be a string.");
|
|
6
|
+
const user = await profile(player);
|
|
7
|
+
return user.names;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = getNames;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const profile = require("../baseMethods/profile");
|
|
2
|
+
const errors = require("../utils/errors.js");
|
|
3
|
+
const getSkin = async (player) => {
|
|
4
|
+
if (!player) throw new TypeError(errors.noName);
|
|
5
|
+
if (typeof player != "string") throw new TypeError(errors.noString);
|
|
6
|
+
const user = await profile(player);
|
|
7
|
+
return user.textures.skin;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = getSkin;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const profile = require("../baseMethods/profile");
|
|
2
|
+
const errors = require("../utils/errors.js");
|
|
3
|
+
const getUuid = async (player) => {
|
|
4
|
+
if (!player) throw new TypeError(errors.noName);
|
|
5
|
+
if (typeof player != "string") throw new TypeError(errors.noString);
|
|
6
|
+
const user = await profile(player);
|
|
7
|
+
return user.uuid;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = getUuid;
|
package/utils/decode.js
ADDED
package/utils/errors.js
ADDED
package/minecraft-data/head.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const uuid = require("./uuid.js");
|
|
2
|
-
const image = require("../util/image.js");
|
|
3
|
-
const head = async (user) => {
|
|
4
|
-
if(!user) throw new TypeError("Introduce un nombre de usuario.");
|
|
5
|
-
if(typeof user != "string") throw new TypeError("El nombre de usuario un tiene que ser un string.");
|
|
6
|
-
let name = await uuid(user);
|
|
7
|
-
return name ? "https://mc-heads.net/head/"+name+".png": undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = head;
|
package/minecraft-data/names.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const fetch = require("node-fetch")
|
|
2
|
-
const uuid = require("./uuid.js");
|
|
3
|
-
const names = async (user) => {
|
|
4
|
-
if(!user) throw new TypeError("Introduce un nombre de usuario.");
|
|
5
|
-
if(typeof user != "string") throw new TypeError("El nombre de usuario un tiene que ser un string.");
|
|
6
|
-
if(!user) throw new TypeError("Introduce un nombre de usuario.");
|
|
7
|
-
if(typeof user != "string") throw new TypeError("El nombre de usuario un tiene que ser un string.");
|
|
8
|
-
let name = await uuid(user);
|
|
9
|
-
const history = await fetch("https://api.mojang.com/user/profiles/"+name+"/names");
|
|
10
|
-
const json = await history.json();
|
|
11
|
-
const array = json.map(e => e.name);
|
|
12
|
-
return array;
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = names;
|
package/minecraft-data/skin.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const uuid = require("./uuid.js");
|
|
2
|
-
const image = require("../util/image.js");
|
|
3
|
-
const skin = async (user) => {
|
|
4
|
-
if(!user) throw new TypeError("Introduce un nombre de usuario.");
|
|
5
|
-
if(typeof user != "string") throw new TypeError("El nombre de usuario un tiene que ser un string.");
|
|
6
|
-
let name = await uuid(user);
|
|
7
|
-
return "https://mc-heads.net/body/"+name+".png";
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = skin;
|
package/minecraft-data/uuid.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const fetch = require("node-fetch");
|
|
2
|
-
const uuid = async (user) => {
|
|
3
|
-
if(!user) throw new TypeError("Introduce un nombre de usuario.");
|
|
4
|
-
if(typeof user != "string") throw new TypeError("El nombre de usuario un tiene que ser un string.");
|
|
5
|
-
const url = "https://api.mojang.com/users/profiles/minecraft/";
|
|
6
|
-
const result = await fetch(url+user)
|
|
7
|
-
const json = await result.json().catch(error => {
|
|
8
|
-
throw "Nombre de jugador invalido."
|
|
9
|
-
});
|
|
10
|
-
return json ? json.id: undefined;
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
module.exports = uuid;
|
package/util/image.js
DELETED