Skip to content

Commit 6e530b9

Browse files
committed
player skin and uuid mojang api proxy (bc cors)
1 parent 10e329b commit 6e530b9

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

lib/server.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const app = express()
33
const netApi = require('./proxy.js')
44
const port = process.env.PORT || 8080
55
const cors = require('cors')
6+
const fetch = require('node-fetch')
67

78
app.use(cors())
89
app.use(netApi({ allowOrigin: '*' }))
@@ -11,6 +12,24 @@ app.use("/proxyCheck",(req,res,next)=>{
1112
res.send("OK")
1213
})
1314

15+
app.get("/getId",(req,res,next)=>{
16+
fetch(`https://api.mojang.com/users/profiles/minecraft/${req.query.nick}`)
17+
.then(data => data.json())
18+
.then(player => {res.send(player.id)})
19+
.catch(error =>{
20+
res.send("ERR")
21+
})
22+
})
23+
24+
app.get("/getSkin",(req,res,next)=>{
25+
fetch(`https://sessionserver.mojang.com/session/minecraft/profile/${req.query.id}?legacy=true`)
26+
.then(data => data.json())
27+
.then(player => {res.json(player)})
28+
.catch(error =>{
29+
res.send("ERR")
30+
})
31+
})
32+
1433
app.listen(port, () => {
1534
console.log(`Server is running on \x1b[34m*:${port}\x1b[0m`)
1635
})

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
"node": "14.x"
2929
},
3030
"dependencies": {
31-
"express-ws": "^4.0.0",
32-
"express": "^4.17.1",
31+
"body-parser": "^1.19.0",
3332
"cors": "^2.8.5",
3433
"crypto": "^1.0.1",
35-
"body-parser": "^1.19.0"
34+
"express": "^4.17.1",
35+
"express-ws": "^4.0.0"
3636
},
3737
"devDependencies": {
3838
"ansi-to-html": "^0.6.14",

src/scripts/Setup.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ function Setup (game) {
7373
.then(data => {
7474
if(data=="OK"){
7575
game.ls.show(`Connecting to ${game.server}...`)
76+
77+
//PLAYER UUID
78+
fetch(`${document.location.protocol}//${hostname}:${port}/getId?nick=${game.nick}`)
79+
.then(response => response.text())
80+
.then(id => {
81+
if(id!=="ERR"){
82+
console.log(`UUID: ${id}`)
83+
//SKIN
84+
fetch(`${document.location.protocol}//${hostname}:${port}/getSkin?id=${id}`)
85+
.then(response => response.json())
86+
.then(data => {
87+
// console.log(data)
88+
const nd=JSON.parse(atob(data.properties[0].value))
89+
// console.log(nd)
90+
console.log(`SKIN: ${nd.textures.SKIN.url}`)
91+
});
92+
}else{
93+
console.log("UUID not found!")
94+
}
95+
});
7696
}
7797
});
7898
game.distanceBasedFog.addShaderToMaterials([

0 commit comments

Comments
 (0)