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
@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-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-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-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."
@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-slap.gemspec
Last active December 14, 2015 00:59
Minecraft themed slap script.
Gem::Specification.new do |s|
s.name = 'mc-slap'
s.version = '0.0.1'
s.platform = Gem::Platform::RUBY
s.author = 'Anthony Martin'
s.email = 'mc-slap@martin-studio.com'
s.summary = 'Minecraft Slap'
s.description = 'Minecraft themed slap script.'
s.files = ['mc-slap.rb']
@inertia186
inertia186 / minecraft-ddos-Block-IPs.txt
Last active December 15, 2015 05:19
If you're setting up a pf (packet filter) firewall, here's the Minecraft specific DDoS threats file we currently use.
70.71.153.43
111.197.56.176
111.197.63.35
114.250.244.70
203.171.233.243
221.219.250.74
65.125.155.90
85.227.160.171
204.14.77.46
174.134.89.68
@inertia186
inertia186 / slap.sh
Last active December 15, 2015 05:29
[Minecraft, SMP] Here's how the staff can invoke the mc-slap.rb script I posted previously. As always, this assumes you run the Minecraft server in a screen session named "minecraft".
#!/bin/bash
MC="/Users/steve/Minecraft"
RUBY="/Users/steve/.rvm/rubies/ruby-1.9.3-p374/bin/ruby"
if [ -z "$1" ]; then
echo $0 \[target\]
fi
target=$1
@inertia186
inertia186 / planet-minecraft.sh
Created March 20, 2013 23:18
[Minecraft, SMP] Planet Minecraft
#!/bin/bash
MC="/Users/steve/Minecraft"
LOG="$MC/server.log"
MESSAGE="We are not falling for it. This is not the server you are looking for. Move along."
for player in `tail -50 $LOG | grep -i "i'm\|im\|i am" | grep -i from | grep -i planet | grep -i minecraft | cut -f 4 -d " " | cut -f 2 -d \< | cut -f 1 -d \> | sort | uniq`
do
if [ -n "`tail -100000 $LOG | grep "Kicked $player from the game: '$MESSAGE'"`" ]; then