2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import  argparse  
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  json  
						 
					
						
							
								
									
										
										
										
											2022-04-07 10:19:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  os  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  sys  
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import  re  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  atexit  
						 
					
						
							
								
									
										
										
										
											2022-04-02 04:49:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  shutil  
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								from  subprocess  import  Popen  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								from  shutil  import  copyfile  
						 
					
						
							
								
									
										
										
										
											2021-08-08 15:36:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  time  import  strftime  
						 
					
						
							
								
									
										
										
										
											2021-11-10 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  logging  
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  requests  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import  Utils  
						 
					
						
							
								
									
										
										
										
											2022-06-04 18:10:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  Utils  import  is_windows  
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								atexit . register ( input ,  " Press enter to exit. " )  
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# 1 or more digits followed by m or g, then optional b  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								max_heap_re  =  re . compile ( r " ^ \ d+[mMgG][bB]?$ " )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  prompt_yes_no ( prompt ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    yes_inputs  =  { ' yes ' ,  ' ye ' ,  ' y ' } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    no_inputs  =  { ' no ' ,  ' n ' } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while  True : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        choice  =  input ( prompt  +  "  [y/n]  " ) . lower ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  choice  in  yes_inputs :  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        elif  choice  in  no_inputs :  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print ( ' Please respond with  " y "  or  " n " . ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  find_ap_randomizer_jar ( forge_dir ) :  
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Create mods folder if needed; find AP randomizer jar; return None if not found. """ 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    mods_dir  =  os . path . join ( forge_dir ,  ' mods ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  os . path . isdir ( mods_dir ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  entry  in  os . scandir ( mods_dir ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-19 13:27:40 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  entry . name . startswith ( " aprandomizer " )  and  entry . name . endswith ( " .jar " ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                logging . info ( f " Found AP randomizer mod:  { entry . name } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  entry . name 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  None 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        os . mkdir ( mods_dir ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-10 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        logging . info ( f " Created mods folder in  { forge_dir } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  None 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  replace_apmc_files ( forge_dir ,  apmc_file ) :  
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Create APData folder if needed; clean .apmc files from APData; copy given .apmc into directory. """ 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  apmc_file  is  None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    apdata_dir  =  os . path . join ( forge_dir ,  ' APData ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-15 08:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    copy_apmc  =  True 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  not  os . path . isdir ( apdata_dir ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        os . mkdir ( apdata_dir ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-10 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        logging . info ( f " Created APData folder in  { forge_dir } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  entry  in  os . scandir ( apdata_dir ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-15 08:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  entry . name . endswith ( " .apmc " )  and  entry . is_file ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  not  os . path . samefile ( apmc_file ,  entry . path ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                os . remove ( entry . path ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-10 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                logging . info ( f " Removed  { entry . name }  in  { apdata_dir } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-15 08:16:30 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            else :  # apmc already in apdata 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                copy_apmc  =  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  copy_apmc : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        copyfile ( apmc_file ,  os . path . join ( apdata_dir ,  os . path . basename ( apmc_file ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-10 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        logging . info ( f " Copied  { os . path . basename ( apmc_file ) }  to  { apdata_dir } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  read_apmc_file ( apmc_file ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    from  base64  import  b64decode 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  open ( apmc_file ,  ' r ' )  as  f : 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  json . loads ( b64decode ( f . read ( ) ) ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  update_mod ( forge_dir ,  url :  str ) :  
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Check mod version, download new mod from GitHub releases page if needed.  """ 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 13:31:03 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ap_randomizer  =  find_ap_randomizer_jar ( forge_dir ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    os . path . basename ( url ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ap_randomizer  is  not  None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        logging . info ( f " Your current mod is  { ap_randomizer } . " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        logging . info ( f " You do not have the AP randomizer mod installed. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ap_randomizer  !=  os . path . basename ( url ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        logging . info ( f " A new release of the Minecraft AP randomizer mod was found:  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                     f " { os . path . basename ( url ) } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  prompt_yes_no ( " Would you like to update? " ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            old_ap_mod  =  os . path . join ( forge_dir ,  ' mods ' ,  ap_randomizer )  if  ap_randomizer  is  not  None  else  None 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            new_ap_mod  =  os . path . join ( forge_dir ,  ' mods ' ,  os . path . basename ( url ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            logging . info ( " Downloading AP randomizer mod. This may take a moment... " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            apmod_resp  =  requests . get ( url ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  apmod_resp . status_code  ==  200 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                with  open ( new_ap_mod ,  ' wb ' )  as  f : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    f . write ( apmod_resp . content ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    logging . info ( f " Wrote new mod file to  { new_ap_mod } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  old_ap_mod  is  not  None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    os . remove ( old_ap_mod ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    logging . info ( f " Removed old mod file from  { old_ap_mod } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                logging . error ( f " Error retrieving the randomizer mod (status code  { apmod_resp . status_code } ). " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                logging . error ( f " Please report this issue on the Archipelago Discord server. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                sys . exit ( 1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 15:36:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  check_eula ( forge_dir ) :  
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    """ Check if the EULA is agreed to, and prompt the user to read and agree if necessary. """ 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 15:36:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    eula_path  =  os . path . join ( forge_dir ,  " eula.txt " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  os . path . isfile ( eula_path ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # Create eula.txt 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        with  open ( eula_path ,  ' w ' )  as  f : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            f . write ( " #By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula). \n " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            f . write ( f " # { strftime ( ' %a   % b  %d   %X   % Z  % Y ' ) } \n " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            f . write ( " eula=false \n " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    with  open ( eula_path ,  ' r+ ' )  as  f : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        text  =  f . read ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ' false '  in  text : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            # Prompt user to agree to the EULA 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-10 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            logging . info ( " You need to agree to the Minecraft EULA in order to run the server. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            logging . info ( " The EULA can be found at https://account.mojang.com/documents/minecraft_eula " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 15:36:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  prompt_yes_no ( " Do you agree to the EULA? " ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                f . seek ( 0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                f . write ( text . replace ( ' false ' ,  ' true ' ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                f . truncate ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-10 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                logging . info ( f " Set  { eula_path }  to true " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 15:36:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                sys . exit ( 0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  find_jdk_dir ( version :  str )  - >  str :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    """ get the specified versions jdk directory """ 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  entry  in  os . listdir ( ) : 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  os . path . isdir ( entry )  and  entry . startswith ( f " jdk { version } " ) : 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  os . path . abspath ( entry ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  find_jdk ( version :  str )  - >  str :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    """ get the java exe location """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-02 04:49:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  is_windows : 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        jdk  =  find_jdk_dir ( version ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-02 04:49:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        jdk_exe  =  os . path . join ( jdk ,  " bin " ,  " java.exe " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  os . path . isfile ( jdk_exe ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  jdk_exe 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        jdk_exe  =  shutil . which ( options [ " minecraft_options " ] . get ( " java " ,  " java " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  not  jdk_exe : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            raise  Exception ( " Could not find Java. Is Java installed on the system? " ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  jdk_exe 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  download_java ( java :  str ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    """ Download Corretto (Amazon JDK) """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    jdk  =  find_jdk_dir ( java ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  jdk  is  not  None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print ( f " Removing old JDK... " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        from  shutil  import  rmtree 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        rmtree ( jdk ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    print ( f " Downloading Java... " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    jdk_url  =  f " https://corretto.aws/downloads/latest/amazon-corretto- { java } -x64-windows-jdk.zip " 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    resp  =  requests . get ( jdk_url ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  resp . status_code  ==  200 :   # OK 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print ( f " Extracting... " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        import  zipfile 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        from  io  import  BytesIO 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        with  zipfile . ZipFile ( BytesIO ( resp . content ) )  as  zf : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            zf . extractall ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print ( f " Error downloading Java (status code  { resp . status_code } ). " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print ( f " If this was not expected, please report this issue on the Archipelago Discord server. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  not  prompt_yes_no ( " Continue anyways? " ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            sys . exit ( 0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  install_forge ( directory :  str ,  forge_version :  str ,  java_version :  str ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    """ download and install forge """ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 00:56:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    java_exe  =  find_jdk ( java_version ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  java_exe  is  not  None : 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        print ( f " Downloading Forge  { forge_version } ... " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        forge_url  =  f " https://maven.minecraftforge.net/net/minecraftforge/forge/ { forge_version } /forge- { forge_version } -installer.jar " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        resp  =  requests . get ( forge_url ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  resp . status_code  ==  200 :   # OK 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            forge_install_jar  =  os . path . join ( directory ,  " forge_install.jar " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  not  os . path . exists ( directory ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                os . mkdir ( directory ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            with  open ( forge_install_jar ,  ' wb ' )  as  f : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                f . write ( resp . content ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print ( f " Installing Forge... " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-19 13:54:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            install_process  =  Popen ( [ java_exe ,  " -jar " ,  forge_install_jar ,  " --installServer " ,  directory ] ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            install_process . wait ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            os . remove ( forge_install_jar ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  run_forge_server ( forge_dir :  str ,  java_version :  str ,  heap_arg :  str )  - >  Popen :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    """ Run the Forge server. """ 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 13:31:03 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    java_exe  =  find_jdk ( java_version ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    if  not  os . path . isfile ( java_exe ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        java_exe  =  " java "   # try to fall back on java in the PATH 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    heap_arg  =  max_heap_re . match ( heap_arg ) . group ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    if  heap_arg [ - 1 ]  in  [ ' b ' ,  ' B ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        heap_arg  =  heap_arg [ : - 1 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    heap_arg  =  " -Xmx "  +  heap_arg 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-02 04:49:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    os_args  =  " win_args.txt "  if  is_windows  else  " unix_args.txt " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args_file  =  os . path . join ( forge_dir ,  " libraries " ,  " net " ,  " minecraftforge " ,  " forge " ,  forge_version ,  os_args ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 00:56:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    forge_args  =  [ ] 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    with  open ( args_file )  as  argfile : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  line  in  argfile : 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 00:56:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            forge_args . extend ( line . strip ( ) . split ( "   " ) ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 00:56:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    args  =  [ java_exe ,  heap_arg ,  * forge_args ,  " -nogui " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    logging . info ( f " Running Forge server:  { args } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:26:46 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    os . chdir ( forge_dir ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-19 13:54:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  Popen ( args ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  get_minecraft_versions ( version ,  release_channel = " release " ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    version_file_endpoint  =  " https://raw.githubusercontent.com/KonoTyran/Minecraft_AP_Randomizer/master/versions/minecraft_versions.json " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    resp  =  requests . get ( version_file_endpoint ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    local  =  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  resp . status_code  ==  200 :   # OK 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            data  =  resp . json ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        except  requests . exceptions . JSONDecodeError : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            logging . warning ( f " Unable to fetch version update file, using local version. (status code  { resp . status_code } ). " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            local  =  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        logging . warning ( f " Unable to fetch version update file, using local version. (status code  { resp . status_code } ). " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        local  =  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  local : 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 16:43:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        with  open ( Utils . user_path ( " minecraft_versions.json " ) ,  ' r ' )  as  f : 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            data  =  json . load ( f ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 16:43:25 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        with  open ( Utils . user_path ( " minecraft_versions.json " ) ,  ' w ' )  as  f : 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            json . dump ( data ,  f ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  version : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  next ( filter ( lambda  entry :  entry [ " version " ]  ==  version ,  data [ release_channel ] ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  resp . json ( ) [ release_channel ] [ 0 ] 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    except  ( StopIteration ,  KeyError ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        logging . error ( f " No compatible mod version found for client version  { version }  on  \" { release_channel } \"  channel. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  release_channel  !=  " release " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            logging . error ( " Consider switching  \" release_channel \"  to  \" release \"  in your Host.yaml file " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            logging . error ( " No suitable mod found on the  \" release \"  channel. Please Contact us on discord to report this error. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        sys . exit ( 0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  is_correct_forge ( forge_dir )  - >  bool :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  os . path . isdir ( os . path . join ( forge_dir ,  " libraries " ,  " net " ,  " minecraftforge " ,  " forge " ,  forge_version ) ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  True 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  False 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  __name__  ==  ' __main__ ' :  
						 
					
						
							
								
									
										
										
										
											2021-11-10 15:35:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Utils . init_logging ( " MinecraftClient " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser  =  argparse . ArgumentParser ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 12:07:03 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( " apmc_file " ,  default = None ,  nargs = ' ? ' ,  help = " Path to an Archipelago Minecraft data file (.apmc) " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --install ' ,  ' -i ' ,  dest = ' install ' ,  default = False ,  action = ' store_true ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        help = " Download and install Java and the Forge server. Does not launch the client afterwards. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --release_channel ' ,  ' -r ' ,  dest = " channel " ,  type = str ,  action = ' store ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        help = " Specify release channel to use. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --java ' ,  ' -j ' ,  metavar = ' 17 ' ,  dest = ' java ' ,  type = str ,  default = False ,  action = ' store ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        help = " specify java version. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --forge ' ,  ' -f ' ,  metavar = ' 1.18.2-40.1.0 ' ,  dest = ' forge ' ,  type = str ,  default = False ,  action = ' store ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        help = " specify forge version. (Minecraft Version-Forge Version) " ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --version ' ,  ' -v ' ,  metavar = ' 9 ' ,  dest = ' data_version ' ,  type = int ,  action = ' store ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        help = " specify Mod data version to download. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args  =  parser . parse_args ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-23 12:13:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    apmc_file  =  os . path . abspath ( args . apmc_file )  if  args . apmc_file  else  None 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 14:19:36 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # Change to executable's working directory 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    os . chdir ( os . path . abspath ( os . path . dirname ( sys . argv [ 0 ] ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-15 06:13:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    options  =  Utils . get_options ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    channel  =  args . channel  or  options [ " minecraft_options " ] [ " release_channel " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    apmc_data  =  None 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    data_version  =  args . data_version  or  None 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-19 13:54:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  apmc_file  is  None  and  not  args . install : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        apmc_file  =  Utils . open_filename ( ' Select APMC file ' ,  ( ( ' APMC File ' ,  ( ' .apmc ' , ) ) , ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  apmc_file  is  not  None  and  data_version  is  None : 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        apmc_data  =  read_apmc_file ( apmc_file ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        data_version  =  apmc_data . get ( ' client_version ' ,  ' ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    versions  =  get_minecraft_versions ( data_version ,  channel ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-05 22:39:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    forge_dir  =  options [ " minecraft_options " ] [ " forge_directory " ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-15 06:13:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    max_heap  =  options [ " minecraft_options " ] [ " max_heap_size " ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    forge_version  =  args . forge  or  versions [ " forge " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    java_version  =  args . java  or  versions [ " java " ] 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    mod_url  =  versions [ " url " ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    java_dir  =  find_jdk_dir ( java_version ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 14:19:36 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  args . install : 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-02 04:49:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  is_windows : 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 00:56:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            print ( " Installing Java " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            download_java ( java_version ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 00:56:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  not  is_correct_forge ( forge_dir ) : 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-02 04:49:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            print ( " Installing Minecraft Forge " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 00:56:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            install_forge ( forge_dir ,  forge_version ,  java_version ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            print ( " Correct Forge version already found, skipping install. " ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												MC: 1.17 support (#120)
* MC: add death_link option
* Minecraft: 1.17 advancements and logic support
* Update Minecraft tracker to 1.17
* Minecraft: add tests for new advancements
* removed jdk/forge download install out of iss and into MinecraftClient.py using flag --install
* Add required_bosses option
choices are none, ender_dragon, wither, both
postgame advancements are set according to the required boss for completion
* fix docstring for PostgameAdvancements
* Minecraft: add starting_items
List of dicts: item, amount, nbt
* Update descriptions for AdvancementGoal and EggShardsRequired
* Minecraft: fix tests for required_bosses attribute
* Minecraft: updated logic for various dragon-related advancements
Split the logic into can_respawn and can_kill dragon
Free the End, Monsters Hunted, The End Again still require both respawn and kill, since the player needs to kill and be credited with the kill
You Need a Mint and Is It a Plane now require only respawn, since the dragon need only be alive; if killed out of logic, it's ok
The Next Generation only requires kill, since the egg spawns regardless of whether the player was credited with the kill or not
* Minecraft client: ignore prereleases unless --prerelease flag is on
* explicitly state all defaults
change structure shuffle and structure compass defaults to true
update install tutorial to point to player-settings page, as well as removing instructions for manual install
* Minecraft client: add Minecraft version check
Adds a minecraft_version field in the apmc, and downloads only mods which contain that version in the name of the .jar file.
This ensures that the client remains compatible even if new mods are released for later versions, since they won't download a mod for a later version than the apmc says.
Co-authored-by: Kono Tyran <Kono.Tyran@gmail.com>
											 
										 
										
											2021-11-30 20:37:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        sys . exit ( 0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  apmc_data  is  None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        raise  FileNotFoundError ( f " APMC file does not exist or is inaccessible at the given location ( { apmc_file } ) " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  is_windows : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  java_dir  is  None  or  not  os . path . isdir ( java_dir ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  prompt_yes_no ( " Did not find java directory. Download and install java now? " ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                download_java ( java_version ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                java_dir  =  find_jdk_dir ( java_version ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  java_dir  is  None  or  not  os . path . isdir ( java_dir ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                raise  NotADirectoryError ( f " Path  { java_dir }  does not exist or could not be accessed. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  is_correct_forge ( forge_dir ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  prompt_yes_no ( f " Did not find forge version  { forge_version }  download and install it now? " ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            install_forge ( forge_dir ,  forge_version ,  java_version ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-02 04:49:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  not  os . path . isdir ( forge_dir ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            raise  NotADirectoryError ( f " Path  { forge_dir }  does not exist or could not be accessed. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  not  max_heap_re . match ( max_heap ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        raise  Exception ( f " Max heap size  { max_heap }  in incorrect format. Use a number followed by M or G, e.g. 512M or 2G. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-20 11:44:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    update_mod ( forge_dir ,  mod_url ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    replace_apmc_files ( forge_dir ,  apmc_file ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 15:36:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    check_eula ( forge_dir ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:00:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    server_process  =  run_forge_server ( forge_dir ,  java_version ,  max_heap ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 11:57:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    server_process . wait ( )