From 29e1755efab5218439b5ff7650627a56780070b0 Mon Sep 17 00:00:00 2001 From: Clarth Date: Tue, 23 Jan 2024 13:44:17 -0500 Subject: [PATCH] Add Minecraft/Modded/Offline-Forceload-Toggle.sh Makes it easy to change "Force Load Chunks When Offline" on and off instead of going through each file individually. Works with the openpartiesandclaims mod. --- Minecraft/Modded/Offline-Forceload-Toggle.sh | 46 ++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Minecraft/Modded/Offline-Forceload-Toggle.sh 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