Join 2,356+ Players and socialize together

Join the Community Today

Come hang out with us on the Minecraft Addicts Forums — it's the perfect place to chat, trade cool stuff, and connect with awesome builders just like you! Let's plan epic builds, create amazing worlds together, and then show off your masterpieces to everyone! Plus, we’re all about having fun, so feel free to talk about anything under the sun—games, hobbies, favorite snacks, you name it! Can't wait for you to join and share all the Minecraft magic!

Applescript Jar Switching Script

Status
Not open for further replies.

seattlewil

Well-known member
Joined
Dec 27, 2010
Messages
616
Yesterday I decided to refresh myself on the little Python I actually knew, and while doing so, I happened upon Applescript for the first time.

For those of you who don't know, Applescript is a programing language created by Apple for the purpose of automating tasks. While I was messing around with the basic functions I thought of a feature that I thought would be useful to have on my computer for Minecraft.

To any of you guys with any basic background in Applescript, it may sound like a very simple project. But, rest assured, it took me a great deal of time (mostly because the little java I know managed to screw me over multiple times). My goal was to create a program that would allow me to have two .jar files (one saved in the bin of the minecraft folder and one saved in a "storage" folder), and to let me switch between them seamlessly with one simple click. In other words, easy switching during rollbacks/modded jar files.

Fast foward to 12:30 in the morning, and here's what I'd come up with...

Code:
tell application "Finder"
	activate
	set jarOLD to file "minecraft.jar" of folder "bin" of folder "minecraft" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
	set jar2 to file "minecraft.jar" of folder "jar2" of folder "jar switching script folder" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
	set tempbin to file "minecraft.jar" of folder "tempbin" of folder "jar switching script folder" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
	set jarOLDf to folder "bin" of folder "minecraft" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
	set jar2f to folder "jar2" of folder "jar switching script folder" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
	set tempbinf to folder "tempbin" of folder "jar switching script folder" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
	duplicate jarOLD to tempbinf with replacing
	duplicate jar2 to jarOLDf with replacing
	duplicate tempbin to jar2f with replacing
end tell
tell application "Finder"
	display dialog "Jar files have been switched." buttons "OK" default button "OK"
end tell

For any of those of you on Macs (sorry everyone else), feel free to pop this into your Applescript Editor program and give it a try (keep in mind, you will have to change the pathways to your minecraft folder and you'll have to create the other folders I reference in the script).

Ultimately, this was less of a "I want to be able to switch jars with one button" (because really, switching jars is fairly easy), I just wanted to learn some Applescript and this was my excuse.

If you stuck with me this whole post, thanks, and I hope you found this either useful or entertaining (everyone loves watching people struggle right?)!
 
Wow nice work seattle, a feature like this is definitely invaluable for quick switching, especially if you've got a singleplayer world on the go to test the new features of the game and then need a quick rollback if I were a mac user, I'd be running that as we speak :)
 
nice job dude! I'm sure this will help the people on the server that use macs.

(for those that actually read the forums)
 
Thanks for the kind words guys! If anyone needs help getting it to run/path correctly, please let me know!
 
Status
Not open for further replies.
Back
Top