File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const config = {
1010 username_occupied : 'Даний юзернейм уже використовується!' ,
1111 user_delete_success : 'Ваш акаунт видалено успішно!'
1212 } ,
13+ defaultServerIcon : 'https://media.minecraftforum.net/attachments/thumbnails/300/619/115/115/636977108000120237.png' ,
1314}
1415export default config ;
1516export type StatusKey = keyof typeof config . MESSAGES ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { toast } from "sonner";
1212import moment from "moment" ;
1313import { RiArrowLeftLine } from "react-icons/ri" ;
1414import { useAuth } from "../../hooks/useAuth" ;
15+ import config from "../../config" ;
1516
1617const ServerPage = ( ) => {
1718 const { id} = useParams ( ) ;
@@ -89,7 +90,7 @@ const ServerPage = () => {
8990 </ div >
9091 < div className = "bg-green-700 p-4 sm:w-2/5 rounded" >
9192 < div className = "flex w-full items-center justify-between" >
92- < img className = "h-16 w-16" src = { serverInfo . icon } />
93+ < img className = "h-16 w-16" src = { serverInfo . icon ?? config . defaultServerIcon } />
9394 < div className = "text-sm sm:text-base whitespace-pre-wrap max-w-52" >
9495 { serverInfo . motd ? < >
9596 < p > { parse ( serverInfo . motd . html [ 0 ] ) } </ p >
@@ -101,8 +102,8 @@ const ServerPage = () => {
101102 < div className = "bg-gray-400 rounded p-1" >
102103 < p > IP адреса:</ p >
103104 < div className = "flex items-center" >
104- < p > { server . formatted_address } </ p >
105- < CopyBtn text = { server . formatted_address } />
105+ < p > { serverInfo . debug . srv ? server . address : server . formatted_address } </ p >
106+ < CopyBtn text = { serverInfo . debug . srv ? server . address : server . formatted_address } />
106107 </ div >
107108 </ div >
108109 < div className = "grid grid-cols-2" >
Original file line number Diff line number Diff line change @@ -16,18 +16,24 @@ interface ServerStatusInfoType {
1616 software : string ;
1717 debug : {
1818 cachetime : number ;
19+ srv : boolean ;
1920 } ;
2021 address : string ;
2122 port : number ;
2223}
2324
2425const getServerStatusInfo = async ( address : string , port ?: number ) : Promise < void | ServerStatusInfoType > => {
25- return await apiClient . get < ServerStatusInfoType > ( port ? `/${ address } :${ port } ` : `/${ address } ` , {
26+ let info = await apiClient . get < ServerStatusInfoType > ( port ? `/${ address } :${ port } ` : `/${ address } ` , {
2627 baseURL : 'https://api.mcsrvstat.us/3/' ,
2728 withCredentials : false ,
28- } )
29- . then ( resp => resp . data )
30- . catch ( err => console . log ( err ) ) ;
29+ } ) ;
30+ if ( port && info . data . port != port ) {
31+ info = await apiClient . get < ServerStatusInfoType > ( `/${ address } ` , {
32+ baseURL : 'https://api.mcsrvstat.us/3/' ,
33+ withCredentials : false ,
34+ } ) ;
35+ } ;
36+ return info . data ;
3137}
3238
3339export default getServerStatusInfo ;
You can’t perform that action at this time.
0 commit comments