forked from cranstonide/linux-minecraft-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmc-temp-creative.sh
executable file
·96 lines (75 loc) · 3.06 KB
/
mc-temp-creative.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Minecraft Script to temprararily enable creative mode (just for fun)
# Github: https://github.com/cranstonide/linux-minecraft-scripts
# It's a good idea to back up before running this script. It does its own backup,
# but expecially during your first couple runs its a safe idea.
############################################
# Script Settings #
# (Note -NO- trailing slashes on paths) #
############################################
# Where is Minecraft?
minecraftDir="/home/user/minecraft"
# Where do you want to store the temporary files?
tempDir="/home/user/temp-minecraft"
# How long (in minutes) should this mode last?
min=10
############################################
# End of settings; Do not modify below #
############################################
# Alert the players that the server is going to be switching into TNT Mode.
screen -p 0 -S minecraft -X eval "stuff \"say Server will be entering TNT mode shortly.\"\015"
sleep 1
screen -p 0 -S minecraft -X eval "stuff \"say Shutting down to backup in 10 seconds.\"\015"
sleep 1
screen -p 0 -S minecraft -X eval "stuff \"say Please exit crafting blocks, dispensers, trades, chests and furnaces.\"\015"
# Wait a moment and stop the server to do the backup.
sleep 10
screen -p 0 -S minecraft -X eval "stuff \"stop\"\015"
sleep 10
# Backup the server into a temporary location.
rm -rvf $tempDir/
mkdir $tempDir/
cp -rvf $minecraftDir/ $tempDir/
# The server is now running in its temporary mode.
./mc-start.sh
sleep 10
screen -p 0 -S minecraft -X eval "stuff \"say The server is now in TNT mode.\"\015"
sleep 1
screen -p 0 -S minecraft -X eval "stuff \"say Please tell other players.\"\015"
sleep 1
# For the next $min minutes, display a countdown.
for ((c=$min; c>=0; c--))
do
sleep 60
############################################
# Creative Mode Actions Begin Here #
############################################
# This section id still under development.
# give each person TNT
for ((d=0; d<=4; d++))
do
while read line
do
screen -p 0 -S minecraft -X eval "stuff \"give $line 46 64\"\015"
screen -p 0 -S minecraft -X eval "stuff \"give $line 76 64\"\015"
done < /home/mark/minecraft/white-list.txt
done
############################################
# Creative Mode Actions End Here #
############################################
# This is the countdown.
screen -p 0 -S minecraft -X eval "stuff \"say TNT mode will last for another $c minutes.\"\015"
done
# Fun and games are over. Let's reset the server back to its original state.
screen -p 0 -S minecraft -X eval "stuff \"say TNT Mode is over. Hope you had fun.\"\015"
sleep 1
screen -p 0 -S minecraft -X eval "stuff \"say Restoring original (pre-TNT) map.\"\015"
sleep 10
screen -p 0 -S minecraft -X eval "stuff \"stop\"\015"
sleep 10
# Delete the temporary world (the one which was just in the $minecraft dir)
rm -rvf $minecraftDir
# Rename the backupDir to minecraftDir to restore the server to normal.
mv $tempDir $minecraftDir
# Restart the server. This time, normal.
./mc-start.sh