From 33a34cfa56591e75cc9a8bdfc9a6555ab0a6df71 Mon Sep 17 00:00:00 2001 From: business-goose Date: Mon, 21 Mar 2022 20:37:24 +0000 Subject: [PATCH] CD into the directory and run the script directly --- .../TotalFreedomMod/commands/Command_updatetfm.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_updatetfm.java b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_updatetfm.java index d785c09..9fdfdba 100644 --- a/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_updatetfm.java +++ b/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_updatetfm.java @@ -8,6 +8,8 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import java.io.File; + @CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH) @CommandParameters(description = "For developers only - update TFM.", usage = "/") public class Command_updatetfm extends FreedomCommand { @@ -16,8 +18,10 @@ public class Command_updatetfm extends FreedomCommand { playerMsg("Updating TFM, please wait...", ChatColor.RED); Utilities.adminAction(sender.getName(), "Updating TFM", true); String path = MainConfig.getString(ConfigurationEntry.TFM_BUILD_SHELLSCRIPT); + String directory = new File(path).getParent(); + try { - Process uptimeProc = Runtime.getRuntime().exec(String.format("bash -c \"./%s\"", path)); + Process uptimeProc = Runtime.getRuntime().exec(String.format("bash -c \"cd %s; %s\"", directory, path)); uptimeProc.waitFor(); playerMsg("Updated TFM! Reloading..."); Utilities.adminAction(sender.getName(), "Update successful, reloading TFM...", false);