Guest User

Help! :[

a guest
Jun 28th, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 15.12 KB | None | 0 0
  1. @echo off
  2.  
  3. setlocal EnableDelayedExpansion
  4.  
  5. rem Set the output directory
  6. set output=Plugins
  7.  
  8. rem Set the directory name that will be used when unzipping files
  9. set zip_temp=Temp
  10.  
  11. rem set the path to the download vbs
  12. set dl_vbs=Resources\dl.vbs
  13.  
  14. rem Set the name for the zip extractor VBS
  15. set zip_vbs=Resources\extract.vbs
  16.  
  17. rem set date_time to Year-Month-Day_HourH-MinuteM
  18. for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set DATETIME_VAR=%%j
  19. set date_time=%DATETIME_VAR:~0,4%-%DATETIME_VAR:~4,2%-%DATETIME_VAR:~6,2%_%DATETIME_VAR:~8,2%H-%DATETIME_VAR:~10,2%M
  20.  
  21. echo Deleting old log files...
  22. rem Remember to keep this updated with %date_time%!
  23. del Log_*-*-*_*H-*M.txt
  24. echo Done.
  25. echo.
  26.  
  27. rem Set the log file name
  28. set log=Log_%date_time%.txt
  29.  
  30. > %log% echo -- Log --
  31. >>%log% echo.
  32.  
  33. rem Empty the output folder
  34. echo Deleting + replacing output (%output%)...
  35. if NOT "%output%"=="." (
  36.     if exist %output% rd /s /q %output%
  37.     md %output%
  38. )
  39. echo Done.
  40. >>%log% echo Output folder "%output%" Deleted and remade.
  41. >>%log% echo.
  42. echo.
  43.  
  44. rem Could be latest verison (latest) or beta version (beta). Or, release version (release).
  45. rem ( See: https://bukkit.org/threads/uniform-links-to-latest-version.118175/ post #10 )
  46. set type=latest
  47.  
  48. rem Start the counter at 1
  49. set /a plugin_counter=1
  50.  
  51. rem download_index = word used in the URL for downloading the file
  52. rem desired_name = name of the plugin; name of the finished downloaded file
  53. rem download_location = an alternate URL if the global one doesn't work
  54. rem zip_location = the name of the jar file in the zip if the download file is a zip rather than jar
  55. rem plugin_disabled_reason = the reason that this particular plugin is not to be downloaded at all
  56.  
  57. set download_index[!plugin_counter!]=afkterminator
  58. set desired_name[!plugin_counter!]=AFK-Terminator
  59. set download_location[!plugin_counter!]=bukget
  60. set /a plugin_counter+=1
  61.  
  62. set download_index[!plugin_counter!]=autorefill
  63. set desired_name[!plugin_counter!]=AutoRefill
  64. set zip_location[!plugin_counter!]=AutoRefill.jar
  65. set download_location[!plugin_counter!]=bukget
  66. set /a plugin_counter+=1
  67.  
  68. set download_index[!plugin_counter!]=autosaveworld
  69. set desired_name[!plugin_counter!]=AutoSaveWorld
  70. set download_location[!plugin_counter!]=bukget
  71. set /a plugin_counter+=1
  72.  
  73. set download_index[!plugin_counter!]=compatnocheatplus-cncp
  74. set desired_name[!plugin_counter!]=CompatNoCheatPlus
  75. set download_location[!plugin_counter!]=bukget
  76. set /a plugin_counter+=1
  77.  
  78. set download_index[!plugin_counter!]=commandlog
  79. set desired_name[!plugin_counter!]=CommandLog
  80. set download_location[!plugin_counter!]=bukget
  81. set /a plugin_counter+=1
  82.  
  83. set download_index[!plugin_counter!]=coreprotect
  84. set desired_name[!plugin_counter!]=CoreProtect
  85. set download_location[!plugin_counter!]=bukget
  86. set /a plugin_counter+=1
  87.  
  88. set download_index[!plugin_counter!]=cshortcut
  89. set desired_name[!plugin_counter!]=C-Shortcut
  90. set download_location[!plugin_counter!]=bukget
  91. set /a plugin_counter+=1
  92.  
  93. set download_index[!plugin_counter!]=deathcontrol
  94. set desired_name[!plugin_counter!]=DeathControl
  95. set download_location[!plugin_counter!]=bukget
  96. set /a plugin_counter+=1
  97.  
  98. set download_index[!plugin_counter!]=disable-respawn-screen
  99. set desired_name[!plugin_counter!]=DisableRespawnScreen
  100. set download_location[!plugin_counter!]=bukget
  101. set /a plugin_counter+=1
  102.  
  103. set download_index[!plugin_counter!]=dropswap
  104. set desired_name[!plugin_counter!]=DropSwap
  105. set download_location[!plugin_counter!]=bukget
  106. set /a plugin_counter+=1
  107.  
  108. set download_index[!plugin_counter!]=emp
  109. set desired_name[!plugin_counter!]=EnjinMinecraftPlugin
  110. set download_location[!plugin_counter!]=bukget
  111. set /a plugin_counter+=1
  112.  
  113. set download_index[!plugin_counter!]=essentials
  114. set desired_name[!plugin_counter!]=Essentials
  115. set zip_location[!plugin_counter!]=target\*
  116. set download_location[!plugin_counter!]=https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/Essentials/target/*zip*/target.zip
  117. set /a plugin_counter+=1
  118.  
  119. set download_index[!plugin_counter!]=essentialschat
  120. set desired_name[!plugin_counter!]=EssentialsChat
  121. set zip_location[!plugin_counter!]=target\*
  122. set download_location[!plugin_counter!]=https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsChat/target/*zip*/target.zip
  123. set /a plugin_counter+=1
  124.  
  125. set download_index[!plugin_counter!]=essentialsspawn
  126. set desired_name[!plugin_counter!]=EssentialsSpawn
  127. set zip_location[!plugin_counter!]=target\*
  128. set download_location[!plugin_counter!]=https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsSpawn/target/*zip*/target.zip
  129. set /a plugin_counter+=1
  130.  
  131. set download_index[!plugin_counter!]=factions
  132. set desired_name[!plugin_counter!]=Factions
  133. set download_location[!plugin_counter!]=bukget
  134. set /a plugin_counter+=1
  135.  
  136. set download_index[!plugin_counter!]=frameprotect
  137. set desired_name[!plugin_counter!]=FrameProtect
  138. set download_location[!plugin_counter!]=bukget
  139. set zip_location[!plugin_counter!]=FrameProtect.jar
  140. set /a plugin_counter+=1
  141.  
  142. set download_index[!plugin_counter!]=frameprotect
  143. set desired_name[!plugin_counter!]=FrameProtectDatabaseUpdater
  144. set download_location[!plugin_counter!]=bukget
  145. set zip_location[!plugin_counter!]=FrameProtectDatabaseUpdater.jar
  146. set /a plugin_counter+=1
  147.  
  148. set download_index[!plugin_counter!]=global-market
  149. set desired_name[!plugin_counter!]=GlobalMarket
  150. set download_location[!plugin_counter!]=bukget
  151. set /a plugin_counter+=1
  152.  
  153. set download_index[!plugin_counter!]=insanemobs
  154. set desired_name[!plugin_counter!]=InsaneMobs
  155. set download_location[!plugin_counter!]=bukget
  156. set /a plugin_counter+=1
  157.  
  158. set download_index[!plugin_counter!]=magicloot
  159. set desired_name[!plugin_counter!]=MagicLoot
  160. set download_location[!plugin_counter!]=bukget
  161. set /a plugin_counter+=1
  162.  
  163. set download_index[!plugin_counter!]=mcore
  164. set desired_name[!plugin_counter!]=MassiveCore
  165. set download_location[!plugin_counter!]=bukget
  166. set /a plugin_counter+=1
  167.  
  168. set download_index[!plugin_counter!]=mcmmo
  169. set desired_name[!plugin_counter!]=mcMMO
  170. set download_location[!plugin_counter!]=bukget
  171. set /a plugin_counter+=1
  172.  
  173. set download_index[!plugin_counter!]=modifyworld
  174. set desired_name[!plugin_counter!]=ModifyWorld
  175. set download_location[!plugin_counter!]=bukget
  176. set /a plugin_counter+=1
  177.  
  178. set download_index[!plugin_counter!]=multiverse-core
  179. set desired_name[!plugin_counter!]=MultiverseCore
  180. set download_location[!plugin_counter!]=bukget
  181. set /a plugin_counter+=1
  182.  
  183. set download_index[!plugin_counter!]=multiverse-inventories
  184. set desired_name[!plugin_counter!]=MultiverseInventories
  185. set download_location[!plugin_counter!]=bukget
  186. set /a plugin_counter+=1
  187.  
  188. set download_index[!plugin_counter!]=multiverse-netherportals
  189. set desired_name[!plugin_counter!]=MultiverseNetherPortals
  190. set download_location[!plugin_counter!]=bukget
  191. set /a plugin_counter+=1
  192.  
  193. set download_index[!plugin_counter!]=multiverse-portals
  194. set desired_name[!plugin_counter!]=MultiversePortals
  195. set download_location[!plugin_counter!]=bukget
  196. set /a plugin_counter+=1
  197.  
  198. set download_index[!plugin_counter!]=multiverse-teleportfilter
  199. set desired_name[!plugin_counter!]=MultiverseTeleportFilder
  200. set download_location[!plugin_counter!]=bukget
  201. set /a plugin_counter+=1
  202.  
  203. set download_index[!plugin_counter!]=nobreeding
  204. set desired_name[!plugin_counter!]=NoBreeding
  205. set download_location[!plugin_counter!]=bukget
  206. set plugin_disabled_reason[!plugin_counter!]=Inactive project; no updates.
  207. set /a plugin_counter+=1
  208.  
  209. set download_index[!plugin_counter!]=nocheatplus
  210. set desired_name[!plugin_counter!]=NoCheatPlus
  211. set download_location[!plugin_counter!]=jenkins
  212. set /a plugin_counter+=1
  213.  
  214. set download_index[!plugin_counter!]=ontime
  215. set desired_name[!plugin_counter!]=OnTime
  216. set download_location[!plugin_counter!]=bukget
  217. set /a plugin_counter+=1
  218.  
  219. set download_index[!plugin_counter!]=openinv
  220. set desired_name[!plugin_counter!]=OpenInv
  221. set download_location[!plugin_counter!]=bukget
  222. set /a plugin_counter+=1
  223.  
  224. set download_index[!plugin_counter!]=permissionsex
  225. set desired_name[!plugin_counter!]=PermissionsEx
  226. set download_location[!plugin_counter!]=bukget
  227. set /a plugin_counter+=1
  228.  
  229. set download_index[!plugin_counter!]=perworldplugins
  230. set desired_name[!plugin_counter!]=PerWorldPlugins
  231. set download_location[!plugin_counter!]=bukget
  232. set /a plugin_counter+=1
  233.  
  234. set download_index[!plugin_counter!]=plotme
  235. set desired_name[!plugin_counter!]=PlotMe
  236. set download_location[!plugin_counter!]=bukget
  237. set /a plugin_counter+=1
  238.  
  239. set download_index[!plugin_counter!]=plotme-defaultgenerator
  240. set desired_name[!plugin_counter!]=PlotMeDefaultGenerator
  241. set download_location[!plugin_counter!]=bukget
  242. set /a plugin_counter+=1
  243.  
  244. set download_index[!plugin_counter!]=protocollib
  245. set desired_name[!plugin_counter!]=ProtocolLib
  246. set download_location[!plugin_counter!]=jenkins
  247. set /a plugin_counter+=1
  248.  
  249. set download_index[!plugin_counter!]=ptweaks-remove-all-server-lag
  250. set desired_name[!plugin_counter!]=pTweaks
  251. set download_location[!plugin_counter!]=bukget
  252. set /a plugin_counter+=1
  253.  
  254. set download_index[!plugin_counter!]=pvpmanager
  255. set desired_name[!plugin_counter!]=PvP-Manager
  256. set download_location[!plugin_counter!]=bukget
  257. set /a plugin_counter+=1
  258.  
  259. set download_index[!plugin_counter!]=pwnplantgrowth
  260. set desired_name[!plugin_counter!]=pwnPlantGrowth
  261. set download_location[!plugin_counter!]=bukget
  262. set /a plugin_counter+=1
  263.  
  264. set download_index[!plugin_counter!]=signedit
  265. set desired_name[!plugin_counter!]=SignEdit
  266. set download_location[!plugin_counter!]=bukget
  267. set /a plugin_counter+=1
  268.  
  269. set download_index[!plugin_counter!]=simplesort
  270. set desired_name[!plugin_counter!]=SimpleSort
  271. set download_location[!plugin_counter!]=bukget
  272. set /a plugin_counter+=1
  273.  
  274. set download_index[!plugin_counter!]=tjp
  275. set desired_name[!plugin_counter!]=TheJoyOfPainting
  276. set download_location[!plugin_counter!]=bukget
  277. set /a plugin_counter+=1
  278.  
  279. set download_index[!plugin_counter!]=toolswap
  280. set desired_name[!plugin_counter!]=ToolSwap
  281. set download_location[!plugin_counter!]=bukget
  282. set /a plugin_counter+=1
  283.  
  284. set download_index[!plugin_counter!]=treeassist
  285. set desired_name[!plugin_counter!]=TreeAssist
  286. set download_location[!plugin_counter!]=bukget
  287. set /a plugin_counter+=1
  288.  
  289. set download_index[!plugin_counter!]=vault
  290. set desired_name[!plugin_counter!]=Vault
  291. set download_location[!plugin_counter!]=bukget
  292. set /a plugin_counter+=1
  293.  
  294. set download_index[!plugin_counter!]=voxelsniper
  295. set desired_name[!plugin_counter!]=VoxelSniper
  296. set download_location[!plugin_counter!]=bukget
  297. set /a plugin_counter+=1
  298.  
  299. set download_index[!plugin_counter!]=whatisit
  300. set desired_name[!plugin_counter!]=WhatIsIt
  301. set download_location[!plugin_counter!]=bukget
  302. set /a plugin_counter+=1
  303.  
  304. set download_index[!plugin_counter!]=worldedit
  305. set desired_name[!plugin_counter!]=WorldEdit
  306. set download_location[!plugin_counter!]=bukget
  307. set /a plugin_counter+=1
  308.  
  309. set download_index[!plugin_counter!]=worldguard
  310. set desired_name[!plugin_counter!]=WorldGuard
  311. set download_location[!plugin_counter!]=bukget
  312.  
  313. echo ---- Beginning downloads ----
  314. echo.
  315.  
  316. rem for every plugin with var %%p being the number of the plugin
  317. rem for all *_c variables, the c stands for current
  318. rem %%p, p for plugin!
  319. for /l %%p in (1,1,!plugin_counter!) do (
  320.  
  321.     if defined zip_location[%%p] (
  322.         set file_name_c=!desired_name[%%p]!.zip
  323.         set file_type_c=zip
  324.     ) else (
  325.         set file_name_c=!desired_name[%%p]!.jar
  326.         set file_type_c=jar
  327.     )
  328.    
  329.     rem Try downloading 3 times.
  330.     for /l %%n in (1,1,3) do (
  331.        rem If the file has not been downloaded.
  332.         if not exist "%output%\!file_name_c!" (
  333.            
  334.             rem If it's the first try, the download didn't fail -- it's just the first try.
  335.             if %%n==1 (
  336.                 echo Downloading !desired_name[%%p]!
  337.                 echo Downloading !file_name_c!>>%log%
  338.            rem If it's the second try or later, the download failed and we are retrying
  339.             ) else (
  340.                 echo Download failed. Retrying...
  341.                 echo Download failed. Retrying...>>%log%
  342.             )
  343.            
  344.             if !download_location[%%p]!==bukget (
  345.                 cscript //nologo %dl_vbs% "https://api.bukget.org/3/plugins/bukkit/!download_index[%%p]!/%type%/download" "%output%\!file_name_c!"
  346.             )
  347.             if !download_location[%%p]!==jenkins (
  348.                 cscript //nologo %dl_vbs% "http://ci.md-5.net/job/!download_index[%%p]!/lastSuccessfulBuild/artifact/target/!file_name_c!" "%output%\!file_name_c!"
  349.             ) else (
  350.                 cscript //nologo %dl_vbs% "!download_location[%%p]!" "%output%\!file_name_c!"
  351.             )
  352.         )
  353.     )
  354.    
  355.     rem If the file STILL doesn't exist, the download failed.
  356.     if not exist "%output%\!file_name_c!" (
  357.         echo Could not download.
  358.         echo Could not download.>>%log%
  359.        
  360.     rem If it didn't fail, continue.
  361.     ) else (
  362.        rem If it's a zip file, we need to unzip it.
  363.         if defined zip_location[%%p] (
  364.            rem Try unzipping 3 times.
  365.             for %%n in (1,1,3) do (
  366.                rem If it's the first try, the unzip attempt didn't fail -- it's just the first try.
  367.                 if %%n==1 (
  368.                     echo Unzipping !desired_name[%%p]!
  369.                     echo Unzipping !file_name_c!>>%log%
  370.                rem If it's the second try or later, the unzip attempt failed and we are retrying
  371.                 ) else (
  372.                     echo Unzipping failed. Retrying...
  373.                     echo Unzip attempt failed. Retrying...>>%log%
  374.                 )
  375.                rem If we have not successfully unzipped
  376.                 if not exist "%output%\!desired_name[%%p]!.jar" (
  377.                    rem Make a temporary folder to unzip to.
  378.                     md %zip_temp%
  379.                    
  380.                     rem Unzip the plugin to the temporary folder
  381.                     cscript //nologo %zip_vbs% "%cd%\%zip_temp%\" "%cd%\%output%\!file_name_c!"
  382.                    
  383.                     rem Move the file we need to another folder (we need this for files we don't know the names of)
  384.                     md "%zip_temp%\final"
  385.                     move "%zip_temp%\!zip_location[%%p]!" "%zip_temp%\final\"
  386.                    
  387.                     rem Rename file to the desired name
  388.                     ren "%zip_temp%\final\*.jar" "!desired_name[%%p]!.jar"
  389.                    
  390.                     rem Move the file to the output directory
  391.                     move "%zip_temp%\final\!desired_name[%%p]!.jar" "%output%\"
  392.                    
  393.                     rem Delete the temporary folder
  394.                     rd /s /q %zip_temp%
  395.                    
  396.                     rem Delete the original zip file
  397.                     del /q "%output%\!file_name_c!"
  398.                 )
  399.             )
  400.         )    
  401.     )
  402.     echo.
  403.     echo.>>%log%
  404. )
  405.  
  406. rem If getting "Access denied" when trying to run this batch, see here -- the internet-security-options-related answer: https://stackoverflow.com/questions/17401413/msxml3-dll-access-denied
  407.  
  408. endlocal
Advertisement
Add Comment
Please, Sign In to add comment