package Ġd um stuff Ċ Ċ import Ġcmd Ċ import Ġensure Success Ċ import Ġkotlinx . serialization . to Utf 8 Bytes Ċ import Ġorg . cad ix dev . atlas . Atlas Ċ import Ġorg . cad ix dev . lo ren z . asm . L ore nz Rem apper Ċ import Ġorg . cad ix dev . lo ren z . io . Mapping Formats Ċ import Ġorg . gradle . api . Gradle Exception Ċ import Ġorg . gradle . api . Project Ċ import Ġorg . gradle . api . Task Ċ import Ġorg . gradle . kotlin . dsl . creating Ċ import Ġorg . gradle . kotlin . dsl . getValue Ċ import Ġstuff . task Group Private Ċ import Ġtoo th pick . Debug Jar Entry Rem apping Transformer Ċ import Ġjava . net . URL Ċ import Ġjava . nio . file . Files Ċ Ċ fun Ġd um Sh it Tasks ( project : ĠProject ): ĠList < Task > Ġ{ ĊĠĠĠ Ġval Ġmod Folder Ġ= Ġproject . project Dir . resolve (" D yes cape Paper - Server / src / main / java ") ĊĠĠĠ Ġval Ġorig Folder Ġ= Ġproject . project Dir . resolve (" work / de comp ") ĊĠĠĠ Ġval Ġwork Folder Ġ= Ġproject . project Dir . resolve (" work / dum Sh it ") ĊĠĠĠ Ġval Ġpatches Ġ= Ġwork Folder . resolve (" patches ") ĊĠĠĠ Ġval Ġvanilla Classes Ġ= Ġwork Folder . resolve (" van illa Classes ") ĊĠĠĠ Ġval Ġvanilla De comp Ġ= Ġwork Folder . resolve (" van illa De comp ") ĊĠĠĠ Ġval Ġmod Classes Ġ= Ġwork Folder . resolve (" mod Classes ") ĊĠĠĠ Ġval Ġmod De comp Ġ= Ġwork Folder . resolve (" mod De comp ") ĊĠĠĠ Ġval Ġpatched Ġ= Ġwork Folder . resolve (" patched ") ĊĠĠĠ Ġval Ġpaper Work Dir Ġ= Ġproject . project Dir . resolve (" work / Paper / work ") ĊĠĠĠ Ġval Ġserver Url Ġ= Ġ" https :// launcher . moj ang . com / v 1 / objects / 0 3 b 8 fa 3 5 7 9 3 7 d 0 bdb 6 6 5 0 ec 8 cc 7 4 5 0 6 ec 2 fd 9 1 a 7 / server . jar " ĊĠĠĠ Ġval Ġserver Mapping Url Ġ= Ġ" https :// launcher . moj ang . com / v 1 / objects / cd 3 6 be 8 de 6 2 b 1 a 5 0 f 1 7 4 b 0 6 7 6 7 b 4 9 b 9 f 7 9 f 3 b 8 0 7 / server . txt " ĊĠĠĠ Ġval Ġm inecraft Version Ġ= Ġ" 2 0 w 2 1 a " ĊĊĠĠĠ Ġval Ġextract Mod : ĠTask Ġby Ġproject . tasks . creating Ġ{ ĊĠĠĠĠĠĠĠ Ġgroup Ġ= Ġtask Group Private ĊĠĠĠĠĠĠĠ Ġonly If Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ! mod Classes . exists () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmod Classes . mkdir s () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġensure Success ( cmd (" jar ", Ġ" xf ", Ġproject . project Dir . resolve (" D yes cape Paper - Server / target / dy escape paper - 1 . 1 5 . 2 . jar "). toString (), Ġ" net / minecraft ", Ġdirectory Ġ= Ġmod Classes , Ġprint To Stdout Ġ= Ġtrue )) ĊĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġde compile Mod : ĠTask Ġby Ġproject . tasks . creating Ġ{ ĊĠĠĠĠĠĠĠ Ġgroup Ġ= Ġtask Group Private ĊĠĠĠĠĠĠĠ Ġdepends On ( extract Mod ) ĊĠĠĠĠĠĠĠ Ġonly If Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ! mod De comp . resolve (" net / minecraft / server / Minecraft Server . java "). exists () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( mod De comp . exists ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmod De comp . delete Re cursively () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmod De comp . mkdir s () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . lifecycle (" De comp iling Ġclasses ...") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġensure Success ( cmd (" java ", Ġ"- jar ", Ġ"$ paper Work Dir / Build Data / bin / fer n flower . jar ", Ġ"- d gs = 1 ", Ġ"- hdc = 0 ", Ġ"- asc = 1 ", Ġ"- ud v = 0 ", Ġ"- rs y = 1 ", Ġ"- ao a = 1 ", Ġmod Classes . absolute Path , Ġmod De comp . absolute Path , Ġdirectory Ġ= Ġproject . rootDir , Ġprint To Stdout Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠIllegalStateException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmod De comp . delete Re cursively () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠGradle Exception (" Failed Ġto Ġde compile Ġclasses .", Ġe ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġdiff Server : ĠTask Ġby Ġproject . tasks . creating Ġ{ ĊĠĠĠĠĠĠĠ Ġgroup Ġ= Ġtask Group Private ĊĠĠĠĠĠĠĠ Ġdepends On ( de compile Mod ) ĊĠĠĠĠĠĠĠ Ġonly If Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ! patches . exists () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( patches . exists ()) Ġpatches . delete Re cursively () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpatches . mkdir s () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġmod De comp . resolve (" net / minecraft "). walk ( File Walk Direction . TOP _ DOWN ). filter Ġ{ Ġfile Ġ-> Ġfile . isFile Ġ}. forEach Ġ{ Ġmod Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrelative Ġ= Ġmod . relative To ( mod De comp ). toString () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġorig Ġ= Ġorig Folder . resolve ( relative ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġpatch Ġ= Ġpatches . resolve ("$ relative . patch ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpatch . parent File . mkdir s () ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġ(_, Ġoutput ) Ġ= Ġcmd (" diff ", Ġ"- Nu ", Ġ"-- label ", Ġ" a /$ relative ", Ġorig . absolute Path , Ġ"-- label ", Ġ" b /$ relative ", Ġmod . absolute Path , Ġdirectory Ġ= Ġpatches ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠFiles . write ( patch . to Path (), Ġoutput ?. to Utf 8 Bytes () !! ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġdownload Van illa Snapshot : ĠTask Ġby Ġproject . tasks . creating Ġ{ ĊĠĠĠĠĠĠĠ Ġgroup Ġ= Ġtask Group Private ĊĠĠĠĠĠĠĠ Ġdepends On ( diff Server ) ĊĠĠĠĠĠĠĠ Ġonly If Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ! work Folder . resolve ("$ minecraft Version . jar "). exists () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwork Folder . resolve ("$ minecraft Version . jar "). write Bytes ( URL ( server Url ). read Bytes ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġremap Van illa Snapshot : ĠTask Ġby Ġproject . tasks . creating Ġ{ ĊĠĠĠĠĠĠĠ Ġgroup Ġ= Ġtask Group Private ĊĠĠĠĠĠĠĠ Ġdepends On ( download Van illa Snapshot ) ĊĠĠĠĠĠĠĠ Ġonly If Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ! work Folder . resolve ("$ minecraft Version - mapped . jar "). exists () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmo j ang File Ġ= Ġwork Folder . resolve (" server . txt ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ(! moj ang File . exists ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmo j ang File . write Text ( URL ( server Mapping Url ). read Text ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmo j ang Mappings Ġ= ĠMapping Formats . by Id (" pro guard "). read ( moj ang File . to Path ()). reverse () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġatlas Ġ= ĠAtlas () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġatlas . install Ġ{ Ġctx Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDebug Jar Entry Rem apping Transformer ( L ore nz Rem apper ( moj ang Mappings , Ġctx . inheritance Provider ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġatlas . run ( work Folder . resolve ("$ minecraft Version . jar "). to Path (), Ġwork Folder . resolve ("$ minecraft Version - mapped . jar "). to Path ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġatlas . close () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġensure Success ( cmd (" mvn ", Ġ" install : install - file ", Ġ"- q ", Ġ"- D file =${ work Folder . resolve ("$ minecraft Version - mapped . jar "). absolute Path }", Ġ"- D packaging = jar ", Ġ"- D groupId = me . min id ig ger ", Ġ"- D artifactId = minecraft - server ", Ġ"- D version =\" $ minecraft Version - SNAPSHOT \"", Ġdirectory Ġ= Ġproject . project Dir )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġextract Van illa Snapshot : ĠTask Ġby Ġproject . tasks . creating Ġ{ ĊĠĠĠĠĠĠĠ Ġgroup Ġ= Ġtask Group Private ĊĠĠĠĠĠĠĠ Ġdepends On ( remap Van illa Snapshot ) ĊĠĠĠĠĠĠĠ Ġonly If Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ! van illa Classes . exists () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvanilla Classes . mkdir s () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġensure Success ( cmd (" jar ", Ġ" xf ", Ġ"$ work Folder /$ minecraft Version - mapped . jar ", Ġ" net / minecraft ", Ġdirectory Ġ= Ġvanilla Classes , Ġprint To Stdout Ġ= Ġtrue )) ĊĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġde compile Van illa Snapshot : ĠTask Ġby Ġproject . tasks . creating Ġ{ ĊĠĠĠĠĠĠĠ Ġgroup Ġ= Ġtask Group Private ĊĠĠĠĠĠĠĠ Ġdepends On ( extract Van illa Snapshot ) ĊĠĠĠĠĠĠĠ Ġonly If Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ! van illa De comp . resolve (" net / minecraft / server / Minecraft Server . java "). exists () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( van illa De comp . exists ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġvanilla De comp . delete Re cursively () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvanilla De comp . mkdir s () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . lifecycle (" De comp iling Ġclasses ...") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġensure Success ( cmd (" java ", Ġ"- jar ", Ġ"$ paper Work Dir / Build Data / bin / fer n flower . jar ", Ġ"- d gs = 1 ", Ġ"- hdc = 0 ", Ġ"- asc = 1 ", Ġ"- ud v = 0 ", Ġ"- rs y = 1 ", Ġ"- ao a = 1 ", Ġvanilla Classes . absolute Path , Ġvanilla De comp . absolute Path , Ġdirectory Ġ= Ġproject . rootDir , Ġprint To Stdout Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠIllegalStateException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġvanilla De comp . delete Re cursively () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠGradle Exception (" Failed Ġto Ġde compile Ġclasses .", Ġe ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġapply Van illa Pat ches : ĠTask Ġby Ġproject . tasks . creating Ġ{ ĊĠĠĠĠĠĠĠ Ġgroup Ġ= Ġtask Group Private ĊĠĠĠĠĠĠĠ Ġdepends On ( de compile Van illa Snapshot ) ĊĠĠĠĠĠĠĠ Ġdo Last Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( patched . exists ()) Ġpatched . delete Re cursively () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpatched . mkdir s () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġpatches . resolve (" net / minecraft "). walk ( File Walk Direction . TOP _ DOWN ). filter Ġ{ Ġfile Ġ-> Ġfile . isFile Ġ}. forEach Ġ{ Ġpatch Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrelative Ġ= Ġpatch . relative To ( patches ). toString (). replace (". patch ", Ġ"") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġde comp File Ġ= Ġvanilla De comp . resolve ( relative ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġpatched File Ġ= Ġpatched . resolve ( relative ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif (! de comp File . exists ()) Ġreturn @ forEach ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpatched File . parent File . mkdir s () ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġde comp File . copy To ( patched File ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġensure Success ( cmd (" patch ", Ġ"- d ", Ġpatch . relative To ( patches ). parent , Ġpatched File . absolute Path , Ġpatch . absolute Path , Ġdirectory Ġ= Ġpatched )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn ĠlistOf ( diff Server , Ġde compile Van illa Snapshot ) Ċ } Ċ