@@ -8,6 +8,8 @@ const supportedDomainHandlers: Record<
88 '9minecraft.net' : NineMinecraftHandler ,
99 'planetminecraft.com' : PlanetMinecraftHandler ,
1010 'tlauncher.org' : TLauncherHandler ,
11+ 'spigotmc.org' : SpigotMCHandler ,
12+ 'dev.bukkit.org' : BukkitHandler ,
1113} ;
1214
1315export function ExtractInfo ( element : HTMLElement ) : SearchResultInfo | false {
@@ -29,16 +31,21 @@ export function ExtractInfo(element: HTMLElement): SearchResultInfo | false {
2931 return supportedDomainHandlers [ domain ] ( link ) ;
3032}
3133
34+ // https://www.curseforge.com/minecraft/mc-mods/create
3235function CurseForgeHandler ( link : string ) : SearchResultInfo | false {
33- const modId = link . split ( '/' ) [ 5 ] ;
34- if ( modId === undefined ) return false ;
36+ const type = link . split ( '/' ) [ 4 ] ;
37+ if ( type !== 'mc-mods' && type !== 'bukkit-plugins' ) return false ;
38+
39+ const id = link . split ( '/' ) [ 5 ] ;
40+ if ( id === undefined ) return false ;
3541
3642 return {
37- modId : modId ,
43+ type : type === 'mc-mods' ? 'mod' : 'plugin' ,
44+ modId : id ,
3845 } ;
3946}
4047
41- // https://www.9minecraft.net/fabric-api/
48+ // https://www.9minecraft.net/fabric-api
4249function NineMinecraftHandler ( link : string ) : SearchResultInfo | false {
4350 const splitLink = link . split ( '/' ) ;
4451 if ( splitLink . length !== 4 ) return false ;
@@ -47,11 +54,12 @@ function NineMinecraftHandler(link: string): SearchResultInfo | false {
4754 if ( modId === undefined ) return false ;
4855
4956 return {
57+ type : 'mod' ,
5058 modId : modId ,
5159 } ;
5260}
5361
54- // https://www.planetminecraft.com/mods/tag/create/
62+ // https://www.planetminecraft.com/mods/tag/create
5563function PlanetMinecraftHandler ( link : string ) : SearchResultInfo | false {
5664 if ( ! link . includes ( '/mods/tag/' ) ) return false ;
5765
@@ -62,6 +70,7 @@ function PlanetMinecraftHandler(link: string): SearchResultInfo | false {
6270 if ( modId === undefined ) return false ;
6371
6472 return {
73+ type : 'mod' ,
6574 modId : modId ,
6675 } ;
6776}
@@ -89,6 +98,41 @@ function TLauncherHandler(link: string): SearchResultInfo | false {
8998 }
9099
91100 return {
101+ type : 'mod' ,
92102 modId : splitModId . join ( '-' ) ,
93103 } ;
94104}
105+
106+ // https://www.spigotmc.org/resources/skinsrestorer.2124
107+ // https://www.spigotmc.org/resources/skinsrestorer.2124/updates
108+ function SpigotMCHandler ( link : string ) : SearchResultInfo | false {
109+ const splitLink = link . split ( '/' ) ;
110+ if ( ! splitLink . includes ( 'resources' ) ) return false ;
111+
112+ const resourcesIndex = splitLink . indexOf ( 'resources' ) ;
113+
114+ const modId = splitLink [ resourcesIndex + 1 ] . split ( '.' ) [ 0 ] ;
115+ if ( modId === undefined ) return false ;
116+
117+ return {
118+ type : 'plugin' ,
119+ modId : modId ,
120+ } ;
121+ }
122+
123+ // https://dev.bukkit.org/projects/grief-prevention
124+ // https://dev.bukkit.org/projects/grief-prevention/images
125+ function BukkitHandler ( link : string ) : SearchResultInfo | false {
126+ const splitLink = link . split ( '/' ) ;
127+ if ( ! splitLink . includes ( 'projects' ) ) return false ;
128+
129+ const projectsIndex = splitLink . indexOf ( 'projects' ) ;
130+
131+ const modId = splitLink [ projectsIndex + 1 ] ;
132+ if ( modId === undefined ) return false ;
133+
134+ return {
135+ type : 'plugin' ,
136+ modId : modId ,
137+ } ;
138+ }
0 commit comments