minecraft-data-v1 2.0.8 → 3.0.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.
@@ -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,18 @@
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
+ console.log(name)
9
+ const history = await fetch("https://api.capes.dev/load/" + user);
10
+ const json = await history.json();
11
+ return {
12
+ skin: "https://mc-heads.net/body/" + name,
13
+ cape: json.minecraft.exists ? json.minecraft.frontImageUrl : "No cape",
14
+ head: "https://mc-heads.net/head/" + name,
15
+ }
16
+ }
17
+
18
+ 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,7 @@
1
1
  module.exports = {
2
- head: require("./minecraft-data/head.js"),
3
- uuid: require("./minecraft-data/uuid.js"),
4
- names: require("./minecraft-data/names.js"),
5
- skin: require("./minecraft-data/skin.js")
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minecraft-data-v1",
3
- "version": "2.0.8",
4
- "description": "Datos de Minecraft",
3
+ "version": "3.0.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
- "jimp": "^0.16.1",
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
- ## **MINECRAFT-DATA-V1**
1
+ # **MINECRAFT-DATA-V1**
2
2
 
3
- > Libreria especializada en datos de Minecraft. Pronto se iran añadiendo mas funciones.
3
+ Get Minecraft player data and use it in your projects!
4
4
 
5
- Funcion | Uso de la funcion
5
+ Function | Usage
6
6
  -|-
7
- head | `await <MC>.head("Jugador");`
8
- uuid | `await <MC>.uuid("Jugador");`
9
- names | `await <MC>.names("Jugador");`
10
- skin | `await <MC>.skin("Jugador");`
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
- * Tipo: String\
14
- **Devuelve la cabeza del skin del jugador**
15
- ### Uuid
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
- * Tipo: String\
23
- **Devuelve la skin del jugador**
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
- > Apis usadas: https://api.mojang.com/, https://mc-heads.net/
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;
@@ -0,0 +1,7 @@
1
+ const decode = (text) => {
2
+ const buff = Buffer.from(text, 'base64');
3
+ const string = buff.toString('utf-8');
4
+ return string;
5
+ }
6
+
7
+ module.exports = decode;
@@ -0,0 +1,7 @@
1
+ const errorList = {
2
+ noName: "A name is required.",
3
+ noString: "The name must be a string."
4
+ }
5
+
6
+ module.exports = errorList;
7
+
@@ -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;
@@ -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;
@@ -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;
@@ -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
@@ -1,11 +0,0 @@
1
- const jimp = require("jimp");
2
-
3
- const image = async (photo) => {
4
- const img = await jimp.read(photo);
5
- let buffer = "";
6
- img.getBuffer(jimp.MIME_PNG, (err, image) => {
7
- buffer = image;
8
- })
9
- return buffer;
10
- }
11
- module.exports = image;