From fa8406dab407f007da6c91ce0a0aa5586f430f30 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 21 Jul 2018 08:09:40 -0400
Subject: [PATCH] Create a symlink on not-windows to current minecraft
 decompile dir

This is useful for project developers switching back and forth between
1.12.2 and 1.13 so we can have our IDE automatically use the
current version we are working on for included mc-dev files.
---
 scripts/decompile.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/scripts/decompile.sh b/scripts/decompile.sh
index f2c1754fd..2018259c3 100755
--- a/scripts/decompile.sh
+++ b/scripts/decompile.sh
@@ -6,9 +6,9 @@ PS1="$"
 basedir="$(cd "$1" && pwd -P)"
 workdir="$basedir/work"
 minecraftversion=$(cat "$workdir/BuildData/info.json"  | grep minecraftVersion | cut -d '"' -f 4)
+windows="$([[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]] && echo "true" || echo "false")"
 decompiledir="$workdir/Minecraft/$minecraftversion"
 classdir="$decompiledir/classes"
-
 echo "Extracting NMS classes..."
 if [ ! -d "$classdir" ]; then
     mkdir -p "$classdir"
@@ -30,4 +30,13 @@ if [ ! -d "$decompiledir/net/minecraft/server" ]; then
         exit 1
     fi
 fi
+
+# set a symlink to current
+currentlink="$workdir/Minecraft/current"
+if ([ ! -e "$currentlink" ] || [ -L "$currentlink" ]) && [ "$windows" == "false" ]; then
+	echo "Pointing $currentlink to $minecraftversion"
+	rm -rf "$currentlink"
+	ln -sfn "$minecraftversion" "$currentlink"
+fi
+
 )