diff --git a/Minecraft/Modded/Offline-Forceload-Toggle.sh b/Minecraft/Modded/Offline-Forceload-Toggle.sh new file mode 100644 index 0000000..ec5ff3b --- /dev/null +++ b/Minecraft/Modded/Offline-Forceload-Toggle.sh @@ -0,0 +1,46 @@ +#!/bin/bash +#Toggle openpartiesandclaims to keep force loaded chunks active even when the player is offline +#designed for bettermc and clay's custom pack. + +# The directory where you want to search for .toml files +search_dir="/home/moddedmc/BetterMC/world/serverconfig/" + +# Check if the script was provided with an argument +if [ $# -ne 1 ]; then + echo "Usage: $0 on/off" + echo + echo "Toggle openpartiesandclaims to keep force loaded chunks active even when the player is offline" + exit 1 +fi + +# Check if the first argument is "off" +if [ "$1" = "off" ]; then + action="false" + # Use 'find' to locate all .toml files and then use 'grep' to find the line containing 'offlineForceload = true' + # Finally, use 'sed' to toggle the value based on the action + find "$search_dir" -type f -name "*.toml" -exec grep -l 'offlineForceload = true' {} \; | while read -r toml_file + do + # Use 'sed' to toggle the value in the file + sed -i 's/offlineForceload = true/offlineForceload = '"$action"'/' "$toml_file" + echo "Modified: $toml_file" + done + message="offlineForceload has been set to FALSE." +elif [ "$1" = "on" ]; then + action="true" + # Use 'find' to locate all .toml files and then use 'grep' to find the line containing 'offlineForceload = false' + # Finally, use 'sed' to toggle the value based on the action + find "$search_dir" -type f -name "*.toml" -exec grep -l 'offlineForceload = false' {} \; | while read -r toml_file + do + # Use 'sed' to toggle the value in the file + sed -i 's/offlineForceload = false/offlineForceload = '"$action"'/' "$toml_file" + echo "Modified: $toml_file" + done + +echo "$message" + message="offlineForceload has been set to TRUE." +else + echo "Invalid argument. Use 'on' or 'off'." + exit 1 +fi + +exit