import subprocess
import re
import sys
import threading
import time
class StdinThread(threading.Thread):
IDENTIFIER = "StdinPlugin"
def __init__(self, server):
threading.Thread.__init__(self)
self.server = server
self.stop = False
def run(self):
while not self.stop:
line = sys.stdin.readline()
if line:
self.server.stdin.write(line)
if self.stop:
break
time.sleep(0.1)
log = open("minecraft.log",'a')
loginregexp = re.compile("\d\d:\d\d:\d\d \/\d+\.\d+\.\d+\.\d+ logged in as ([\w\d\.]+)")
server = subprocess.Popen(("java", "-cp", "minecraft-server.jar", "com.mojang.minecraft.server.MinecraftServer"), stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
plugin = StdinThread(server)
plugin.start()
while True:
try:
output = server.stderr.readline().strip()
if not output:
continue
log.write("%s\n" % output)
log.flush()
print output
nameresult = loginregexp.match(output)
if nameresult != None:
x = open("allowed.txt")
if not nameresult.groups()[0].lower() in x.read().lower().splitlines():
server.stdin.write("kick " + nameresult.groups()[0] + "\n")
x.close()
except(KeyboardInterrupt):
print "Shutting down..."
log.write("Shutting down...\n")
log.flush()
plugin.stop = True
sys.exit()
Just make an allowed.txt in the server dir, paste this into a .py file, run with python 2.6 and enjoy.
I've copied some random bits of code from cmss.
EDIT:
Realised it's case sensitive. Fixed.
Now with (easy)paid-only servers! Make an allowedfree.txt for free users that are allowed on.
import subprocess
import re
import sys
import threading
import time
from urllib import urlopen
class StdinThread(threading.Thread):
IDENTIFIER = "StdinPlugin"
def __init__(self, server):
threading.Thread.__init__(self)
self.server = server
self.stop = False
def run(self):
while not self.stop:
line = sys.stdin.readline()
if line:
self.server.stdin.write(line)
if self.stop:
break
time.sleep(0.1)
log = open("minecraft.log",'a')
loginregexp = re.compile("\d\d:\d\d:\d\d \/\d+\.\d+\.\d+\.\d+ logged in as ([\w\d\.]+)")
server = subprocess.Popen(("java", "-cp", "minecraft-server.jar", "com.mojang.minecraft.server.MinecraftServer"), stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
plugin = StdinThread(server)
plugin.start()
while True:
try:
output = server.stderr.readline().strip()
if not output:
continue
log.write("%s\n" % output)
log.flush()
print output
nameresult = loginregexp.match(output)
if nameresult != None:
x = open("allowedfree.txt")
f = urlopen("http://minecraft.net/skin/"+player+".png")
if "" in f.readline() and not nameresult.groups()[0].lower() in x.read().lower().splitlines():
server.stdin.write("kick " + nameresult.groups()[0] + "\n")
x.close()
except(KeyboardInterrupt):
print "Shutting down..."
log.write("Shutting down...\n")
log.flush()
plugin.stop = True
sys.exit()
Rollback Post to RevisionRollBack
I disagree with you, therefore you are wrong.
Quality of output = Skill * Effort
no extra commands. this simply kicks anyone who's not in the "allowed.txt" file
at some point I might modify this if I get around to it, and post it on this thread, so that you can add/remove users to the list from within the game. and maybe make it so it can show the list within the game as well.
mail, if you get around to doing this before I do, can you also make an option to let the owner decide whether to let anyone who's trusted change the list, or op-only?
I could probably manage something like that, but it would take me a while since I'm still very new to python.
Just make an allowed.txt in the server dir, paste this into a .py file, run with python 2.6 and enjoy.
I've copied some random bits of code from cmss.
EDIT:
Realised it's case sensitive. Fixed.
Now with (easy)paid-only servers! Make an allowedfree.txt for free users that are allowed on.
Quality of output = Skill * Effort
Quality of output = Skill * Effort
(i'm looking for a rank system, so i can give a selected group /solid and /tp have no idea where to look)
at some point I might modify this if I get around to it, and post it on this thread, so that you can add/remove users to the list from within the game. and maybe make it so it can show the list within the game as well.
mail, if you get around to doing this before I do, can you also make an option to let the owner decide whether to let anyone who's trusted change the list, or op-only?
I could probably manage something like that, but it would take me a while since I'm still very new to python.
Quality of output = Skill * Effort
I was only 2 day sick when I had it.
It's fake swine flu. mail got the VACCINE to swine flu TODAY.
Thank you for the simple instruction on how to do this mail.
Quality of output = Skill * Effort
Quality of output = Skill * Effort