Skip to content

Instantly share code, notes, and snippets.

View inertia186's full-sized avatar
🏠
Working from home

Anthony Martin inertia186

🏠
Working from home
View GitHub Profile
#!/bin/bash
## A small wrapper around the mcrcon binary.
##
## See: https://forums.bukkit.org/threads/admin-rcon-mcrcon-remote-connection-client-for-minecraft-servers.70910/
MC="/path/to/server"
RCON_EXEC="$MC/scripts/gits/mcrcon-code/mcrcon"
RCON_HOST="127.0.0.1"
RCON_PORT=25577
#!/bin/bash
export LANG="en_US.UTF-8"
MC=/Users/steve/Minecraft
# Many of these options are explaiend here:
# http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html
# http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
# http://blog.ragozin.info/2011/09/hotspot-jvm-garbage-collection-options.html
## Cleanly recovers from a crash event.
IFS=$'\n'
MC="/Users/steve/Minecraft"
LOG="$MC/logs/latest.log"
ALERT="$MC/scripts/alert-admin.sh"
error="$2"
if [ -n "$error" ]; then
path="`echo "$error" | cut -f 8 -d " "`"
@inertia186
inertia186 / mc-butcher.sh
Last active December 13, 2015 20:49
[Minecraft, SMP] Butchers all hostile mobs by switching to Peaceful then back to Normal.
cmd="difficulty 0"
bash -c "screen -p 0 -S minecraft -X eval 'stuff \"$cmd\"\015'"
sleep 1 # This is required so that the commands happen in different game ticks.
cmd="difficulty 2"
bash -c "screen -p 0 -S minecraft -X eval 'stuff \"$cmd\"\015'"
@inertia186
inertia186 / mc-uptime.sh
Created February 17, 2013 20:04
[Minecraft, SMP] Tells uptime to all ops who are logged in.
MC="/Users/steve/Minecraft"
for player in `cat $MC/ops.txt`
do
query=`$MC/scripts/Dinnerbone-mcstatus-a24e563/cli.py localhost | grep -i $player | wc -l`
query=$(sed -e 's/^[[:space:]]*//' <<<"$query")
if [ $query -eq 0 ]; then
echo Skipping $player, not logged in.
@inertia186
inertia186 / mc-clear-contraband.sh
Created February 17, 2013 20:15
[Minecraft, SMP] Clears any unauthorized items from the inventories of all survival mode players.
TARGET="@a[m=0]"
LIST="7 19 90 119 137 383"
for item in $LIST; do
cmd="clear $TARGET $item"
bash -c "screen -p 0 -S minecraft -X eval 'stuff \"$cmd\"\015'"
echo $cmd
done
@inertia186
inertia186 / mc-start.sh
Last active December 13, 2015 21:08
[Minecraft, SMP] This is a very basic launch script for Minecraft. It uses "screen" so you can inject external commands and scripts.
#!/bin/bash
MC=/Users/steve/Minecraft/
echo \#\#\#
echo \#\#\# It is normal to see a \"NameError: global name 'socket' is not defined\" here if the server really is down.
echo \#\#\#
query=`$MC/scripts/Dinnerbone-mcstatus-a24e563/cli.py -t 1 -r 0 localhost | wc -l`
query=$(sed -e 's/^[[:space:]]*//' <<<"$query")
@inertia186
inertia186 / mc-announce-ban.sh
Created February 18, 2013 06:27
[Minecraft, SMP] This script will announce that a player will be banned for a particular reason, then bans them after 15 seconds.
cmd="say $1 will be banned in 15 seconds. Reason: $2"
bash -c "screen -p 0 -S minecraft -X eval 'stuff \"$cmd\"\015'"
sleep 15
cmd="ban $1 $2"
bash -c "screen -p 0 -S minecraft -X eval 'stuff \"$cmd\"\015'"
@inertia186
inertia186 / mc-stop.sh
Created February 18, 2013 06:15
[Minecraft, SMP] A really simple shutdown announcement with a five minute warning. I know this approach is very repetitive and could make use of script functions instead. But hey, it works.
#!/bin/bash
MC="/Users/steve/Minecraft"
cmd="say Restarting in 5 minutes."
echo $cmd
bash -c "screen -p 0 -S minecraft -X eval 'stuff \"$cmd\"\015'"
sleep 60
cmd="say Restarting in 4 minutes."