forked from PEXPlugins/PermissionsEx
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UUID fetching service for user heads using https://api.minetool…
…s.eu/ https://api.minetools.eu/ had to be used because Mojang API does not serve CORS Response headers.
- Loading branch information
Showing
5 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import axios from 'axios' | ||
|
||
const getUUID = async (name) => { | ||
const url = `https://api.minetools.eu/uuid/${name}` | ||
const response = await axios.get( | ||
url, | ||
{} | ||
).catch(e => { throw e }) | ||
const id = response.data.id | ||
|
||
return id !== 'null' ? id : null | ||
} | ||
|
||
export default { getUUID } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react' | ||
|
||
import uuidSvc from '../../services/uuid' | ||
|
||
class UserImg extends React.Component { | ||
|
||
constructor(props) { | ||
super(props) | ||
|
||
this.state = { | ||
name: this.props.name, | ||
uuid: null | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
const name = this.props.name | ||
uuidSvc.getUUID(name).then(uuid => { | ||
this.setState({ uuid, name }) | ||
}) | ||
} | ||
|
||
render() { | ||
if (this.props.name !== this.state.name) { | ||
this.componentDidMount() | ||
} | ||
const uuid = this.state.uuid | ||
const url = uuid && uuid !== null ? `https://visage.surgeplay.com/face/50/${uuid}` : 'https://visage.surgeplay.com/face/50/X-Steve' | ||
return <img style={{ padding: 0, alignContent: 'center', width: '55px' }} src={url}></img> | ||
} | ||
} | ||
|
||
export default UserImg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.